Conditions | 11 |
Paths | 6 |
Total Lines | 32 |
Code Lines | 12 |
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 |
||
87 | public function hidden() |
||
88 | { |
||
89 | $class = $this->model; // Must be a local var to test |
||
90 | |||
91 | // There aren't multiple locales specified |
||
92 | if (count(\Illuminate\Support\Facades\Config::get('site.site.locales')) <= 1 ) { return true; |
||
93 | } |
||
94 | |||
95 | // We're editing a model with no locale attribute |
||
96 | if ($this->item && !$this->item->locale) { return true; |
||
97 | } |
||
98 | |||
99 | // The model was explicitly disabled |
||
100 | if (!property_exists($class, 'localizable') || $class::$localizable === false ) { |
||
101 | return true; |
||
102 | } |
||
103 | |||
104 | // Auto localize is turned on and we're on a child model |
||
105 | if (\Illuminate\Support\Facades\Config::get('painel.core.auto_localize_root_models') |
||
106 | && app('facilitador.wildcard')->detectParent() |
||
107 | ) { return true; |
||
108 | } |
||
109 | |||
110 | // If auto-localizeable is turned off and this model doesn't have it |
||
111 | // turned on |
||
112 | if (!\Illuminate\Support\Facades\Config::get('painel.core.auto_localize_root_models') |
||
113 | && property_exists($class, 'localizable') && !$class::$localizable |
||
114 | ) { return true; |
||
115 | } |
||
116 | |||
117 | // Otherwise, allow localization |
||
118 | return false; |
||
119 | } |
||
169 |