AbstractHandle   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 83
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 1 Features 1
Metric Value
wmc 8
c 2
b 1
f 1
lcom 2
cbo 0
dl 0
loc 83
ccs 18
cts 18
cp 1
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A hasInfo() 0 4 1
A getInfo() 0 8 2
A getInfos() 0 4 1
A hasOption() 0 4 1
A addOption() 0 5 1
A addOptions() 0 7 2
1
<?php
2
/**
3
 * This file is part of the bee4/transport package.
4
 * For the full copyright and license information, please view the LICENSE
5
 * file that was distributed with this source code.
6
 *
7
 * @copyright Bee4 2015
8
 * @author Stephane HULARD <[email protected]>
9
 * @package Bee4\Transport\Handle
10
 */
11
namespace Bee4\Transport\Handle;
12
13
/**
14
 * Add information container capabilities
15
 * @package Bee4\Transport\Handle
16
 */
17
abstract class AbstractHandle implements HandleInterface
18
{
19
    /**
20
     * Last execution details
21
     * @var string
22
     */
23
    protected $infos = [];
24
25
    /**
26
     * cURL option to be used to execute current handle
27
     * @var array
28
     */
29
    protected $options = [];
30
31
    /**
32
     * Check if execution details contain requested info
33
     * @param string $name
34
     * @return boolean
35
     */
36 11
    public function hasInfo($name)
37
    {
38 11
        return isset($this->infos[$name]);
39
    }
40
41
    /**
42
     * Return last execution detail
43
     * @param string $name
44
     * @return int|string|double
45
     */
46 11
    public function getInfo($name)
47
    {
48 11
        if ($this->hasInfo($name)) {
49 11
            return $this->infos[$name];
50
        }
51
52 1
        return null;
53
    }
54
55
    /**
56
     * Retrieve all infos
57
     * @return array
58
     */
59 1
    public function getInfos()
60
    {
61 1
        return $this->infos;
62
    }
63
64
    /**
65
     * Add an option to the handle
66
     * @param int $name
67
     * @param mixed $value
0 ignored issues
show
Bug introduced by
There is no parameter named $value. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
68
     * @return Handle
69
     */
70 1
    public function hasOption($name)
71
    {
72 1
        return isset($this->options[$name]);
73
    }
74
75
    /**
76
     * Add an option to the handle
77
     * @param int $name
78
     * @param mixed $value
79
     * @return Handle
80
     */
81 13
    public function addOption($name, $value)
82
    {
83 13
        $this->options[$name] = $value;
84 13
        return $this;
85
    }
86
87
    /**
88
     * Add multiple option at once
89
     * @param string[] $options
90
     * @return Handle
91
     */
92 12
    public function addOptions(array $options)
93
    {
94 12
        foreach ($options as $name => $value) {
95 12
            $this->addOption($name, $value);
96 12
        }
97 12
        return $this;
98
    }
99
}
100