TypeClosure   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 23
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A cast() 0 3 1
1
<?php
2
3
namespace Mvkasatkin\typecast\type;
4
5
class TypeClosure implements CastInterface
6
{
7
    /**
8
     * @var \Closure
9
     */
10
    protected $closure;
11
12
    /**
13
     * @param \Closure $closure
14
     */
15
    public function __construct(\Closure $closure)
16
    {
17
        $this->closure = $closure;
18
    }
19
20
    /**
21
     * @param $value
22
     *
23
     * @return mixed
24
     */
25
    public function cast($value)
26
    {
27
        return ($this->closure)($value);
28
    }
29
}
30