Completed
Push — master ( 7f89eb...d01340 )
by Portey
05:11
created

AbstractType::build()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 3
ccs 0
cts 2
cp 0
rs 10
cc 1
eloc 1
nc 1
nop 1
crap 2
1
<?php
2
/*
3
* This file is a part of graphql-youshido project.
4
*
5
* @author Alexandr Viniychuk <[email protected]>
6
* created: 11/27/15 2:05 AM
7
*/
8
9
namespace Youshido\GraphQL\Type;
10
11
12
use Youshido\GraphQL\Type\Config\Object\EnumTypeConfig;
13
use Youshido\GraphQL\Type\Config\Object\InputObjectTypeConfig;
14
use Youshido\GraphQL\Type\Config\Object\ObjectTypeConfig;
15
16
abstract class AbstractType implements TypeInterface
17
{
18
19
    /**
20
     * @var ObjectTypeConfig|InputObjectTypeConfig
21
     */
22
    protected $config;
23
24
    protected $isBuild = false;
25
26 1
    public function getDescription()
27
    {
28 1
        return $this->getConfig()->get('description', '');
29
    }
30
31
    /**
32
     * @return ObjectTypeConfig|InputObjectTypeConfig|EnumTypeConfig
33
     */
34 15
    public function getConfig()
35
    {
36 15
        $this->checkBuild();
37
38 15
        return $this->config;
39
    }
40
41
    abstract public function checkBuild();
42
43 1
    public function parseValue($value)
44
    {
45 1
        if (!$this->isValidValue($value)) {
46
            return null;
47
        }
48
49 1
        return $this->serialize($value);
50
    }
51
52
    public function serialize($value)
53
    {
54
        return $value;
55
    }
56
57
    public function __toString()
58
    {
59
        return $this->getName();
60
    }
61
}