DataTypeGuesserSpec   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A it_should_be_initializable() 0 4 1
A it_should_guess_form_type_given_internal_data_type() 0 15 1
A it_should_guess_date_fields() 0 9 1
1
<?php
2
3
namespace spec\Knp\RadBundle\Form;
4
5
use PhpSpec\ObjectBehavior;
6
7
class DataTypeGuesserSpec extends ObjectBehavior
8
{
9
    function it_should_be_initializable()
0 ignored issues
show
Coding Style introduced by
Method name "DataTypeGuesserSpec::it_should_be_initializable" is not in camel caps format
Loading history...
10
    {
11
        $this->shouldHaveType('Knp\RadBundle\Form\DataTypeGuesser');
12
    }
13
14
    function it_should_guess_form_type_given_internal_data_type()
0 ignored issues
show
Coding Style introduced by
Method name "DataTypeGuesserSpec::it_should_guess_form_type_given_internal_data_type" is not in camel caps format
Loading history...
15
    {
16
        $this->setData((object) array(
17
            'test' => true,
18
            'coll' => array(),
19
        ));
20
21
        $guess = $this->guessType('', 'test');
22
        $guess->getType()->shouldBe('checkbox');
23
24
        $guess = $this->guessType('', 'coll');
25
        $guess->getType()->shouldBe('collection');
26
27
        $guess = $this->guessType('', 'inexistant')->shouldReturn(null);
0 ignored issues
show
Unused Code introduced by
$guess is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
28
    }
29
30
    function it_should_guess_date_fields()
0 ignored issues
show
Coding Style introduced by
Method name "DataTypeGuesserSpec::it_should_guess_date_fields" is not in camel caps format
Loading history...
31
    {
32
        $this->setData((object) array(
33
            'date' => new \DateTime,
34
        ));
35
36
        $guess = $this->guessType('', 'date');
37
        $guess->getType()->shouldBe('date');
38
    }
39
}
40