CallbackMod   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 42
rs 10
c 0
b 0
f 0
wmc 4
lcom 1
cbo 1

3 Methods

Rating   Name   Duplication   Size   Complexity  
A key() 0 4 1
A value() 0 4 1
A callCallback() 0 8 2
1
<?php
2
3
namespace LaravelLangBundler\BundleItems\Mods;
4
5
use LaravelLangBundler\BundleItems\ItemWrapper;
6
7
class CallbackMod extends ItemWrapper
8
{
9
    /**
10
     * Alter key and return.
11
     *
12
     * @param string $key
13
     *
14
     * @return string
15
     */
16
    public function key($key)
17
    {
18
        return $this->callCallback($key);
19
    }
20
21
    /**
22
     * Alter value and return.
23
     *
24
     * @param string $value
25
     *
26
     * @return mixed
27
     */
28
    public function value($value)
29
    {
30
        return $this->callCallback($value);
31
    }
32
33
    /**
34
     * Call the given callback.
35
     *
36
     * @param string $string
37
     *
38
     * @return string
39
     */
40
    protected function callCallback($string)
41
    {
42
        if (is_callable($this->wrapperParameters['callback'])) {
43
            $callback = $this->wrapperParameters['callback'];
44
45
            return $callback($string);
46
        }
47
    }
48
}
49