Passed
Branch main (f9aaf7)
by Jonathan
14:43
created

FamilyDatatablesExtenderCollector   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 9
dl 0
loc 41
rs 10
c 0
b 0
f 0
wmc 5

4 Methods

Rating   Name   Duplication   Size   Complexity  
A description() 0 3 1
A familyColumns() 0 7 2
A title() 0 3 1
A hookInterface() 0 3 1
1
<?php
2
3
/**
4
 * webtrees-lib: MyArtJaub library for webtrees
5
 *
6
 * @package MyArtJaub\Webtrees
7
 * @subpackage Hooks
8
 * @author Jonathan Jaubart <[email protected]>
9
 * @copyright Copyright (c) 2011-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\Hooks\Hooks;
16
17
use Fisharebest\Webtrees\I18N;
18
use MyArtJaub\Webtrees\Common\Hooks\AbstractHookCollector;
19
use MyArtJaub\Webtrees\Contracts\Hooks\FamilyDatatablesExtenderInterface;
20
21
/**
22
 * Hook collector for hooks implementing FamilyDatatablesExtenderInterface.
23
 * Used to extend the columns of families datatables.
24
 *
25
 * @extends AbstractHookCollector<FamilyDatatablesExtenderInterface>
26
 */
27
class FamilyDatatablesExtenderCollector extends AbstractHookCollector implements
28
    FamilyDatatablesExtenderInterface
29
{
30
    /**
31
     * {@inheritDoc}
32
     * @see \MyArtJaub\Webtrees\Common\Hooks\AbstractHookCollector::title()
33
     */
34
    public function title(): string
35
    {
36
        return I18N::translate('Columns extender for tables of families');
37
    }
38
39
    /**
40
     * {@inheritDoc}
41
     * @see \MyArtJaub\Webtrees\Common\Hooks\AbstractHookCollector::description()
42
     */
43
    public function description(): string
44
    {
45
        return I18N::translate('Add additional columns to tables of families');
46
    }
47
48
    /**
49
     * {@inheritDoc}
50
     * @see \MyArtJaub\Webtrees\Common\Hooks\AbstractHookCollector::hookInterface()
51
     */
52
    public function hookInterface(): string
53
    {
54
        return FamilyDatatablesExtenderInterface::class;
55
    }
56
57
    /**
58
     * {@inheritDoc}
59
     * @see \MyArtJaub\Webtrees\Contracts\Hooks\FamilyDatatablesExtenderInterface::familyColumns()
60
     */
61
    public function familyColumns(iterable $records): array
62
    {
63
        $result = [];
64
        foreach ($this->hooks() as $hook) {
65
            $result = array_merge($result, $hook->familyColumns($records));
66
        }
67
        return $result;
68
    }
69
}
70