1 | <?php |
||
13 | trait JSendResponseTrait |
||
14 | { |
||
15 | use MessageTrait; |
||
16 | |||
17 | /** |
||
18 | * @var string |
||
19 | */ |
||
20 | private $message; |
||
21 | /** |
||
22 | * @var int|null |
||
23 | */ |
||
24 | private $code; |
||
25 | |||
26 | /** |
||
27 | * @param int|null $code |
||
28 | */ |
||
29 | final public function respond(int $code = null): void |
||
37 | |||
38 | /** |
||
39 | * @return int |
||
40 | */ |
||
41 | final public function getStatusCode() |
||
49 | |||
50 | /** |
||
51 | * @param $code |
||
52 | * @param string $reasonPhrase |
||
53 | * |
||
54 | * @return JSend|JSendInterface |
||
55 | * @throws EnsuranceException |
||
56 | */ |
||
57 | public function withStatus($code, $reasonPhrase = '') |
||
70 | |||
71 | /** |
||
72 | * @return string |
||
73 | */ |
||
74 | public function getReasonPhrase() |
||
78 | } |
||
79 |
This check looks for methods that are used by a trait but not required by it.
To illustrate, let’s look at the following code example
The trait
Idable
provides a methodequalsId
that in turn relies on the methodgetId()
. If this method does not exist on a class mixing in this trait, the method will fail.Adding the
getId()
as an abstract method to the trait will make sure it is available.