10
10
11
11
class AbstractBlockSniff implements Sniff
12
12
{
13
- const CHILD_HTML_METHOD = 'getChildHtml ' ;
14
- const CHILD_CHILD_HTML_METHOD = 'getChildChildHtml ' ;
13
+ private const CHILD_HTML_METHOD = 'getChildHtml ' ;
14
+ private const CHILD_CHILD_HTML_METHOD = 'getChildChildHtml ' ;
15
15
16
16
/**
17
17
* Warning violation code.
@@ -38,18 +38,13 @@ public function process(File $phpcsFile, $stackPtr)
38
38
if (!isset ($ phpcsFile ->getTokens ()[$ stackPtr + 1 ]['content ' ])) {
39
39
return ;
40
40
}
41
+
41
42
$ content = $ phpcsFile ->getTokens ()[$ stackPtr + 1 ]['content ' ];
42
- $ isTheNextMethodGetChildSomething = in_array (
43
- $ content ,
44
- [
45
- self ::CHILD_HTML_METHOD ,
46
- self ::CHILD_CHILD_HTML_METHOD
47
- ]
48
- );
49
- if (!$ isTheNextMethodGetChildSomething ) {
43
+
44
+ if (!$ this ->isApplicable ($ content )) {
50
45
return ;
51
46
}
52
-
47
+
53
48
$ paramsCount = $ this ->getParametersCount ($ phpcsFile , $ stackPtr + 1 );
54
49
if ($ content === self ::CHILD_HTML_METHOD && $ paramsCount >= 3 ) {
55
50
$ phpcsFile ->addError (
@@ -67,6 +62,17 @@ public function process(File $phpcsFile, $stackPtr)
67
62
}
68
63
}
69
64
65
+ /**
66
+ * Return if it is applicable to do the check
67
+ *
68
+ * @param String $content
69
+ * @return bool
70
+ */
71
+ private function isApplicable (String $ content ): bool
72
+ {
73
+ return in_array ($ content , [self ::CHILD_HTML_METHOD , self ::CHILD_CHILD_HTML_METHOD ]);
74
+ }
75
+
70
76
/**
71
77
* Get the quantity of parameters on a method
72
78
*
0 commit comments