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

ExecutionExtractor   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 10
c 1
b 0
f 0
dl 0
loc 24
rs 10
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A extract() 0 18 3
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