EntryManager::createEntry()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 8

Duplication

Lines 11
Ratio 100 %

Importance

Changes 0
Metric Value
dl 11
loc 11
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 8
nc 1
nop 2
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