Passed
Branch feature/2.1-geodispersion-dev (1d61a8)
by Jonathan
61:21
created

PlaceMapperTrait::config()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
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, 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 MyArtJaub\Webtrees\Common\GeoDispersion\Config\NullPlaceMapperConfig;
18
use MyArtJaub\Webtrees\Contracts\GeoDispersion\PlaceMapperConfigInterface;
19
20
/**
21
 * Trait for implementation of the PlaceMapperInterface
22
 *
23
 * @see \MyArtJaub\Webtrees\Contracts\GeoDispersion\PlaceMapperInterface
24
 */
25
trait PlaceMapperTrait
26
{
27
    private ?PlaceMapperConfigInterface $config = null;
28
    private array $data = [];
29
30
    /**
31
     * Implementation of PlaceMapperInterface::boot
32
     *
33
     * @see \MyArtJaub\Webtrees\Contracts\GeoDispersion\PlaceMapperInterface::boot()
34
     */
35
    public function boot(): void
36
    {
37
    }
38
39
    /**
40
     * Implementation of PlaceMapperInterface::config
41
     *
42
     * @see \MyArtJaub\Webtrees\Contracts\GeoDispersion\PlaceMapperInterface::config()
43
     *
44
     * @return PlaceMapperConfigInterface
45
     */
46
    public function config(): PlaceMapperConfigInterface
47
    {
48
        return $this->config ?? new NullPlaceMapperConfig();
49
    }
50
51
    /**
52
     * Implementation of PlaceMapperInterface::setConfig
53
     *
54
     * @see \MyArtJaub\Webtrees\Contracts\GeoDispersion\PlaceMapperInterface::setConfig()
55
     *
56
     * @param PlaceMapperConfigInterface $config
57
     */
58
    public function setConfig(PlaceMapperConfigInterface $config): void
59
    {
60
        $this->config = $config;
61
    }
62
63
    /**
64
     * Implementation of PlaceMapperInterface::data
65
     *
66
     * @see \MyArtJaub\Webtrees\Contracts\GeoDispersion\PlaceMapperInterface::data()
67
     *
68
     * @param string $key
69
     * @return NULL|mixed
70
     */
71
    public function data(string $key)
72
    {
73
        return $this->data[$key] ?? null;
74
    }
75
76
    /**
77
     * Implementation of PlaceMapperInterface::setData
78
     *
79
     * @see \MyArtJaub\Webtrees\Contracts\GeoDispersion\PlaceMapperInterface::setData()
80
     *
81
     * @param string $key
82
     * @param mixed|null $data
83
     */
84
    public function setData(string $key, $data): void
85
    {
86
        $this->data[$key] = $data;
87
    }
88
}
89