Client::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

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