Completed
Push — master ( 97cb14...e37317 )
by Eugene
04:42
created

InvalidOptionException::outOfRange()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 8
ccs 5
cts 5
cp 1
rs 9.4285
cc 2
eloc 5
nc 2
nop 2
crap 2
1
<?php
2
3
/*
4
 * This file is part of the rybakit/msgpack.php package.
5
 *
6
 * (c) Eugene Leonovich <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace MessagePack\Exception;
13
14
class InvalidOptionException extends \InvalidArgumentException
15
{
16 16
    public static function outOfRange(string $invalidOption, array $validOptions) : self
17
    {
18 16
        $use = \count($validOptions) > 2
19 13
            ? \sprintf('one of %2$s or %1$s', \array_pop($validOptions), \implode(', ', $validOptions))
20 16
            : \implode(' or ', $validOptions);
21
22 16
        return new self(\sprintf('Invalid option %s, use %s.', $invalidOption, $use));
23
    }
24
}
25