Completed
Pull Request — develop (#27)
by Chris
02:13
created

AbstractAnnotationReadable::initResult()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
c 0
b 0
f 0
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace Chrisyue\PhpM3u8\M3u8\Core;
4
5
abstract class AbstractAnnotationReadable extends AbstractParentCore
6
{
7
    private $children;
8
9
    /**
10
     * @var Chrisyue\PhpM3u8\M3u8\PropertyReader\PropertyReaderInterface
11
     */
12
    public $reader;
13
14
    /**
15
     * @var string
16
     */
17
    public $class;
18
19
    protected function getChildren()
20
    {
21
        if (null === $this->children) {
22
            $this->children = $this->reader->read($this->class, ChildCoreInterface::class);
23
        }
24
25
        return $this->children;
26
    }
27
28
    protected function initResult()
29
    {
30
        return new $this->class();
31
    }
32
33
    protected function getChildValue($result, $property)
34
    {
35
        return $result->$property;
36
    }
37
38
    protected function setChildValue($result, $property, $value)
39
    {
40
        $result->$property = $value;
41
    }
42
43
    protected function addChildValue($result, $property, $value)
44
    {
45
        array_push($result->$property, $value);
46
    }
47
}
48