ProjectTrait   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 5
c 1
b 0
f 0
dl 0
loc 17
ccs 0
cts 5
cp 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A projectFromArgs() 0 8 2
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