AsyncAction::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 6
nc 1
nop 3
1
<?php
2
namespace Workana\AsyncJobs;
3
4
use Bernard\Message;
5
6
/**
7
 * Async action
8
 *
9
 * @author Carlos Frutos <[email protected]>
10
 */
11
class AsyncAction extends Job
12
{
13
    /**
14
     * @var string
15
     */
16
    protected $class;
17
18
    /**
19
     * @var string
20
     */
21
    protected $method;
22
23
    /**
24
     * @var Parameter[]
25
     */
26
    protected $parameters;
27
28
    public function __construct($class, $method, array $parameters = [])
29
    {
30
        $this->class = (string) $class;
31
        $this->method = (string) $method;
32
        $this->parameters = array_map(function($paramValue) {
33
            return new Parameter($paramValue);
34
        }, $parameters);
35
    }
36
37
    /**
38
     * @return string
39
     */
40
    public function getClass()
41
    {
42
        return $this->class;
43
    }
44
45
    /**
46
     * @return string
47
     */
48
    public function getMethod()
49
    {
50
        return $this->method;
51
    }
52
53
    /**
54
     * @return Parameter[]
55
     */
56
    public function getParameters()
57
    {
58
        return $this->parameters;
59
    }
60
61
    /**
62
     * @return array
63
     */
64
    public function getParameterValues()
65
    {
66
        return array_map(function(Parameter $param) {
67
            return $param->getValue();
68
        }, $this->parameters);
69
    }
70
71
    /**
72
     * @return string
73
     */
74
    public function __toString()
75
    {
76
        return "{$this->class}::{$this->method}";
77
    }
78
}