Completed
Branch feature/split-orm (94afb7)
by Anton
03:11
created

AggregationDefinition::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

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