PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 4.17.0
GiveWP – Donation Plugin and Fundraising Platform v4.17.0
4.17.0 4.16.9 4.16.8.1 4.16.8 4.16.7.2 4.16.7.1 4.16.7 4.16.6.1 4.16.6 4.16.5.1 4.16.5 4.16.4 4.16.3 4.16.2 4.16.1 4.16.0 4.15.5 4.15.4 4.15.3 4.15.2 4.15.1 4.15.0 2.3.0 2.3.1 2.3.2 All 256 releases
give / vendor / vendor-prefixed / stellarwp / admin-notices / src / ValueObjects / NoticeUrgency.php

NoticeUrgency.php in GiveWP – Donation Plugin and Fundraising Platform 4.17.0, at vendor/vendor-prefixed/stellarwp/admin-notices/src/ValueObjects/NoticeUrgency.php

76 lines 1.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Give\Vendors\StellarWP\AdminNotices\ValueObjects;
4
5 use InvalidArgumentException;
6
7 /**
8 * A value object representing the urgency of a notice.
9 *
10 * @since 1.0.0
11 */
12 class NoticeUrgency
13 {
14 const INFO = 'info';
15 const WARNING = 'warning';
16 const ERROR = 'error';
17 const SUCCESS = 'success';
18
19 /**
20 * @var string
21 */
22 private $urgency;
23
24 /**
25 * @since 1.0.0
26 */
27 public static function info(): self
28 {
29 return new self(self::INFO);
30 }
31
32 /**
33 * @since 1.0.0
34 */
35 public static function warning(): self
36 {
37 return new self(self::WARNING);
38 }
39
40 /**
41 * @since 1.0.0
42 */
43 public static function error(): self
44 {
45 return new self(self::ERROR);
46 }
47
48 /**
49 * @since 1.0.0
50 */
51 public static function success(): self
52 {
53 return new self(self::SUCCESS);
54 }
55
56 /**
57 * @since 1.0.0
58 */
59 public function __construct(string $urgency)
60 {
61 if (!in_array($urgency, [self::INFO, self::WARNING, self::ERROR, self::SUCCESS])) {
62 throw new InvalidArgumentException('Invalid urgency');
63 }
64
65 $this->urgency = $urgency;
66 }
67
68 /**
69 * @since 1.0.0
70 */
71 public function __toString(): string
72 {
73 return $this->urgency;
74 }
75 }
76