Completed
Push — master ( 857394...4794c5 )
by Mahmoud
03:25
created

CreatePaypalAccountObjectTask   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A run() 0 10 1
1
<?php
2
3
namespace App\Containers\Paypal\Tasks;
4
5
use App\Containers\Paypal\Data\Repositories\PaypalAccountRepository;
6
use App\Containers\Paypal\Models\PaypalAccount;
7
use App\Containers\User\Models\User;
8
use App\Port\Task\Abstracts\Task;
9
use Auth;
10
11
/**
12
 * Class CreatePaypalAccountObjectTask
13
 *
14
 * @author  Mahmoud Zalt  <[email protected]>
15
 */
16
class CreatePaypalAccountObjectTask extends Task
17
{
18
19
    /**
20
     * @var  \App\Containers\Paypal\Data\Repositories\PaypalAccountRepository
21
     */
22
    private $paypalAccountRepository;
23
24
    /**
25
     * CreatePaypalAccountTask constructor.
26
     *
27
     * @param \App\Containers\Paypal\Data\Repositories\PaypalAccountRepository $paypalAccountRepository
28
     */
29
    public function __construct(PaypalAccountRepository $paypalAccountRepository)
30
    {
31
        $this->paypalAccountRepository = $paypalAccountRepository;
32
    }
33
34
    /**
35
     * Create paypal account in my database
36
     *
37
     * @param \App\Containers\User\Models\User $user
38
     * @param                                  $some_id
39
     *
40
     * @return  \App\Containers\Paypal\Models\PaypalAccount|mixed
41
     */
42
    public function run(User $user, $some_id)
43
    {
44
        $paypalAccount = new PaypalAccount();
45
        $paypalAccount->some_id = $some_id; // TODO: To Be Continue...
0 ignored issues
show
Documentation introduced by
The property some_id does not exist on object<App\Containers\Pa...l\Models\PaypalAccount>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
46
        $paypalAccount->user()->associate($user);
47
48
        $paypalAccount = $this->paypalAccountRepository->create($paypalAccount->toArray());
49
50
        return $paypalAccount;
51
    }
52
53
}
54