MapAdapterResult   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 53
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 10
dl 0
loc 53
rs 10
c 0
b 0
f 0
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A geoAnalysisResult() 0 3 1
A merge() 0 5 1
A features() 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\Module\GeoDispersion\Model;
16
17
use MyArtJaub\Webtrees\Common\GeoDispersion\GeoAnalysis\GeoAnalysisResult;
18
19
/**
20
 * Result of a GeoAnalysisMapAdapter conversion.
21
 * It includes the GeoAnalysisResult with places excluded by the mapping,
22
 * and a list of features to display populated with analysis result properties.
23
 *
24
 */
25
class MapAdapterResult
26
{
27
    private GeoAnalysisResult $result;
28
29
    /**
30
     * @var array<int, \Brick\Geo\IO\GeoJSON\Feature> $features
31
     */
32
    private array $features;
33
34
    /**
35
     * Constructor for MapAdapterResult
36
     *
37
     * @param GeoAnalysisResult $result
38
     * @param \Brick\Geo\IO\GeoJSON\Feature[] $features
39
     */
40
    final public function __construct(GeoAnalysisResult $result, array $features)
41
    {
42
        $this->result = $result;
43
        $this->features = $features;
44
    }
45
46
    /**
47
     * Get the GeoAnalysisResult after mapping of the places
48
     *
49
     * @return GeoAnalysisResult
50
     */
51
    public function geoAnalysisResult(): GeoAnalysisResult
52
    {
53
        return $this->result;
54
    }
55
56
    /**
57
     * Get the list of features to display on the map
58
     *
59
     * @return array<int, \Brick\Geo\IO\GeoJSON\Feature>
60
     */
61
    public function features(): array
62
    {
63
        return $this->features;
64
    }
65
66
    /**
67
     * Merge the current MapAdapter with another.
68
     * The current object is modified, not the second one.
69
     *
70
     * @param MapAdapterResult $other
71
     * @return static
72
     */
73
    public function merge(MapAdapterResult $other): self
74
    {
75
        return new static(
76
            $this->result->merge($other->result),
77
            [...$this->features, ...$other->features]
78
        );
79
    }
80
}
81