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

MoreLikeThis::createFromQueryBuilder()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 3
dl 0
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\MoreLikeThis 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 more like this criterion is matched by content which contains similar terms
16
 * found in the given content, text or url fetch.
17
 */
18
class MoreLikeThis extends Criterion
19
{
20
    const CONTENT = 1;
21
    const TEXT = 2;
22
    const URL = 3;
23
24
    /**
25
     * The type of the parameter from which terms are extracted for finding similar objects.
26
     *
27
     * @var int
28
     */
29
    protected $type;
30
31
    /**
32
     * Creates a new more like this criterion.
33
     *
34
     * @param int $type the type (one of CONTENT,TEXT,URL)
35
     * @param mixed $value the value depending on the type
36
     *
37
     * @throws \InvalidArgumentException if the value type doesn't match the expected type
38
     */
39
    public function __construct($type, $value)
40
    {
41
        $this->type = $type;
42
43
        parent::__construct(null, null, $value);
44
    }
45
46
    public function getSpecifications()
47
    {
48
        return [
49
            new Specifications(Operator::EQ, Specifications::FORMAT_SINGLE),
50
        ];
51
    }
52
}
53