Completed
Push — develop ( c5e17b...b595d4 )
by Nate
04:27
created

DissociateUserFromOrganization   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 4
dl 0
loc 38
ccs 0
cts 19
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A run() 0 17 3
A performAction() 0 4 1
1
<?php
2
3
/**
4
 * @copyright  Copyright (c) Flipbox Digital Limited
5
 * @license    https://flipboxfactory.com/software/organization/license
6
 * @link       https://www.flipboxfactory.com/software/organization/
7
 */
8
9
namespace flipbox\organizations\actions\organizations;
10
11
use flipbox\craft\ember\actions\records\DeleteRecordTrait;
12
use flipbox\organizations\records\UserAssociation;
13
use yii\base\Action;
14
use yii\web\HttpException;
15
16
/**
17
 * @author Flipbox Factory <[email protected]>
18
 * @since 3.0.0
19
 */
20
class DissociateUserFromOrganization extends Action
21
{
22
    use DeleteRecordTrait, LookupAssociationTrait;
23
24
    /**
25
     * @param string $user
26
     * @param string $organization
27
     * @return null|\yii\base\Model|\yii\web\Response
28
     * @throws HttpException
29
     */
30
    public function run(
31
        string $user,
32
        string $organization
33
    )
34
    {
35
        if (null === ($user = $this->findUser($user))) {
36
            return $this->handleNotFoundResponse();
37
        }
38
39
        if (null === ($organization = $this->findOrganization($organization))) {
40
            return $this->handleNotFoundResponse();
41
        }
42
43
        return $this->runInternal(
44
            $organization->getUsers()->findOrCreate($user)
45
        );
46
    }
47
48
    /**
49
     * @inheritdoc
50
     * @param UserAssociation $record
0 ignored issues
show
Bug introduced by
There is no parameter named $record. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
51
     * @return bool
52
     */
53
    protected function performAction(UserAssociation $association): bool
54
    {
55
        return $association->save();
56
    }
57
}
58