ArgumentToSelectionConverter::toSelection()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 1
1
<?php
2
3
/**
4
 * This file is part of the Happyr Doctrine Specification package.
5
 *
6
 * (c) Tobias Nyholm <[email protected]>
7
 *     Kacper Gunia <[email protected]>
8
 *     Peter Gribanov <[email protected]>
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
namespace Happyr\DoctrineSpecification\Query\Selection;
15
16
use Happyr\DoctrineSpecification\Operand\Field;
17
18
/**
19
 * This service is intended for backward compatibility and may be removed in the future.
20
 */
21
class ArgumentToSelectionConverter
22
{
23
    /**
24
     * Convert the argument into the field operand if it is not an selection.
25
     *
26
     * @param Selection|string $argument
27
     *
28
     * @return Selection
29
     */
30
    public static function toSelection($argument)
31
    {
32
        if ($argument instanceof Selection) {
33
            return $argument;
34
        }
35
36
        return new Field($argument);
37
    }
38
}
39