1 | <?php namespace Cornford\Alerter; |
||
9 | class Alert extends AlertType implements AlertableInterface { |
||
10 | |||
11 | /** |
||
12 | * The content of the alert. |
||
13 | * |
||
14 | * @var string |
||
15 | */ |
||
16 | protected $content; |
||
17 | |||
18 | /** |
||
19 | * The type of the alert. |
||
20 | * |
||
21 | * @var string |
||
22 | */ |
||
23 | protected $type; |
||
24 | |||
25 | /** |
||
26 | * The view of the alert. |
||
27 | * |
||
28 | * @var string |
||
29 | */ |
||
30 | protected $view; |
||
31 | |||
32 | /** |
||
33 | * The path for the alert view. |
||
34 | * |
||
35 | * @var string |
||
36 | */ |
||
37 | protected $viewPath; |
||
38 | |||
39 | /** |
||
40 | * Construct a new alerter instance. |
||
41 | * |
||
42 | * @param string $type |
||
43 | * @param string $content |
||
44 | * |
||
45 | * @return self |
||
|
|||
46 | */ |
||
47 | private function __construct($type, $content) |
||
63 | |||
64 | /** |
||
65 | * Create a new alerter instance. |
||
66 | * |
||
67 | * @param string $type |
||
68 | * @param string $content |
||
69 | * |
||
70 | * @return self |
||
71 | * |
||
72 | * @throws \Cornford\Alerter\Exceptions\AlertContentException |
||
73 | * @throws \Cornford\Alerter\Exceptions\AlertTypeException |
||
74 | */ |
||
75 | public static function create($type, $content) |
||
87 | |||
88 | /** |
||
89 | * Return the stored alert type. |
||
90 | * |
||
91 | * @return string |
||
92 | */ |
||
93 | public function getType() |
||
97 | |||
98 | /** |
||
99 | * Return the stored alert content. |
||
100 | * |
||
101 | * @return string |
||
102 | */ |
||
103 | public function getContent() |
||
107 | |||
108 | /** |
||
109 | * Return the stored alert variable if it exists. |
||
110 | * |
||
111 | * @param string $variable ob |
||
112 | * |
||
113 | * @return string |
||
114 | * |
||
115 | * @throws \Cornford\Alerter\Exceptions\AlertVariableException |
||
116 | */ |
||
117 | public function __get($variable) |
||
125 | |||
126 | /** |
||
127 | * Set the alert view. |
||
128 | * |
||
129 | * @param string $view |
||
130 | * |
||
131 | * @return self |
||
132 | */ |
||
133 | public function useView($view) |
||
139 | |||
140 | /** |
||
141 | * Set the alert view path. |
||
142 | * |
||
143 | * @param string $path |
||
144 | * |
||
145 | * @return self |
||
146 | */ |
||
147 | public function useViewPath($path) |
||
153 | |||
154 | /** |
||
155 | * Return a string of alert display HTML for a set display view. |
||
156 | * |
||
157 | * @param string $view |
||
158 | * @param string $viewPath |
||
159 | * |
||
160 | * @return string |
||
161 | */ |
||
162 | public function display($viewPath = null, $view = null) |
||
174 | |||
175 | } |
||
176 |
Adding a
@return
annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.Please refer to the PHP core documentation on constructors.