1 | <?php |
||
11 | class TaskService extends BaseService |
||
12 | { |
||
13 | /** |
||
14 | * @param TaskRepository $taskRepository |
||
15 | */ |
||
16 | public function __construct(TaskRepository $taskRepository) |
||
20 | |||
21 | /** |
||
22 | * @return TaskRepository |
||
23 | */ |
||
24 | protected function getTaskRepository() |
||
28 | |||
29 | /** |
||
30 | * Check if the task exists. |
||
31 | * |
||
32 | * @param int $taskId |
||
33 | * @return object |
||
34 | */ |
||
35 | protected function checkTask($taskId) |
||
41 | |||
42 | /** |
||
43 | * Get all tasks. |
||
44 | * |
||
45 | * @return array |
||
46 | */ |
||
47 | public function getTasks() |
||
53 | |||
54 | /** |
||
55 | * Get one task by id. |
||
56 | * |
||
57 | * @param int $taskId |
||
58 | * @return object |
||
59 | */ |
||
60 | public function getTask($taskId) |
||
66 | |||
67 | /** |
||
68 | * Search tasks by name. |
||
69 | * |
||
70 | * @param string $tasksName |
||
71 | * @return array |
||
72 | */ |
||
73 | public function searchTasks($tasksName) |
||
79 | |||
80 | /** |
||
81 | * Create a task. |
||
82 | * |
||
83 | * @param array|object|null $input |
||
84 | * @return object |
||
85 | */ |
||
86 | public function createTask($input) |
||
93 | |||
94 | /** |
||
95 | * Update a task. |
||
96 | * |
||
97 | * @param array|object|null $input |
||
98 | * @param int $taskId |
||
99 | * @return object |
||
100 | */ |
||
101 | public function updateTask($input, $taskId) |
||
109 | |||
110 | /** |
||
111 | * Delete a task. |
||
112 | * |
||
113 | * @param int $taskId |
||
114 | * @return string |
||
115 | */ |
||
116 | public function deleteTask($taskId) |
||
123 | } |
||
124 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: