44
55namespace Faissaloux \PestInside ;
66
7+ use Faissaloux \PestInside \Contracts \Content ;
8+
79/**
810 * @internal
911 */
1012trait Investigator
1113{
1214 /**
13- * @param array<string|array<string>> $array
15+ * @param Content| array<int| string, string |array<string, string >> $content
1416 * @return array<string>
1517 */
16- private function notLowercasesIn (array $ array ): array
18+ private function notLowercasesIn (Content | array $ content ): array
1719 {
1820 $ unwanted = [];
1921
20- foreach ($ array as $ word ) {
22+ foreach ($ content as $ word ) {
2123 if (is_array ($ word )) {
2224 array_push ($ unwanted , ...$ this ->notLowercasesIn ($ word ));
2325
@@ -35,15 +37,15 @@ private function notLowercasesIn(array $array): array
3537 }
3638
3739 /**
38- * @param array<string|array<string>> $array
40+ * @param Content| array<int| string, string |array<string, string >> $content
3941 * @return array<string>
4042 */
41- private function duplicatesIn (array $ array ): array
43+ private function duplicatesIn (Content | array $ content ): array
4244 {
4345 $ unwanted = [];
4446 $ unique = [];
4547
46- foreach ($ array as $ word ) {
48+ foreach ($ content as $ word ) {
4749 if (is_array ($ word )) {
4850 array_push ($ unwanted , ...$ this ->duplicatesIn ($ word ));
4951
@@ -61,14 +63,14 @@ private function duplicatesIn(array $array): array
6163 }
6264
6365 /**
64- * @param array<string|array<string>> $array
66+ * @param Content| array<int| string, string |array<string, string >> $content
6567 * @return array<string>
6668 */
67- private function multipleWordsIn (array $ array ): array
69+ private function multipleWordsIn (Content | array $ content ): array
6870 {
6971 $ unwanted = [];
7072
71- foreach ($ array as $ word ) {
73+ foreach ($ content as $ word ) {
7274 if (is_array ($ word )) {
7375 array_push ($ unwanted , ...$ this ->multipleWordsIn ($ word ));
7476
@@ -84,19 +86,19 @@ private function multipleWordsIn(array $array): array
8486 }
8587
8688 /**
87- * @param array<string|array<string>> $array
89+ * @param Content| array<int| string, string |array<string, string >> $content
8890 * @return array<string>
8991 */
90- private function dataNotOrderedIn (array $ array ): array
92+ private function dataNotOrderedIn (Content | array $ content ): array
9193 {
92- if (count ($ array ) < 2 ) {
94+ if (count ($ content ) < 2 ) {
9395 return [];
9496 }
9597
9698 $ unwanted = [];
97- $ lastWord = $ array [0 ];
99+ $ lastWord = $ content [0 ];
98100
99- foreach ($ array as $ key => $ value ) {
101+ foreach ($ content as $ key => $ value ) {
100102 if ($ key === 0 ) {
101103 continue ;
102104 }
@@ -124,14 +126,18 @@ private function dataNotOrderedIn(array $array): array
124126 }
125127
126128 /**
127- * @param array<string|array<string>> $array
129+ * @param Content| array<int| string, string |array<string, string >> $content
128130 * @return array<string>
129131 */
130- private function notStringsIn (array $ array ): array
132+ private function notStringsIn (Content | array $ content ): array
131133 {
134+ if ($ content instanceof Content && ($ extension = $ content ->getExtension ()) !== 'php ' ) {
135+ throw new NotSupported ("toReturnStrings is not supported on $ extension files. " );
136+ }
137+
132138 $ unwanted = [];
133139
134- foreach ($ array as $ word ) {
140+ foreach ($ content as $ word ) {
135141 if (is_array ($ word )) {
136142 array_push ($ unwanted , ...$ this ->notStringsIn ($ word ));
137143
0 commit comments