Passed
Push — feature/code-analysis ( e964aa...4fe35d )
by Jonathan
14:33
created

GeoAnalysisResultItem   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 64
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 11
dl 0
loc 64
rs 10
c 0
b 0
f 0
wmc 6

6 Methods

Rating   Name   Duplication   Size   Complexity  
A count() 0 3 1
A __clone() 0 3 1
A __construct() 0 4 1
A increment() 0 4 1
A place() 0 3 1
A key() 0 3 1
1
<?php
2
3
/**
4
 * webtrees-lib: MyArtJaub library for webtrees
5
 *
6
 * @package MyArtJaub\Webtrees
7
 * @subpackage GeoDispersion
8
 * @author Jonathan Jaubart <[email protected]>
9
 * @copyright Copyright (c) 2021-2022, Jonathan Jaubart
10
 * @license http://www.gnu.org/licenses/gpl.html GNU General Public License, version 3
11
 */
12
13
declare(strict_types=1);
14
15
namespace MyArtJaub\Webtrees\Common\GeoDispersion\GeoAnalysis;
16
17
/**
18
 * Individual item in the result of a geographical dispersion analysis.
19
 * It references the GeoAnalysis Place, and its number of occurrences in the analysis.
20
 */
21
class GeoAnalysisResultItem
22
{
23
    private GeoAnalysisPlace $place;
24
    private int $count;
25
26
    /**
27
     * Constructor for GeoAnalysisResultItem
28
     *
29
     * @param GeoAnalysisPlace $place
30
     * @param int $count
31
     */
32
    public function __construct(GeoAnalysisPlace $place, int $count = 0)
33
    {
34
        $this->place = $place;
35
        $this->count = $count;
36
    }
37
38
    /**
39
     * Get the item key.
40
     *
41
     * @return string
42
     */
43
    public function key(): string
44
    {
45
        return $this->place->key();
46
    }
47
48
    /**
49
     * Get the referenced GeoAnalysis Place
50
     *
51
     * @return GeoAnalysisPlace
52
     */
53
    public function place(): GeoAnalysisPlace
54
    {
55
        return $this->place;
56
    }
57
58
    /**
59
     * Get the count of occurrences of the GeoAnalysis Place in the analysis
60
     *
61
     * @return int
62
     */
63
    public function count(): int
64
    {
65
        return $this->count;
66
    }
67
68
    /**
69
     * Increment the count of occurrences of the GeoAnalysis Place in the analysis
70
     *
71
     * @return $this
72
     */
73
    public function increment(): self
74
    {
75
        $this->count++;
76
        return $this;
77
    }
78
79
    /**
80
     * Clone the item object
81
     */
82
    public function __clone()
83
    {
84
        $this->place = clone $this->place;
85
    }
86
}
87