Completed
Pull Request — 2.0.x (#6)
by Andrew
02:53
created

forNonStringValue()   A

Complexity

Conditions 2
Paths 1

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 10
rs 9.4286
cc 2
eloc 6
nc 1
nop 2
1
<?php
2
/**
3
 * @author     Andrew Coulton <[email protected]>
4
 * @copyright  2015 inGenerator Ltd
5
 * @license    http://kohanaframework.org/license
6
 */
7
8
namespace Ingenerator\KohanaView\Exception;
9
10
11
/**
12
 * Thrown when a TemplateSpecifyingView does not return a valid template name
13
 *
14
 * @package Ingenerator\KohanaView\Exception
15
 */
16
class UnspecifiedTemplateNameException extends \UnexpectedValueException
17
{
18
19
    /**
20
     * @param string $view_class
21
     *
22
     * @return static
23
     */
24
    public static function forEmptyValue($view_class)
25
    {
26
        return new static(
27
            $view_class.'::getTemplateName() must return a template name, empty value returned'
28
        );
29
    }
30
31
    /**
32
     * @param string $view_class
33
     * @param string $template
34
     *
35
     * @return static
36
     */
37
    public static function forNonStringValue($view_class, $template)
38
    {
39
        return new static(
40
            sprintf(
41
                '%s::getTemplateName() must return a string template name, %s value returned',
42
                $view_class,
43
                is_object($template) ? get_class($template) : gettype($template)
44
            )
45
        );
46
    }
47
48
}
49