FragmentXpath::__construct()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 1
1
<?php
2
/**
3
 * Webino (http://webino.sk)
4
 *
5
 * @link        https://github.com/webino/WebinoDraw for the canonical source repository
6
 * @copyright   Copyright (c) 2012-2017 Webino, s. r. o. (http://webino.sk)
7
 * @author      Peter Bačinský <[email protected]>
8
 * @license     BSD-3-Clause
9
 */
10
11
namespace WebinoDraw\Ajax;
12
13
use WebinoDraw\Exception\UnexpectedValueException;
14
15
/**
16
 *
17
 */
18
class FragmentXpath
19
{
20
    /**
21
     * @var string
22
     */
23
    protected $content;
24
25
    /**
26
     * @param string $string
27
     */
28
    public function __construct($string = null)
29
    {
30
        (null === $string) or
31
            $this->set($string);
32
    }
33
34
    /**
35
     * @param string $string
36
     * @return FragmentXpath
37
     * @throws UnexpectedValueException
38
     */
39
    public function set($string)
40
    {
41
        if (!is_string($string)) {
42
            throw new UnexpectedValueException('Expected string, but provided ' . gettype($string));
43
        }
44
45
        $this->content = $string;
46
        return $this;
47
    }
48
49
    /**
50
     * @return string
51
     */
52
    public function __toString()
53
    {
54
        return $this->content;
55
    }
56
}
57