Completed
Push — master ( 9aea2e...2f8383 )
by Nastasia
02:07
created

ArrayWeMap   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 58
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

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

7 Methods

Rating   Name   Duplication   Size   Complexity  
A getName() 4 4 1
A getDescription() 4 4 1
A getArgs() 4 4 1
A getType() 4 4 1
A getRequiredFunctions() 4 4 1
A getBannedFunctions() 4 4 1
A configure() 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 PhpSchool\CallableFunctions\Exercise;
4
5
use PhpSchool\PhpWorkshop\Check\FunctionRequirementsCheck;
6
use PhpSchool\PhpWorkshop\Exercise\AbstractExercise;
7
use PhpSchool\PhpWorkshop\Exercise\CliExercise;
8
use PhpSchool\PhpWorkshop\Exercise\ExerciseInterface;
9
use PhpSchool\PhpWorkshop\Exercise\ExerciseType;
10
use PhpSchool\PhpWorkshop\ExerciseCheck\FunctionRequirementsExerciseCheck;
11
use PhpSchool\PhpWorkshop\ExerciseCheck\StdOutExerciseCheck;
12
use PhpSchool\PhpWorkshop\ExerciseDispatcher;
13
14
/**
15
 * Class ArrayWeMap
16
 * @package PhpSchool\CallableFunctions\Exercise
17
 */
18 View Code Duplication
class ArrayWeMap extends AbstractExercise implements ExerciseInterface, CliExercise, FunctionRequirementsExerciseCheck
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
19
{
20
    /**
21
     * @return string
22
     */
23
    public function getName()
24
    {
25
        return 'Array we map!';
26
    }
27
28
    /**
29
     * @return string
30
     */
31
    public function getDescription()
32
    {
33
        return 'Exercice with array map';
34
    }
35
36
    /**
37
     * @return array
38
     */
39
    public function getArgs()
40
    {
41
        return ['Sarra', 'Helen', 'Anas'];
42
    }
43
44
    /**
45
     * @return ExerciseType
46
     */
47
    public function getType()
48
    {
49
        return ExerciseType::CLI();
50
    }
51
52
    /**
53
     * @return string[]
54
     */
55
    public function getRequiredFunctions()
56
    {
57
        return ['array_map'];
58
    }
59
60
    /**
61
     * @return string[]
62
     */
63
    public function getBannedFunctions()
64
    {
65
        return [];
66
    }
67
68
    /**
69
     * @param ExerciseDispatcher $dispatcher
70
     */
71
    public function configure(ExerciseDispatcher $dispatcher)
72
    {
73
        $dispatcher->requireCheck(FunctionRequirementsCheck::class, $dispatcher::CHECK_AFTER);
74
    }
75
}
76