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

Raw   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
dl 0
loc 40
ccs 0
cts 12
cp 0
rs 10
c 0
b 0
f 0
wmc 3
lcom 0
cbo 1

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A transformForJsonRequest() 0 4 1
A __toString() 0 4 1
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