Conditions | 8 |
Paths | 6 |
Total Lines | 52 |
Code Lines | 34 |
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 |
||
19 | public function run($request) |
||
20 | { |
||
21 | $this->request = $request; |
||
22 | $this->addOption("classes", "Classes to publish (comma separated)", 'Page'); |
||
23 | $this->addOption("go", "Set this to 1 to proceed", 0); |
||
24 | |||
25 | $options = $this->askOptions(); |
||
26 | |||
27 | $classes = $options['classes']; |
||
28 | $go = $options['go']; |
||
29 | |||
30 | $cbSave = function ($List, $publish = false) { |
||
31 | foreach ($List as $Item) { |
||
32 | $this->message('Saving item "' . $Item->getTitle() . '"'); |
||
33 | if ($publish) { |
||
34 | $Item->publishRecursive(); |
||
35 | } else { |
||
36 | $Item->write(); |
||
37 | } |
||
38 | } |
||
39 | }; |
||
40 | |||
41 | $classesToPublish = explode(',', $classes); |
||
42 | |||
43 | if ($go) { |
||
44 | foreach ($classesToPublish as $class) { |
||
45 | $this->message("Publishing class $class"); |
||
46 | |||
47 | $List = $class::get(); |
||
48 | $singl = $class::singleton(); |
||
49 | $fluent = $singl->has_extension("\\TractorCow\\Fluent\\Extension\\FluentExtension"); |
||
50 | |||
51 | $publish = $singl->has_extension(Versioned::class); |
||
52 | |||
53 | // With fluent we need to change state when saving |
||
54 | if ($fluent) { |
||
55 | $state = \TractorCow\Fluent\State\FluentState::singleton(); |
||
56 | $allLocales = \TractorCow\Fluent\Model\Locale::get(); |
||
57 | foreach ($allLocales as $locale) { |
||
58 | $this->message('Publishing with locale ' . $locale->Locale, "info"); |
||
59 | $state->withState(function ($state) use ($locale, $List, $cbSave, $publish) { |
||
60 | $state->setLocale($locale->Locale); |
||
61 | $cbSave($List, $publish); |
||
62 | }); |
||
63 | } |
||
64 | } else { |
||
65 | $cbSave($List, $publish); |
||
66 | } |
||
67 | } |
||
68 | } else { |
||
69 | foreach ($classesToPublish as $class) { |
||
70 | $this->message("Would publish " . $class::get()->count() . " items for class " . $class); |
||
71 | } |
||
75 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths