| 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() |
||
| 45 | |||
| 46 | /** |
||
| 47 | * @param $code |
||
| 48 | * @param string $reasonPhrase |
||
| 49 | * |
||
| 50 | * @return JSend|JSendInterface |
||
| 51 | * @throws EnsuranceException |
||
| 52 | */ |
||
| 53 | public function withStatus($code, $reasonPhrase = '') |
||
| 66 | |||
| 67 | /** |
||
| 68 | * @return string |
||
| 69 | */ |
||
| 70 | public function getReasonPhrase() |
||
| 74 | } |
||
| 75 |
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
Idableprovides a methodequalsIdthat 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.