Completed
Push — develop ( 7137c5...4ec3be )
by Neomerx
05:43
created

RawNameType   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 1
dl 0
loc 28
ccs 9
cts 9
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getSQLDeclaration() 0 11 1
A getName() 0 4 1
1
<?php namespace Limoncello\Data\Migrations;
2
3
/**
4
 * Copyright 2015-2017 [email protected]
5
 *
6
 * Licensed under the Apache License, Version 2.0 (the "License");
7
 * you may not use this file except in compliance with the License.
8
 * You may obtain a copy of the License at
9
 *
10
 * http://www.apache.org/licenses/LICENSE-2.0
11
 *
12
 * Unless required by applicable law or agreed to in writing, software
13
 * distributed under the License is distributed on an "AS IS" BASIS,
14
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
 * See the License for the specific language governing permissions and
16
 * limitations under the License.
17
 */
18
19
use Doctrine\DBAL\Platforms\AbstractPlatform;
20
use Doctrine\DBAL\Types\Type;
21
22
/**
23
 * The type could be used for referring custom database types in table columns.
24
 *
25
 * @package Limoncello\Data
26
 */
27
class RawNameType extends Type
28
{
29
    /** Type name */
30
    const TYPE_NAME = 'RawName';
31
32
    /**
33
     * @inheritdoc
34
     */
35 1
    public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform)
36
    {
37 1
        assert(
38 1
            array_key_exists(static::TYPE_NAME, $fieldDeclaration),
39 1
            'Raw type name is not set. Use `Column::setCustomSchemaOption` to set the name.'
40
        );
41 1
        $rawName = $fieldDeclaration[static::TYPE_NAME];
42 1
        assert(empty($rawName) === false);
43
44 1
        return $rawName;
45
    }
46
47
    /**
48
     * @inheritdoc
49
     */
50 1
    public function getName()
51
    {
52 1
        return self::TYPE_NAME;
53
    }
54
}
55