Passed
Pull Request — master (#25)
by Alexander
07:37
created

JsExpression   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 4
c 1
b 0
f 0
dl 0
loc 25
ccs 0
cts 4
cp 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A __toString() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Json;
6
7
/**
8
 * JsExpression marks a string as a JavaScript expression.
9
 * When using [[\Yiisoft\Json\Json::encode()]] or [[\Yiisoft\Json\Json::htmlEncode()]] to encode a value, JsonExpression objects
10
 * will be specially handled and encoded as a JavaScript expression instead of a string.
11
 */
12
class JsExpression
13
{
14
    /**
15
     * @var string the JavaScript expression represented by this object
16
     */
17
    public $expression;
18
19
    /**
20
     * Constructor.
21
     *
22
     * @param string $expression the JavaScript expression represented by this object
23
     */
24
    public function __construct($expression)
25
    {
26
        $this->expression = $expression;
27
    }
28
29
    /**
30
     * The PHP magic function converting an object into a string.
31
     *
32
     * @return string the JavaScript expression.
33
     */
34
    public function __toString()
35
    {
36
        return $this->expression;
37
    }
38
}
39