1
- <?php declare (strict_types=1 );
2
- /**
1
+ <?php
2
+
3
+ declare (strict_types=1 );
4
+
5
+ /*
3
6
* This file is part of the CleverAge/FlysystemProcessBundle package.
4
7
*
5
- * Copyright (C) 2017-2019 Clever-Age
8
+ * Copyright (c) Clever-Age
6
9
*
7
10
* For the full copyright and license information, please view the LICENSE
8
11
* file that was distributed with this source code.
18
21
use Symfony \Component \OptionsResolver \OptionsResolver ;
19
22
20
23
/**
21
- * Iterate over the content of a filesystem
24
+ * Iterate over the content of a filesystem.
22
25
*/
23
26
class ListContentTask extends AbstractConfigurableTask implements IterableTaskInterface
24
27
{
@@ -40,14 +43,14 @@ protected function configureOptions(OptionsResolver $resolver): void
40
43
*/
41
44
public function execute (ProcessState $ state ): void
42
45
{
43
- if ($ this ->fsContent === null || key ($ this ->fsContent ) === null ) {
46
+ if (null === $ this ->fsContent || null === key ($ this ->fsContent )) {
44
47
$ filesystem = $ this ->getFilesystem ($ state , 'filesystem ' );
45
48
$ pattern = $ this ->getOption ($ state , 'file_pattern ' );
46
49
47
50
$ this ->fsContent = $ this ->getFilteredFilesystemContents ($ filesystem , $ pattern );
48
51
}
49
52
50
- if (key ($ this ->fsContent ) === null ) {
53
+ if (null === key ($ this ->fsContent )) {
51
54
$ state ->setSkipped (true );
52
55
$ this ->fsContent = null ;
53
56
} else {
@@ -57,23 +60,23 @@ public function execute(ProcessState $state): void
57
60
58
61
public function next (ProcessState $ state ): bool
59
62
{
60
- if (!is_array ($ this ->fsContent )) {
63
+ if (!\ is_array ($ this ->fsContent )) {
61
64
return false ;
62
65
}
63
66
64
67
next ($ this ->fsContent );
65
68
66
- return key ($ this ->fsContent ) !== null ;
69
+ return null !== key ($ this ->fsContent );
67
70
}
68
71
69
72
/**
70
73
* @throws FilesystemException
71
74
*/
72
- protected function getFilteredFilesystemContents (FilesystemOperator $ filesystem , string $ pattern = null ): array
75
+ protected function getFilteredFilesystemContents (FilesystemOperator $ filesystem , ? string $ pattern = null ): array
73
76
{
74
77
$ results = [];
75
78
foreach ($ filesystem ->listContents ('' ) as $ item ) {
76
- if ($ pattern === null || \ preg_match ($ pattern , $ item ['path ' ])) {
79
+ if (null === $ pattern || preg_match ($ pattern , ( string ) $ item ['path ' ])) {
77
80
$ results [] = $ item ;
78
81
}
79
82
}
0 commit comments