Passed
Push — master ( 46cb80...c9437b )
by Mauro
02:03
created

BaseTask   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 100 %

Coupling/Cohesion

Components 2
Dependencies 4

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 2
cbo 4
dl 29
loc 29
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 5 5 1
A getTaskService() 6 6 1
A getInput() 4 4 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
namespace App\Controller\Task;
4
5
use App\Controller\BaseController;
6
use App\Service\TaskService;
7
use Slim\Container;
8
9
/**
10
 * Base Task Controller.
11
 */
12 View Code Duplication
abstract class BaseTask extends BaseController
13
{
14
    /**
15
     * @param Container $container
16
     */
17
    public function __construct(Container $container)
18
    {
19
        $this->logger = $container->get('logger');
20
        $this->database = $container->get('db');
21
    }
22
23
    /**
24
     * @return TaskService
25
     */
26
    protected function getTaskService()
27
    {
28
        $service = new TaskService($this->database);
29
30
        return $service;
31
    }
32
33
    /**
34
     * @return array
35
     */
36
    protected function getInput()
37
    {
38
        return $this->request->getParsedBody();
39
    }
40
}
41