Completed
Push — master ( 055f1b...f72a4b )
by Pavel
52s
created

InvalidMethodParametersException::typeMismatch()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 1
Bugs 1 Features 0
Metric Value
c 1
b 1
f 0
dl 0
loc 6
ccs 4
cts 4
cp 1
rs 9.4285
cc 1
eloc 3
nc 1
nop 4
crap 1
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: batanov.pavel
5
 * Date: 16.05.2016
6
 * Time: 10:06
7
 */
8
9
namespace Bankiru\Api\Rpc\Exception;
10
11
class InvalidMethodParametersException extends \InvalidArgumentException implements RpcException
12
{
13
    /**
14
     * @param string   $method
15
     * @param string[] $missing
16
     *
17
     * @return static
18
     */
19 2
    public static function missing($method, array $missing)
20
    {
21 2
        return new static(
22 2
            sprintf(
23 2
                'Some parameters for method "%s" are missing and do not have the default value: %s',
24 2
                $method,
25 2
                implode(', ', $missing)
26 2
            )
27 2
        );
28
    }
29
30
    /**
31
     * @param string $method
32
     * @param string $name
33
     * @param string $expected
34
     * @param string $actual
35
     *
36
     * @return static
37
     */
38 1
    public static function typeMismatch($method, $name, $expected, $actual)
39
    {
40 1
        return new static(
41 1
            sprintf('Parameter %s for method "%s" has invalid type: %s given, %s expected', $name, $method, $actual, $expected)
42 1
        );
43
    }
44
}
45