Passed
Pull Request — master (#185)
by
unknown
02:58
created

Source::getConstrain()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * Cycle DataMapper ORM
5
 *
6
 * @license   MIT
7
 * @author    Anton Titov (Wolfy-J)
8
 */
9
10
declare(strict_types=1);
11
12
namespace Cycle\ORM\Select;
13
14
use Spiral\Database\DatabaseInterface;
15
16
final class Source implements SourceInterface
17
{
18
    /** @var DatabaseInterface */
19
    private $database;
20
21
    /** @var string */
22
    private $table;
23
24
    /** @var ScopeInterface|null */
25
    private $scope = null;
26
27
    /**
28
     * @param DatabaseInterface $database
29
     * @param string $table
30
     */
31
    public function __construct(DatabaseInterface $database, string $table)
32
    {
33
        $this->database = $database;
34
        $this->table = $table;
35
    }
36
37
    /**
38
     * @inheritdoc
39
     */
40
    public function getDatabase(): DatabaseInterface
41
    {
42
        return $this->database;
43
    }
44
45
    /**
46
     * @inheritdoc
47
     */
48
    public function getTable(): string
49
    {
50
        return $this->table;
51
    }
52
53
    /**
54
     * @inheritdoc
55
     */
56
    public function withScope(?ScopeInterface $scope): SourceInterface
57
    {
58
        $source = clone $this;
59
        $source->scope = $scope;
60
61
        return $source;
62
    }
63
64
    /**
65
     * @inheritdoc
66
     */
67
    public function getScope(): ?ScopeInterface
68
    {
69
        return $this->scope;
70
    }
71
72
    /**
73
     * @inheritdoc
74
     * @deprecated Use {@see withScope()} instead.
75
     */
76
    public function withConstrain(?ConstrainInterface $constrain): SourceInterface
77
    {
78
        return $this->withScope($constrain);
79
    }
80
81
    /**
82
     * @inheritdoc
83
     * @deprecated Use {@see getScope()} instead.
84
     */
85
    public function getConstrain(): ?ConstrainInterface
86
    {
87
        return $this->getScope();
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->getScope() could return the type Cycle\ORM\Select\ScopeInterface which includes types incompatible with the type-hinted return Cycle\ORM\Select\ConstrainInterface|null. Consider adding an additional type-check to rule them out.
Loading history...
88
    }
89
}
90