Caching::cache()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

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