SimplePlaceMapper   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A title() 0 3 1
A map() 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\PlaceMappers;
16
17
use Fisharebest\Webtrees\I18N;
18
use Fisharebest\Webtrees\Place;
19
use MyArtJaub\Webtrees\Contracts\GeoDispersion\PlaceMapperInterface;
20
21
/**
22
 * Simple Place Mapper, returning the lowest level place name.
23
 * Depending on the map, can be a very quick mapper, but no handling of duplicates or place name changes.
24
 */
25
class SimplePlaceMapper implements PlaceMapperInterface
26
{
27
    use PlaceMapperTrait;
28
29
    /**
30
     * {@inheritDoc}
31
     * @see \MyArtJaub\Webtrees\Contracts\GeoDispersion\PlaceMapperInterface::title()
32
     */
33
    public function title(): string
34
    {
35
        return I18N::translate('Mapping on place name');
36
    }
37
38
    /**
39
     * {@inheritDoc}
40
     * @see \MyArtJaub\Webtrees\Contracts\GeoDispersion\PlaceMapperInterface::map()
41
     */
42
    public function map(Place $place, string $feature_property): ?string
43
    {
44
        return $place->firstParts(1)->first();
45
    }
46
}
47