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

AutoEscapeExtension   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 13
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 88.89%

Importance

Changes 0
Metric Value
dl 0
loc 13
ccs 8
cts 9
cp 0.8889
rs 10
c 0
b 0
f 0
wmc 2
lcom 0
cbo 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A register() 0 10 2
1
<?php
2
3
namespace League\Plates\Extension\AutoEscape;
4
5
use League\Plates;
6
7
final class AutoEscapeExtension implements Plates\Extension
8
{
9 16
    public function register(Plates\Engine $plates) {
10 16
        $plates->addConfig([
11 16
            'auto_escape' => false,
12
        ]);
13 16
        $plates->pushComposers(function($c) {
0 ignored issues
show
Documentation Bug introduced by
The method pushComposers does not exist on object<League\Plates\Engine>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
14 16
            return $c->get('config')['auto_escape'] ? [
15
                'autoEscape.autoEscape' => autoEscapeComposer(),
16 16
            ] : [];
17 16
        });
18 16
    }
19
}
20