| Total Complexity | 5 |
| Total Lines | 43 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 16 | trait ScopeTrait |
||
| 17 | { |
||
| 18 | /** @var null|ScopeInterface */ |
||
| 19 | protected $constrain; |
||
| 20 | |||
| 21 | abstract public function getAlias(): string; |
||
| 22 | |||
| 23 | /** |
||
| 24 | * Associate scope with the selector. |
||
| 25 | * |
||
| 26 | * @return AbstractLoader|$this |
||
| 27 | */ |
||
| 28 | public function setScope(ScopeInterface $scope = null): self |
||
| 29 | { |
||
| 30 | $this->constrain = $scope; |
||
| 31 | return $this; |
||
| 32 | } |
||
| 33 | |||
| 34 | /** |
||
| 35 | * @deprecated Use {@see setScope()} instead. |
||
| 36 | * |
||
| 37 | * @return AbstractLoader|$this |
||
| 38 | */ |
||
| 39 | public function setConstrain(ConstrainInterface $constrain = null): self |
||
| 42 | } |
||
| 43 | |||
| 44 | protected function applyScope(SelectQuery $query): SelectQuery |
||
| 45 | { |
||
| 46 | if ($this->constrain !== null) { |
||
| 47 | $this->constrain->apply(new QueryBuilder($query, $this)); |
||
|
|
|||
| 48 | } |
||
| 49 | |||
| 50 | return $query; |
||
| 51 | } |
||
| 52 | |||
| 53 | /** |
||
| 54 | * @deprecated Use {@see applyScope()} instead. |
||
| 55 | */ |
||
| 56 | protected function applyConstrain(SelectQuery $query): SelectQuery |
||
| 59 | } |
||
| 60 | } |
||
| 61 |