StackManager::add()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
crap 1
1
<?php namespace Comodojo\Cache\Components;
2
3
use \Comodojo\Cache\Interfaces\EnhancedCacheItemPoolInterface;
4
use \Comodojo\Exception\CacheException;
5
use \Exception;
6
7
/**
8
 * @package     Comodojo Cache
9
 * @author      Marco Giovinazzi <[email protected]>
10
 * @license     MIT
11
 *
12
 * LICENSE:
13
 *
14
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20
 * THE SOFTWARE.
21
 */
22
23
class StackManager extends AbstractStackManager {
24
25 45
    public function add(EnhancedCacheItemPoolInterface $provider, $weight) {
26
27 45
        return $this->genericAdd($provider, $weight);
0 ignored issues
show
Bug introduced by
Are you sure the usage of $this->genericAdd($provider, $weight) targeting Comodojo\Cache\Component...ckManager::genericAdd() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
28
29
    }
30
31 1
    public function remove($id) {
32
33
        try {
34
35 1
            return parent::remove($id);
36
37
        } catch (Exception $e) {
38
39
            throw new CacheException($e->getMessage());
40
41
        }
42
43
    }
44
45 1
    public function get($id) {
46
47
        try {
48
49 1
            return parent::get($id);
50
51
        } catch (Exception $e) {
52
53
            throw new CacheException($e->getMessage());
54
55
        }
56
57
    }
58
59
}
60