Completed
Push — create_from_qb ( 323041 )
by
unknown
12:48
created

ParentLocationId::createFromQueryBuilder()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 6
Ratio 100 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 3
dl 6
loc 6
rs 10
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * File containing the eZ\Publish\API\Repository\Values\Content\Query\Criterion\ParentLocationId class.
5
 *
6
 * @copyright Copyright (C) eZ Systems AS. All rights reserved.
7
 * @license For full copyright and license information view LICENSE file distributed with this source code.
8
 */
9
namespace eZ\Publish\API\Repository\Values\Content\Query\Criterion;
10
11
use eZ\Publish\API\Repository\Values\Content\Query\Criterion;
12
use eZ\Publish\API\Repository\Values\Content\Query\Criterion\Operator\Specifications;
13
14
/**
15
 * A criterion that matches content based on its parent location id.
16
 *
17
 * Own location id is done using {@see LocationId}
18
 *
19
 * Supported operators:
20
 * - IN: matches against a list of location ids
21
 * - EQ: matches against a unique location id
22
 */
23
class ParentLocationId extends Criterion
24
{
25
    /**
26
     * Creates a new ParentLocationId criterion.
27
     *
28
     * @param int|int[] $value One or more locationId parent locations must be matched against
29
     *
30
     * @throws \InvalidArgumentException if a non numeric id is given
31
     * @throws \InvalidArgumentException if the value type doesn't match the operator
32
     */
33
    public function __construct($value)
34
    {
35
        parent::__construct(null, null, $value);
36
    }
37
38
    public function getSpecifications()
39
    {
40
        return [
41
            new Specifications(
42
                Operator::IN,
43
                Specifications::FORMAT_ARRAY,
44
                Specifications::TYPE_INTEGER | Specifications::TYPE_STRING
45
            ),
46
            new Specifications(
47
                Operator::EQ,
48
                Specifications::FORMAT_SINGLE,
49
                Specifications::TYPE_INTEGER | Specifications::TYPE_STRING
50
            ),
51
        ];
52
    }
53
}
54