Completed
Push — master ( 857394...4794c5 )
by Mahmoud
03:25
created

SetApplicationTokenTask::run()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 8
rs 9.4285
cc 1
eloc 4
nc 1
nop 2
1
<?php
2
3
namespace App\Containers\Application\Tasks;
4
5
use App\Containers\Application\Data\Repositories\ApplicationRepository;
6
use App\Containers\Application\Models\Application;
7
use App\Port\Task\Abstracts\Task;
8
9
/**
10
 * Class SetApplicationTokenTask.
11
 *
12
 * @author Mahmoud Zalt <[email protected]>
13
 */
14
class SetApplicationTokenTask extends Task
15
{
16
17
    /**
18
     * @var  \App\Containers\Application\Data\Repositories\ApplicationRepository
19
     */
20
    private $applicationRepository;
21
22
    /**
23
     * CreateApplicationTask constructor.
24
     *
25
     * @param \App\Containers\Application\Data\Repositories\ApplicationRepository $applicationRepository
26
     */
27
    public function __construct(ApplicationRepository $applicationRepository)
28
    {
29
        $this->applicationRepository = $applicationRepository;
30
    }
31
32
    /**
33
     * @param \App\Containers\Application\Models\Application $application
34
     * @param                                                $token
35
     *
36
     * @return  \App\Containers\Application\Models\Application|mixed
37
     */
38
    public function run(Application $application, $token)
39
    {
40
        $attributes = ['token' => $token];
41
42
        $application = $this->applicationRepository->update($attributes, $application->id);
0 ignored issues
show
Documentation introduced by
The property id does not exist on object<App\Containers\Ap...ion\Models\Application>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
43
44
        return $application;
45
    }
46
47
}
48