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

ObjectEscapedProxy   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 44.44%

Importance

Changes 0
Metric Value
dl 0
loc 31
ccs 8
cts 18
cp 0.4444
rs 10
c 0
b 0
f 0
wmc 8
lcom 1
cbo 1

7 Methods

Rating   Name   Duplication   Size   Complexity  
A offsetExists() 0 3 1
A offsetGet() 0 3 1
A offsetSet() 0 3 1
A offsetUnset() 0 3 1
A getIterator() 0 5 2
A __call() 0 3 1
A __get() 0 3 1
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