TenantTransformer   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A transform() 0 17 3
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Cortex\Tenants\Transformers\Adminarea;
6
7
use Cortex\Tenants\Models\Tenant;
8
use Rinvex\Support\Traits\Escaper;
9
use League\Fractal\TransformerAbstract;
10
11
class TenantTransformer extends TransformerAbstract
12
{
13
    use Escaper;
14
15
    /**
16
     * @return array
17
     */
18
    public function transform(Tenant $tenant): array
19
    {
20
        $country = $tenant->country_code ? country($tenant->country_code) : null;
21
        $language = $tenant->language_code ? language($tenant->language_code) : null;
22
23
        return $this->escape([
24
            'id' => (string) $tenant->getRouteKey(),
25
            'name' => (string) $tenant->name,
26
            'email' => (string) $tenant->email,
27
            'phone' => (string) $tenant->phone,
28
            'country_code' => (string) optional($country)->getName(),
29
            'country_emoji' => (string) optional($country)->getEmoji(),
30
            'language_code' => (string) optional($language)->getName(),
31
            'created_at' => (string) $tenant->created_at,
32
            'updated_at' => (string) $tenant->updated_at,
33
        ]);
34
    }
35
}
36