Completed
Push — 2.0.x ( f85be6...e30486 )
by Andrew
02:32
created

UnspecifiedTemplateNameException   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 0
cbo 0
dl 0
loc 33
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A forEmptyValue() 0 6 1
A forNonStringValue() 0 10 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