| 1 | <?php |
||||||
| 2 | |||||||
| 3 | declare(strict_types=1); |
||||||
| 4 | |||||||
| 5 | namespace VGirol\JsonApiStructure\Concern; |
||||||
| 6 | |||||||
| 7 | use VGirol\JsonApiStructure\Messages; |
||||||
| 8 | |||||||
| 9 | /** |
||||||
| 10 | * Validations relating to the meta object |
||||||
| 11 | */ |
||||||
| 12 | trait ValidateMetaObject |
||||||
| 13 | { |
||||||
| 14 | /** |
||||||
| 15 | * Assert that a json fragment is a valid meta object. |
||||||
| 16 | * |
||||||
| 17 | * It will do the following checks : |
||||||
| 18 | * 1) validates that the meta object is not an array of objects (@see mustNotBeArrayOfObjects). |
||||||
| 19 | * 2) validates that each member of the meta object is valid (@see validateMemberName). |
||||||
| 20 | * |
||||||
| 21 | * @param array $json |
||||||
| 22 | * @param boolean $strict If true, unsafe characters are not allowed when checking members name. |
||||||
| 23 | * |
||||||
| 24 | * @return void |
||||||
| 25 | * @throws \VGirol\JsonApiStructure\Exception\ValidationException |
||||||
| 26 | */ |
||||||
| 27 | 75 | public function validateMetaObject($json, bool $strict): void |
|||||
| 28 | { |
||||||
| 29 | 75 | $this->mustNotBeArrayOfObjects($json, Messages::META_OBJECT_MUST_BE_ARRAY, 403); |
|||||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||||||
| 30 | |||||||
| 31 | 69 | foreach (array_keys($json) as $key) { |
|||||
| 32 | 69 | $this->validateMemberName($key, $strict); |
|||||
|
0 ignored issues
–
show
The method
validateMemberName() does not exist on VGirol\JsonApiStructure\Concern\ValidateMetaObject. Did you maybe mean validateMetaObject()?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed. Loading history...
|
|||||||
| 33 | } |
||||||
| 34 | 27 | } |
|||||
| 35 | } |
||||||
| 36 |