Completed
Push — master ( c59138...74df60 )
by Beniamin
04:20
created

InvalidStageException::create()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 11
ccs 7
cts 7
cp 1
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 6
nc 2
nop 1
crap 2
1
<?php
2
3
/**
4
 * This file is part of phuria/pipolino package.
5
 *
6
 * Copyright (c) 2017 Beniamin Jonatan Šimko
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 Phuria\Pipolino;
13
14
/**
15
 * @author Beniamin Jonatan Šimko <[email protected]>
16
 */
17
class InvalidStageException extends \RuntimeException
18
{
19
    /**
20
     * @param mixed $stage
21
     *
22
     * @return InvalidStageException
23
     */
24 3
    public static function create($stage)
25
    {
26 3
        if (is_object($stage)) {
27 1
            return new self(sprintf(
28 1
                'Object [%s] is not valid stage. Please check __invoke() implementation.',
29 1
                get_class($stage)
30 1
            ));
31
        }
32
33 2
        return new self(sprintf('Invalid stage implementation detected. Probably stage is not callable.'));
34
    }
35
}
36