Completed
Branch EDTR/master (83b47e)
by
unknown
25:37 queued 16:41
created

Locale   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
dl 0
loc 32
rs 10
c 0
b 0
f 0
wmc 2
lcom 0
cbo 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A initialize() 0 11 1
1
<?php
2
3
namespace EventEspresso\core\domain\entities\routing\data_nodes\core;
4
5
use EEH_DTT_Helper;
6
use EventEspresso\core\services\json\JsonDataNode;
7
use EventEspresso\core\services\json\JsonDataNodeValidator;
8
9
/**
10
 * Class Locale
11
 * Description
12
 *
13
 * @package EventEspresso\core\domain\entities\routing\data_nodes
14
 * @author  Brent Christensen
15
 * @since   $VID:$
16
 */
17
class Locale extends JsonDataNode
18
{
19
20
    const NODE_NAME = 'locale';
21
22
23
    /**
24
     * JsonDataNodeHandler constructor.
25
     *
26
     * @param JsonDataNodeValidator $validator
27
     */
28
    public function __construct(JsonDataNodeValidator $validator)
29
    {
30
        parent::__construct($validator);
31
        $this->setNodeName(Locale::NODE_NAME);
32
    }
33
34
    /**
35
     * @inheritDoc
36
     */
37
    public function initialize()
38
    {
39
        $this->addData('user', get_user_locale());
40
        $this->addData('site', get_locale());
41
        $this->addData('siteTimezone', [
42
            'city'   => EEH_DTT_Helper::get_timezone_string_for_display(),
43
            'name'   => get_option('timezone_string'),
44
            'offset' => EEH_DTT_Helper::get_site_timezone_gmt_offset(),
45
        ]);
46
        $this->setInitialized(true);
47
    }
48
}
49