Conditions | 11 |
Paths | 6 |
Total Lines | 39 |
Code Lines | 25 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
62 | public function onKernelRequest(GetResponseEvent $event) |
||
63 | { |
||
64 | $request = $event->getRequest(); |
||
65 | $method = $request->getMethod(); |
||
66 | |||
67 | if ( |
||
68 | 'DELETE' === $method |
||
69 | || $request->isMethodSafe(false) |
||
70 | || !($attributes = RequestAttributesExtractor::extractAttributes($request)) |
||
71 | || !$attributes['receive'] |
||
72 | || ( |
||
73 | '' === ($requestContent = $request->getContent()) |
||
74 | && ('POST' === $method || 'PUT' === $method) |
||
75 | ) |
||
76 | ) { |
||
77 | return; |
||
78 | } |
||
79 | |||
80 | $context = $this->serializerContextBuilder->createFromRequest($request, false, $attributes); |
||
81 | if (false === $context['input_class']) { |
||
82 | return; |
||
83 | } |
||
84 | |||
85 | // BC check to be removed in 3.0 |
||
86 | if (null !== $this->formatsProvider) { |
||
87 | $this->formats = $this->formatsProvider->getFormatsFromAttributes($attributes); |
||
88 | } |
||
89 | $this->formatMatcher = new FormatMatcher($this->formats); |
||
90 | $format = $this->getFormat($request); |
||
91 | |||
92 | $data = $request->attributes->get('data'); |
||
93 | if (null !== $data) { |
||
94 | $context[AbstractNormalizer::OBJECT_TO_POPULATE] = $data; |
||
95 | } |
||
96 | |||
97 | $request->attributes->set( |
||
98 | 'data', |
||
99 | $this->serializer->deserialize( |
||
100 | $requestContent, $context['input_class'], $format, $context |
||
101 | ) |
||
139 |