Conditions | 10 |
Paths | 144 |
Total Lines | 47 |
Code Lines | 37 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 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 |
||
54 | return $key ?? null; |
||
55 | } |
||
56 | |||
57 | /** {@inheritdoc} */ |
||
58 | public function getApiValue($yfValue, array $field) |
||
59 | { |
||
60 | $this->loadCacheList(); |
||
61 | if ($value = $this->cacheList[$yfValue] ?? null) { |
||
62 | return $value; |
||
63 | } |
||
64 | if ($value = $this->cacheList[\App\Language::translate($yfValue, 'Products', 'pl-PL')] ?? null) { |
||
65 | return $value; |
||
66 | } |
||
67 | return null; |
||
68 | } |
||
69 | |||
70 | /** |
||
71 | * Get picklist values. |
||
72 | * |
||
73 | * @return array |
||
74 | */ |
||
75 | private function getPicklistValues(): array |
||
|
|||
76 | { |
||
77 | $picklistValues = \App\Fields\Picklist::getValues($this->fieldModel->getName()); |
||
78 | $values = []; |
||
79 | foreach ($picklistValues as $value) { |
||
80 | $values[trim(mb_strtolower($value['picklistValue']), '.')] = $value['picklistValue']; |
||
81 | $values[trim(mb_strtolower(\App\Language::translate( |
||
82 | $value['picklistValue'], |
||
83 | 'Products', |
||
84 | 'pl-PL' |
||
85 | )), '.')] = $value['picklistValue']; |
||
86 | } |
||
87 | return $values; |
||
88 | } |
||
89 | |||
90 | /** |
||
91 | * Get all unit measure from API. |
||
92 | * |
||
93 | * @return array|null |
||
94 | */ |
||
95 | private function getAllFromApi(): ?array |
||
96 | { |
||
97 | if (null === $this->cache) { |
||
98 | $this->cache = []; |
||
99 | try { |
||
100 | foreach ($this->getFromApi('Dictionary/UnitMeasure') as $value) { |
||
101 | if (empty($value['key'])) { |
||
125 |
This check looks for private methods that have been defined, but are not used inside the class.