EntryManager   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 39
Duplicated Lines 58.97 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 1
dl 23
loc 39
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A createEntry() 11 11 1
A updateEntry() 12 12 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 Hechoenlaravel\JarvisFoundation\Traits;
4
5
/**
6
 * Trait EntryManager
7
 * Use this trait to manage entries for the entities
8
 * @author Jose Luis Fonseca <[email protected]>
9
 * @package Hechoenlaravel\JarvisFoundation\Traits
10
 */
11
trait EntryManager
12
{
13
    use DispatchesCommands;
14
15
    /**
16
     * @param $entityId
17
     * @param array $input
18
     * @return mixed
19
     */
20 View Code Duplication
    public function createEntry($entityId, array $input = [])
0 ignored issues
show
Duplication introduced by
This method 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...
21
    {
22
        $input['entity'] = $entityId;
23
        return $this->execute('Hechoenlaravel\JarvisFoundation\Entries\CreateEntryCommand',
24
            'Hechoenlaravel\JarvisFoundation\Entries\Handler\CreateEntryCommandHandler', $input, [
25
                'Hechoenlaravel\JarvisFoundation\Entries\Middleware\SetEntity',
26
                'Hechoenlaravel\JarvisFoundation\Entries\Middleware\ValidateEntryData',
27
                'Hechoenlaravel\JarvisFoundation\Entries\Middleware\FilterFieldFromInput',
28
                'Hechoenlaravel\JarvisFoundation\Entries\Middleware\RunPreSaveEvent'
29
            ]);
30
    }
31
32
    /**
33
     * @param $entityId
34
     * @param array $input
35
     * @return mixed
36
     */
37 View Code Duplication
    public function updateEntry($entityId, $entryId, array $input = [])
0 ignored issues
show
Duplication introduced by
This method 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...
38
    {
39
        $input['entity'] = $entityId;
40
        $input['entry_id'] = $entryId;
41
        return $this->execute('Hechoenlaravel\JarvisFoundation\Entries\UpdateEntryCommand',
42
            'Hechoenlaravel\JarvisFoundation\Entries\Handler\UpdateEntryCommandHandler', $input, [
43
                'Hechoenlaravel\JarvisFoundation\Entries\Middleware\SetEntity',
44
                'Hechoenlaravel\JarvisFoundation\Entries\Middleware\ValidateEntryData',
45
                'Hechoenlaravel\JarvisFoundation\Entries\Middleware\FilterFieldFromInput',
46
                'Hechoenlaravel\JarvisFoundation\Entries\Middleware\RunPreSaveEvent'
47
            ]);
48
    }
49
}
50