SourceResource   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
c 1
b 0
f 0
dl 0
loc 26
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setTenantManager() 0 3 1
A toArray() 0 7 1
1
<?php
2
3
namespace App\Http\Resources;
4
5
use App\Services\TenantManager;
6
use Illuminate\Http\Resources\Json\JsonResource;
7
8
class SourceResource extends JsonResource
9
{
10
    /**
11
     * @var TenantManager
12
     */
13
    protected static $tenantManager;
14
15
    public static function setTenantManager($tenantManager)
16
    {
17
        self::$tenantManager = $tenantManager;
18
    }
19
20
    /**
21
     * Transform the resource into an array.
22
     *
23
     * @param \Illuminate\Http\Request $request
24
     *
25
     * @return array
26
     */
27
    public function toArray($request)
28
    {
29
        $array = parent::toArray($request);
30
        $array['url'] = config('app.apply_url').'/'.static::$tenantManager->getTenant()->subdomain.'/'.$array['key']
31
            .'-'.preg_replace("/[^A-Za-z0-9\-]/", '', str_replace(' ', '-', $this->recruitment->job_title));
0 ignored issues
show
Bug Best Practice introduced by
The property recruitment does not exist on App\Http\Resources\SourceResource. Since you implemented __get, consider adding a @property annotation.
Loading history...
32
33
        return $array;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $array also could return the type Illuminate\Contracts\Sup...ayable|JsonSerializable which is incompatible with the documented return type array.
Loading history...
34
    }
35
}
36