| Conditions | 10 |
| Paths | 24 |
| Total Lines | 37 |
| Code Lines | 22 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 3 | ||
| Bugs | 0 | Features | 1 |
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 |
||
| 100 | protected function serializeValue(LiipImagineSerializableField $liipAnnotation, $object, $value) |
||
| 101 | { |
||
| 102 | if ($vichField = $liipAnnotation->getVichUploaderField()) { |
||
| 103 | $value = $this->vichStorage->resolveUri($object, $vichField); |
||
| 104 | } |
||
| 105 | |||
| 106 | $result = []; |
||
| 107 | if (array_key_exists('includeOriginal', $this->config) && $this->config['includeOriginal']) { |
||
| 108 | if ( |
||
| 109 | array_key_exists('includeHostForOriginal', $this->config) && |
||
| 110 | $this->config['includeHostForOriginal'] && |
||
| 111 | $liipAnnotation->getVichUploaderField() |
||
| 112 | ) { |
||
| 113 | $result['original'] = $this->getHostUrl().$value; |
||
| 114 | } else { |
||
| 115 | $result['original'] = $value; |
||
| 116 | } |
||
| 117 | } |
||
| 118 | |||
| 119 | $filters = $liipAnnotation->getFilter(); |
||
| 120 | if (is_array($filters)) { |
||
| 121 | foreach ($filters as $filter) { |
||
| 122 | $result[$filter] = $this->cacheManager->getBrowserPath($value, $filter); |
||
| 123 | } |
||
| 124 | |||
| 125 | return $result; |
||
| 126 | } |
||
| 127 | |||
| 128 | $filtered = $this->cacheManager->getBrowserPath($value, $filters); |
||
| 129 | if (count($result) !== 0) { |
||
| 130 | $result[$filters] = $filtered; |
||
| 131 | |||
| 132 | return $result; |
||
| 133 | } |
||
| 134 | |||
| 135 | return $filtered; |
||
| 136 | } |
||
| 137 | |||
| 156 |