Completed
Push — master ( 1af4f5...caaac4 )
by Andreas
03:43
created

translator   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 75%

Importance

Changes 0
Metric Value
dl 0
loc 34
ccs 3
cts 4
cp 0.75
rs 10
c 0
b 0
f 0
wmc 2
lcom 1
cbo 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A to_constant() 0 7 2
1
<?php
2
/**
3
 * @author CONTENT CONTROL http://www.contentcontrol-berlin.de/
4
 * @copyright CONTENT CONTROL http://www.contentcontrol-berlin.de/
5
 * @license http://www.gnu.org/licenses/gpl.html GNU General Public License
6
 */
7
8
namespace midgard\portable\mgdschema;
9
10
class translator
11
{
12
    const TYPE_NONE = 4;
13
    const TYPE_BOOLEAN = 20;
14
    const TYPE_INT = 24;
15
    const TYPE_UINT = 28;
16
    const TYPE_FLOAT = 56;
17
    const TYPE_STRING = 64;
18
    const TYPE_LONGTEXT = 196;
19
    const TYPE_TIMESTAMP = 139645924049440;
20
    const TYPE_GUID = 139645923896704;
21
22
    private static $typemap = array(
23
        'unsigned integer' => self::TYPE_UINT,
24
        'integer' => self::TYPE_INT,
25
        'boolean' => self::TYPE_BOOLEAN,
26
        'bool' => self::TYPE_BOOLEAN,
27
        'guid' => self::TYPE_GUID,
28
        //'varchar(80)' => self::TYPE_GUID, // <== true for all cases?
0 ignored issues
show
Unused Code Comprehensibility introduced by
45% 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...
29
        'string' => self::TYPE_STRING,
30
        'datetime' => self::TYPE_TIMESTAMP,
31
        'text' => self::TYPE_LONGTEXT,
32
        'longtext' => self::TYPE_LONGTEXT,
33
        'float' => self::TYPE_FLOAT
34
    );
35
36 15
    public static function to_constant($typeattribute)
37
    {
38 15
        if (!array_key_exists($typeattribute, self::$typemap)) {
39
            throw new \Exception('unknown type ' . $typeattribute);
40
        }
41 15
        return self::$typemap[$typeattribute];
42
    }
43
}
44