ProjectTrait::projectFromArgs()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 4
c 1
b 0
f 0
dl 0
loc 8
ccs 0
cts 5
cp 0
rs 10
cc 2
nc 2
nop 1
crap 6
1
<?php
2
3
namespace App\Controller\Traits;
4
5
use App\Model\Project;
6
use Ronanchilvers\Orm\Orm;
7
8
/**
9
 * Controller trait for project controllers
10
 *
11
 * @author Ronan Chilvers <[email protected]>
12
 */
13
trait ProjectTrait
14
{
15
    /**
16
     * Get a project from an args array
17
     *
18
     * @param array $args
19
     * @return \App\Model\Project|null
20
     * @author Ronan Chilvers <[email protected]>
21
     */
22
    protected function projectFromArgs($args)
23
    {
24
        $project = Orm::finder(Project::class)->forKey($args['key']);
25
        if ($project instanceof Project) {
26
            return $project;
27
        }
28
29
        return null;
30
    }
31
}
32