Completed
Push — master ( 6acd1a...f4119b )
by Mahmoud
09:56 queued 05:17
created

CreateStripeAccountObjectTask   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
c 1
b 0
f 0
lcom 1
cbo 4
dl 0
loc 46
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A run() 0 14 1
1
<?php
2
3
namespace App\Containers\Stripe\Tasks;
4
5
use App\Containers\Stripe\Models\StripeAccount;
6
use App\Containers\Stripe\Data\Repositories\StripeAccountRepository;
7
use App\Containers\User\Models\User;
8
use App\Port\Action\Abstracts\Action;
9
use Auth;
10
11
/**
12
 * Class CreateStripeAccountObjectTask.
13
 *
14
 * @author Mahmoud Zalt <[email protected]>
15
 */
16
class CreateStripeAccountObjectTask extends Action
17
{
18
19
    /**
20
     * @var  \App\Containers\Stripe\Data\Repositories\StripeAccountRepository
21
     */
22
    private $stripeAccountRepository;
23
24
    /**
25
     * CreateStripeAccountObjectTask constructor.
26
     *
27
     * @param \App\Containers\Stripe\Data\Repositories\StripeAccountRepository $stripeAccountRepository
28
     */
29
    public function __construct(StripeAccountRepository $stripeAccountRepository)
30
    {
31
        $this->stripeAccountRepository = $stripeAccountRepository;
32
    }
33
34
    /**
35
     * Create stripe account in my database
36
     *
37
     * @param \App\Containers\User\Models\User $user
38
     * @param                                  $customer_id
39
     * @param                                  $card_id
40
     * @param                                  $card_funding
41
     * @param                                  $card_last_digits
42
     * @param                                  $card_fingerprint
43
     *
44
     * @return  \App\Containers\Stripe\Models\StripeAccount|mixed
45
     */
46
    public function run(User $user, $customer_id, $card_id, $card_funding, $card_last_digits, $card_fingerprint)
47
    {
48
        $stripeAccount = new StripeAccount();
49
        $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...
50
        $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...
51
        $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...
52
        $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...
53
        $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...
54
        $stripeAccount->user()->associate($user);
55
56
        $stripeAccount = $this->stripeAccountRepository->create($stripeAccount->toArray());
57
58
        return $stripeAccount;
59
    }
60
61
}
62