BitNot::transform()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8

Duplication

Lines 8
Ratio 100 %

Importance

Changes 0
Metric Value
dl 8
loc 8
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
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\Operand;
15
16
use Doctrine\ORM\QueryBuilder;
17
18
@trigger_error('The '.__NAMESPACE__.'\BitNot class is deprecated since version 1.1 and will be removed in 2.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...
19
20
/**
21
 * @deprecated This class is deprecated since version 1.1 and will be removed in 2.0.
22
 */
23 View Code Duplication
class BitNot implements Operand
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...
24
{
25
    /**
26
     * @var Operand|string
27
     */
28
    private $field;
29
30
    /**
31
     * @param Operand|string $field
32
     */
33
    public function __construct($field)
34
    {
35
        $this->field = $field;
36
    }
37
38
    /**
39
     * @param QueryBuilder $qb
40
     * @param string       $dqlAlias
41
     *
42
     * @return string
43
     */
44
    public function transform(QueryBuilder $qb, $dqlAlias)
45
    {
46
        $field = ArgumentToOperandConverter::toField($this->field);
47
48
        $field = $field->transform($qb, $dqlAlias);
49
50
        return sprintf('(~ %s)', $field);
51
    }
52
}
53