Client   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
c 1
b 0
f 0
dl 0
loc 18
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A get() 0 7 2
1
<?php
2
3
namespace Startwind\Inventorio\Util;
4
5
class Client
6
{
7
    private \GuzzleHttp\Client $client;
8
9
    private array $cache = [];
10
11
    public function __construct(\GuzzleHttp\Client $client)
12
    {
13
        $this->client = $client;
14
    }
15
16
    public function get(string $url)
17
    {
18
        if (array_key_exists($url, $this->cache)) {
19
            return $this->cache[$url];
20
        } else {
21
            $this->cache[$url] = $this->client->request('GET', $url);
22
            return $this->cache[$url];
23
        }
24
    }
25
}