1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* Copyright (c) 2011-present Mediasift Ltd |
5
|
|
|
* All rights reserved. |
6
|
|
|
* |
7
|
|
|
* Redistribution and use in source and binary forms, with or without |
8
|
|
|
* modification, are permitted provided that the following conditions |
9
|
|
|
* are met: |
10
|
|
|
* |
11
|
|
|
* * Redistributions of source code must retain the above copyright |
12
|
|
|
* notice, this list of conditions and the following disclaimer. |
13
|
|
|
* |
14
|
|
|
* * Redistributions in binary form must reproduce the above copyright |
15
|
|
|
* notice, this list of conditions and the following disclaimer in |
16
|
|
|
* the documentation and/or other materials provided with the |
17
|
|
|
* distribution. |
18
|
|
|
* |
19
|
|
|
* * Neither the names of the copyright holders nor the names of his |
20
|
|
|
* contributors may be used to endorse or promote products derived |
21
|
|
|
* from this software without specific prior written permission. |
22
|
|
|
* |
23
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
24
|
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
25
|
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
26
|
|
|
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE |
27
|
|
|
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
28
|
|
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
29
|
|
|
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
30
|
|
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
31
|
|
|
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
32
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN |
33
|
|
|
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
34
|
|
|
* POSSIBILITY OF SUCH DAMAGE. |
35
|
|
|
* |
36
|
|
|
* @category Libraries |
37
|
|
|
* @package Storyplayer/Modules/Exceptions |
38
|
|
|
* @author Stuart Herbert <[email protected]> |
39
|
|
|
* @copyright 2011-present Mediasift Ltd www.datasift.com |
40
|
|
|
* @license http://www.opensource.org/licenses/bsd-license.php BSD License |
41
|
|
|
* @link http://datasift.github.io/storyplayer |
42
|
|
|
*/ |
43
|
|
|
|
44
|
|
|
namespace Storyplayer\SPv2\Modules; |
45
|
|
|
|
46
|
|
|
use Storyplayer\SPv2\Modules\Exceptions\ActionFailedException; |
47
|
|
|
use Storyplayer\SPv2\Modules\Exceptions\ExpectFailedException; |
48
|
|
|
use Storyplayer\SPv2\Modules\Exceptions\NotImplementedException; |
49
|
|
|
use Storyplayer\SPv2\Modules\Exceptions\ObsoleteModuleException; |
50
|
|
|
use Storyplayer\SPv2\Modules\Exceptions\StoryCannotRunException; |
51
|
|
|
use Storyplayer\SPv2\Modules\Exceptions\StoryShouldFailException; |
52
|
|
|
|
53
|
|
|
class Exceptions |
54
|
|
|
{ |
55
|
|
|
/** |
56
|
|
|
* create a new ActionFailedException |
57
|
|
|
* |
58
|
|
|
* @param string $methodName |
59
|
|
|
* should always be the __METHOD__ constant |
60
|
|
|
* @param string $reason |
61
|
|
|
* why did the action fail? |
62
|
|
|
* @param array $params |
63
|
|
|
* supporting data on why the action failed |
64
|
|
|
* @return ActionFailedException |
65
|
|
|
*/ |
66
|
|
|
public static function newActionFailedException($methodName, $reason = '', $params = []) |
|
|
|
|
67
|
|
|
{ |
68
|
|
|
return new ActionFailedException($methodName); |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* create a new ExpectFailedException |
73
|
|
|
* |
74
|
|
|
* @param string $methodName |
75
|
|
|
* should always be the __METHOD__ constant |
76
|
|
|
* @param string $expected |
77
|
|
|
* an explanation of the result that was expected |
78
|
|
|
* @param string $actual |
79
|
|
|
* an explanation of what the result was |
80
|
|
|
* @return ExpectFailedException |
81
|
|
|
*/ |
82
|
|
|
public static function newExpectFailedException($methodName, $expected, $actual) |
83
|
|
|
{ |
84
|
|
|
return new ExpectFailedException($methodName, $expected, $actual); |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
/** |
88
|
|
|
* create a new NotImplementedException |
89
|
|
|
* |
90
|
|
|
* @param string $methodName |
91
|
|
|
* should be the equivalent of the __METHOD__ constant |
92
|
|
|
* @return NotImplementedException |
93
|
|
|
*/ |
94
|
|
|
public static function newNotImplementedException($methodName) |
95
|
|
|
{ |
96
|
|
|
return new NotImplementedException($methodName); |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
/** |
100
|
|
|
* create a new ObsoleteModuleException |
101
|
|
|
* |
102
|
|
|
* @param string $moduleName |
103
|
|
|
* the name of the module that is now obsolete |
104
|
|
|
* @param string $replacementName |
105
|
|
|
* the name of the module that should be used going forward |
106
|
|
|
* @return ObsoleteModuleException |
107
|
|
|
*/ |
108
|
|
|
public static function newObsoleteModuleException($moduleName, $replacementName) |
109
|
|
|
{ |
110
|
|
|
return new ObsoleteModuleException($moduleName, $replacementName); |
111
|
|
|
} |
112
|
|
|
|
113
|
|
|
/** |
114
|
|
|
* create a new StoryCannotRunException |
115
|
|
|
* |
116
|
|
|
* @param string $reason |
117
|
|
|
* why can't the story run? |
118
|
|
|
* @return StoryCannotRunException |
119
|
|
|
*/ |
120
|
|
|
public static function newStoryCannotRunException($reason) |
121
|
|
|
{ |
122
|
|
|
return new StoryCannotRunException($reason); |
123
|
|
|
} |
124
|
|
|
|
125
|
|
|
/** |
126
|
|
|
* create a new StoryShouldFailException |
127
|
|
|
* |
128
|
|
|
* @return StoryShouldFailException |
129
|
|
|
*/ |
130
|
|
|
public static function newStoryShouldFailException() |
131
|
|
|
{ |
132
|
|
|
return new StoryShouldFailException(); |
133
|
|
|
} |
134
|
|
|
} |
135
|
|
|
|
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.