Input   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 5
dl 0
loc 38
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __get() 0 3 1
A __construct() 0 7 2
A __toString() 0 3 1
A __set() 0 3 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
        if (array_key_exists('text', $data)) {
31
            $data['text'] = trim(preg_replace(['/ +/'], [' '], $data['text']));
32
        }
33
34
        $this->data = $data;
35
    }
36
37
    /**
38
     * {@inheritdoc}
39
     */
40
    public function __toString()
41
    {
42
        return (string)$this->data['text'];
43
    }
44
45
    /**
46
     * {@inheritdoc}
47
     */
48
    public function __get($name)
49
    {
50
        return $this->data[$name];
51
    }
52
53
    /**
54
     * {@inheritdoc}
55
     */
56
    public function __set($name, $value)
57
    {
58
        throw new \LogicException('Impossible to set on a frozen input.');
59
    }
60
}
61