Completed
Push — master ( 544e34...6465ee )
by Jonathan
06:11
created

FunctionsPrintLists::sortableNames()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 14
rs 9.4285
cc 1
eloc 9
nc 1
nop 1
1
<?php
2
/**
3
 * webtrees-lib: MyArtJaub library for webtrees
4
*
5
* @package MyArtJaub\Webtrees
6
* @subpackage Functions
7
* @author Jonathan Jaubart <[email protected]>
8
* @copyright Copyright (c) 2016, Jonathan Jaubart
9
* @license http://www.gnu.org/licenses/gpl.html GNU General Public License, version 3
10
*/
11
namespace MyArtJaub\Webtrees\Functions;
12
13
use Fisharebest\Webtrees\Individual;
14
15
/**
16
 * Class FunctionsPrintLists - create sortable lists using datatables.net
17
 */
18
class FunctionsPrintLists {
19
    
20
    /**
21
     * Copy of core function, which is not public.
22
     *
23
     * @param Individual $individual
24
     *
25
     * @return string[]
26
     * @see \Fisharebest\Webtrees\Functions\FunctionsPrintLists
27
     */
28
    public static function sortableNames(Individual $individual) {
29
        $names   = $individual->getAllNames();
30
        $primary = $individual->getPrimaryName();
31
32
        list($surn, $givn) = explode(',', $names[$primary]['sort']);
33
34
        $givn = str_replace('@P.N.', 'AAAA', $givn);
35
        $surn = str_replace('@N.N.', 'AAAA', $surn);
36
37
        return array(
38
            $surn . 'AAAA' . $givn,
39
            $givn . 'AAAA' . $surn,
40
        );
41
    }
42
43
}