Skip to content

Commit

Permalink
Exceptions changed
Browse files Browse the repository at this point in the history
  • Loading branch information
mkorkmaz committed Nov 28, 2018
1 parent 8ef1a82 commit a128ebc
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 19 deletions.
4 changes: 2 additions & 2 deletions src/EntityTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@

namespace Selami\Entity;

use Selami\Entity\Exception\InvalidArgumentException;
use stdClass;
use Selami\Entity\Interfaces\EntityInterface;
use Selami\Entity\Exception\UnexpectedValueException;

trait EntityTrait
{
Expand Down Expand Up @@ -37,7 +37,7 @@ public function __unset($name)
public static function createFromJsonFile(string $filePath, string $id) : EntityInterface
{
if (!file_exists($filePath)) {
throw new UnexpectedValueException(sprintf('Model definition file (%s) does not exist!', $filePath));
throw new InvalidArgumentException(sprintf('Model definition file (%s) does not exist!', $filePath));
}
$json = file_get_contents($filePath);
return static::createFromJson($json, $id);
Expand Down
9 changes: 0 additions & 9 deletions src/Exception/UnexpectedValueException.php

This file was deleted.

4 changes: 2 additions & 2 deletions src/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

use stdClass;
use Opis\JsonSchema\Schema;
use Selami\Entity\Exception\UnexpectedValueException;
use Selami\Entity\Exception\InvalidArgumentException;

final class Model
{
Expand Down Expand Up @@ -41,7 +41,7 @@ public function getSchema(?stdClass $model = null) : Schema
public static function createFromJsonFile(string $filePath) : Model
{
if (!file_exists($filePath)) {
throw new UnexpectedValueException(sprintf('Model definition file (%s) does not exist!', $filePath));
throw new InvalidArgumentException(sprintf('Model definition file (%s) does not exist!', $filePath));
}
return new static(file_get_contents($filePath));
}
Expand Down
4 changes: 2 additions & 2 deletions src/ValueObjectTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
namespace Selami\Entity;

use stdClass;
use Selami\Entity\Exception\UnexpectedValueException;
use Selami\Entity\Exception\InvalidArgumentException;
use Selami\Entity\Exception\BadMethodCallException;
use Selami\Entity\Interfaces\ValueObjectInterface;

Expand Down Expand Up @@ -32,7 +32,7 @@ final public function __unset($name)
public static function createFromJsonFile(string $filePath, stdClass $data) : ValueObjectInterface
{
if (!file_exists($filePath)) {
throw new UnexpectedValueException(sprintf('Model definition file (%s) does not exist!', $filePath));
throw new InvalidArgumentException(sprintf('Model definition file (%s) does not exist!', $filePath));
}
$json = file_get_contents($filePath);
return static::createFromJson($json, $data);
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/EntityTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public function shouldFailForRequiredInput() : void

/**
* @test
* @expectedException \Selami\Entity\Exception\UnexpectedValueException
* @expectedException \Selami\Entity\Exception\InvalidArgumentException
*/
public function shouldFailForAModelFileDoesNotExist() : void
{
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/ModelTest.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

use Selami\Entity\Model;
use Selami\Entity\Exception\UnexpectedValueException;
use Selami\Entity\Exception\InvalidArgumentException;

class ModelTest extends \Codeception\Test\Unit
{
Expand Down Expand Up @@ -40,7 +40,7 @@ public function shouldReturnModelObjectSuccessfully() : void

/**
* @test
* @expectedException UnexpectedValueException
* @expectedException InvalidArgumentException
*/
public function shouldFailForAFileThatDoesNotExist() : void
{
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/ValueObjectTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public function shouldFailForRequiredInput() : void

/**
* @test
* @expectedException \Selami\Entity\Exception\UnexpectedValueException
* @expectedException \Selami\Entity\Exception\InvalidArgumentException
*/
public function shouldFailForAModelFileDoesNotExist() : void
{
Expand Down

0 comments on commit a128ebc

Please sign in to comment.