aboutsummaryrefslogtreecommitdiffhomepage
path: root/api/Users/Services/UserService.php
diff options
context:
space:
mode:
authorMarvin Borner2018-10-30 18:41:29 +0100
committerMarvin Borner2018-10-30 18:41:29 +0100
commit39aa8530424310663c888f9e02224158961532e3 (patch)
tree4b825dc642cb6eb9a060e54bf8d69288fbee4904 /api/Users/Services/UserService.php
parentbd568608bcda0729044e823aedfa799e10692e14 (diff)
PHP is crap
Diffstat (limited to 'api/Users/Services/UserService.php')
-rw-r--r--api/Users/Services/UserService.php88
1 files changed, 0 insertions, 88 deletions
diff --git a/api/Users/Services/UserService.php b/api/Users/Services/UserService.php
deleted file mode 100644
index 923acd0..0000000
--- a/api/Users/Services/UserService.php
+++ /dev/null
@@ -1,88 +0,0 @@
-<?php
-
-namespace Api\Users\Services;
-
-use Exception;
-use Illuminate\Auth\AuthManager;
-use Illuminate\Database\DatabaseManager;
-use Illuminate\Events\Dispatcher;
-use Api\Users\Exceptions\UserNotFoundException;
-use Api\Users\Events\UserWasCreated;
-use Api\Users\Events\UserWasDeleted;
-use Api\Users\Events\UserWasUpdated;
-use Api\Users\Repositories\UserRepository;
-
-class UserService
-{
- private $auth;
-
- private $database;
-
- private $dispatcher;
-
- private $userRepository;
-
- public function __construct(
- AuthManager $auth,
- DatabaseManager $database,
- Dispatcher $dispatcher,
- UserRepository $userRepository
- ) {
- $this->auth = $auth;
- $this->database = $database;
- $this->dispatcher = $dispatcher;
- $this->userRepository = $userRepository;
- }
-
- public function getAll($options = [])
- {
- return $this->userRepository->get($options);
- }
-
- public function getById($userId, array $options = [])
- {
- $user = $this->getRequestedUser($userId);
-
- return $user;
- }
-
- public function create($data)
- {
- $user = $this->userRepository->create($data);
-
- $this->dispatcher->fire(new UserWasCreated($user));
-
- return $user;
- }
-
- public function update($userId, array $data)
- {
- $user = $this->getRequestedUser($userId);
-
- $this->userRepository->update($user, $data);
-
- $this->dispatcher->fire(new UserWasUpdated($user));
-
- return $user;
- }
-
- public function delete($userId)
- {
- $user = $this->getRequestedUser($userId);
-
- $this->userRepository->delete($userId);
-
- $this->dispatcher->fire(new UserWasDeleted($user));
- }
-
- private function getRequestedUser($userId)
- {
- $user = $this->userRepository->getById($userId);
-
- if (is_null($user)) {
- throw new UserNotFoundException();
- }
-
- return $user;
- }
-}