|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
|
|
4
|
|
|
/** |
|
5
|
|
|
* This file is part of WebHelper Parser. |
|
6
|
|
|
* |
|
7
|
|
|
* (c) James <[email protected]> |
|
8
|
|
|
* |
|
9
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
10
|
|
|
* file that was distributed with this source code. |
|
11
|
|
|
*/ |
|
12
|
|
|
|
|
13
|
|
|
namespace WebHelper\Parser\Exception; |
|
14
|
|
|
|
|
15
|
|
|
use DomainException; |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* Invalid configuration file content. |
|
19
|
|
|
* |
|
20
|
|
|
* @author James <[email protected]> |
|
21
|
|
|
*/ |
|
22
|
|
|
class InvalidConfigException extends DomainException implements ParserExceptionInterface |
|
23
|
|
|
{ |
|
24
|
|
|
/** |
|
25
|
|
|
* the exception to throw if the configuration file results as an empty active config. |
|
26
|
|
|
* |
|
27
|
|
|
* @param string $file file pathname |
|
28
|
|
|
* |
|
29
|
|
|
* @return InvalidConfigException the exception to throw |
|
30
|
|
|
*/ |
|
31
|
2 |
|
public static function forEmptyConfig($file) |
|
32
|
|
|
{ |
|
33
|
2 |
|
return new self(sprintf( |
|
34
|
2 |
|
'File "%s" returns an empty configuration', |
|
35
|
|
|
$file |
|
36
|
2 |
|
), self::EMPTY_CONFIG); |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* the exception to throw if a directive has no ending key. |
|
41
|
|
|
* |
|
42
|
|
|
* @param string $key a directive name |
|
43
|
|
|
* |
|
44
|
|
|
* @return InvalidConfigException the exception to throw |
|
45
|
|
|
*/ |
|
46
|
1 |
|
public static function forEndingKeyNotFound($key) |
|
47
|
|
|
{ |
|
48
|
1 |
|
return new self(sprintf( |
|
49
|
1 |
|
'No ending directive for %s', |
|
50
|
|
|
$key |
|
51
|
1 |
|
), self::BLOCK_DIRECTIVE_ERROR); |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
/** |
|
55
|
|
|
* the exception to throw if a simple directive does not match against the accepted syntax. |
|
56
|
|
|
* |
|
57
|
|
|
* @param string $line the line of the simple directive |
|
58
|
|
|
* |
|
59
|
|
|
* @return InvalidConfigException the exception to throw |
|
60
|
|
|
*/ |
|
61
|
1 |
|
public static function forSimpleDirectiveSyntaxError($line) |
|
62
|
|
|
{ |
|
63
|
1 |
|
return new self(sprintf( |
|
64
|
1 |
|
'Syntax error for the line "%s"', |
|
65
|
|
|
$line |
|
66
|
1 |
|
), self::SIMPLE_DIRECTIVE_ERROR); |
|
67
|
|
|
} |
|
68
|
|
|
} |
|
69
|
|
|
|