Completed
Push — master ( 61a5ce...0094ca )
by Mahmoud
03:11
created

Controller::getUserApplications()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 6
rs 9.4285
cc 1
eloc 3
nc 1
nop 1
1
<?php
2
3
namespace App\Containers\Application\UI\API\Controllers;
4
5
use App\Containers\Application\Actions\CreateApplicationWithTokenAction;
6
use App\Containers\Application\Actions\ListAllAppsAction;
7
use App\Containers\Application\UI\API\Requests\CreateApplicationRequest;
8
use App\Containers\Application\UI\API\Transformers\ApplicationTransformer;
9
use App\Port\Controller\Abstracts\PortApiController;
10
11
/**
12
 * Class Controller.
13
 *
14
 * @author Mahmoud Zalt <[email protected]>
15
 */
16
class Controller extends PortApiController
17
{
18
19
    /**
20
     * @param \App\Containers\Application\UI\API\Requests\GenerateApplicationTokenRequest $request
21
     * @param \App\Containers\Application\Actions\GenerateApplicationTokenAction          $action
22
     *
23
     * @return  \Dingo\Api\Http\Response
24
     */
25
    public function createApplication(CreateApplicationRequest $request, CreateApplicationWithTokenAction $action)
26
    {
27
        $app = $action->run($request->name, $request->user()->id);
0 ignored issues
show
Documentation introduced by
The property name does not exist on object<App\Containers\Ap...eateApplicationRequest>. 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...
28
29
        return $this->response->item($app, new ApplicationTransformer());
30
    }
31
32
    /**
33
     * @param \App\Containers\Application\Actions\ListAllAppsAction $action
34
     *
35
     * @return  \Dingo\Api\Http\Response
36
     */
37
    public function getUserApplications(ListAllAppsAction $action)
38
    {
39
        $apps = $action->run();
40
41
        return $this->response->collection($apps, new ApplicationTransformer());
42
    }
43
44
}
45