Caching   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 10
dl 0
loc 26
rs 10
c 0
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getCacheFields() 0 5 2
A cache() 0 7 1
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of Solr Client Symfony package.
7
 *
8
 * (c) ingatlan.com Zrt. <[email protected]>
9
 *
10
 * This source file is subject to the MIT license that is bundled
11
 * with this source code in the file LICENSE.
12
 */
13
14
namespace iCom\SolrClient\Query\Helper;
15
16
/**
17
 * @psalm-immutable
18
 */
19
trait Caching
20
{
21
    /**
22
     * @var ?bool
23
     */
24
    private $cache;
25
26
    /**
27
     * @var ?int
28
     */
29
    private $cost;
30
31
    public function cache(bool $cache, ?int $cost = null): self
32
    {
33
        $self = clone $this;
34
        $self->cache = $cache;
35
        $self->cost = $cost;
36
37
        return $self;
38
    }
39
40
    private function getCacheFields(): array
41
    {
42
        return [
43
            'cache' => null !== $this->cache ? var_export($this->cache, true) : null,
44
            'cost' => $this->cost,
45
        ];
46
    }
47
}
48