Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Next, individual getters Signed-off-by: Davis Peixoto <davis.peixoto@gmail.com>
- Loading branch information
1 parent
e0a1e28
commit b738e4f
Showing
4 changed files
with
232 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
<?php | ||
/** | ||
* Created by PhpStorm. | ||
* User: davis | ||
* Date: 7/23/17 | ||
* Time: 3:12 AM | ||
*/ | ||
|
||
namespace DavisPeixoto\BlogCore\Service; | ||
|
||
|
||
use DavisPeixoto\BlogCore\Interfaces\ServiceInterface; | ||
use DavisPeixoto\BlogCore\Repository\AuthorRepository; | ||
use Psr\Log\LoggerInterface; | ||
use Exception; | ||
use stdClass; | ||
|
||
/** | ||
* Class ListAuthors | ||
* @package DavisPeixoto\BlogCore\Service | ||
*/ | ||
class ListAuthors implements ServiceInterface | ||
{ | ||
/** | ||
* @var AuthorRepository | ||
*/ | ||
private $authorRepository; | ||
|
||
/** | ||
* @var array | ||
*/ | ||
private $filters; | ||
|
||
/** | ||
* @var LoggerInterface | ||
*/ | ||
private $logger; | ||
|
||
/** | ||
* ListAuthors constructor. | ||
* @param AuthorRepository $authorRepository | ||
* @param array $filters | ||
* @param LoggerInterface $logger | ||
*/ | ||
public function __construct(AuthorRepository $authorRepository, Array $filters, LoggerInterface $logger) | ||
{ | ||
$this->authorRepository = $authorRepository; | ||
$this->filters = $filters; | ||
$this->logger = $logger; | ||
} | ||
|
||
/** | ||
* @return array|stdClass[] | ||
*/ | ||
public function run(): array | ||
{ | ||
try { | ||
return $this->authorRepository->getList($this->filters); | ||
} catch (Exception $e) { | ||
$this->logger->error($e->getMessage()); | ||
} | ||
|
||
return []; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
<?php | ||
/** | ||
* Created by PhpStorm. | ||
* User: davis | ||
* Date: 7/23/17 | ||
* Time: 3:12 AM | ||
*/ | ||
|
||
namespace DavisPeixoto\BlogCore\Service; | ||
|
||
|
||
use DavisPeixoto\BlogCore\Interfaces\ServiceInterface; | ||
use DavisPeixoto\BlogCore\Repository\TrailRepository; | ||
use Psr\Log\LoggerInterface; | ||
use Exception; | ||
use stdClass; | ||
|
||
/** | ||
* Class ListTrails | ||
* @package DavisPeixoto\BlogCore\Service | ||
*/ | ||
class ListTrails implements ServiceInterface | ||
{ | ||
/** | ||
* @var TrailRepository | ||
*/ | ||
private $trailRepository; | ||
|
||
/** | ||
* @var array | ||
*/ | ||
private $filters; | ||
|
||
/** | ||
* @var LoggerInterface | ||
*/ | ||
private $logger; | ||
|
||
/** | ||
* ListTrails constructor. | ||
* @param TrailRepository $trailRepository | ||
* @param array $filters | ||
* @param LoggerInterface $logger | ||
*/ | ||
public function __construct(TrailRepository $trailRepository, Array $filters, LoggerInterface $logger) | ||
{ | ||
$this->trailRepository = $trailRepository; | ||
$this->filters = $filters; | ||
$this->logger = $logger; | ||
} | ||
|
||
/** | ||
* @return array|stdClass[] | ||
*/ | ||
public function run(): array | ||
{ | ||
try { | ||
return $this->trailRepository->getList($this->filters); | ||
} catch (Exception $e) { | ||
$this->logger->error($e->getMessage()); | ||
} | ||
|
||
return []; | ||
} | ||
} |