Skip to content

Commit

Permalink
Add InvalidArgumentException & Exception
Browse files Browse the repository at this point in the history
  • Loading branch information
loic425 committed Apr 11, 2024
1 parent b96ee2b commit cc473c0
Show file tree
Hide file tree
Showing 8 changed files with 54 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
namespace spec\Sylius\Component\Resource\Exception;

use PhpSpec\ObjectBehavior;
use Sylius\Resource\Exception\ExceptionInterface;
use Sylius\Resource\Exception\RuntimeException;

final class DeleteHandlingExceptionSpec extends ObjectBehavior
{
Expand All @@ -22,6 +24,16 @@ function it_extends_an_exception(): void
$this->shouldHaveType(\Exception::class);
}

function it_is_a_runtime_exception(): void
{
$this->shouldHaveType(RuntimeException::class);
}

function it_implements_exception_interface(): void
{
$this->shouldImplement(ExceptionInterface::class);
}

function it_has_a_message(): void
{
$this->getMessage()->shouldReturn('Ups, something went wrong during deleting a resource, please try again.');
Expand Down
2 changes: 1 addition & 1 deletion src/Component/src/Exception/DeleteHandlingException.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

namespace Sylius\Resource\Exception;

class DeleteHandlingException extends \Exception
class DeleteHandlingException extends RuntimeException
{
protected string $flash;

Expand Down
18 changes: 18 additions & 0 deletions src/Component/src/Exception/Exception.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

/*
* This file is part of the Sylius package.
*
* (c) Sylius Sp. z o.o.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

declare(strict_types=1);

namespace Sylius\Resource\Exception;

class Exception extends \Exception implements ExceptionInterface
{
}
18 changes: 18 additions & 0 deletions src/Component/src/Exception/InvalidArgumentException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

/*
* This file is part of the Sylius package.
*
* (c) Sylius Sp. z o.o.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

declare(strict_types=1);

namespace Sylius\Resource\Exception;

class InvalidArgumentException extends \InvalidArgumentException implements ExceptionInterface
{
}
4 changes: 2 additions & 2 deletions src/Component/src/Exception/UnexpectedTypeException.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

namespace Sylius\Resource\Exception;

class UnexpectedTypeException extends \InvalidArgumentException
class UnexpectedTypeException extends InvalidArgumentException
{
/**
* @param mixed $value
Expand All @@ -23,7 +23,7 @@ public function __construct($value, string $expectedType)
parent::__construct(sprintf(
'Expected argument of type "%s", "%s" given.',
$expectedType,
is_object($value) ? get_class($value) : gettype($value),
get_debug_type($value),
));
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Component/src/Exception/UnsupportedMethodException.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

namespace Sylius\Resource\Exception;

class UnsupportedMethodException extends \Exception
class UnsupportedMethodException extends Exception
{
public function __construct(string $methodName)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Component/src/Exception/UpdateHandlingException.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

namespace Sylius\Resource\Exception;

class UpdateHandlingException extends \Exception
class UpdateHandlingException extends Exception
{
protected string $flash;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

namespace Sylius\Resource\Exception;

final class VariantWithNoOptionsValuesException extends \Exception
final class VariantWithNoOptionsValuesException extends Exception
{
public function __construct()
{
Expand Down

0 comments on commit cc473c0

Please sign in to comment.