Completed
Push — master ( d4bbbf...cc8a32 )
by Dwight
8s
created

InteractsWithConnection   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 75%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 1
cbo 0
dl 0
loc 48
ccs 6
cts 8
cp 0.75
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A openConnection() 0 8 2
A closeConnection() 0 4 1
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
Bug introduced by Dwight Watson
The property client does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
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