Completed
Push — 1.x ( 249f8e...9ce618 )
by Akihito
11s
created

AuraSqlQueryDeleteProvider::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 0
c 1
b 0
f 1
nc 1
nop 1
dl 0
loc 4
ccs 0
cts 0
cp 0
crap 2
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Ray\AuraSqlModule;
6
7
use Aura\SqlQuery\Common\DeleteInterface;
8
use Aura\SqlQuery\QueryFactory;
9
use Override;
10
use Ray\AuraSqlModule\Annotation\AuraSqlQueryConfig;
11
use Ray\Di\ProviderInterface;
12
13
/** @implements ProviderInterface<DeleteInterface> */
14
final class AuraSqlQueryDeleteProvider implements ProviderInterface
15
{
16
    /** @param string $db The database type */
17
    public function __construct(
18
        #[AuraSqlQueryConfig]
19
        private string $db
20
    ) {
21
    }
22
23
    /**
24
     * {@inheritDoc}
25 5
     */
26
    #[Override]
27 5
    public function get(): DeleteInterface
28 5
    {
29
        return (new QueryFactory($this->db))->newDelete();
0 ignored issues
show
Bug Best Practice introduced by
The expression return new Aura\SqlQuery...$this->db)->newDelete() returns the type Aura\SqlQuery\Common\DeleteInterface which is incompatible with the return type mandated by Ray\Di\ProviderInterface::get() of Ray\Di\T.

In the issue above, the returned value is violating the contract defined by the mentioned interface.

Let's take a look at an example:

interface HasName {
    /** @return string */
    public function getName();
}

class Name {
    public $name;
}

class User implements HasName {
    /** @return string|Name */
    public function getName() {
        return new Name('foo'); // This is a violation of the ``HasName`` interface
                                // which only allows a string value to be returned.
    }
}
Loading history...
30
    }
31
}
32