1 | <?php |
||
9 | class EngageSparkChannel |
||
10 | { |
||
11 | /** @var string */ |
||
12 | private $mode; |
||
13 | |||
14 | /** @var string */ |
||
15 | private $clientRef; |
||
16 | |||
17 | /** @var EngageSpark */ |
||
18 | protected $smsc; |
||
19 | |||
20 | public function __construct(EngageSpark $smsc) |
||
24 | |||
25 | /** |
||
26 | * Send the given notification. |
||
27 | * |
||
28 | * @param mixed $notifiable |
||
29 | * @param Notification $notification |
||
30 | * |
||
31 | * @return void |
||
32 | */ |
||
33 | public function send($notifiable, Notification $notification) |
||
47 | |||
48 | /** |
||
49 | * Gets a list of phones from the given notifiable. |
||
50 | * |
||
51 | * @param mixed $notifiable |
||
52 | * @param Notification $notification |
||
53 | * |
||
54 | * @return string[] |
||
55 | */ |
||
56 | protected function getRecipients($notifiable, Notification $notification) |
||
60 | |||
61 | /** |
||
62 | * Gets a list of phones from the given notifiable. |
||
63 | * |
||
64 | * @param mixed $notifiable |
||
65 | * @param Notification $notification |
||
66 | * |
||
67 | * @return string[] |
||
68 | */ |
||
69 | protected function getRecipient($notifiable, Notification $notification) |
||
81 | |||
82 | protected function sendMessage($recipient, EngageSparkMessage $message) |
||
116 | |||
117 | protected function getWebHook(EngageSparkMessage $message) |
||
121 | |||
122 | protected function getOrgId() |
||
126 | |||
127 | public function getClientRef() |
||
131 | |||
132 | protected function getSenderId(EngageSparkMessage $message) |
||
136 | |||
137 | protected function setClientRef(Notification $notification) |
||
143 | |||
144 | protected function getMode() |
||
148 | |||
149 | protected function setMode(EngageSparkMessage $message) |
||
155 | |||
156 | protected function getFormattedMobile($to) |
||
162 | } |
||
163 |
If you define a variable conditionally, it can happen that it is not defined for all execution paths.
Let’s take a look at an example:
In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined.
Available Fixes
Check for existence of the variable explicitly:
Define a default value for the variable:
Add a value for the missing path: