Code Duplication    Length = 38-38 lines in 2 locations

app/Containers/Stripe/Tasks/CreateStripeCustomerTask.php 1 location

@@ 16-53 (lines=38) @@
13
 *
14
 * @author Mahmoud Zalt <[email protected]>
15
 */
16
class CreateStripeCustomerTask extends Task
17
{
18
19
    private $stripe;
20
21
    /**
22
     * StripeApi constructor.
23
     *
24
     * @param \Cartalyst\Stripe\Stripe $stripe
25
     */
26
    public function __construct(Stripe $stripe)
27
    {
28
        $this->stripe = $stripe->make(Config::get('services.stripe.secret'), Config::get('services.stripe.version'));
29
    }
30
31
    /**
32
     * @param string $email
33
     * @param string $description
34
     *
35
     * @return array stripe customer object
36
     * @throws StripeApiErrorException
37
     */
38
    public function run($email, $description = '')
39
    {
40
        try {
41
42
            $response = $this->stripe->customers()->create([
43
                'email'       => $email,
44
                'description' => $description,
45
            ]);
46
47
        } catch (Exception $e) {
48
            throw (new StripeApiErrorException('Stripe API error (createCustomer)'))->debug($e->getMessage(), true);
49
        }
50
51
        return $response;
52
    }
53
54
}
55

app/Containers/Wepay/Tasks/CreateWepayCustomerTask.php 1 location

@@ 16-53 (lines=38) @@
13
 *
14
 * @author Rockers Technologies <[email protected]>
15
 */
16
class CreateWepayCustomerTask extends Task
17
{
18
19
    public $wepayLaravel;
20
21
    /**
22
     * WepayApi constructor.
23
     *
24
     * @param \KevinEm\WePay\Laravel\WePayLaravel $wepayLaravel
25
     */
26
    public function __construct(WePayLaravel $wepayLaravel)
27
    {
28
        $this->wepayLaravel = $wepayLaravel->make(
29
            Config::get('wepay-container.client_secret'),
30
            Config::get('wepay-container.version')
31
        );
32
    }
33
34
    /**
35
     * @param        $email
36
     * @param string $description
37
     *
38
     * @return array Wepay customer object
39
     * @throws WepayApiErrorException
40
     */
41
    public function run($email, $description = '')
42
    {
43
        try {
44
45
            $response = $this->wepayLaravel->customers()->create([
46
                'email'       => $email,
47
                'description' => $description,
48
            ]);
49
50
        } catch (Exception $e) {
51
            throw (new WepayApiErrorException('Wepay API error (createCustomer)'))->debug($e->getMessage(), true);
52
        }
53
54
        return $response;
55
    }
56