| Conditions | 3 |
| Paths | 3 |
| Total Lines | 23 |
| Code Lines | 13 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 35 | public function run(Request $request) { |
||
| 36 | // read |
||
| 37 | $id = $this->getParam('id'); |
||
|
|
|||
| 38 | $api = ApiQuery::create()->findOneById($id); |
||
| 39 | |||
| 40 | // check existence |
||
| 41 | if ($api === null) { |
||
| 42 | throw new ResourceNotFoundException('Api not found.'); |
||
| 43 | } |
||
| 44 | |||
| 45 | // hydrate |
||
| 46 | $data = Json::decode($request->getContent()); |
||
|
1 ignored issue
–
show
|
|||
| 47 | $serializer = Api::getSerializer(); |
||
| 48 | $api = $serializer->hydrate($api, $data); |
||
| 49 | |||
| 50 | // validate |
||
| 51 | if (!$api->validate()) { |
||
| 52 | throw new ValidationException($api->getValidationFailures()); |
||
| 53 | } else { |
||
| 54 | $api->save(); |
||
| 55 | return $this->response->run($request, $api); |
||
| 56 | } |
||
| 57 | } |
||
| 58 | } |
||
| 59 |
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.