Conditions | 1 |
Paths | 1 |
Total Lines | 72 |
Code Lines | 33 |
Lines | 0 |
Ratio | 0 % |
Changes | 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 |
||
24 | protected function configureResourceNode(ArrayNodeDefinition $resourceNode): void |
||
25 | { |
||
26 | $resourceNode |
||
27 | ->children() |
||
28 | ->scalarNode('schedule')->cannotBeEmpty()->end() |
||
29 | ->scalarNode('command')->cannotBeEmpty()->end() |
||
|
|||
30 | ->arrayNode('args') |
||
31 | ->requiresAtLeastOneElement() |
||
32 | ->treatNullLike([]) |
||
33 | ->beforeNormalization()->castToArray()->end() |
||
34 | ->scalarPrototype()->cannotBeEmpty()->end() |
||
35 | ->end() |
||
36 | ->scalarNode('state') |
||
37 | ->beforeNormalization() |
||
38 | ->ifString() |
||
39 | ->then(function (string $value) { |
||
40 | Assert::oneOf($value, Job::getStates(), sprintf( |
||
41 | 'Invalid state provided: %s. Expected one of: %s', |
||
42 | $value, |
||
43 | implode(', ', Job::getStates()) |
||
44 | )); |
||
45 | |||
46 | return $value; |
||
47 | }) |
||
48 | ->end() |
||
49 | ->cannotBeEmpty() |
||
50 | ->end() |
||
51 | ->scalarNode('queue')->cannotBeEmpty()->end() |
||
52 | ->scalarNode('priority')->cannotBeEmpty()->end() |
||
53 | // ->scalarNode('created_at')->cannotBeEmpty()->end() |
||
54 | // ->scalarNode('started_at')->cannotBeEmpty()->end() |
||
55 | // ->scalarNode('checked_at')->cannotBeEmpty()->end() |
||
56 | // ->scalarNode('closed_at')->cannotBeEmpty()->end() |
||
57 | ->scalarNode('execute_after')->cannotBeEmpty()->end() |
||
58 | // ->arrayNode('dependencies') |
||
59 | // ->defaultValue([]) |
||
60 | // ->requiresAtLeastOneElement() |
||
61 | // ->treatNullLike([]) |
||
62 | // ->beforeNormalization() |
||
63 | // ->ifTrue(function ($values){ |
||
64 | // return !empty($values); |
||
65 | // }) |
||
66 | // ->then(function(){ |
||
67 | // throw new NotImplementedException(sprintf( |
||
68 | // 'Providing "dependencies" at %s fixture not yet implemented', |
||
69 | // $this->getName() |
||
70 | // )); |
||
71 | // }) |
||
72 | // ->end() |
||
73 | // ->beforeNormalization()->castToArray()->end() |
||
74 | // ->scalarPrototype()->cannotBeEmpty()->end() |
||
75 | // ->end() |
||
76 | ->scalarNode('worker_name')->cannotBeEmpty()->end() |
||
77 | ->scalarNode('output')->cannotBeEmpty()->end() |
||
78 | ->scalarNode('error_output')->cannotBeEmpty()->end() |
||
79 | ->scalarNode('exit_code')->cannotBeEmpty()->end() |
||
80 | ->scalarNode('max_runtime')->cannotBeEmpty()->end() |
||
81 | ->scalarNode('max_retries')->cannotBeEmpty()->end() |
||
82 | // ->scalarNode('original_job') |
||
83 | // ->cannotBeEmpty() |
||
84 | // ->beforeNormalization() |
||
85 | // ->ifString() |
||
86 | // ->then(function(){ |
||
87 | // throw new NotImplementedException(sprintf( |
||
88 | // 'Providing "original_job" at %s fixture not yet implemented', |
||
89 | // $this->getName() |
||
90 | // )); |
||
91 | // }) |
||
92 | // ->end() |
||
93 | // ->end() |
||
94 | ->scalarNode('retry_jobs')->cannotBeEmpty()->end() |
||
95 | ->end() |
||
96 | ; |
||
99 |