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