GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Pull Request — master (#35)
by Dwight
01:18
created

FeedbackService::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 7
ccs 6
cts 6
cp 1
rs 9.4285
cc 1
eloc 5
nc 1
nop 4
crap 1
1
<?php
2
3
namespace NotificationChannels\Apn;
4
5
use ZendService\Apple\Apns\Client\Feedback as Client;
6
use NotificationChannels\Apn\Exception\ConnectionFailed;
7
8
class FeedbackService
9
{
10
    /**
11
     * The feedback client instance.
12
     *
13
     * @var \ZendService\Apple\Apns\Client\Feedback
14
     */
15
    protected $client;
16
17
    /**
18
     * Create feedback service instance.
19
     *
20
     * @param  \ZendService\Apple\Apns\Client\Feedback  $client
21
     * @param  string  $environment
22
     * @param  string  $certificate
23
     * @param  string|null  $passPhrase
24
     * @return void
0 ignored issues
show
Comprehensibility Best Practice introduced by
Adding a @return annotation to constructors is generally not recommended as a constructor does not have a meaningful return value.

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.

Loading history...
25
     */
26 1
    public function __construct(Client $client, $environment, $certificate, $passPhrase = null)
27
    {
28 1
        $this->client = $client;
29 1
        $this->environment = $environment;
0 ignored issues
show
Bug introduced by
The property environment 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...
30 1
        $this->certificate = $certificate;
0 ignored issues
show
Bug introduced by
The property certificate 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...
31 1
        $this->passPhrase = $passPhrase;
0 ignored issues
show
Bug introduced by
The property passPhrase 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...
32 1
    }
33
34
    /**
35
     * Get feedback from the Apple Feedback Service about failed deliveries.
36
     *
37
     * @return array|ApnFeedback[]
38
     * @throws Exceptions\ConnectionFailed
39
     */
40 1
    public function get()
41
    {
42 1
        $this->openConnection();
43
44 1
        $feedback = $this->fetchFeedback();
45
46 1
        $this->client->close();
47
48 1
        return $feedback;
49
    }
50
51
    /**
52
     * Open the connection to the feedback service.
53
     *
54
     * @return void
55
     * @throws \NotificationChannels\Apn\Exception\ConnectionFailed
56
     */
57 1
    protected function openConnection()
58
    {
59
        try {
60 1
            $this->client->open($this->environment, $this->certificate, $this->passPhrase);
61
        } catch (Exception $exception) {
0 ignored issues
show
Bug introduced by
The class NotificationChannels\Apn\Exception does not exist. Did you forget a USE statement, or did you not list all dependencies?

Scrutinizer analyzes your composer.json/composer.lock file if available to determine the classes, and functions that are defined by your dependencies.

It seems like the listed class was neither found in your dependencies, nor was it found in the analyzed files in your repository. If you are using some other form of dependency management, you might want to disable this analysis.

Loading history...
62
            throw ConnectionFailed::create($exception);
63
        }
64 1
    }
65
66
    /**
67
     * Fetch the feedback from APNS and collect our feedback object.
68
     *
69
     * @return array
70
     */
71 1
    protected function fetchFeedback()
72
    {
73 1
        $feedback = [];
74
75
        /** @var FeedbackResponse $response */
76 1
        foreach ($this->client->feedback() as $response) {
77 1
            $feedback[] = new ApnFeedback($response->getToken(), $response->getTime());
78
        }
79
80 1
        return $feedback;
81
    }
82
}
83