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

DissociateUserFromOrganization::run()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 17

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 0
Metric Value
dl 0
loc 17
ccs 0
cts 15
cp 0
rs 9.7
c 0
b 0
f 0
cc 3
nc 3
nop 2
crap 12
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