Passed
Branch psalm-3 (d5d890)
by Wilmer
02:56
created

PdoValue::build()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 6
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 3
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Db\Pdo;
6
7
use Yiisoft\Db\Expression\ExpressionInterface;
8
use Yiisoft\Db\Query\QueryBuilderInterface;
0 ignored issues
show
Bug introduced by
The type Yiisoft\Db\Query\QueryBuilderInterface was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
9
10
/**
11
 * Class PdoValue represents a $value that should be bound to PDO with exact $type.
12
 *
13
 * For example, it will be useful when you need to bind binary data to BLOB column in DBMS:
14
 *
15
 * ```php
16
 * [':name' => 'John', ':profile' => new PdoValue($profile, \PDO::PARAM_LOB)]`.
17
 * ```
18
 *
19
 * To see possible types, check [PDO::PARAM_* constants](http://php.net/manual/en/pdo.constants.php).
20
 *
21
 * @link http://php.net/manual/en/pdostatement.bindparam.php
22
 */
23
final class PdoValue implements ExpressionInterface
24
{
25
    public function __construct(private ?string $value = null, private ?int $type = null)
26
    {
27
    }
28
29
    public function build(
30
        QueryBuilderInterface $queryBuilder,
0 ignored issues
show
Unused Code introduced by
The parameter $queryBuilder is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

30
        /** @scrutinizer ignore-unused */ QueryBuilderInterface $queryBuilder,

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
31
        ExpressionInterface $expression,
32
        array &$params = []
33
    ): string {
34
        return (new PdoValueBuilder())->build($expression, $params);
35
    }
36
37
    public function getValue(): ?string
38
    {
39
        return $this->value;
40
    }
41
42
    /**
43
     * @return int|null One of PDO_PARAM_* constants
44
     *
45
     * {@see http://php.net/manual/en/pdo.constants.php}
46
     */
47
    public function getType(): ?int
48
    {
49
        return $this->type;
50
    }
51
}
52