Test Failed
Push — master ( 99edcd...37bac2 )
by
04:31 queued 02:01
created

Input::unserialize()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 2
eloc 2
nc 2
nop 1
1
<?php
2
3
/*
4
 * This file is part of the LineMob package.
5
 *
6
 * (c) Ishmael Doss <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace LineMob\Core;
13
14
/**
15
 * @property string $text
16
 * @property string $userId
17
 * @property string $replyToken
18
 *
19
 * @author Ishmael Doss <[email protected]>
20
 */
21
class Input
22
{
23
    /**
24
     * @var array
25
     */
26
    private $data = [];
27
28
    public function __construct(array $data)
29
    {
30
        $data['text'] = trim(preg_replace(['/ +/'], [' '], $data['text']));
31
32
        $this->data = $data;
33
    }
34
35
    /**
36
     * {@inheritdoc}
37
     */
38
    public function __toString()
39
    {
40
        return (string)$this->data['text'];
41
    }
42
43
    /**
44
     * {@inheritdoc}
45
     */
46
    public function __get($name)
47
    {
48
        return $this->data[$name];
49
    }
50
51
    /**
52
     * {@inheritdoc}
53
     */
54
    public function __set($name, $value)
55
    {
56
        throw new \LogicException('Impossible to set on a frozen input.');
57
    }
58
}
59