WooCommerceApi   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 2
dl 0
loc 44
ccs 0
cts 24
cp 0
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 24 2
1
<?php
2
3
namespace Codexshaper\WooCommerce;
4
5
use Automattic\WooCommerce\Client;
6
use Codexshaper\WooCommerce\Traits\WooCommerceTrait;
7
8
class WooCommerceApi
9
{
10
    use WooCommerceTrait;
11
12
    /**
13
     *@var \Automattic\WooCommerce\Client
14
     */
15
    protected $client;
16
17
    /**
18
     *@var array
19
     */
20
    protected $headers = [];
21
22
    /**
23
     * Build Woocommerce connection.
24
     *
25
     * @return void
0 ignored issues
show
Comprehensibility Best Practice introduced by
Adding a @return annotation to constructors is generally not recommended as a constructor does not have a meaningful return value.

Adding a @return annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.

Please refer to the PHP core documentation on constructors.

Loading history...
26
     */
27
    public function __construct()
28
    {
29
        try {
30
            $this->headers = [
31
                'header_total'       => config('woocommerce.header_total') ?? 'X-WP-Total',
32
                'header_total_pages' => config('woocommerce.header_total_pages') ?? 'X-WP-TotalPages',
33
            ];
34
35
            $this->client = new Client(
36
                config('woocommerce.store_url'),
37
                config('woocommerce.consumer_key'),
38
                config('woocommerce.consumer_secret'),
39
                [
40
                    'version'           => 'wc/'.config('woocommerce.api_version'),
41
                    'wp_api'            => config('woocommerce.wp_api_integration'),
42
                    'verify_ssl'        => config('woocommerce.verify_ssl'),
43
                    'query_string_auth' => config('woocommerce.query_string_auth'),
44
                    'timeout'           => config('woocommerce.timeout'),
45
                ]
46
            );
47
        } catch (\Exception $e) {
48
            throw new \Exception($e->getMessage(), 1);
49
        }
50
    }
51
}
52