Passed
Push — master ( a2a2c3...5dc036 )
by Carlos
03:01
created

Raw::transformForJsonRequest()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 2
dl 0
loc 4
rs 10
c 0
b 0
f 0
ccs 0
cts 4
cp 0
crap 2
1
<?php
2
3
/*
4
 * This file is part of the overtrue/wechat.
5
 *
6
 * (c) overtrue <[email protected]>
7
 *
8
 * This source file is subject to the MIT license that is bundled
9
 * with this source code in the file LICENSE.
10
 */
11
12
namespace EasyWeChat\Kernel\Messages;
13
14
/**
15
 * Class Raw.
16
 */
17
class Raw extends Message
18
{
19
    /**
20
     * @var string
21
     */
22
    protected $type = 'raw';
23
24
    /**
25
     * Properties.
26
     *
27
     * @var array
28
     */
29
    protected $properties = ['content'];
30
31
    /**
32
     * Constructor.
33
     *
34
     * @param string $content
35
     */
36
    public function __construct(string $content)
37
    {
38
        parent::__construct(['content' => strval($content)]);
39
    }
40
41
    /**
42
     * @param array $appends
43
     * @param bool  $withType
44
     *
45
     * @return array
46
     */
47
    public function transformForJsonRequest(array $appends = [], $withType = true): array
48
    {
49
        return json_decode($this->content, true) ?? [];
50
    }
51
52
    public function __toString()
53
    {
54
        return $this->get('content') ?? '';
55
    }
56
}
57