Completed
Pull Request — v4.0-dev (#203)
by
unknown
01:35
created

ObjectEscapedProxy::offsetGet()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace League\Plates\Extension\AutoEscape;
4
5
use ArrayAccess;
6
use IteratorAggregate;
7
use League\Plates;
8
9
final class ObjectEscapedProxy extends EscapedProxy implements ArrayAccess, IteratorAggregate
10
{
11
    protected $initialized = false;
12
13
    public function offsetExists($offset) {
14
        return isset($this->wrapped[$offset]);
15
    }
16 8
    public function offsetGet($offset) {
17 8
        return EscapedProxy::create($this->wrapped[$offset], $this->escape);
18
    }
19
    public function offsetSet($offset, $value) {
20
        $this->wrapped[$offset] = EscapedProxy::create($value, $this->escape);
21
    }
22
    public function offsetUnset($offset) {
23
        unset($this->wrapped[$offset]);
24
    }
25
26 8
    public function getIterator() {
27 8
        foreach ($this->wrapped as $key => $value) {
28 8
            yield $key => EscapedProxy::create($value, $this->escape);
29
        }
30 8
    }
31
32
    public function __call($method, array $args) {
33
        return EscapedProxy::create($this->wrapped->{$method}(...$args), $this->escape);
0 ignored issues
show
Bug introduced by
The method $method cannot be called on $this->wrapped (of type array).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
34
    }
35
36 12
    public function __get($name) {
37 12
        return EscapedProxy::create($this->wrapped->{$name}, $this->escape);
38
    }
39
}
40