Completed
Push — development ( 1fb984...7ea9e3 )
by Nils
08:29
created

BooleanOption   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 22
rs 10
c 0
b 0
f 0
wmc 3
lcom 0
cbo 1

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setValue() 0 8 2
A getType() 0 4 1
1
<?php
2
3
namespace PasswordGenerator\Model\Option;
4
5
use InvalidArgumentException;
6
7
//require_once(dirname(__FILE__).'/Option.php');
0 ignored issues
show
Unused Code Comprehensibility introduced by
80% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
8
9
class BooleanOption extends Option
10
{
11
    /**
12
     * {@inheritdoc}
13
     */
14
    public function setValue($value)
15
    {
16
        if (!is_bool($value)) {
17
            throw new InvalidArgumentException('Boolean required');
18
        }
19
20
        parent::setValue($value);
0 ignored issues
show
Documentation introduced by
$value is of type boolean, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
21
    }
22
23
    /**
24
     * {@inheritdoc}
25
     */
26
    public function getType()
27
    {
28
        return self::TYPE_BOOLEAN;
29
    }
30
}
31