AccessToken   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 1
dl 0
loc 25
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 2
A __toString() 0 4 1
1
<?php
2
3
/*
4
 * This file is part of the slince/shopify-api-php
5
 *
6
 * (c) Slince <[email protected]>
7
 *
8
 * This source file is subject to the MIT license that is bundled
9
 * with this source code in the file LICENSE.
10
 */
11
12
namespace Slince\Shopify;
13
14
use Slince\Shopify\Exception\InvalidArgumentException;
15
16
class AccessToken
17
{
18
    /**
19
     * @var string
20
     */
21
    protected $token;
22
23
    public function __construct($token)
24
    {
25
        if (0 === preg_match('/^([a-zA-Z0-9_]{10,100})$/', $token)) {
26
            throw new InvalidArgumentException('Access token should be between 10 and 100 letters and numbers');
27
        }
28
        $this->token = $token;
29
    }
30
31
    /**
32
     * Transform the token to string.
33
     *
34
     * @return string
35
     */
36
    public function __toString()
37
    {
38
        return $this->token;
39
    }
40
}
41