Completed
Push — master ( 53e43c...41b088 )
by Vitaly
03:02
created

VirtualQuery::createStaticFields()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 21
Code Lines 18

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 21
rs 9.3142
cc 1
eloc 18
nc 1
nop 1
1
<?php
2
//[PHPCOMPRESSOR(remove,start)]
3
/**
4
 * Created by Vitaly Iegorov <[email protected]>.
5
 * on 22.03.16 at 15:46
6
 */
7
namespace samsoncms\api\generator;
8
9
use samsoncms\api\generator\metadata\Virtual;
10
use samsonphp\generator\Generator;
11
12
/**
13
 * Virtual entity query class generator.
14
 *
15
 * @package samsoncms\api\generator
16
 */
17
class VirtualQuery extends RealQuery
18
{
19
    /**
20
     * Query constructor.
21
     *
22
     * @param Generator $generator
23
     * @param           $metadata
24
     */
25 View Code Duplication
    public function __construct(Generator $generator, $metadata)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
26
    {
27
        parent::__construct($generator, $metadata);
28
29
        $this->className .= 'Query';
30
        $this->parentClass = '\\' . \samsoncms\api\query\Entity::class;
31
        $this->entityClass = '\samsoncms\api\generated\\' . $metadata->entity;
32
    }
33
34
    /**
35
     * Class static fields generation part.
36
     *
37
     * @param Virtual $metadata Entity metadata
38
     */
39
    protected function createStaticFields($metadata)
40
    {
41
        $this->generator
42
            ->commentVar('array', 'Collection of real additional field names')
43
            ->defClassVar('$fieldRealNames', 'public static', $metadata->realNames)
44
            ->commentVar('array', 'Collection of additional field names')
45
            ->defClassVar('$fieldNames', 'public static', $metadata->fieldNames)
46
            // TODO: two above fields should be protected
47
            ->commentVar('array', 'Collection of navigation identifiers')
48
            ->defClassVar('$navigationIDs', 'protected static', array($metadata->entityID))
49
            ->commentVar('string', 'Entity full class name')
50
            ->defClassVar('$identifier', 'protected static', $this->entityClass)
51
            ->commentVar('array', 'Collection of localized additional fields identifiers')
52
            ->defClassVar('$localizedFieldIDs', 'protected static', $metadata->localizedFieldIDs)
53
            ->commentVar('array', 'Collection of NOT localized additional fields identifiers')
54
            ->defClassVar('$notLocalizedFieldIDs', 'protected static', $metadata->notLocalizedFieldIDs)
55
            ->commentVar('array', 'Collection of localized additional fields identifiers')
56
            ->defClassVar('$fieldIDs', 'protected static', $metadata->fields)
57
            ->commentVar('array', 'Collection of additional fields value column names')
58
            ->defClassVar('$fieldValueColumns', 'protected static', $metadata->allFieldValueColumns);
59
    }
60
}
61
//[PHPCOMPRESSOR(remove,end)]
62