Completed
Push — V6 ( 3ff7d1...d91002 )
by Georges
02:25
created

DriverStatistic::setRawData()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 6
Ratio 100 %

Importance

Changes 0
Metric Value
dl 6
loc 6
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 1
1
<?php
2
/**
3
 *
4
 * This file is part of phpFastCache.
5
 *
6
 * @license MIT License (MIT)
7
 *
8
 * For full copyright and license information, please see the docs/CREDITS.txt file.
9
 *
10
 * @author Khoa Bui (khoaofgod)  <[email protected]> http://www.phpfastcache.com
11
 * @author Georges.L (Geolim4)  <[email protected]>
12
 *
13
 */
14
namespace phpFastCache\Entities;
15
16
/**
17
 * Class DriverStatistic
18
 * @package phpFastCache\Entities
19
 */
20 View Code Duplication
class DriverStatistic
0 ignored issues
show
Comprehensibility Best Practice introduced by
The type phpFastCache\Entities\DriverStatistic has been defined more than once; this definition is ignored, only the first definition in src/phpFastCache/Entities/DriverStatistic.php (L20-131) is considered.

This check looks for classes that have been defined more than once.

If you can, we would recommend to use standard object-oriented programming techniques. For example, to avoid multiple types, it might make sense to create a common interface, and then multiple, different implementations for that interface.

This also has the side-effect of providing you with better IDE auto-completion, static analysis and also better OPCode caching from PHP.

Loading history...
21
{
22
    /**
23
     * @var string
24
     */
25
    protected $info = '';
26
27
    /**
28
     * @var string
29
     */
30
    protected $size = 0;
31
32
    /**
33
     * @var string
34
     */
35
    protected $data = '';
36
37
    /**
38
     * @var mixed
39
     */
40
    protected $rawData;
41
42
    /**
43
     * @return string|bool Return infos or false if no information available
44
     */
45
    public function getInfo()
46
    {
47
        return $this->info;
48
    }
49
50
    /**
51
     * @return int|bool Return size in octet or false if no information available
52
     */
53
    public function getSize()
54
    {
55
        return $this->size;
56
    }
57
58
    /**
59
     * @return mixed
60
     */
61
    public function getData()
62
    {
63
        return $this->data;
64
    }
65
66
    /**
67
     * @param $info
68
     * @return $this
69
     */
70
    public function setInfo($info)
71
    {
72
        $this->info = ($info ?: '');
73
74
        return $this;
75
    }
76
77
78
    /**
79
     * @param int $size
80
     * @return $this
81
     */
82
    public function setSize($size)
83
    {
84
        $this->size = ($size ?: 0);
0 ignored issues
show
Documentation Bug introduced by
The property $size was declared of type string, but $size ?: 0 is of type integer. Maybe add a type cast?

This check looks for assignments to scalar types that may be of the wrong type.

To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.

$answer = 42;

$correct = false;

$correct = (bool) $answer;
Loading history...
Documentation Bug introduced by
The property $size was declared of type string, but $size ?: 0 is of type integer. Maybe add a type cast?

This check looks for assignments to scalar types that may be of the wrong type.

To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.

$answer = 42;

$correct = false;

$correct = (bool) $answer;
Loading history...
85
86
        return $this;
87
    }
88
89
    /**
90
     * @param mixed $data
91
     * @return $this
92
     */
93
    public function setData($data)
94
    {
95
        $this->data = ($data ?: '');
96
97
        return $this;
98
    }
99
100
    /**
101
     * @return mixed
102
     */
103
    public function getRawData()
104
    {
105
        return $this->rawData;
106
    }
107
108
    /**
109
     * @param mixed $raw
110
     * @return $this
111
     */
112
    public function setRawData($raw)
113
    {
114
        $this->rawData = $raw;
115
116
        return $this;
117
    }
118
119
    /**
120
     * @return array
121
     */
122
    public function getPublicDesc()
123
    {
124
        return[
125
            'Info' => 'Cache Information',
126
            'Size' => 'Cache Size',
127
            'Data' => 'Cache items keys',
128
            'RawData' => 'Cache raw data',
129
        ];
130
    }
131
}