PGTCaller   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 3
dl 0
loc 45
ccs 14
cts 14
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A call() 0 22 2
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: leo108
5
 * Date: 2016/10/26
6
 * Time: 11:01
7
 */
8
9
namespace Leo108\CAS\Services;
10
11
use GuzzleHttp\Client;
12
use Illuminate\Support\Facades\Log;
13
14
class PGTCaller
15
{
16
    /**
17
     * @var Client
18
     */
19
    protected $client;
20
21
    /**
22
     * PGTCaller constructor.
23
     * @param Client $client
24
     */
25 18
    public function __construct(Client $client)
26
    {
27 18
        $this->client = $client;
28 18
    }
29
30
    /**
31
     * @param string $pgtUrl
32
     * @param string $pgt
33
     * @param string $pgtiou
34
     * @return bool
35
     */
36 1
    public function call($pgtUrl, $pgt, $pgtiou)
37
    {
38
        $query = [
39 1
            'pgtId'  => $pgt,
40 1
            'pgtIou' => $pgtiou,
41
        ];
42 1
        parse_str(parse_url($pgtUrl, PHP_URL_QUERY), $originQuery);
43
44
        try {
45
            $option = [
46 1
                'query'  => array_merge($originQuery, $query),
47 1
                'verify' => config('cas.verify_ssl', true),
48
            ];
49 1
            $res    = $this->client->get($pgtUrl, $option);
50
51 1
            return $res->getStatusCode() == 200;
52 1
        } catch (\Exception $e) {
53 1
            Log::warning('call pgt url failed, msg:'.$e->getMessage());
54
55 1
            return false;
56
        }
57
    }
58
}
59