Client::get()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 5
c 1
b 0
f 0
nc 2
nop 1
dl 0
loc 7
rs 10
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
}