Skip to content

Commit a128ebc

Browse files
committed
Exceptions changed
1 parent 8ef1a82 commit a128ebc

File tree

7 files changed

+10
-19
lines changed

7 files changed

+10
-19
lines changed

src/EntityTrait.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33

44
namespace Selami\Entity;
55

6+
use Selami\Entity\Exception\InvalidArgumentException;
67
use stdClass;
78
use Selami\Entity\Interfaces\EntityInterface;
8-
use Selami\Entity\Exception\UnexpectedValueException;
99

1010
trait EntityTrait
1111
{
@@ -37,7 +37,7 @@ public function __unset($name)
3737
public static function createFromJsonFile(string $filePath, string $id) : EntityInterface
3838
{
3939
if (!file_exists($filePath)) {
40-
throw new UnexpectedValueException(sprintf('Model definition file (%s) does not exist!', $filePath));
40+
throw new InvalidArgumentException(sprintf('Model definition file (%s) does not exist!', $filePath));
4141
}
4242
$json = file_get_contents($filePath);
4343
return static::createFromJson($json, $id);

src/Exception/UnexpectedValueException.php

Lines changed: 0 additions & 9 deletions
This file was deleted.

src/Model.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
use stdClass;
77
use Opis\JsonSchema\Schema;
8-
use Selami\Entity\Exception\UnexpectedValueException;
8+
use Selami\Entity\Exception\InvalidArgumentException;
99

1010
final class Model
1111
{
@@ -41,7 +41,7 @@ public function getSchema(?stdClass $model = null) : Schema
4141
public static function createFromJsonFile(string $filePath) : Model
4242
{
4343
if (!file_exists($filePath)) {
44-
throw new UnexpectedValueException(sprintf('Model definition file (%s) does not exist!', $filePath));
44+
throw new InvalidArgumentException(sprintf('Model definition file (%s) does not exist!', $filePath));
4545
}
4646
return new static(file_get_contents($filePath));
4747
}

src/ValueObjectTrait.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
namespace Selami\Entity;
55

66
use stdClass;
7-
use Selami\Entity\Exception\UnexpectedValueException;
7+
use Selami\Entity\Exception\InvalidArgumentException;
88
use Selami\Entity\Exception\BadMethodCallException;
99
use Selami\Entity\Interfaces\ValueObjectInterface;
1010

@@ -32,7 +32,7 @@ final public function __unset($name)
3232
public static function createFromJsonFile(string $filePath, stdClass $data) : ValueObjectInterface
3333
{
3434
if (!file_exists($filePath)) {
35-
throw new UnexpectedValueException(sprintf('Model definition file (%s) does not exist!', $filePath));
35+
throw new InvalidArgumentException(sprintf('Model definition file (%s) does not exist!', $filePath));
3636
}
3737
$json = file_get_contents($filePath);
3838
return static::createFromJson($json, $data);

tests/unit/EntityTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ public function shouldFailForRequiredInput() : void
111111

112112
/**
113113
* @test
114-
* @expectedException \Selami\Entity\Exception\UnexpectedValueException
114+
* @expectedException \Selami\Entity\Exception\InvalidArgumentException
115115
*/
116116
public function shouldFailForAModelFileDoesNotExist() : void
117117
{

tests/unit/ModelTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22

33
use Selami\Entity\Model;
4-
use Selami\Entity\Exception\UnexpectedValueException;
4+
use Selami\Entity\Exception\InvalidArgumentException;
55

66
class ModelTest extends \Codeception\Test\Unit
77
{
@@ -40,7 +40,7 @@ public function shouldReturnModelObjectSuccessfully() : void
4040

4141
/**
4242
* @test
43-
* @expectedException UnexpectedValueException
43+
* @expectedException InvalidArgumentException
4444
*/
4545
public function shouldFailForAFileThatDoesNotExist() : void
4646
{

tests/unit/ValueObjectTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ public function shouldFailForRequiredInput() : void
135135

136136
/**
137137
* @test
138-
* @expectedException \Selami\Entity\Exception\UnexpectedValueException
138+
* @expectedException \Selami\Entity\Exception\InvalidArgumentException
139139
*/
140140
public function shouldFailForAModelFileDoesNotExist() : void
141141
{

0 commit comments

Comments
 (0)