Passed
Push — master ( a4f7f2...d3cc39 )
by Melech
04:09
created

Join   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 9
c 1
b 0
f 0
dl 0
loc 33
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 1
A __toString() 0 11 1
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the Valkyrja Framework package.
7
 *
8
 * (c) Melech Mizrachi <[email protected]>
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
namespace Valkyrja\Orm\Data;
15
16
use Stringable;
17
use Valkyrja\Orm\Constant\Statement;
0 ignored issues
show
Bug introduced by
The type Valkyrja\Orm\Constant\Statement 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...
18
use Valkyrja\Orm\Enum\Comparison;
19
use Valkyrja\Orm\Enum\JoinOperator;
20
use Valkyrja\Orm\Enum\JoinType;
21
22
/**
23
 * Class Join.
24
 *
25
 * @author Melech Mizrachi
26
 */
27
readonly class Join implements Stringable
28
{
29
    /**
30
     * @param non-empty-string $table      The join table
0 ignored issues
show
Documentation Bug introduced by
The doc comment non-empty-string at position 0 could not be parsed: Unknown type name 'non-empty-string' at position 0 in non-empty-string.
Loading history...
31
     * @param non-empty-string $column     The column to compare
32
     * @param non-empty-string $joinColumn The join table column
33
     */
34
    public function __construct(
35
        public string $table,
36
        public string $column,
37
        public string $joinColumn,
38
        public Comparison $comparison,
39
        public JoinOperator $operator,
40
        public JoinType $type = JoinType::DEFAULT,
41
    ) {
42
    }
43
44
    /**
45
     * Get the join as a string.
46
     *
47
     * @return non-empty-string
0 ignored issues
show
Documentation Bug introduced by
The doc comment non-empty-string at position 0 could not be parsed: Unknown type name 'non-empty-string' at position 0 in non-empty-string.
Loading history...
48
     */
49
    public function __toString(): string
50
    {
51
        $type       = $this->type->value;
52
        $join       = Statement::JOIN;
53
        $table      = $this->table;
54
        $operator   = $this->operator->value;
55
        $comparison = $this->comparison->value;
56
        $column     = $this->column;
57
        $joinColumn = $this->joinColumn;
58
59
        return "$type $join $table $operator $column $comparison $joinColumn";
60
    }
61
}
62