Total Complexity | 8 |
Total Lines | 67 |
Duplicated Lines | 0 % |
Changes | 2 | ||
Bugs | 1 | Features | 0 |
1 | <?php |
||
7 | class CheckXliffProprietaryPipeline { |
||
8 | /** |
||
9 | * @var array|null |
||
10 | */ |
||
11 | private ?array $tmp; |
||
12 | |||
13 | /** |
||
14 | * @var array|null |
||
15 | */ |
||
16 | private ?array $steps; |
||
17 | |||
18 | /** |
||
19 | * CheckXliffProprietaryPipeline constructor. |
||
20 | * |
||
21 | * @param array|null $tmp |
||
22 | */ |
||
23 | public function __construct( ?array $tmp = [] ) { |
||
24 | $this->tmp = $tmp; |
||
25 | $this->steps = []; |
||
26 | } |
||
27 | |||
28 | /** |
||
29 | * @param CheckInterface $step |
||
30 | */ |
||
31 | public function addCheck( CheckInterface $step ) { |
||
32 | $this->steps[] = $step; |
||
33 | } |
||
34 | |||
35 | /** |
||
36 | * @return array |
||
37 | */ |
||
38 | public function run(): array { |
||
39 | $fileType = []; |
||
40 | |||
41 | /** @var CheckInterface $step */ |
||
42 | foreach ( $this->steps as $step ) { |
||
43 | if ( null !== $step->check( $this->tmp ) ) { |
||
44 | $fileType = $step->check( $this->tmp ); |
||
45 | } |
||
46 | } |
||
47 | |||
48 | if ( !empty( $fileType ) && $this->isValid( $fileType ) ) { |
||
49 | return $fileType; |
||
50 | } |
||
51 | |||
52 | return [ |
||
53 | 'proprietary' => false, |
||
54 | 'proprietary_name' => null, |
||
55 | 'proprietary_short_name' => null, |
||
56 | 'converter_version' => null, |
||
57 | ]; |
||
58 | } |
||
59 | |||
60 | /** |
||
61 | * @param $fileType |
||
62 | * |
||
63 | * @return bool |
||
64 | */ |
||
65 | private function isValid( $fileType ): bool { |
||
74 | } |
||
75 | } |
||
76 |