Completed
Push — master ( 805de4...131e3d )
by Vitaly
02:35
created

Application::analyzeEntityRecord()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 7

Duplication

Lines 13
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 13
loc 13
rs 9.4285
cc 1
eloc 7
nc 1
nop 2
1
<?php
2
//[PHPCOMPRESSOR(remove,start)]
3
namespace samsoncms\api\generator\analyzer;
4
5
use samsoncms\api\Field;
6
7
/**
8
 * Created by Vitaly Iegorov <[email protected]>.
9
 * on 23.03.16 at 16:21
10
 */
11
class Application extends \samsoncms\api\generator\analyzer\Virtual
12
{
13
    /** @var string Metadata class */
14
    protected $metadataClass = \samsoncms\api\generator\metadata\Application::class;
15
16
    /**
17
     * Analyze entity.
18
     *
19
     * @param \samsoncms\api\generator\metadata\Virtual $metadata
20
     * @param array $structureRow Entity database row
21
     */
22 View Code Duplication
    public function analyzeEntityRecord(&$metadata, array $structureRow)
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...
23
    {
24
        $metadata->structureRow = $structureRow;
25
26
        // Get CapsCase and transliterated entity name
27
        $metadata->entity = $this->entityName($structureRow['Name']);
28
        $metadata->entityClassName = $this->fullEntityName($metadata->entity);
29
        $metadata->entityRealName = $structureRow['Name'];
30
        $metadata->entityID = $structureRow['StructureID'];
31
32
        // Try to find entity parent identifier for building future relations
33
        $metadata->parentID = $this->getParentEntity($structureRow['StructureID']);
34
    }
35
36
    /**
37
     * Virtual entity additional field analyzer.
38
     *
39
     * @param \samsoncms\api\generator\metadata\Virtual $metadata Metadata instance for filling
40
     * @param int      $fieldID Additional field identifier
41
     * @param array $fieldRow Additional field database row
42
     */
43 View Code Duplication
    public function analyzeFieldRecord(&$metadata, $fieldID, array $fieldRow)
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...
44
    {
45
        // Get camelCase and transliterated field name
46
        $fieldName = $this->fieldName($fieldRow['Name']);
47
48
        // TODO: Set default for additional field storing type accordingly.
49
50
        // Store field metadata
51
        $metadata->realNames[$fieldRow['Name']] = $fieldName;
52
        $metadata->allFieldIDs[$fieldID] = $fieldName;
53
        $metadata->allFieldNames[$fieldName] = $fieldID;
54
        $metadata->allFieldValueColumns[$fieldID] = Field::valueColumn($fieldRow[Field::F_TYPE]);
55
        $metadata->allFieldTypes[$fieldID] = Field::phpType($fieldRow['Type']);
56
        $metadata->allFieldCmsTypes[$fieldID] = (int)$fieldRow['Type'];
57
        $metadata->fieldDescriptions[$fieldID] = $fieldRow['Description'] . ', ' . $fieldRow['Name'] . '#' . $fieldID;
58
        $metadata->fieldRawDescriptions[$fieldID] = $fieldRow['Description'];
59
    }
60
}
61
//[PHPCOMPRESSOR(remove,end)]
62