Conditions | 1 |
Paths | 1 |
Total Lines | 121 |
Code Lines | 52 |
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 |
||
50 | public static function module_styles( $args ) { |
||
51 | $attrs = $args['attrs'] ?? []; |
||
52 | $order_class = $args['orderClass']; |
||
53 | $elements = $args['elements']; |
||
54 | $settings = $args['settings'] ?? []; |
||
55 | $parent_attrs = $args['parentAttrs'] ?? []; |
||
56 | |||
57 | $parent_default_attributes = ModuleRegistration::get_default_attrs( 'example/parent-module' ); |
||
58 | $parent_attrs_with_default = array_replace_recursive( $parent_default_attributes, $parent_attrs ); |
||
59 | |||
60 | $content_container_selector = "{$order_class} .example_child_module__content-container"; |
||
61 | |||
62 | Style::add( |
||
63 | [ |
||
64 | 'id' => $args['id'], |
||
65 | 'name' => $args['name'], |
||
66 | 'orderIndex' => $args['orderIndex'], |
||
67 | 'storeInstance' => $args['storeInstance'], |
||
68 | 'styles' => [ |
||
69 | // Module. |
||
70 | $elements->style( |
||
71 | [ |
||
72 | 'attrName' => 'module', |
||
73 | 'styleProps' => [ |
||
74 | 'disabledOn' => [ |
||
75 | 'disabledModuleVisibility' => $settings['disabledModuleVisibility'] ?? null, |
||
76 | ], |
||
77 | 'advancedStyles' => [ |
||
78 | [ |
||
79 | 'componentName' => 'divi/text', |
||
80 | 'props' => [ |
||
81 | 'selector' => $content_container_selector, |
||
82 | 'attr' => $attrs['module']['advanced']['text'] ?? [], |
||
83 | ] |
||
84 | ] |
||
85 | ] |
||
86 | ], |
||
87 | ] |
||
88 | ), |
||
89 | |||
90 | // Title. |
||
91 | $elements->style( |
||
92 | [ |
||
93 | 'attrName' => 'title', |
||
94 | ] |
||
95 | ), |
||
96 | |||
97 | // Content. |
||
98 | $elements->style( |
||
99 | [ |
||
100 | 'attrName' => 'content', |
||
101 | ] |
||
102 | ), |
||
103 | |||
104 | // Icon. |
||
105 | $elements->style( |
||
106 | [ |
||
107 | 'attrName' => 'icon', |
||
108 | 'styleProps' => [ |
||
109 | 'advancedStyles' => [ |
||
110 | [ |
||
111 | 'componentName' => 'divi/common', |
||
112 | 'props' => [ |
||
113 | 'attr' => $attrs['icon']['innerContent'] ?? $parent_attrs_with_default['icon']['innerContent'] ?? [], |
||
114 | 'declarationFunction' => [ChildModule::class, 'icon_font_declaration'], |
||
115 | ] |
||
116 | ], |
||
117 | [ |
||
118 | 'componentName' => 'divi/common', |
||
119 | 'props' => [ |
||
120 | 'attr' => $attrs['icon']['advanced']['color'] ?? $parent_attrs_with_default['icon']['advanced']['color'] ?? [], |
||
121 | 'property' => 'color', |
||
122 | ] |
||
123 | ], |
||
124 | [ |
||
125 | 'componentName' => 'divi/common', |
||
126 | 'props' => [ |
||
127 | 'attr' => $attrs['icon']['advanced']['size'] ?? $parent_attrs_with_default['icon']['advanced']['size'] ?? [], |
||
128 | 'property' => 'font-size', |
||
129 | ] |
||
130 | ], |
||
131 | ] |
||
132 | ] |
||
133 | ] |
||
134 | ), |
||
135 | |||
136 | /* |
||
137 | * We need to add CssStyle at the very bottom of other |
||
138 | * components so that custom css can override module styles |
||
139 | * till we find a more elegant solution. |
||
140 | */ |
||
141 | CssStyle::style( |
||
142 | [ |
||
143 | 'selector' => $args['orderClass'], |
||
144 | 'attr' => $attrs['css'] ?? [], |
||
145 | 'cssFields' => self::custom_css(), |
||
146 | ] |
||
147 | ), |
||
148 | |||
149 | // ATTENTION: The code is intentionally added and commented in FE only as an example of expected value format. |
||
150 | // If you have custom style processing, the style output should be passed as an `array` of style declarations |
||
151 | // to the `styles` property of the `Style::add` method. For example: |
||
152 | // [ |
||
153 | // [ |
||
154 | // 'atRules' => false, |
||
155 | // 'selector' => $icon_selector, |
||
156 | // 'declaration' => 'color: red;' |
||
157 | // ], |
||
158 | // [ |
||
159 | // 'atRules' => '@media only screen and (max-width: 767px)', |
||
160 | // 'selector' => $icon_selector, |
||
161 | // 'declaration' => 'color: green;' |
||
162 | // ], |
||
163 | // ], |
||
164 | |||
165 | // The code below is an example of how to use the `CssStyle::style` method to generate CSS style. |
||
166 | CssStyle::style( |
||
167 | [ |
||
168 | 'selector' => $args['orderClass'], |
||
169 | 'attr' => $attrs['css'] ?? [], |
||
170 | 'cssFields' => self::custom_css(), |
||
171 | ] |
||
179 |
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