Store   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 61
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
c 0
b 0
f 0
lcom 1
cbo 3
dl 0
loc 61
ccs 10
cts 10
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A delete() 0 4 1
A insert() 0 12 2
1
<?php
2
3
namespace BestServedCold\LaravelZendSearch\Lucene;
4
5
use BestServedCold\LaravelZendSearch\Lucene\Store\Insert;
6
use BestServedCold\LaravelZendSearch\Lucene\Store\Delete;
7
8
/**
9
 * Class Store
10
 *
11
 * @package BestServedCold\LaravelZendSearch\Lucene
12
 */
13
class Store
14
{
15
    /**
16
     * @var Delete
17
     */
18
    private $delete;
19
20
    /**
21
     * @var Insert
22
     */
23
    private $insert;
24
25
    /**
26
     * Store constructor.
27
     *
28
     * @param Delete $delete
29
     * @param Insert $insert
30
     */
31 20
    public function __construct(Delete $delete, Insert $insert)
32
    {
33 20
        $this->delete = $delete;
34 20
        $this->insert = $insert;
35 20
    }
36
37
    /**
38
     * Delete
39
     *
40
     * @param  Index          $index
41
     * @param  integer        $id
42
     * @param  boolean|string $uid
43
     * @return Delete
44
     */
45 4
    public function delete(Index $index, $id, $uid = false)
46
    {
47 4
        return $this->delete->delete($index, $id, $uid);
48
    }
49
50
    /**
51
     * Insert
52
     *
53
     * @param  Index           $index
54
     * @param  int             $id
55
     * @param  array           $fields
56
     * @param  string|boolean  $uid
57
     * @param  boolean         $deleteFirst
58
     * @param  array           $boostFields
59
     * @return mixed
60
     */
61 2
    public function insert(
62
        Index $index,
63
        $id,
64
        array $fields,
65
        $uid = false,
66
        $deleteFirst = true,
67
        $boostFields = []
68
    ) {
69 2
        $deleteFirst ? $this->delete($index, $id, $uid) : null;
70 2
        $index->close();
71 2
        return $this->insert->insert($index, $id, $fields, $uid, $boostFields);
72
    }
73
}
74