Passed
Pull Request — master (#6)
by
unknown
03:19
created

VariableResolver::resolve()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 6
c 1
b 0
f 0
nc 2
nop 2
dl 0
loc 11
ccs 0
cts 6
cp 0
crap 6
rs 10
1
<?php
2
3
namespace Slides\Connector\Auth\Clients\Mandrill;
4
5
use Exception;
6
7
/**
8
 * Class VariableResolver
9
 *
10
 * @package Slides\Connector\Auth\Clients\Mandrill
11
 */
12
class VariableResolver
13
{
14
    /**
15
     * @param string $name
16
     * @param string $email
17
     *
18
     * @return array
19
     *
20
     * @throws Exception
21
     */
22
    final public function resolve(string $name, string $email): array
23
    {
24
        $method = 'get' . ucfirst($name) . 'Variable';
25
26
        if (!method_exists($this, $method)) {
27
            throw new Exception('Method ' . $method . ' should be defined.');
28
        }
29
30
        return [
31
            'name' => $name,
32
            'content' => call_user_func([$this, $method], $email)
33
        ];
34
    }
35
}