LazyAttribute   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 21
ccs 5
cts 5
cp 1
rs 10
c 0
b 0
f 0
wmc 2
lcom 1
cbo 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getAttribute() 0 4 1
1
<?php
2
namespace Wandu\Http\Attribute;
3
4
use Psr\Http\Message\ServerRequestInterface;
5
use Wandu\Http\Contracts\AttributeInterface;
6
7
class LazyAttribute implements AttributeInterface
8
{
9
    /** @var callable */
10
    protected $handler;
11
    
12
    /**
13
     * @param callable $handler
14
     */
15 2
    public function __construct(callable $handler)
16
    {
17 2
        $this->handler = $handler;
18 2
    }
19
20
    /**
21
     * {@inheritdoc}
22
     */
23 2
    public function getAttribute(ServerRequestInterface $request)
24
    {
25 2
        return call_user_func($this->handler, $request);
26
    }
27
}
28