Completed
Pull Request — master (#14)
by Tim
02:03
created

Logger::postDeserialize()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 13
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 13
rs 9.4285
cc 3
eloc 5
nc 4
nop 0
1
<?php
2
3
/**
4
 * TechDivision\Import\Configuration\Jms\Configuration\Logger
5
 *
6
 * NOTICE OF LICENSE
7
 *
8
 * This source file is subject to the Open Software License (OSL 3.0)
9
 * that is available through the world-wide-web at this URL:
10
 * http://opensource.org/licenses/osl-3.0.php
11
 *
12
 * PHP version 5
13
 *
14
 * @author    Tim Wagner <[email protected]>
15
 * @copyright 2016 TechDivision GmbH <[email protected]>
16
 * @license   http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
 * @link      https://github.com/techdivision/import-configuration-jms
18
 * @link      http://www.techdivision.com
19
 */
20
21
namespace TechDivision\Import\Configuration\Jms\Configuration;
22
23
use JMS\Serializer\Annotation\Type;
24
use JMS\Serializer\Annotation\SerializedName;
25
use JMS\Serializer\Annotation\PostDeserialize;
26
use Doctrine\Common\Collections\ArrayCollection;
27
use TechDivision\Import\Configuration\LoggerConfigurationInterface;
28
29
/**
30
 * The logger configuration.
31
 *
32
 * @author    Tim Wagner <[email protected]>
33
 * @copyright 2016 TechDivision GmbH <[email protected]>
34
 * @license   http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
35
 * @link      https://github.com/techdivision/import-configuration-jms
36
 * @link      http://www.techdivision.com
37
 */
38
class Logger implements LoggerConfigurationInterface
39
{
40
41
    /**
42
     * The trait that provides parameter handling functionality.
43
     *
44
     * @var \TechDivision\Import\Configuration\Jms\Configuration\ParamsTrait
45
     */
46
    use ParamsTrait;
47
48
    /**
49
     * The logger's channel name to use.
50
     *
51
     * @var string
52
     * @Type("string")
53
     * @SerializedName("channel-name")
54
     */
55
    protected $channelName;
56
57
    /**
58
     * The logger's unique name to use.
59
     *
60
     * @var string
61
     * @Type("string")
62
     */
63
    protected $name;
64
65
    /**
66
     * The logger's type to use.
67
     *
68
     * @var string
69
     * @Type("string")
70
     */
71
    protected $type;
72
73
    /**
74
     * The factory used to create the logger instance.
75
     *
76
     * @var string
77
     * @Type("string")
78
     */
79
    protected $factory = 'TechDivision\Import\Configuration\Jms\Configuration\LoggerFactory';
80
81
    /**
82
     * ArrayCollection with the information of the configured processors.
83
     *
84
     * @var \Doctrine\Common\Collections\ArrayCollection
85
     * @Type("ArrayCollection<TechDivision\Import\Configuration\Jms\Configuration\Logger\Processor>")
86
     */
87
    protected $processors;
88
89
    /**
90
     * ArrayCollection with the information of the configured handlers.
91
     *
92
     * @var \Doctrine\Common\Collections\ArrayCollection
93
     * @Type("ArrayCollection<TechDivision\Import\Configuration\Jms\Configuration\Logger\Handler>")
94
     */
95
    protected $handlers;
96
97
    /**
98
     * Lifecycle callback that will be invoked after deserialization.
99
     *
100
     * @return void
101
     * @PostDeserialize
102
     */
103
    public function postDeserialize()
104
    {
105
106
        // create an empty collection if no processors has been specified
107
        if ($this->processors === null) {
108
            $this->processors = new ArrayCollection();
109
        }
110
111
        // create an empty collection if no handlers has been specified
112
        if ($this->handlers === null) {
113
            $this->handlers = new ArrayCollection();
114
        }
115
    }
116
117
    /**
118
     * Return's the logger's channel name to use.
119
     *
120
     * @return string The channel name
121
     */
122
    public function getChannelName()
123
    {
124
        return $this->channelName;
125
    }
126
127
    /**
128
     * Return's the logger's unique name to use.
129
     *
130
     * @return string The unique name
131
     */
132
    public function getName()
133
    {
134
        return $this->name;
135
    }
136
137
    /**
138
     * Return's the factory used to create the logger instance.
139
     *
140
     * @return string The factory to use
141
     */
142
    public function getFactory()
143
    {
144
        return $this->factory;
145
    }
146
147
    /**
148
     * Return's the logger's type to use.
149
     *
150
     * @return string The type
151
     */
152
    public function getType()
153
    {
154
        return $this->type;
155
    }
156
157
    /**
158
     * Return's the array with the logger's processors.
159
     *
160
     * @return \Doctrine\Common\Collections\ArrayCollection The ArrayCollection with the processors
161
     */
162
    public function getProcessors()
163
    {
164
        return $this->processors;
165
    }
166
167
    /**
168
     * Return's the array with the logger's handlers.
169
     *
170
     * @return \Doctrine\Common\Collections\ArrayCollection The ArrayCollection with the handlers
171
     */
172
    public function getHandlers()
173
    {
174
        return $this->handlers;
175
    }
176
}
177