AnswerApi   C
last analyzed

Complexity

Total Complexity 21

Size/Duplication

Total Lines 210
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 19

Importance

Changes 0
Metric Value
wmc 21
lcom 1
cbo 19
dl 0
loc 210
rs 6.875
c 0
b 0
f 0

20 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A acceptAnswer() 0 10 1
A answers() 0 7 1
A answersByIds() 0 7 1
A answersOnQuestions() 0 7 1
A answersOnUsers() 0 7 1
A createAnswer() 0 10 1
A createAnswerFlag() 0 10 1
A deleteAnswer() 0 10 1
A downvoteAnswer() 0 10 1
A editAnswer() 0 10 1
A meAnswers() 0 10 1
A meTagsTopAnswers() 0 10 1
A renderAnswer() 0 10 1
A topUserAnswersInTags() 0 7 1
A undoAcceptAnswer() 0 10 1
A undoDownvoteAnswer() 0 10 1
A undoUpvoteAnswer() 0 10 1
A upvoteAnswer() 0 10 1
A checkAuthenticationIsEnabled() 0 6 2
1
<?php
2
3
/*
4
 * This file is part of the Stack Exchange Api Client library.
5
 *
6
 * (c) Beñat Espiña <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
declare(strict_types=1);
13
14
namespace BenatEspina\StackExchangeApiClient\Api;
15
16
use BenatEspina\StackExchangeApiClient\Api\Answer\AcceptAnswer;
17
use BenatEspina\StackExchangeApiClient\Api\Answer\Answers;
18
use BenatEspina\StackExchangeApiClient\Api\Answer\AnswersByIds;
19
use BenatEspina\StackExchangeApiClient\Api\Answer\AnswersOnQuestions;
20
use BenatEspina\StackExchangeApiClient\Api\Answer\AnswersOnUsers;
21
use BenatEspina\StackExchangeApiClient\Api\Answer\CreateAnswer;
22
use BenatEspina\StackExchangeApiClient\Api\Answer\CreateAnswerFlag;
23
use BenatEspina\StackExchangeApiClient\Api\Answer\DeleteAnswer;
24
use BenatEspina\StackExchangeApiClient\Api\Answer\DownvoteAnswer;
25
use BenatEspina\StackExchangeApiClient\Api\Answer\EditAnswer;
26
use BenatEspina\StackExchangeApiClient\Api\Answer\MeAnswers;
27
use BenatEspina\StackExchangeApiClient\Api\Answer\MeTagsTopAnswers;
28
use BenatEspina\StackExchangeApiClient\Api\Answer\RenderAnswer;
29
use BenatEspina\StackExchangeApiClient\Api\Answer\TopUserAnswersInTags;
30
use BenatEspina\StackExchangeApiClient\Api\Answer\UndoAcceptAnswer;
31
use BenatEspina\StackExchangeApiClient\Api\Answer\UndoDownvoteAnswer;
32
use BenatEspina\StackExchangeApiClient\Api\Answer\UndoUpvoteAnswer;
33
use BenatEspina\StackExchangeApiClient\Api\Answer\UpvoteAnswer;
34
use BenatEspina\StackExchangeApiClient\Authentication\Authentication;
35
use BenatEspina\StackExchangeApiClient\Authentication\AuthenticationIsRequired;
36
use BenatEspina\StackExchangeApiClient\Http\HttpClient;
37
use BenatEspina\StackExchangeApiClient\Serializer\Serializer;
38
39
/**
40
 * @author Beñat Espiña <[email protected]>
41
 */
42
class AnswerApi
43
{
44
    public const QUERY_PARAMS = [
45
        'order'  => 'desc',
46
        'sort'   => 'activity',
47
        'site'   => 'stackoverflow',
48
        'filter' => HttpClient::FILTER_ALL,
49
    ];
50
51
    private $client;
52
    private $serializer;
53
    private $authentication;
54
55
    public function __construct(HttpClient $client, Serializer $serializer, Authentication $authentication = null)
56
    {
57
        $this->client = $client;
58
        $this->serializer = $serializer;
59
        $this->authentication = $authentication;
60
    }
61
62
    public function acceptAnswer(string $id, array $parameters = self::QUERY_PARAMS)
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
63
    {
64
        $this->checkAuthenticationIsEnabled();
65
66
        return (new AcceptAnswer(
67
            $this->client,
68
            $this->serializer,
69
            $this->authentication)
0 ignored issues
show
Bug introduced by
It seems like $this->authentication can be null; however, __construct() does not accept null, maybe add an additional type check?

Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code:

/** @return stdClass|null */
function mayReturnNull() { }

function doesNotAcceptNull(stdClass $x) { }

// With potential error.
function withoutCheck() {
    $x = mayReturnNull();
    doesNotAcceptNull($x); // Potential error here.
}

// Safe - Alternative 1
function withCheck1() {
    $x = mayReturnNull();
    if ( ! $x instanceof stdClass) {
        throw new \LogicException('$x must be defined.');
    }
    doesNotAcceptNull($x);
}

// Safe - Alternative 2
function withCheck2() {
    $x = mayReturnNull();
    if ($x instanceof stdClass) {
        doesNotAcceptNull($x);
    }
}
Loading history...
70
        )->__invoke($id, $parameters);
71
    }
72
73
    public function answers(array $parameters = self::QUERY_PARAMS)
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
74
    {
75
        return (new Answers(
76
            $this->client,
77
            $this->serializer
78
        ))->__invoke($parameters);
79
    }
80
81
    public function answersByIds($ids, array $parameters = self::QUERY_PARAMS)
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
82
    {
83
        return (new AnswersByIds(
84
            $this->client,
85
            $this->serializer
86
        ))->__invoke($ids, $parameters);
87
    }
88
89
    public function answersOnQuestions($ids, array $parameters = self::QUERY_PARAMS)
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
90
    {
91
        return (new AnswersOnQuestions(
92
            $this->client,
93
            $this->serializer
94
        ))->__invoke($ids, $parameters);
95
    }
96
97
    public function answersOnUsers($ids, array $parameters = self::QUERY_PARAMS)
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
98
    {
99
        return (new AnswersOnUsers(
100
            $this->client,
101
            $this->serializer
102
        ))->__invoke($ids, $parameters);
103
    }
104
105
    public function createAnswer(string $questionId, string $body, array $parameters = self::QUERY_PARAMS)
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
106
    {
107
        $this->checkAuthenticationIsEnabled();
108
109
        return (new CreateAnswer(
110
            $this->client,
111
            $this->serializer,
112
            $this->authentication
0 ignored issues
show
Bug introduced by
It seems like $this->authentication can be null; however, __construct() does not accept null, maybe add an additional type check?

Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code:

/** @return stdClass|null */
function mayReturnNull() { }

function doesNotAcceptNull(stdClass $x) { }

// With potential error.
function withoutCheck() {
    $x = mayReturnNull();
    doesNotAcceptNull($x); // Potential error here.
}

// Safe - Alternative 1
function withCheck1() {
    $x = mayReturnNull();
    if ( ! $x instanceof stdClass) {
        throw new \LogicException('$x must be defined.');
    }
    doesNotAcceptNull($x);
}

// Safe - Alternative 2
function withCheck2() {
    $x = mayReturnNull();
    if ($x instanceof stdClass) {
        doesNotAcceptNull($x);
    }
}
Loading history...
113
        ))->__invoke($questionId, $body, $parameters);
114
    }
115
116
    public function createAnswerFlag(string $id, array $parameters = self::QUERY_PARAMS)
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
117
    {
118
        $this->checkAuthenticationIsEnabled();
119
120
        return (new CreateAnswerFlag(
121
            $this->client,
122
            $this->serializer,
123
            $this->authentication
0 ignored issues
show
Bug introduced by
It seems like $this->authentication can be null; however, __construct() does not accept null, maybe add an additional type check?

Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code:

/** @return stdClass|null */
function mayReturnNull() { }

function doesNotAcceptNull(stdClass $x) { }

// With potential error.
function withoutCheck() {
    $x = mayReturnNull();
    doesNotAcceptNull($x); // Potential error here.
}

// Safe - Alternative 1
function withCheck1() {
    $x = mayReturnNull();
    if ( ! $x instanceof stdClass) {
        throw new \LogicException('$x must be defined.');
    }
    doesNotAcceptNull($x);
}

// Safe - Alternative 2
function withCheck2() {
    $x = mayReturnNull();
    if ($x instanceof stdClass) {
        doesNotAcceptNull($x);
    }
}
Loading history...
124
        ))->__invoke($id, $parameters);
125
    }
126
127
    public function deleteAnswer(string $id, array $parameters = self::QUERY_PARAMS)
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
128
    {
129
        $this->checkAuthenticationIsEnabled();
130
131
        return (new DeleteAnswer(
132
            $this->client,
133
            $this->serializer,
134
            $this->authentication
0 ignored issues
show
Bug introduced by
It seems like $this->authentication can be null; however, __construct() does not accept null, maybe add an additional type check?

Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code:

/** @return stdClass|null */
function mayReturnNull() { }

function doesNotAcceptNull(stdClass $x) { }

// With potential error.
function withoutCheck() {
    $x = mayReturnNull();
    doesNotAcceptNull($x); // Potential error here.
}

// Safe - Alternative 1
function withCheck1() {
    $x = mayReturnNull();
    if ( ! $x instanceof stdClass) {
        throw new \LogicException('$x must be defined.');
    }
    doesNotAcceptNull($x);
}

// Safe - Alternative 2
function withCheck2() {
    $x = mayReturnNull();
    if ($x instanceof stdClass) {
        doesNotAcceptNull($x);
    }
}
Loading history...
135
        ))->__invoke($id, $parameters);
136
    }
137
138
    public function downvoteAnswer(string $id, array $parameters = self::QUERY_PARAMS)
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
139
    {
140
        $this->checkAuthenticationIsEnabled();
141
142
        return (new DownvoteAnswer(
143
            $this->client,
144
            $this->serializer,
145
            $this->authentication
0 ignored issues
show
Bug introduced by
It seems like $this->authentication can be null; however, __construct() does not accept null, maybe add an additional type check?

Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code:

/** @return stdClass|null */
function mayReturnNull() { }

function doesNotAcceptNull(stdClass $x) { }

// With potential error.
function withoutCheck() {
    $x = mayReturnNull();
    doesNotAcceptNull($x); // Potential error here.
}

// Safe - Alternative 1
function withCheck1() {
    $x = mayReturnNull();
    if ( ! $x instanceof stdClass) {
        throw new \LogicException('$x must be defined.');
    }
    doesNotAcceptNull($x);
}

// Safe - Alternative 2
function withCheck2() {
    $x = mayReturnNull();
    if ($x instanceof stdClass) {
        doesNotAcceptNull($x);
    }
}
Loading history...
146
        ))->__invoke($id, $parameters);
147
    }
148
149
    public function editAnswer(string $id, string $body, array $parameters = self::QUERY_PARAMS)
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
150
    {
151
        $this->checkAuthenticationIsEnabled();
152
153
        return (new EditAnswer(
154
            $this->client,
155
            $this->serializer,
156
            $this->authentication
0 ignored issues
show
Bug introduced by
It seems like $this->authentication can be null; however, __construct() does not accept null, maybe add an additional type check?

Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code:

/** @return stdClass|null */
function mayReturnNull() { }

function doesNotAcceptNull(stdClass $x) { }

// With potential error.
function withoutCheck() {
    $x = mayReturnNull();
    doesNotAcceptNull($x); // Potential error here.
}

// Safe - Alternative 1
function withCheck1() {
    $x = mayReturnNull();
    if ( ! $x instanceof stdClass) {
        throw new \LogicException('$x must be defined.');
    }
    doesNotAcceptNull($x);
}

// Safe - Alternative 2
function withCheck2() {
    $x = mayReturnNull();
    if ($x instanceof stdClass) {
        doesNotAcceptNull($x);
    }
}
Loading history...
157
        ))->__invoke($id, $body, $parameters);
158
    }
159
160
    public function meAnswers(array $parameters = self::QUERY_PARAMS)
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
161
    {
162
        $this->checkAuthenticationIsEnabled();
163
164
        return (new MeAnswers(
165
            $this->client,
166
            $this->serializer,
167
            $this->authentication
0 ignored issues
show
Bug introduced by
It seems like $this->authentication can be null; however, __construct() does not accept null, maybe add an additional type check?

Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code:

/** @return stdClass|null */
function mayReturnNull() { }

function doesNotAcceptNull(stdClass $x) { }

// With potential error.
function withoutCheck() {
    $x = mayReturnNull();
    doesNotAcceptNull($x); // Potential error here.
}

// Safe - Alternative 1
function withCheck1() {
    $x = mayReturnNull();
    if ( ! $x instanceof stdClass) {
        throw new \LogicException('$x must be defined.');
    }
    doesNotAcceptNull($x);
}

// Safe - Alternative 2
function withCheck2() {
    $x = mayReturnNull();
    if ($x instanceof stdClass) {
        doesNotAcceptNull($x);
    }
}
Loading history...
168
        ))->__invoke($parameters);
169
    }
170
171
    public function meTagsTopAnswers($tags, array $parameters = self::QUERY_PARAMS)
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
172
    {
173
        $this->checkAuthenticationIsEnabled();
174
175
        return (new MeTagsTopAnswers(
176
            $this->client,
177
            $this->serializer,
178
            $this->authentication
0 ignored issues
show
Bug introduced by
It seems like $this->authentication can be null; however, __construct() does not accept null, maybe add an additional type check?

Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code:

/** @return stdClass|null */
function mayReturnNull() { }

function doesNotAcceptNull(stdClass $x) { }

// With potential error.
function withoutCheck() {
    $x = mayReturnNull();
    doesNotAcceptNull($x); // Potential error here.
}

// Safe - Alternative 1
function withCheck1() {
    $x = mayReturnNull();
    if ( ! $x instanceof stdClass) {
        throw new \LogicException('$x must be defined.');
    }
    doesNotAcceptNull($x);
}

// Safe - Alternative 2
function withCheck2() {
    $x = mayReturnNull();
    if ($x instanceof stdClass) {
        doesNotAcceptNull($x);
    }
}
Loading history...
179
        ))->__invoke($tags, $parameters);
180
    }
181
182
    public function renderAnswer(string $id, string $body, array $parameters = self::QUERY_PARAMS)
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
183
    {
184
        $this->checkAuthenticationIsEnabled();
185
186
        return (new RenderAnswer(
187
            $this->client,
188
            $this->serializer,
189
            $this->authentication
190
        ))->__invoke($id, $body, $parameters);
191
    }
192
193
    public function topUserAnswersInTags(string $userId, $tags, array $parameters = self::QUERY_PARAMS)
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
194
    {
195
        return (new TopUserAnswersInTags(
196
            $this->client,
197
            $this->serializer
198
        ))->__invoke($userId, $tags, $parameters);
199
    }
200
201
    public function undoAcceptAnswer(string $id, array $parameters = self::QUERY_PARAMS)
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
202
    {
203
        $this->checkAuthenticationIsEnabled();
204
205
        return (new UndoAcceptAnswer(
206
            $this->client,
207
            $this->serializer,
208
            $this->authentication
0 ignored issues
show
Bug introduced by
It seems like $this->authentication can be null; however, __construct() does not accept null, maybe add an additional type check?

Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code:

/** @return stdClass|null */
function mayReturnNull() { }

function doesNotAcceptNull(stdClass $x) { }

// With potential error.
function withoutCheck() {
    $x = mayReturnNull();
    doesNotAcceptNull($x); // Potential error here.
}

// Safe - Alternative 1
function withCheck1() {
    $x = mayReturnNull();
    if ( ! $x instanceof stdClass) {
        throw new \LogicException('$x must be defined.');
    }
    doesNotAcceptNull($x);
}

// Safe - Alternative 2
function withCheck2() {
    $x = mayReturnNull();
    if ($x instanceof stdClass) {
        doesNotAcceptNull($x);
    }
}
Loading history...
209
        ))->__invoke($id, $parameters);
210
    }
211
212
    public function undoDownvoteAnswer(string $id, array $parameters = self::QUERY_PARAMS)
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
213
    {
214
        $this->checkAuthenticationIsEnabled();
215
216
        return (new UndoDownvoteAnswer(
217
            $this->client,
218
            $this->serializer,
219
            $this->authentication
0 ignored issues
show
Bug introduced by
It seems like $this->authentication can be null; however, __construct() does not accept null, maybe add an additional type check?

Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code:

/** @return stdClass|null */
function mayReturnNull() { }

function doesNotAcceptNull(stdClass $x) { }

// With potential error.
function withoutCheck() {
    $x = mayReturnNull();
    doesNotAcceptNull($x); // Potential error here.
}

// Safe - Alternative 1
function withCheck1() {
    $x = mayReturnNull();
    if ( ! $x instanceof stdClass) {
        throw new \LogicException('$x must be defined.');
    }
    doesNotAcceptNull($x);
}

// Safe - Alternative 2
function withCheck2() {
    $x = mayReturnNull();
    if ($x instanceof stdClass) {
        doesNotAcceptNull($x);
    }
}
Loading history...
220
        ))->__invoke($id, $parameters);
221
    }
222
223
    public function undoUpvoteAnswer(string $id, array $parameters = self::QUERY_PARAMS)
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
224
    {
225
        $this->checkAuthenticationIsEnabled();
226
227
        return (new UndoUpvoteAnswer(
228
            $this->client,
229
            $this->serializer,
230
            $this->authentication
0 ignored issues
show
Bug introduced by
It seems like $this->authentication can be null; however, __construct() does not accept null, maybe add an additional type check?

Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code:

/** @return stdClass|null */
function mayReturnNull() { }

function doesNotAcceptNull(stdClass $x) { }

// With potential error.
function withoutCheck() {
    $x = mayReturnNull();
    doesNotAcceptNull($x); // Potential error here.
}

// Safe - Alternative 1
function withCheck1() {
    $x = mayReturnNull();
    if ( ! $x instanceof stdClass) {
        throw new \LogicException('$x must be defined.');
    }
    doesNotAcceptNull($x);
}

// Safe - Alternative 2
function withCheck2() {
    $x = mayReturnNull();
    if ($x instanceof stdClass) {
        doesNotAcceptNull($x);
    }
}
Loading history...
231
        ))->__invoke($id, $parameters);
232
    }
233
234
    public function upvoteAnswer(string $id, array $parameters = self::QUERY_PARAMS)
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
235
    {
236
        $this->checkAuthenticationIsEnabled();
237
238
        return (new UpvoteAnswer(
239
            $this->client,
240
            $this->serializer,
241
            $this->authentication
0 ignored issues
show
Bug introduced by
It seems like $this->authentication can be null; however, __construct() does not accept null, maybe add an additional type check?

Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code:

/** @return stdClass|null */
function mayReturnNull() { }

function doesNotAcceptNull(stdClass $x) { }

// With potential error.
function withoutCheck() {
    $x = mayReturnNull();
    doesNotAcceptNull($x); // Potential error here.
}

// Safe - Alternative 1
function withCheck1() {
    $x = mayReturnNull();
    if ( ! $x instanceof stdClass) {
        throw new \LogicException('$x must be defined.');
    }
    doesNotAcceptNull($x);
}

// Safe - Alternative 2
function withCheck2() {
    $x = mayReturnNull();
    if ($x instanceof stdClass) {
        doesNotAcceptNull($x);
    }
}
Loading history...
242
        ))->__invoke($id, $parameters);
243
    }
244
245
    private function checkAuthenticationIsEnabled() : void
246
    {
247
        if (!$this->authentication instanceof Authentication) {
248
            throw new AuthenticationIsRequired();
249
        }
250
    }
251
}
252