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\Exception\ConnectionFailed; |
||
7 | |||
8 | trait InteractsWithConnection |
||
9 | { |
||
10 | /** |
||
11 | * The connection environment. |
||
12 | * |
||
13 | * @var string |
||
14 | */ |
||
15 | protected $environment; |
||
16 | |||
17 | /** |
||
18 | * The connection certificate. |
||
19 | * |
||
20 | * @var string |
||
21 | */ |
||
22 | protected $certificate; |
||
23 | |||
24 | /** |
||
25 | * The connection pass phrase. |
||
26 | * |
||
27 | * @var string |
||
28 | */ |
||
29 | protected $passPhrase; |
||
30 | |||
31 | /** |
||
32 | * Open the connection to the feedback service. |
||
33 | * |
||
34 | * @return void |
||
35 | * @throws \NotificationChannels\Apn\Exception\ConnectionFailed |
||
36 | */ |
||
37 | 3 | protected function openConnection() |
|
38 | { |
||
39 | try { |
||
40 | 3 | $this->client->open($this->environment, $this->certificate, $this->passPhrase); |
|
0 ignored issues
–
show
|
|||
41 | } catch (Exception $exception) { |
||
42 | throw ConnectionFailed::create($exception); |
||
43 | } |
||
44 | 3 | } |
|
45 | |||
46 | /** |
||
47 | * Close the connection. |
||
48 | * |
||
49 | * @return void |
||
50 | */ |
||
51 | 3 | protected function closeConnection() |
|
52 | { |
||
53 | 3 | $this->client->close(); |
|
54 | 3 | } |
|
55 | } |
||
56 |
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: