Passed
Push — master ( a535f0...f38dcf )
by Jean Paul
08:30
created

Extractor::getArrayRepresentation()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 11
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 5
nc 2
nop 0
dl 0
loc 11
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Coco\SourceWatcher\Core;
4
5
use Coco\SourceWatcher\Core\Extractors\CsvExtractor;
6
use Coco\SourceWatcher\Core\Extractors\JsonExtractor;
7
use Coco\SourceWatcher\Core\IO\Inputs\Input;
8
9
/**
10
 * Class Extractor
11
 *
12
 * @package Coco\SourceWatcher\Core
13
 */
14
abstract class Extractor extends Step
15
{
16
    protected ?Input $input = null;
17
18
    public function getInput () : Input
19
    {
20
        return $this->input;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->input could return the type null which is incompatible with the type-hinted return Coco\SourceWatcher\Core\IO\Inputs\Input. Consider adding an additional type-check to rule them out.
Loading history...
21
    }
22
23
    public function setInput ( ?Input $input ) : void
24
    {
25
        $this->input = $input;
26
    }
27
28
    public abstract function extract ();
29
30
    public function getArrayRepresentation () : array
31
    {
32
        $result = parent::getArrayRepresentation();
33
34
        if ( $this instanceof CsvExtractor || $this instanceof JsonExtractor ) {
35
            $fileInput = $this->getInput();
36
37
            $result["input"] = [ "class" => get_class( $fileInput ), "location" => $fileInput->getInput() ];
38
        }
39
40
        return $result;
41
    }
42
}
43