Completed
Pull Request — master (#396)
by
unknown
03:27
created

CreatorQueryString::__construct()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 14

Duplication

Lines 14
Ratio 100 %

Importance

Changes 0
Metric Value
dl 14
loc 14
rs 9.7998
c 0
b 0
f 0
cc 3
nc 3
nop 1
1
<?php
2
3
namespace CultuurNet\UDB3\SavedSearches\Properties;
4
5 View Code Duplication
class CreatorQueryString extends QueryString
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
6
{
7
    /**
8
     * @param string[] $queryParts
9
     */
10
    public function __construct(string ...$queryParts)
11
    {
12
        if (empty($queryParts)) {
13
            throw new \InvalidArgumentException('At least one query part is required.');
14
        }
15
16
        $query = implode(' OR ', $queryParts);
17
        if (count($queryParts) > 1) {
18
            $query = '(' . $query . ')';
19
        }
20
        $query = 'creator:' . $query;
21
22
        parent::__construct($query);
23
    }
24
}
25