CreateStripeAccountObjectTask::run()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 14
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 10
nc 1
nop 6
1
<?php
2
3
namespace App\Containers\Stripe\Tasks;
4
5
use App\Containers\Stripe\Data\Repositories\StripeAccountRepository;
6
use App\Containers\Stripe\Models\StripeAccount;
7
use App\Containers\User\Models\User;
8
use App\Ship\Parents\Tasks\Task;
9
10
/**
11
 * Class CreateStripeAccountObjectTask.
12
 *
13
 * @author Mahmoud Zalt <[email protected]>
14
 */
15
class CreateStripeAccountObjectTask extends Task
16
{
17
18
    /**
19
     * @var  \App\Containers\Stripe\Data\Repositories\StripeAccountRepository
20
     */
21
    private $stripeAccountRepository;
22
23
    /**
24
     * CreateStripeAccountObjectTask constructor.
25
     *
26
     * @param \App\Containers\Stripe\Data\Repositories\StripeAccountRepository $stripeAccountRepository
27
     */
28
    public function __construct(StripeAccountRepository $stripeAccountRepository)
29
    {
30
        $this->stripeAccountRepository = $stripeAccountRepository;
31
    }
32
33
    /**
34
     * Create stripe account in my database
35
     *
36
     * @param \App\Containers\User\Models\User $user
37
     * @param                                  $customer_id
38
     * @param                                  $card_id
39
     * @param                                  $card_funding
40
     * @param                                  $card_last_digits
41
     * @param                                  $card_fingerprint
42
     *
43
     * @return  \App\Containers\Stripe\Models\StripeAccount|mixed
44
     */
45
    public function run(User $user, $customer_id, $card_id, $card_funding, $card_last_digits, $card_fingerprint)
46
    {
47
        $stripeAccount = new StripeAccount();
48
        $stripeAccount->customer_id = $customer_id;
0 ignored issues
show
Documentation introduced by
The property customer_id does not exist on object<App\Containers\St...e\Models\StripeAccount>. 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...
49
        $stripeAccount->card_id = $card_id;
0 ignored issues
show
Documentation introduced by
The property card_id does not exist on object<App\Containers\St...e\Models\StripeAccount>. 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...
50
        $stripeAccount->card_funding = $card_funding;
0 ignored issues
show
Documentation introduced by
The property card_funding does not exist on object<App\Containers\St...e\Models\StripeAccount>. 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...
51
        $stripeAccount->card_last_digits = $card_last_digits;
0 ignored issues
show
Documentation introduced by
The property card_last_digits does not exist on object<App\Containers\St...e\Models\StripeAccount>. 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...
52
        $stripeAccount->card_fingerprint = $card_fingerprint;
0 ignored issues
show
Documentation introduced by
The property card_fingerprint does not exist on object<App\Containers\St...e\Models\StripeAccount>. 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...
53
        $stripeAccount->user()->associate($user);
54
55
        $stripeAccount = $this->stripeAccountRepository->create($stripeAccount->toArray());
56
57
        return $stripeAccount;
58
    }
59
60
}
61