Passed
Pull Request — master (#16)
by Fabrice
12:30 queued 09:49
created

DelayedExtractQueryTrait::setExtractQuery()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 13
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 6
c 1
b 0
f 0
nc 3
nop 1
dl 0
loc 13
rs 10
1
<?php
2
3
/*
4
 * This file is part of YaEtl
5
 *     (c) Fabrice de Stefanis / https://github.com/fab2s/YaEtl
6
 * This source file is licensed under the MIT license which you will
7
 * find in the LICENSE file or at https://opensource.org/licenses/MIT
8
 */
9
10
namespace fab2s\YaEtl\Laravel\Extractors;
11
12
use fab2s\NodalFlow\YaEtlException;
13
use fab2s\YaEtl\Extractors\DbExtractorAbstract;
14
15
trait DelayedExtractQueryTrait
16
{
17
    /**
18
     * Set the extract query
19
     *
20
     * @param Builder $extractQuery
21
     *
22
     * @throws YaEtlException
23
     *
24
     * @return static
25
     */
26
    public function setExtractQuery($extractQuery): DbExtractorAbstract
27
    {
28
        if (!($extractQuery instanceof Builder)) {
0 ignored issues
show
Bug introduced by
The type fab2s\YaEtl\Laravel\Extractors\Builder was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
29
            throw new YaEtlException('Argument 1 passed to ' . __METHOD__ . ' must be an instance of ' . Builder::class . ', ' . \gettype($extractQuery) . ' given');
30
        }
31
32
        if (!isset($this->pdo)) {
33
            $this->configurePdo($extractQuery->getConnection()->getPdo());
0 ignored issues
show
Bug introduced by
It seems like configurePdo() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

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

33
            $this->/** @scrutinizer ignore-call */ 
34
                   configurePdo($extractQuery->getConnection()->getPdo());
Loading history...
34
        }
35
36
        parent::setExtractQuery($extractQuery);
37
38
        return $this;
39
    }
40
}
41