Completed
Push — 1.0 ( 75b22b...f155d9 )
by Peter
15:56 queued 05:56
created

ArgumentToSelectionConverter::toSelection()   A

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
namespace Happyr\DoctrineSpecification\Query\Selection;
4
5
use Happyr\DoctrineSpecification\Operand\Field;
6
7
/**
8
 * This service is intended for backward compatibility and may be removed in the future.
9
 */
10
class ArgumentToSelectionConverter
11
{
12
    /**
13
     * Convert the argument into the field operand if it is not an selection.
14
     *
15
     * @param Selection|string $argument
16
     *
17
     * @return Selection
18
     */
19
    public static function toSelection($argument)
20
    {
21
        if ($argument instanceof Selection) {
22
            return $argument;
23
        }
24
25
        return new Field($argument);
26
    }
27
}
28