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

AbstractAnnotationReadable::getChildValue()   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 2
1
<?php
2
3
namespace Chrisyue\PhpM3u8\M3u8\Core;
4
5
use Chrisyue\PhpM3u8\M3u8\OptionsTrait;
6
use Chrisyue\PhpM3u8\M3u8\ReaderAwareTrait;
7
use Chrisyue\PhpM3u8\M3u8\NameAwareTrait;
8
use Chrisyue\PhpM3u8\M3u8\PropertyReader\PropertyReaderInterface;
9
10
abstract class AbstractAnnotationReadable extends AbstractParentCore
11
{
12
    private $children;
13
14
    /**
15
     * @var Chrisyue\PhpM3u8\M3u8\PropertyReader\PropertyReaderInterface
16
     */
17
    public $reader;
18
19
    /**
20
     * @var string
21
     */
22
    public $class;
23
24
    protected function getChildren()
25
    {
26
        if (null === $this->children) {
27
            $this->children = $this->reader->read($this->class, ChildCoreInterface::class);
28
        }
29
30
        return $this->children;
31
    }
32
33
    protected function initResult()
34
    {
35
        return new $this->class;
36
    }
37
38
    protected function getChildValue($result, $property)
39
    {
40
        return $result->$property;
41
    }
42
43
    protected function setChildValue($result, $property, $value)
44
    {
45
        $result->$property = $value;
46
    }
47
48
    protected function addChildValue($result, $property, $value)
49
    {
50
        $result->$property[] = $value;
51
    }
52
}
53