ConsoleException   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 0
dl 0
loc 23
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A ambientFileDoesNotExist() 0 4 1
A ambientFilesDoesNotReturnAnInstanceOfAValidAmbient() 0 4 1
A directoryIsNotReadable() 0 4 1
A ambientIsNotInstanceOfAmbientInterface() 0 5 2
1
<?php
2
/**
3
 * ShouldPHP
4
 *
5
 * @author  Gabriel Jacinto <[email protected]>
6
 * @status  dev
7
 * @link    https://github.com/GabrielJMJ/ShouldPHP
8
 * @license MIT
9
 */
10
11
namespace Gabrieljmj\Should\Exception;
12
13
use Gabrieljmj\Should\Exception\ExceptionCodes;
14
15
class ConsoleException extends \RuntimeException
16
{
17
    public static function ambientFileDoesNotExist($file)
18
    {
19
        throw new ConsoleException('The file of an ambient was not found: ' . $file, ExceptionCodes::AMBIENT_FILE_DOES_NOT_EXIST);
20
    }
21
22
    public static function ambientFilesDoesNotReturnAnInstanceOfAValidAmbient($file)
23
    {
24
        throw new ConsoleException('The file of an ambient does not return an instance of a valid ambient: ' . $file, ExceptionCodes::AMBIENT_FILE_DOES_NOT_RETURN_A_VALID_AMBIENT_INSTANCE);
25
    }
26
27
    public static function directoryIsNotReadable($dir)
28
    {
29
        throw new ConsoleException('Directory not readable: ' . $dir, ExceptionCodes::DIRECTORY_NOT_READABLE);
30
    }
31
32
    public static function ambientIsNotInstanceOfAmbientInterface($ambient)
33
    {
34
        $ambient = is_object($ambient) ? get_class($ambient) : print_r($ambient, true);
35
        throw new ConsoleException('The ambient class indicated is not a vlid ambient: ' . $ambient, ExceptionCodes::AMBIENT_IS_NOT_VALID);
36
    }
37
}