TypeGuesser   A
last analyzed

Complexity

Total Complexity 12

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Test Coverage

Coverage 100%
Metric Value
dl 0
loc 28
wmc 12
lcom 0
cbo 5
ccs 19
cts 19
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B guessType() 0 25 5
1
<?php
2
3
namespace Muffin\Traits;
4
5
use Muffin\Types;
6
7
trait TypeGuesser
8
{
9 18
    private function guessType($columnName, $value)
10
    {
11 18
        $type = new Types\String($columnName);
12 18
        if(is_bool($value))
13 18
        {
14 3
            $type = new Types\Boolean($columnName);
15 3
        }
16
17 18
        if(is_int($value))
18 18
        {
19 12
            $type = new Types\Integer($columnName);
20 12
        }
21
22 18
        if(is_float($value))
23 18
        {
24 3
            $type = new Types\Float($columnName);
25 3
        }
26
27 18
        if($value instanceof \DateTime)
28 18
        {
29 3
            $type = new Types\Datetime($columnName);
30 3
        }
31
32 18
        return $type;
33
    }
34
}
35