CreateWepayAccountAction   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A run() 0 20 1
1
<?php
2
3
namespace App\Containers\Wepay\Actions;
4
5
use Apiato\Core\Foundation\Facades\Apiato;
6
use App\Containers\Wepay\Data\Repositories\WepayAccountRepository;
7
use App\Containers\Wepay\Models\WepayAccount;
8
use App\Ship\Parents\Actions\Action;
9
use App\Ship\Transporters\DataTransporter;
10
11
/**
12
 * Class CreateWepayAccountAction.
13
 *
14
 * @author Rockers Technologies <[email protected]>
15
 */
16
class CreateWepayAccountAction extends Action
17
{
18
19
    protected $repository;
20
21
    public function __construct(WepayAccountRepository $repository)
22
    {
23
        $this->repository = $repository;
24
    }
25
26
    /**
27
     * @param \App\Ship\Transporters\DataTransporter $data
28
     *
29
     * @return  \App\Containers\Wepay\Models\WepayAccount
30
     */
31
    public function run(DataTransporter $data): WepayAccount
32
    {
33
        $user = Apiato::call('[email protected]');
34
35
        $wepayAccount = new WepayAccount();
36
        $wepayAccount->name = $data->name;
37
        $wepayAccount->description = $data->description;
38
        $wepayAccount->type = $data->type;
39
        $wepayAccount->imageUrl = $data->imageUrl;
40
        $wepayAccount->gaqDomains = json_decode($data->gaqDomains);
41
        $wepayAccount->mcc = $data->mcc;
42
        $wepayAccount->country = $data->country;
43
        $wepayAccount->currencies = $data->currencies;
44
45
        $wepayAccount = $this->repository->create($wepayAccount->toArray());
46
47
        Apiato::call('[email protected]', [$wepayAccount, $user, $data->nickname]);
48
49
        return $wepayAccount;
50
    }
51
52
}
53