Completed
Push — master ( d039a4...8016f7 )
by Mahmoud
03:07
created

Transformer   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 3
c 1
b 0
f 1
lcom 0
cbo 0
dl 0
loc 27
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A user() 0 4 1
A ifAdmin() 0 8 2
1
<?php
2
3
namespace App\Port\Transformer\Abstracts;
4
5
use App\Containers\Authentication\Tasks\GetAuthenticatedUserTask;
6
use Illuminate\Support\Facades\App;
7
use League\Fractal\TransformerAbstract as FractalTransformerAbstract;
8
9
/**
10
 * Class Transformer.
11
 *
12
 * @author  Mahmoud Zalt <[email protected]>
13
 */
14
abstract class Transformer extends FractalTransformerAbstract
15
{
16
17
    /**
18
     * @return  mixed
19
     */
20
    public function user()
21
    {
22
        return App::make(GetAuthenticatedUserTask::class)->run();
23
    }
24
25
    /**
26
     * @param $adminResponse
27
     * @param $clientResponse
28
     *
29
     * @return  array
30
     */
31
    public function ifAdmin($adminResponse, $clientResponse)
32
    {
33
        if ($this->user()->hasAdminRole()) {
34
            return array_merge($clientResponse, $adminResponse);
35
        }
36
37
        return $clientResponse;
38
    }
39
40
}
41