Completed
Push — feature/0.7.0 ( 91054f...38440f )
by Ryuichi
04:10
created

CoreService::__destruct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
c 3
b 0
f 0
nc 1
nop 0
dl 0
loc 5
rs 9.4285
1
<?php
2
namespace WebStream\Core;
3
4
use WebStream\Delegate\Resolver;
5
use WebStream\DI\Injector;
6
use WebStream\Module\Container;
7
use WebStream\Annotation\Filter;
8
use WebStream\Annotation\Base\IAnnotatable;
9
10
/**
11
 * CoreService
12
 * @author Ryuichi TANAKA.
13
 * @since 2011/09/11
14
 * @version 0.4.1
15
 */
16
class CoreService implements CoreInterface, IAnnotatable
17
{
18
    use Injector;
19
20
    /**
21
     * @var CoreDelegator コアデリゲータ
22
     */
23
    private $coreDelegator;
24
25
    /**
26
     * @var array<mixed> カスタムアノテーション
27
     */
28
    protected $annotation;
29
30
    /**
31
     * @var LoggerAdapter ロガー
32
     */
33
    protected $logger;
34
35
    /**
36
     * {@inheritdoc}
37
     */
38
    public function __destruct()
39
    {
40
        $this->logger->debug("Service end.");
41
        $this->__clear();
42
    }
43
44
    /**
45
     * {@inheritdoc}
46
     * @Filter(type="initialize")
47
     */
48
    public function __initialize(Container $container)
49
    {
50
        $pageName = $this->coreDelegator->getPageName();
51
        $resolver = new Resolver($container);
52
        $this->{$pageName} = $resolver->runModel();
53
    }
54
55
    /**
56
     * {@inheritdoc}
57
     */
58
    public function __customAnnotation(array $annotation)
59
    {
60
        $this->annotation = $annotation;
61
    }
62
63
    /**
64
     * Controllerから存在しないメソッドが呼ばれたときの処理
65
     * @param string メソッド名
66
     * @param array 引数の配列
67
     * @return 実行結果
68
     */
69
    final public function __call($method, $arguments)
70
    {
71
        $pageName = $this->coreDelegator->getPageName();
72
73
        return $this->{$pageName}->run($method, $arguments);
74
    }
75
}
76