PluginProbe
404 Solution / trunk
404 Solution vtrunk
4.3.5 4.3.4 4.3.3 4.3.2 4.3.1 4.3.0 4.2.0 4.1.19 4.1.18 4.1.17 4.1.16 4.1.15 4.1.13 4.1.12 4.1.11 4.1.10 4.1.9 4.1.8 4.1.7 4.1.6 4.1.5 4.1.4 4.1.3 trunk 2.30.0 All 109 releases
404-solution / includes / php / objs / WPNotice.php

WPNotice.php in 404 Solution trunk, at includes/php/objs/WPNotice.php

62 lines 1.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3
4 if (!defined('ABSPATH')) {
5 exit;
6 }
7
8 /** Stores a message and its importance. */
9 class ABJ_404_Solution_WPNotice {
10
11 const ERROR = 'notice-error';
12 const WARNING = 'notice-warning';
13 const SUCCESS = 'notice-success';
14 const INFO = 'notice-info';
15
16 /** @var string */
17 private $type = null;
18
19 /** @var mixed */
20 private $message = '';
21
22 /**
23 * @param mixed $type
24 * @param mixed $message
25 */
26 public function __construct($type, $message) {
27 $this->type = self::INFO;
28
29 $f = abj_service('functions');
30 $typeStr = is_string($type) ? $type : (is_scalar($type) ? (string)$type : '');
31 $VALID_TYPES = array(self::ERROR, self::WARNING, self::SUCCESS, self::INFO);
32 if (!in_array($typeStr, $VALID_TYPES)) {
33 if ($f->strtolower($typeStr) == 'info') {
34 $typeStr = self::INFO;
35 } else if ($f->strtolower($typeStr) == 'warning') {
36 $typeStr = self::WARNING;
37 } else if ($f->strtolower($typeStr) == 'success') {
38 $typeStr = self::SUCCESS;
39 } else if ($f->strtolower($typeStr) == 'error') {
40 $typeStr = self::ERROR;
41 } else {
42 throw new Exception("Invalid type passed to constructor (" . esc_html($typeStr) . "). Expected: " .
43 (string)json_encode($VALID_TYPES));
44 }
45 }
46
47 $this->type = $typeStr;
48 $this->message = $message;
49 }
50
51 /** @return string */
52 function getType(): string {
53 return $this->type;
54 }
55
56 /** @return mixed */
57 function getMessage() {
58 return $this->message;
59 }
60
61 }
62