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

PlaceMapperTrait::config()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

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