33namespace Stolt \LeanPackage \Analysers ;
44
55use RuntimeException ;
6- use Stolt \LeanPackage \Analyser ;
76use Stolt \LeanPackage \Exceptions \InvalidGlobPattern ;
87use Stolt \LeanPackage \Exceptions \InvalidGlobPatternFile ;
98use Stolt \LeanPackage \Exceptions \NonExistentGlobPatternFile ;
109use Stolt \LeanPackage \Exceptions \PresetNotAvailable ;
11- use Stolt \LeanPackage \Gitattributes \ValueObject as GitattributesValueObject ;
1210use Stolt \LeanPackage \Gitattributes \FileRepository as GitattributesFileRepository ;
11+ use Stolt \LeanPackage \Gitattributes \ValueObject as GitattributesValueObject ;
1312use Stolt \LeanPackage \Glob ;
1413use Stolt \LeanPackage \Helpers \Str ;
1514use Stolt \LeanPackage \Presets \Finder ;
@@ -158,20 +157,20 @@ public function __construct(
158157 protected readonly Finder $ finder ,
159158 protected readonly GitattributesFileRepository $ gitattributesFileRepository ,
160159 string $ directory = '' ,
161- ?ExportIgnoreConfiguration $ configuration = null )
162- {
160+ ?ExportIgnoreConfiguration $ configuration = null
161+ ) {
163162 $ this ->defaultGlobPattern = $ finder ->getDefaultPreset ();
164163
165164 $ configuration ??= new ExportIgnoreConfiguration (
166165 directory: $ directory ,
167- globPattern: '{ ' . implode (', ' , $ this ->defaultGlobPattern ) . '}* ' ,
166+ globPattern: '{ ' . \ implode (', ' , $ this ->defaultGlobPattern ) . '}* ' ,
168167 );
169168
170169 $ this ->configuration = $ configuration ;
171170
172171 $ this ->directory = $ configuration ->directory ;
173172
174- if (!is_dir ($ this ->directory ) && defined ('WORKING_DIRECTORY ' )) {
173+ if (!\ is_dir ($ this ->directory ) && \ defined ('WORKING_DIRECTORY ' )) {
175174 $ this ->directory = WORKING_DIRECTORY ;
176175 }
177176
@@ -206,9 +205,9 @@ public function getDirectory(): string
206205 * Set the directory to analyse.
207206 *
208207 * @param string $directory The directory to analyse.
209- * @return AbstractExportIgnoreAnalyser
210208 *
211209 * @throws RuntimeException
210+ * @return AbstractExportIgnoreAnalyser
212211 */
213212 public function setDirectory (string $ directory = __DIR__ ): AbstractExportIgnoreAnalyser
214213 {
@@ -358,8 +357,8 @@ public function isKeepReadmeEnabled(): bool
358357 * Sets the glob pattern for not export-ignoring license files.
359358 *
360359 * @param string $globPattern
361- * @return AbstractExportIgnoreAnalyser
362360 * @throws InvalidGlobPattern
361+ * @return AbstractExportIgnoreAnalyser
363362 */
364363 public function setKeepGlobPattern (string $ globPattern ): AbstractExportIgnoreAnalyser
365364 {
@@ -538,9 +537,9 @@ public function getGitattributesFileRepository(): GitattributesFileRepository
538537 * Set the glob pattern file.
539538 *
540539 * @param string $file
541- * @return AbstractExportIgnoreAnalyser
542540 * @throws InvalidGlobPatternFile
543541 * @throws NonExistentGlobPatternFile
542+ * @return AbstractExportIgnoreAnalyser
544543 */
545544 public function setGlobPatternFromFile (string $ file ): AbstractExportIgnoreAnalyser
546545 {
@@ -580,9 +579,9 @@ public function setGlobPatternFromFile(string $file): AbstractExportIgnoreAnalys
580579 *
581580 * @param string $pattern The glob pattern to use to detect expected export-ignores files.
582581 *
583- * @return AbstractExportIgnoreAnalyser
584582 *
585583 * @throws InvalidGlobPattern
584+ * @return AbstractExportIgnoreAnalyser
586585 */
587586 public function setGlobPattern (string $ pattern ): AbstractExportIgnoreAnalyser
588587 {
@@ -604,7 +603,7 @@ protected function guardGlobPattern(string $pattern): void
604603 $ invalidGlobPattern = false ;
605604
606605 if (\substr ($ pattern , 0 ) !== '{ '
607- && (!str_ends_with ($ pattern , '} ' ) && !str_ends_with ($ pattern , '}* ' ))) {
606+ && (!\ str_ends_with ($ pattern , '} ' ) && !\ str_ends_with ($ pattern , '}* ' ))) {
608607 $ invalidGlobPattern = true ;
609608 }
610609
@@ -645,11 +644,11 @@ protected function getGitignorePatterns(string $gitignoreFile): array
645644
646645 \array_filter ($ gitignoreLines , static function ($ line ) use (&$ gitignoredPatterns ) {
647646 $ line = \trim ($ line );
648- if ($ line !== '' && !str_contains ($ line , '# ' )) {
649- if (str_starts_with ($ line , "/ " )) {
647+ if ($ line !== '' && !\ str_contains ($ line , '# ' )) {
648+ if (\ str_starts_with ($ line , "/ " )) {
650649 $ gitignoredPatterns [] = \substr ($ line , 1 );
651650 }
652- if (str_ends_with ($ line , "/ " )) {
651+ if (\ str_ends_with ($ line , "/ " )) {
653652 $ gitignoredPatterns [] = \substr ($ line , 0 , -1 );
654653 }
655654 $ gitignoredPatterns [] = $ line ;
@@ -679,9 +678,9 @@ public function getGitignoredPatterns(): array
679678 */
680679 protected function patternHasMatch (string $ globPattern ): bool
681680 {
682- if (str_starts_with (\trim ($ globPattern ), '/ ' )) {
681+ if (\ str_starts_with (\trim ($ globPattern ), '/ ' )) {
683682 $ globPattern = \trim (\substr ($ globPattern , 1 ));
684- } elseif (str_ends_with (\trim ($ globPattern ), '/ ' )) {
683+ } elseif (\ str_ends_with (\trim ($ globPattern ), '/ ' )) {
685684 $ globPattern = \trim (\substr ($ globPattern , 0 , -1 ));
686685 } else {
687686 $ globPattern = '{ ' . \trim ($ globPattern ) . '}* ' ;
@@ -800,7 +799,7 @@ public function getPresentNonExportIgnoresContent(): string
800799 \array_filter ($ gitattributesLines , static function (string $ line ) use (
801800 &$ nonExportIgnoreLines
802801 ) {
803- if (!str_contains ($ line , 'export-ignore ' ) || \strstr ($ line , '# ' )) {
802+ if (!\ str_contains ($ line , 'export-ignore ' ) || \strstr ($ line , '# ' )) {
804803 $ nonExportIgnoreLines [] = \trim ($ line );
805804 }
806805 });
@@ -823,7 +822,7 @@ public function getPresentNonExportIgnoresContent(): string
823822 &$ exportIgnoresPlacementPlaceholderSet ,
824823 &$ exportIgnoresPlacementPlaceholder
825824 ) {
826- if (!str_contains ($ line , 'export-ignore ' ) || \strstr ($ line , '# ' )) {
825+ if (!\ str_contains ($ line , 'export-ignore ' ) || \strstr ($ line , '# ' )) {
827826 return $ nonExportIgnoreLines [] = \trim ($ line );
828827 } else {
829828 if ($ exportIgnoresPlacementPlaceholderSet === false ) {
@@ -854,8 +853,8 @@ protected function getAlignedExportIgnoreArtifacts(array $artifacts): array
854853 return \array_map (static function (string $ artifact ) use (&$ longestArtifact ) {
855854 if (\strlen ($ artifact ) < $ longestArtifact ) {
856855 return $ artifact . \str_repeat (
857- ' ' ,
858- $ longestArtifact - \strlen ($ artifact )
856+ ' ' ,
857+ $ longestArtifact - \strlen ($ artifact )
859858 );
860859 }
861860 return $ artifact ;
@@ -871,7 +870,7 @@ protected function getByDirectoriesToFilesExportIgnoreArtifacts(array $artifacts
871870 });
872871
873872 $ files = \array_filter ($ artifacts , static function (string $ artifact ) {
874- if (!str_contains ($ artifact , '/ ' )) {
873+ if (!\ str_contains ($ artifact , '/ ' )) {
875874 return $ artifact ;
876875 }
877876 });
0 commit comments