Completed
Push — ezp-30928-as_a_developer_i_wan... ( 4d81da...f06b29 )
by
unknown
14:36
created

FieldRelation   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
dl 0
loc 22
c 0
b 0
f 0
rs 10
wmc 2
lcom 0
cbo 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getSpecifications() 0 9 1
A createFromQueryBuilder() 0 6 1
1
<?php
2
3
/**
4
 * File containing the eZ\Publish\API\Repository\Values\Content\Query\Criterion\FieldRelation 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 the relations in relation field.
16
 * This includes Relation and RelationList field types in standard installation, but also any
17
 * other field type storing {@link \eZ\Publish\API\Repository\Values\Content\Relation::FIELD}
18
 * type relation.
19
 *
20
 * Supported operators:
21
 * - IN: will match if Content relates to one or more of the given ids through given relation field
22
 * - CONTAINS: will match if Content relates to all of the given ids through given relation field
23
 */
24
class FieldRelation extends Criterion
25
{
26
    public function getSpecifications()
27
    {
28
        $types = Specifications::TYPE_INTEGER | Specifications::TYPE_STRING;
29
30
        return [
31
            new Specifications(Operator::CONTAINS, Specifications::FORMAT_SINGLE | Specifications::FORMAT_ARRAY, $types),
32
            new Specifications(Operator::IN, Specifications::FORMAT_ARRAY, $types),
33
        ];
34
    }
35
36
    /**
37
     * @deprecated since 7.2, will be removed in 8.0. Use the constructor directly instead.
38
     */
39
    public static function createFromQueryBuilder($target, $operator, $value)
40
    {
41
        @trigger_error('The ' . __METHOD__ . ' method is deprecated since version 7.2 and will be removed in 8.0.', E_USER_DEPRECATED);
0 ignored issues
show
Security Best Practice introduced by
It seems like you do not handle an error condition here. This can introduce security issues, and is generally not recommended.

If you suppress an error, we recommend checking for the error condition explicitly:

// For example instead of
@mkdir($dir);

// Better use
if (@mkdir($dir) === false) {
    throw new \RuntimeException('The directory '.$dir.' could not be created.');
}
Loading history...
42
43
        return new self($target, $operator, $value);
44
    }
45
}
46