Skip to content

Commit bf646e5

Browse files
committed
Throw exception if we cannot create an object with the data providerd
1 parent 2872a35 commit bf646e5

File tree

4 files changed

+5
-5
lines changed

4 files changed

+5
-5
lines changed

Model/Category.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class Category
4949
public function __construct(array $data)
5050
{
5151
if (empty($data)) {
52-
return;
52+
throw new \InvalidArgumentException('You must provide an array with data.');
5353
}
5454

5555
$this->id = $data['id'];

Model/Media.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ class Media
2828

2929
public function __construct(array $data = [])
3030
{
31-
if (empty($data)) {
32-
return;
31+
if (empty($data) || empty($data['source_url'])) {
32+
throw new \InvalidArgumentException('You must provide an array with data.');
3333
}
3434

3535
$this->id = $data['id'];

Model/MenuItem.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class MenuItem
2424
public function __construct(array $data = [])
2525
{
2626
if (empty($data)) {
27-
return;
27+
throw new \InvalidArgumentException('You must provide an array with data.');
2828
}
2929

3030
$this->id = (int) $data['id'];

Model/Page.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class Page
5252
public function __construct(array $data = [])
5353
{
5454
if (empty($data)) {
55-
return;
55+
throw new \InvalidArgumentException('You must provide an array with data.');
5656
}
5757

5858
// Set dates

0 commit comments

Comments
 (0)