AggregationDefinition::getQuery()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
/**
3
 * Spiral, Core Components
4
 *
5
 * @author Wolfy-J
6
 */
7
8
namespace Spiral\ODM\Schemas\Definitions;
9
10
/**
11
 * Aggregation definition (links one Document with another).
12
 */
13
final class AggregationDefinition
14
{
15
    /**
16
     * Aggregation type, see Document::ONE and Document::MANY.
17
     *
18
     * @var int
19
     */
20
    private $type;
21
22
    /**
23
     * Linked class.
24
     *
25
     * @var string
26
     */
27
    private $class;
28
29
    /**
30
     * Query template.
31
     *
32
     * @var array
33
     */
34
    private $query = [];
35
36
    /**
37
     * @param int    $type
38
     * @param string $class
39
     * @param array  $query
40
     */
41
    public function __construct(int $type, string $class, array $query)
42
    {
43
        $this->type = $type;
44
        $this->class = $class;
45
        $this->query = $query;
46
    }
47
48
    /**
49
     * Aggregation type, see Document::ONE and Document::MANY.
50
     *
51
     * @return int
52
     */
53
    public function getType(): int
54
    {
55
        return $this->type;
56
    }
57
58
    /**
59
     * Linked class.
60
     *
61
     * @return string
62
     */
63
    public function getClass(): string
64
    {
65
        return $this->class;
66
    }
67
68
    /**
69
     * Query template.
70
     *
71
     * @return array
72
     */
73
    public function getQuery(): array
74
    {
75
        return $this->query;
76
    }
77
78
    /**
79
     * @return array
80
     */
81
    public function packSchema(): array
82
    {
83
        return [$this->type, $this->class, $this->query];
84
    }
85
}