Completed
Push — 2.0 ( d39b3c...f2914f )
by Kirill
02:52
created

AttributeExists   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 17
rs 10
c 0
b 0
f 0
wmc 2
lcom 0
cbo 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A whenExists() 0 8 2
1
<?php
2
/**
3
 * This file is part of laravel.su package.
4
 * For the full copyright and license information, please view the LICENSE
5
 * file that was distributed with this source code.
6
 */
7
declare(strict_types=1);
8
9
namespace App\GraphQL\Feature\Kernel;
10
11
/**
12
 * Class AttributeExists
13
 * @package App\GraphQL\Feature\Kernel
14
 */
15
trait AttributeExists
16
{
17
    /**
18
     * @param array $args
19
     * @param string $name
20
     * @param \Closure $then
21
     * @return mixed
22
     */
23
    protected function whenExists(array $args, string $name, \Closure $then)
24
    {
25
        if (isset($args[$name])) {
26
            return $then($args[$name]);
27
        }
28
29
        return null;
30
    }
31
}