@@ 69-74 (lines=6) @@ | ||
66 | if (array_key_exists('before_normalization', $context)) { |
|
67 | $beforeNormalization = $context['before_normalization']; |
|
68 | ||
69 | if (!is_callable($beforeNormalization)) { |
|
70 | throw new \InvalidArgumentException(sprintf( |
|
71 | 'Invalid callable for before normalization. "%s" given.', |
|
72 | is_object($beforeNormalization) ? get_class($beforeNormalization) : gettype($beforeNormalization) |
|
73 | )); |
|
74 | } |
|
75 | ||
76 | $beforeNormalization($object, $format, $context); |
|
77 | } |
|
@@ 90-95 (lines=6) @@ | ||
87 | if (array_key_exists('after_normalization', $context)) { |
|
88 | $afterNormalization = $context['after_normalization']; |
|
89 | ||
90 | if (!is_callable($afterNormalization)) { |
|
91 | throw new \InvalidArgumentException(sprintf( |
|
92 | 'Invalid callable for after normalization. "%s" given.', |
|
93 | is_object($afterNormalization) ? get_class($afterNormalization) : gettype($afterNormalization) |
|
94 | )); |
|
95 | } |
|
96 | ||
97 | $data = $afterNormalization($data, $object, $format, $context); |
|
98 |
@@ 39-45 (lines=7) @@ | ||
36 | */ |
|
37 | public function normalize($object, $format = null, array $context = []) |
|
38 | { |
|
39 | if (!$object instanceof ResourceCollection) { |
|
40 | throw new \InvalidArgumentException(sprintf( |
|
41 | 'The normalizer support only "%s" but "%s" given.', |
|
42 | ResourceCollection::class, |
|
43 | is_object($object) ? get_class($object) : gettype($object) |
|
44 | )); |
|
45 | } |
|
46 | ||
47 | $data = []; |
|
48 | $links = []; |