These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | namespace NotificationChannels\Apn; |
||
4 | |||
5 | use Exception; |
||
6 | use NotificationChannels\Apn\Exceptions\ConnectionFailed; |
||
7 | |||
8 | trait InteractsWithConnection |
||
9 | { |
||
10 | /** |
||
11 | * The connection credentials. |
||
12 | * |
||
13 | * @var \NotificationChannels\Apn\ApnCredentials |
||
14 | */ |
||
15 | protected $credentials; |
||
16 | |||
17 | /** |
||
18 | * Open the connection to the feedback service. |
||
19 | * |
||
20 | * @param \NotificationChannels\Apn\ApnCredentials $credentials |
||
21 | * |
||
22 | * @return void |
||
23 | * @throws \NotificationChannels\Apn\Exception\ConnectionFailed |
||
24 | */ |
||
25 | 3 | protected function openConnection(ApnCredentials $credentials = null) |
|
26 | { |
||
27 | try { |
||
28 | 3 | $credentials = $credentials ?: $this->credentials; |
|
29 | |||
30 | 3 | $this->client->open($credentials->environment, $credentials->certificate, $credentials->passPhrase); |
|
0 ignored issues
–
show
|
|||
31 | } catch (Exception $exception) { |
||
32 | throw ConnectionFailed::create($exception); |
||
33 | } |
||
34 | 3 | } |
|
35 | |||
36 | /** |
||
37 | * Close the connection. |
||
38 | * |
||
39 | * @return void |
||
40 | */ |
||
41 | 3 | protected function closeConnection() |
|
42 | { |
||
43 | 3 | $this->client->close(); |
|
44 | 3 | } |
|
45 | } |
||
46 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: