Passed
Push — master ( ece31d...41b8a6 )
by Paul
10:20 queued 04:17
created

ReviewHtml   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 16
c 0
b 0
f 0
dl 0
loc 45
ccs 0
cts 24
cp 0
rs 10
wmc 6

3 Methods

Rating   Name   Duplication   Size   Complexity  
A offsetGet() 0 8 3
A __construct() 0 5 1
A __toString() 0 8 2
1
<?php
2
3
namespace GeminiLabs\SiteReviews\Modules\Html;
4
5
use ArrayObject;
6
use GeminiLabs\SiteReviews\Review;
7
8
class ReviewHtml extends ArrayObject
9
{
10
    /**
11
     * @var Review
12
     */
13
    public $review;
14
15
    /**
16
     * @var array
17
     */
18
    public $values;
19
20
    public function __construct(Review $review, array $values = [])
21
    {
22
        $this->review = $review;
23
        $this->values = $values;
24
        parent::__construct($values, ArrayObject::STD_PROP_LIST | ArrayObject::ARRAY_AS_PROPS);
25
    }
26
27
    /**
28
     * @return string|void
29
     */
30
    public function __toString()
31
    {
32
        if (empty($this->values)) {
33
            return;
34
        }
35
        return glsr(Template::class)->build('templates/review', [
36
            'context' => $this->values,
37
            'review' => $this->review,
38
        ]);
39
    }
40
41
    /**
42
     * @param mixed $key
43
     * @return mixed
44
     */
45
    public function offsetGet($key)
46
    {
47
        if (property_exists($this, $key)) {
48
            return $this->$key;
49
        }
50
        return array_key_exists($key, $this->values)
51
            ? $this->values[$key]
52
            : null;
53
    }
54
}
55