Passed
Push — master ( 7d2fba...2be253 )
by Jean Paul
01:17
created

SourceWatcher::extract()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 15
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 4
c 1
b 0
f 0
nc 1
nop 3
dl 0
loc 15
rs 10
1
<?php
2
3
namespace Coco\SourceWatcher\Core;
4
5
class SourceWatcher
6
{
7
    private StepLoader $stepLoader;
8
9
    public function __construct ()
10
    {
11
        $this->stepLoader = new StepLoader();
12
    }
13
14
    public function extract ( string $extractorName, $input, array $options = [] ) : SourceWatcher
15
    {
16
        /*
17
         * Since PHP 5.5, the class keyword is also used for class name resolution.
18
         * You can get a string containing the fully qualified name of the ClassName class by using ClassName::class.
19
         * This is particularly useful with namespaced classes.
20
         *
21
         * Coco\SourceWatcher\Core\Extractor, $extractorName
22
         */
23
24
        $extractor = $this->stepLoader->step( Extractor::class, $extractorName );
25
        $extractor->setInput( $input );
0 ignored issues
show
Bug introduced by
The method setInput() does not exist on Coco\SourceWatcher\Core\Step. It seems like you code against a sub-type of Coco\SourceWatcher\Core\Step such as Coco\SourceWatcher\Core\Extractor. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

25
        $extractor->/** @scrutinizer ignore-call */ 
26
                    setInput( $input );
Loading history...
26
        $extractor->options( $options );
27
28
        return $this;
29
    }
30
31
    public function transform () : SourceWatcher
32
    {
33
34
    }
0 ignored issues
show
Bug Best Practice introduced by
In this branch, the function will implicitly return null which is incompatible with the type-hinted return Coco\SourceWatcher\Core\SourceWatcher. Consider adding a return statement or allowing null as return value.

For hinted functions/methods where all return statements with the correct type are only reachable via conditions, ?null? gets implicitly returned which may be incompatible with the hinted type. Let?s take a look at an example:

interface ReturnsInt {
    public function returnsIntHinted(): int;
}

class MyClass implements ReturnsInt {
    public function returnsIntHinted(): int
    {
        if (foo()) {
            return 123;
        }
        // here: null is implicitly returned
    }
}
Loading history...
35
36
    public function load () : SourceWatcher
37
    {
38
39
    }
0 ignored issues
show
Bug Best Practice introduced by
In this branch, the function will implicitly return null which is incompatible with the type-hinted return Coco\SourceWatcher\Core\SourceWatcher. Consider adding a return statement or allowing null as return value.

For hinted functions/methods where all return statements with the correct type are only reachable via conditions, ?null? gets implicitly returned which may be incompatible with the hinted type. Let?s take a look at an example:

interface ReturnsInt {
    public function returnsIntHinted(): int;
}

class MyClass implements ReturnsInt {
    public function returnsIntHinted(): int
    {
        if (foo()) {
            return 123;
        }
        // here: null is implicitly returned
    }
}
Loading history...
40
}
41