GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — dev ( 37e84b...c7bcbf )
by Андрей
06:51
created

Entry   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 34
Duplicated Lines 11.76 %

Coupling/Cohesion

Components 0
Dependencies 8

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 6
c 1
b 0
f 0
lcom 0
cbo 8
dl 4
loc 34
ccs 0
cts 17
cp 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B completeEntry() 4 20 6

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
 * @link https://github.com/old-town/old-town-workflow
4
 * @author  Malofeykin Andrey  <[email protected]>
5
 */
6
namespace OldTown\Workflow\Engine;
7
8
use OldTown\Workflow\Exception\InternalWorkflowException;
9
use OldTown\Workflow\Exception\InvalidArgumentException;
10
use OldTown\Workflow\Loader\ActionDescriptor;
11
use Traversable;
12
use DateTime;
13
14
/**
15
 * Class Entry
16
 *
17
 * @package OldTown\Workflow\Engine
18
 */
19
class Entry extends AbstractEngine implements EntryInterface
20
{
21
    /**
22
     * @param ActionDescriptor $action
23
     * @param                  $id
24
     * @param array|Traversable $currentSteps
25
     * @param                  $state
26
     *
27
     * @return void
28
     *
29
     * @throws InvalidArgumentException
30
     * @throws InternalWorkflowException
31
     */
32
    public function completeEntry(ActionDescriptor $action = null, $id, $currentSteps, $state)
33
    {
34 View Code Duplication
        if (!is_array($currentSteps) && !$currentSteps  instanceof Traversable) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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...
35
            $errMsg = 'Invalid currentSteps';
36
            throw new InvalidArgumentException($errMsg);
37
        }
38
39
        $workflowManager = $this->getWorkflowManager();
40
        $context = $workflowManager->getContext();
41
42
        $store = $workflowManager->getConfiguration()->getWorkflowStore();
43
        $store->setEntryState($id, $state);
44
45
        $oldStatus = null !== $action ? $action->getUnconditionalResult()->getOldStatus() : 'Finished';
46
        $actionIdValue = null !== $action ? $action->getId() : -1;
47
        foreach ($currentSteps as $step) {
48
            $store->markFinished($step, $actionIdValue, new DateTime(), $oldStatus, $context->getCaller());
49
            $store->moveToHistory($step);
50
        }
51
    }
52
}
53