Passed
Push — master ( f38dcf...954e17 )
by Jean Paul
01:37
created

ExecutionExtractor::extract()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 18
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 9
c 1
b 0
f 0
nc 3
nop 0
dl 0
loc 18
rs 9.9666
1
<?php
2
3
namespace Coco\SourceWatcher\Core\Extractors;
4
5
use Coco\SourceWatcher\Core\Extractor;
6
use Coco\SourceWatcher\Core\IO\Inputs\ExtractorResultInput;
7
use Coco\SourceWatcher\Core\SourceWatcherException;
8
9
/**
10
 * Class ExecutionExtractor
11
 *
12
 * @package Coco\SourceWatcher\Core\Extractors
13
 */
14
class ExecutionExtractor extends Extractor
15
{
16
    /**
17
     * @return array
18
     * @throws SourceWatcherException
19
     */
20
    public function extract ()
21
    {
22
        if ( $this->input == null ) {
23
            throw new SourceWatcherException( "An input must be provided." );
24
        }
25
26
        $inputIsValid = $this->input instanceof ExtractorResultInput;
27
28
        if ( !$inputIsValid ) {
29
            throw new SourceWatcherException( sprintf( "The input must be an instance of %s",
30
                ExtractorResultInput::class ) );
31
        }
32
33
        $previousExtractor = $this->input->getInput();
34
35
        $this->result = $previousExtractor->getResult();
36
37
        return $this->result;
38
    }
39
}
40