Skip to content

Commit

Permalink
Do not wrap exception message in array (#141)
Browse files Browse the repository at this point in the history
  • Loading branch information
mvorisek authored Mar 15, 2020
1 parent 7aa0260 commit b89f97e
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/StaticAddToTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ trait StaticAddToTrait
public static function addTo(object $parent, $seed = [], array $add_args = [])
{
if (func_num_args() > 3) { // prevent bad usage
throw new \Error(['Too many method arguments']);
throw new \Error('Too many method arguments');
}

if (is_object($seed)) {
$object = $seed;
} else {
if (!is_array($seed)) {
if (!is_scalar($seed)) { // allow single element seed but prevent bad usage
throw (new Exception(['Seed must be an array or a scalar']))
throw (new Exception('Seed must be an array or a scalar'))
->addMoreInfo('seed_type', gettype($seed));
}

Expand All @@ -62,7 +62,7 @@ private static function _addTo_add(object $parent, object $object, bool $unsafe,
{
// check if object is instance of this class
if (!$unsafe && !($object instanceof static)) {
throw (new Exception(['Seed class name is not a subtype of the current class']))
throw (new Exception('Seed class name is not a subtype of the current class'))
->addMoreInfo('seed_class', get_class($object))
->addMoreInfo('current_class', static::class);
}
Expand All @@ -83,7 +83,7 @@ private static function _addTo_add(object $parent, object $object, bool $unsafe,
public static function addToWithClassName(object $parent, $seed = [], array $add_args = [])
{
if (func_num_args() > 3) { // prevent bad usage
throw new \Error(['Too many method arguments']);
throw new \Error('Too many method arguments');
}

return static::_addToWithClassName($parent, $seed, false, $add_args);
Expand All @@ -99,7 +99,7 @@ public static function addToWithClassName(object $parent, $seed = [], array $add
public static function addToWithClassNameUnsafe(object $parent, $seed = [], array $add_args = [])
{
if (func_num_args() > 3) { // prevent bad usage
throw new \Error(['Too many method arguments']);
throw new \Error('Too many method arguments');
}

return static::_addToWithClassName($parent, $seed, true, $add_args);
Expand All @@ -115,7 +115,7 @@ private static function _addToWithClassName(object $parent, $seed, bool $unsafe,
} else {
if (!is_array($seed)) {
if (!is_scalar($seed)) { // allow single element seed but prevent bad usage
throw (new Exception(['Seed must be an array or a scalar']))
throw (new Exception('Seed must be an array or a scalar'))
->addMoreInfo('seed_type', gettype($seed));
}

Expand Down

0 comments on commit b89f97e

Please sign in to comment.