@@ -14,39 +14,39 @@ |
||
14 | 14 | { |
15 | 15 | |
16 | 16 | |
17 | - /** |
|
18 | - * ExceptionLogger constructor. |
|
19 | - * |
|
20 | - * @param \Exception $exception |
|
21 | - */ |
|
22 | - public function __construct(\Exception $exception) |
|
23 | - { |
|
24 | - $this->log($exception); |
|
25 | - } |
|
17 | + /** |
|
18 | + * ExceptionLogger constructor. |
|
19 | + * |
|
20 | + * @param \Exception $exception |
|
21 | + */ |
|
22 | + public function __construct(\Exception $exception) |
|
23 | + { |
|
24 | + $this->log($exception); |
|
25 | + } |
|
26 | 26 | |
27 | 27 | |
28 | - /** |
|
29 | - * write exception details to log file |
|
30 | - * |
|
31 | - * @param \Exception $exception |
|
32 | - * @param int $time |
|
33 | - */ |
|
34 | - public function log(\Exception $exception, $time = 0) |
|
35 | - { |
|
36 | - if (! $time) { |
|
37 | - $time = time(); |
|
38 | - } |
|
39 | - $exception_log = '----------------------------------------------------------------------------------------'; |
|
40 | - $exception_log .= PHP_EOL; |
|
41 | - $exception_log .= '[' . date('Y-m-d H:i:s', $time) . '] Exception Details' . PHP_EOL; |
|
42 | - $exception_log .= 'Message: ' . $exception->getMessage() . PHP_EOL; |
|
43 | - $exception_log .= 'Code: ' . $exception->getCode() . PHP_EOL; |
|
44 | - $exception_log .= 'File: ' . $exception->getFile() . PHP_EOL; |
|
45 | - $exception_log .= 'Line No: ' . $exception->getLine() . PHP_EOL; |
|
46 | - $exception_log .= 'Stack trace: ' . PHP_EOL; |
|
47 | - $exception_log .= $exception->getTraceAsString() . PHP_EOL; |
|
48 | - $exception_log .= '----------------------------------------------------------------------------------------'; |
|
49 | - $exception_log .= PHP_EOL; |
|
50 | - error_log($exception_log); |
|
51 | - } |
|
28 | + /** |
|
29 | + * write exception details to log file |
|
30 | + * |
|
31 | + * @param \Exception $exception |
|
32 | + * @param int $time |
|
33 | + */ |
|
34 | + public function log(\Exception $exception, $time = 0) |
|
35 | + { |
|
36 | + if (! $time) { |
|
37 | + $time = time(); |
|
38 | + } |
|
39 | + $exception_log = '----------------------------------------------------------------------------------------'; |
|
40 | + $exception_log .= PHP_EOL; |
|
41 | + $exception_log .= '[' . date('Y-m-d H:i:s', $time) . '] Exception Details' . PHP_EOL; |
|
42 | + $exception_log .= 'Message: ' . $exception->getMessage() . PHP_EOL; |
|
43 | + $exception_log .= 'Code: ' . $exception->getCode() . PHP_EOL; |
|
44 | + $exception_log .= 'File: ' . $exception->getFile() . PHP_EOL; |
|
45 | + $exception_log .= 'Line No: ' . $exception->getLine() . PHP_EOL; |
|
46 | + $exception_log .= 'Stack trace: ' . PHP_EOL; |
|
47 | + $exception_log .= $exception->getTraceAsString() . PHP_EOL; |
|
48 | + $exception_log .= '----------------------------------------------------------------------------------------'; |
|
49 | + $exception_log .= PHP_EOL; |
|
50 | + error_log($exception_log); |
|
51 | + } |
|
52 | 52 | } |
@@ -33,18 +33,18 @@ |
||
33 | 33 | */ |
34 | 34 | public function log(\Exception $exception, $time = 0) |
35 | 35 | { |
36 | - if (! $time) { |
|
36 | + if ( ! $time) { |
|
37 | 37 | $time = time(); |
38 | 38 | } |
39 | 39 | $exception_log = '----------------------------------------------------------------------------------------'; |
40 | 40 | $exception_log .= PHP_EOL; |
41 | - $exception_log .= '[' . date('Y-m-d H:i:s', $time) . '] Exception Details' . PHP_EOL; |
|
42 | - $exception_log .= 'Message: ' . $exception->getMessage() . PHP_EOL; |
|
43 | - $exception_log .= 'Code: ' . $exception->getCode() . PHP_EOL; |
|
44 | - $exception_log .= 'File: ' . $exception->getFile() . PHP_EOL; |
|
45 | - $exception_log .= 'Line No: ' . $exception->getLine() . PHP_EOL; |
|
46 | - $exception_log .= 'Stack trace: ' . PHP_EOL; |
|
47 | - $exception_log .= $exception->getTraceAsString() . PHP_EOL; |
|
41 | + $exception_log .= '['.date('Y-m-d H:i:s', $time).'] Exception Details'.PHP_EOL; |
|
42 | + $exception_log .= 'Message: '.$exception->getMessage().PHP_EOL; |
|
43 | + $exception_log .= 'Code: '.$exception->getCode().PHP_EOL; |
|
44 | + $exception_log .= 'File: '.$exception->getFile().PHP_EOL; |
|
45 | + $exception_log .= 'Line No: '.$exception->getLine().PHP_EOL; |
|
46 | + $exception_log .= 'Stack trace: '.PHP_EOL; |
|
47 | + $exception_log .= $exception->getTraceAsString().PHP_EOL; |
|
48 | 48 | $exception_log .= '----------------------------------------------------------------------------------------'; |
49 | 49 | $exception_log .= PHP_EOL; |
50 | 50 | error_log($exception_log); |
@@ -15,27 +15,27 @@ |
||
15 | 15 | class InvalidFilePathException extends InvalidArgumentException |
16 | 16 | { |
17 | 17 | |
18 | - /** |
|
19 | - * InvalidClassException constructor. |
|
20 | - * |
|
21 | - * @param string $file_path |
|
22 | - * @param string $message |
|
23 | - * @param int $code |
|
24 | - * @param \Exception $previous |
|
25 | - */ |
|
26 | - public function __construct($file_path, $message = '', $code = 0, \Exception $previous = null) |
|
27 | - { |
|
28 | - if (empty($message)) { |
|
29 | - $message = sprintf( |
|
30 | - __( |
|
31 | - 'The "%1$s" file is either missing or could not be read due to permissions. Please ensure that the following path is correct and verify that the file permissions are correct:%2$s %3$s', |
|
32 | - 'event_espresso' |
|
33 | - ), |
|
34 | - basename($file_path), |
|
35 | - '<br />', |
|
36 | - $file_path |
|
37 | - ); |
|
38 | - } |
|
39 | - parent::__construct($message, $code, $previous); |
|
40 | - } |
|
18 | + /** |
|
19 | + * InvalidClassException constructor. |
|
20 | + * |
|
21 | + * @param string $file_path |
|
22 | + * @param string $message |
|
23 | + * @param int $code |
|
24 | + * @param \Exception $previous |
|
25 | + */ |
|
26 | + public function __construct($file_path, $message = '', $code = 0, \Exception $previous = null) |
|
27 | + { |
|
28 | + if (empty($message)) { |
|
29 | + $message = sprintf( |
|
30 | + __( |
|
31 | + 'The "%1$s" file is either missing or could not be read due to permissions. Please ensure that the following path is correct and verify that the file permissions are correct:%2$s %3$s', |
|
32 | + 'event_espresso' |
|
33 | + ), |
|
34 | + basename($file_path), |
|
35 | + '<br />', |
|
36 | + $file_path |
|
37 | + ); |
|
38 | + } |
|
39 | + parent::__construct($message, $code, $previous); |
|
40 | + } |
|
41 | 41 | } |
@@ -16,46 +16,46 @@ |
||
16 | 16 | class InvalidDataTypeException extends InvalidArgumentException |
17 | 17 | { |
18 | 18 | |
19 | - /** |
|
20 | - * InvalidDataTypeException constructor |
|
21 | - * |
|
22 | - * @param string $var_name name of the variable that was of the wrong type ie: "$my_var" |
|
23 | - * @param mixed $variable the actual variable that was of the wrong data type, ie: $my_var |
|
24 | - * @param string $expected data type we wanted ie: "integer", "string", "array", etc. |
|
25 | - * or an entire rewrite of: "{something something} was expected." |
|
26 | - * @param string $message |
|
27 | - * @param int $code |
|
28 | - * @param Exception $previous |
|
29 | - */ |
|
30 | - public function __construct($var_name, $variable, $expected, $message = '', $code = 0, Exception $previous = null) |
|
31 | - { |
|
32 | - if (empty($message)) { |
|
33 | - $expected = strpos(' was expected.', $expected) === false |
|
34 | - ? $this->addIndefiniteArticle($expected) . ' was expected.' |
|
35 | - : $expected; |
|
36 | - $message = sprintf( |
|
37 | - __( |
|
38 | - 'The supplied data for "%1$s" was %2$s, but %3$s', |
|
39 | - 'event_espresso' |
|
40 | - ), |
|
41 | - $var_name, |
|
42 | - $this->addIndefiniteArticle(gettype($variable)), |
|
43 | - $expected |
|
44 | - ); |
|
45 | - } |
|
46 | - parent::__construct($message, $code, $previous); |
|
47 | - } |
|
19 | + /** |
|
20 | + * InvalidDataTypeException constructor |
|
21 | + * |
|
22 | + * @param string $var_name name of the variable that was of the wrong type ie: "$my_var" |
|
23 | + * @param mixed $variable the actual variable that was of the wrong data type, ie: $my_var |
|
24 | + * @param string $expected data type we wanted ie: "integer", "string", "array", etc. |
|
25 | + * or an entire rewrite of: "{something something} was expected." |
|
26 | + * @param string $message |
|
27 | + * @param int $code |
|
28 | + * @param Exception $previous |
|
29 | + */ |
|
30 | + public function __construct($var_name, $variable, $expected, $message = '', $code = 0, Exception $previous = null) |
|
31 | + { |
|
32 | + if (empty($message)) { |
|
33 | + $expected = strpos(' was expected.', $expected) === false |
|
34 | + ? $this->addIndefiniteArticle($expected) . ' was expected.' |
|
35 | + : $expected; |
|
36 | + $message = sprintf( |
|
37 | + __( |
|
38 | + 'The supplied data for "%1$s" was %2$s, but %3$s', |
|
39 | + 'event_espresso' |
|
40 | + ), |
|
41 | + $var_name, |
|
42 | + $this->addIndefiniteArticle(gettype($variable)), |
|
43 | + $expected |
|
44 | + ); |
|
45 | + } |
|
46 | + parent::__construct($message, $code, $previous); |
|
47 | + } |
|
48 | 48 | |
49 | 49 | |
50 | - /** |
|
51 | - * @param $string |
|
52 | - * @return string |
|
53 | - */ |
|
54 | - protected function addIndefiniteArticle($string) |
|
55 | - { |
|
56 | - if (strtolower($string) === 'null') { |
|
57 | - return $string; |
|
58 | - } |
|
59 | - return (stripos('aeiou', $string[0]) !== false ? 'an ' : 'a ') . $string; |
|
60 | - } |
|
50 | + /** |
|
51 | + * @param $string |
|
52 | + * @return string |
|
53 | + */ |
|
54 | + protected function addIndefiniteArticle($string) |
|
55 | + { |
|
56 | + if (strtolower($string) === 'null') { |
|
57 | + return $string; |
|
58 | + } |
|
59 | + return (stripos('aeiou', $string[0]) !== false ? 'an ' : 'a ') . $string; |
|
60 | + } |
|
61 | 61 | } |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | { |
32 | 32 | if (empty($message)) { |
33 | 33 | $expected = strpos(' was expected.', $expected) === false |
34 | - ? $this->addIndefiniteArticle($expected) . ' was expected.' |
|
34 | + ? $this->addIndefiniteArticle($expected).' was expected.' |
|
35 | 35 | : $expected; |
36 | 36 | $message = sprintf( |
37 | 37 | __( |
@@ -56,6 +56,6 @@ discard block |
||
56 | 56 | if (strtolower($string) === 'null') { |
57 | 57 | return $string; |
58 | 58 | } |
59 | - return (stripos('aeiou', $string[0]) !== false ? 'an ' : 'a ') . $string; |
|
59 | + return (stripos('aeiou', $string[0]) !== false ? 'an ' : 'a ').$string; |
|
60 | 60 | } |
61 | 61 | } |
@@ -16,22 +16,22 @@ |
||
16 | 16 | class InvalidInterfaceException extends DomainException |
17 | 17 | { |
18 | 18 | |
19 | - /** |
|
20 | - * InvalidInterfaceException constructor. |
|
21 | - * |
|
22 | - * @param string $interface_name |
|
23 | - * @param string $message |
|
24 | - * @param int $code |
|
25 | - * @param \Exception $previous |
|
26 | - */ |
|
27 | - public function __construct($interface_name, $message = '', $code = 0, \Exception $previous = null) |
|
28 | - { |
|
29 | - if (empty($message)) { |
|
30 | - $message = sprintf( |
|
31 | - __('The "%1$s" Interface is either missing or invalid.', 'event_espresso'), |
|
32 | - $interface_name |
|
33 | - ); |
|
34 | - } |
|
35 | - parent::__construct($message, $code, $previous); |
|
36 | - } |
|
19 | + /** |
|
20 | + * InvalidInterfaceException constructor. |
|
21 | + * |
|
22 | + * @param string $interface_name |
|
23 | + * @param string $message |
|
24 | + * @param int $code |
|
25 | + * @param \Exception $previous |
|
26 | + */ |
|
27 | + public function __construct($interface_name, $message = '', $code = 0, \Exception $previous = null) |
|
28 | + { |
|
29 | + if (empty($message)) { |
|
30 | + $message = sprintf( |
|
31 | + __('The "%1$s" Interface is either missing or invalid.', 'event_espresso'), |
|
32 | + $interface_name |
|
33 | + ); |
|
34 | + } |
|
35 | + parent::__construct($message, $code, $previous); |
|
36 | + } |
|
37 | 37 | } |
@@ -13,24 +13,24 @@ |
||
13 | 13 | class InsufficientPermissionsException extends \RuntimeException |
14 | 14 | { |
15 | 15 | |
16 | - /** |
|
17 | - * @access public |
|
18 | - * @param string $action |
|
19 | - * @param string $message |
|
20 | - * @param int $code |
|
21 | - * @param \Exception $previous |
|
22 | - */ |
|
23 | - public function __construct($action, $message = '', $code = 0, \Exception $previous = null) |
|
24 | - { |
|
25 | - if (empty($message)) { |
|
26 | - $message = sprintf( |
|
27 | - __( |
|
28 | - 'We\'re sorry, but you do not have the required permissions to perform the following action: %1$s', |
|
29 | - 'event_espresso' |
|
30 | - ), |
|
31 | - ucwords(str_replace('_', ' ', $action)) |
|
32 | - ); |
|
33 | - } |
|
34 | - parent::__construct($message, $code, $previous); |
|
35 | - } |
|
16 | + /** |
|
17 | + * @access public |
|
18 | + * @param string $action |
|
19 | + * @param string $message |
|
20 | + * @param int $code |
|
21 | + * @param \Exception $previous |
|
22 | + */ |
|
23 | + public function __construct($action, $message = '', $code = 0, \Exception $previous = null) |
|
24 | + { |
|
25 | + if (empty($message)) { |
|
26 | + $message = sprintf( |
|
27 | + __( |
|
28 | + 'We\'re sorry, but you do not have the required permissions to perform the following action: %1$s', |
|
29 | + 'event_espresso' |
|
30 | + ), |
|
31 | + ucwords(str_replace('_', ' ', $action)) |
|
32 | + ); |
|
33 | + } |
|
34 | + parent::__construct($message, $code, $previous); |
|
35 | + } |
|
36 | 36 | } |
@@ -12,27 +12,27 @@ |
||
12 | 12 | class UnexpectedEntityException extends \UnexpectedValueException |
13 | 13 | { |
14 | 14 | |
15 | - /** |
|
16 | - * UnexpectedEntityException constructor |
|
17 | - * |
|
18 | - * @param mixed $entity the actual object or variable that was received |
|
19 | - * @param string $expected_class classname of the entity we wanted |
|
20 | - * @param string $message |
|
21 | - * @param int $code |
|
22 | - * @param \Exception $previous |
|
23 | - */ |
|
24 | - public function __construct($entity, $expected_class, $message = '', $code = 0, \Exception $previous = null) |
|
25 | - { |
|
26 | - if (empty($message)) { |
|
27 | - $message = sprintf( |
|
28 | - __( |
|
29 | - 'The retrieved entity is an instance of "%1$s", but an instance of "%2$s" was expected.', |
|
30 | - 'event_espresso' |
|
31 | - ), |
|
32 | - is_object($entity) ? get_class($entity) : gettype($entity), |
|
33 | - $expected_class |
|
34 | - ); |
|
35 | - } |
|
36 | - parent::__construct($message, $code, $previous); |
|
37 | - } |
|
15 | + /** |
|
16 | + * UnexpectedEntityException constructor |
|
17 | + * |
|
18 | + * @param mixed $entity the actual object or variable that was received |
|
19 | + * @param string $expected_class classname of the entity we wanted |
|
20 | + * @param string $message |
|
21 | + * @param int $code |
|
22 | + * @param \Exception $previous |
|
23 | + */ |
|
24 | + public function __construct($entity, $expected_class, $message = '', $code = 0, \Exception $previous = null) |
|
25 | + { |
|
26 | + if (empty($message)) { |
|
27 | + $message = sprintf( |
|
28 | + __( |
|
29 | + 'The retrieved entity is an instance of "%1$s", but an instance of "%2$s" was expected.', |
|
30 | + 'event_espresso' |
|
31 | + ), |
|
32 | + is_object($entity) ? get_class($entity) : gettype($entity), |
|
33 | + $expected_class |
|
34 | + ); |
|
35 | + } |
|
36 | + parent::__construct($message, $code, $previous); |
|
37 | + } |
|
38 | 38 | } |
@@ -13,25 +13,25 @@ |
||
13 | 13 | { |
14 | 14 | |
15 | 15 | |
16 | - /** |
|
17 | - * EntityConstructionException constructor |
|
18 | - * |
|
19 | - * @param string $entity_class class name of the entity being constructed |
|
20 | - * @param string $message |
|
21 | - * @param int $code |
|
22 | - * @param \Exception $previous |
|
23 | - */ |
|
24 | - public function __construct($entity_class, $message = '', $code = 0, \Exception $previous = null) |
|
25 | - { |
|
26 | - if (empty($message)) { |
|
27 | - $message = sprintf( |
|
28 | - __( |
|
29 | - 'The "%1$s" entity could not be instantiated for an unknown reason', |
|
30 | - 'event_espresso' |
|
31 | - ), |
|
32 | - $entity_class |
|
33 | - ); |
|
34 | - } |
|
35 | - parent::__construct($message, $code, $previous); |
|
36 | - } |
|
16 | + /** |
|
17 | + * EntityConstructionException constructor |
|
18 | + * |
|
19 | + * @param string $entity_class class name of the entity being constructed |
|
20 | + * @param string $message |
|
21 | + * @param int $code |
|
22 | + * @param \Exception $previous |
|
23 | + */ |
|
24 | + public function __construct($entity_class, $message = '', $code = 0, \Exception $previous = null) |
|
25 | + { |
|
26 | + if (empty($message)) { |
|
27 | + $message = sprintf( |
|
28 | + __( |
|
29 | + 'The "%1$s" entity could not be instantiated for an unknown reason', |
|
30 | + 'event_espresso' |
|
31 | + ), |
|
32 | + $entity_class |
|
33 | + ); |
|
34 | + } |
|
35 | + parent::__construct($message, $code, $previous); |
|
36 | + } |
|
37 | 37 | } |
@@ -15,26 +15,26 @@ |
||
15 | 15 | abstract class FormatterBase implements FormatterInterface |
16 | 16 | { |
17 | 17 | |
18 | - /** |
|
19 | - * Recursively applies the formatting to all VALUES in this multi-dimensional array |
|
20 | - * |
|
21 | - * @param array $input |
|
22 | - * @return array |
|
23 | - * @throws InvalidDataTypeException if $input is not an array |
|
24 | - */ |
|
25 | - public function formatArray($input) |
|
26 | - { |
|
27 | - if (! is_array($input)) { |
|
28 | - throw new InvalidDataTypeException('input', $input, 'array'); |
|
29 | - } |
|
30 | - // we can use $this inside the closure in PHP 5.3, so pass in a variable pointing to this instead |
|
31 | - $formatter = $this; |
|
32 | - array_walk_recursive( |
|
33 | - $input, |
|
34 | - function (&$value, $key) use ($formatter) { |
|
35 | - $value = $formatter->format($value); |
|
36 | - } |
|
37 | - ); |
|
38 | - return $input; |
|
39 | - } |
|
18 | + /** |
|
19 | + * Recursively applies the formatting to all VALUES in this multi-dimensional array |
|
20 | + * |
|
21 | + * @param array $input |
|
22 | + * @return array |
|
23 | + * @throws InvalidDataTypeException if $input is not an array |
|
24 | + */ |
|
25 | + public function formatArray($input) |
|
26 | + { |
|
27 | + if (! is_array($input)) { |
|
28 | + throw new InvalidDataTypeException('input', $input, 'array'); |
|
29 | + } |
|
30 | + // we can use $this inside the closure in PHP 5.3, so pass in a variable pointing to this instead |
|
31 | + $formatter = $this; |
|
32 | + array_walk_recursive( |
|
33 | + $input, |
|
34 | + function (&$value, $key) use ($formatter) { |
|
35 | + $value = $formatter->format($value); |
|
36 | + } |
|
37 | + ); |
|
38 | + return $input; |
|
39 | + } |
|
40 | 40 | } |
@@ -24,14 +24,14 @@ |
||
24 | 24 | */ |
25 | 25 | public function formatArray($input) |
26 | 26 | { |
27 | - if (! is_array($input)) { |
|
27 | + if ( ! is_array($input)) { |
|
28 | 28 | throw new InvalidDataTypeException('input', $input, 'array'); |
29 | 29 | } |
30 | 30 | // we can use $this inside the closure in PHP 5.3, so pass in a variable pointing to this instead |
31 | 31 | $formatter = $this; |
32 | 32 | array_walk_recursive( |
33 | 33 | $input, |
34 | - function (&$value, $key) use ($formatter) { |
|
34 | + function(&$value, $key) use ($formatter) { |
|
35 | 35 | $value = $formatter->format($value); |
36 | 36 | } |
37 | 37 | ); |
@@ -15,26 +15,26 @@ |
||
15 | 15 | class LeaveAlone extends FormatterBase |
16 | 16 | { |
17 | 17 | |
18 | - /** |
|
19 | - * Removes the emojis from the inputted string |
|
20 | - * |
|
21 | - * @param string|int|float $input anything easily cast into a string |
|
22 | - * @return string |
|
23 | - * @throws InvalidDataTypeException if $input is not a string |
|
24 | - */ |
|
25 | - public function format($input) |
|
26 | - { |
|
27 | - return $input; |
|
28 | - } |
|
18 | + /** |
|
19 | + * Removes the emojis from the inputted string |
|
20 | + * |
|
21 | + * @param string|int|float $input anything easily cast into a string |
|
22 | + * @return string |
|
23 | + * @throws InvalidDataTypeException if $input is not a string |
|
24 | + */ |
|
25 | + public function format($input) |
|
26 | + { |
|
27 | + return $input; |
|
28 | + } |
|
29 | 29 | |
30 | - /** |
|
31 | - * Just returns the inputted $input array |
|
32 | - * |
|
33 | - * @param array $input |
|
34 | - * @return array |
|
35 | - */ |
|
36 | - public function formatArray($input) |
|
37 | - { |
|
38 | - return $input; |
|
39 | - } |
|
30 | + /** |
|
31 | + * Just returns the inputted $input array |
|
32 | + * |
|
33 | + * @param array $input |
|
34 | + * @return array |
|
35 | + */ |
|
36 | + public function formatArray($input) |
|
37 | + { |
|
38 | + return $input; |
|
39 | + } |
|
40 | 40 | } |