Issues (117)

Model/DataTablesOrder.php (1 issue)

Labels
Severity
1
<?php
2
3
/*
4
 * This file is part of the jquery-datatables-bundle package.
5
 *
6
 * (c) 2018 WEBEWEB
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace WBW\Bundle\JQuery\DataTablesBundle\Model;
13
14
use WBW\Bundle\JQuery\DataTablesBundle\Api\DataTablesOrderInterface;
15
16
/**
17
 * DataTables order.
18
 *
19
 * @author webeweb <https://github.com/webeweb>
20
 * @package WBW\Bundle\JQuery\DataTablesBundle\Model
21
 */
22
class DataTablesOrder implements DataTablesOrderInterface {
23
24
    /**
25
     * Column.
26
     *
27
     * @var int|null
28
     */
29
    private $column;
30
31
    /**
32
     * Dir.
33
     *
34
     * @var string|null
35
     */
36
    private $dir;
37
38
    /**
39
     * Constructor.
40
     */
41
    public function __construct() {
42
        // NOTHING TO DO
43
    }
44
45
    /**
46
     * {@inheritDoc}
47
     */
48
    public function getColumn(): ?int {
49
        return $this->column;
50
    }
51
52
    /**
53
     * {@inheritDoc}
54
     */
55
    public function getDir(): ?string {
56
        return $this->dir;
57
    }
58
59
    /**
60
     * Set the column.
61
     *
62
     * @param int|null $column The column.
63
     * @return DataTablesOrderInterface Returns this order.
64
     */
65
    public function setColumn(?int $column): DataTablesOrderInterface {
66
        $this->column = (0 <= $column ? $column : null);
67
        return $this;
68
    }
69
70
    /**
71
     * Set the dir.
72
     *
73
     * @param string|null $dir The dir.
74
     * @return DataTablesOrderInterface Returns this order.
75
     */
76
    public function setDir(?string $dir): DataTablesOrderInterface {
77
78
        if (false === in_array($dir, DataTablesEnumerator::enumDirs())) {
79
            $dir = self::DATATABLES_DIR_ASC;
80
        }
81
82
        $this->dir = strtoupper($dir);
0 ignored issues
show
It seems like $dir can also be of type null; however, parameter $string of strtoupper() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

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

82
        $this->dir = strtoupper(/** @scrutinizer ignore-type */ $dir);
Loading history...
83
        return $this;
84
    }
85
}
86