make findByName nullable.

This commit is contained in:
James Cole 2018-02-19 19:44:58 +01:00
parent b3fe24b713
commit 6b32213735
No known key found for this signature in database
GPG Key ID: C16961E655E74B5E
2 changed files with 4 additions and 4 deletions

View File

@ -96,9 +96,9 @@ class CategoryRepository implements CategoryRepositoryInterface
* *
* @param string $name * @param string $name
* *
* @return Category * @return Category|null
*/ */
public function findByName(string $name): Category public function findByName(string $name): ?Category
{ {
$categories = $this->user->categories()->get(['categories.*']); $categories = $this->user->categories()->get(['categories.*']);
foreach ($categories as $category) { foreach ($categories as $category) {
@ -107,7 +107,7 @@ class CategoryRepository implements CategoryRepositoryInterface
} }
} }
return new Category; return null;
} }
/** /**

View File

@ -74,7 +74,7 @@ interface CategoryRepositoryInterface
* *
* @return Category * @return Category
*/ */
public function findByName(string $name): Category; public function findByName(string $name): ?Category;
/** /**
* @param Category $category * @param Category $category