Completed
Push — master ( a7cf71...06c6ea )
by Craig
06:43
created

CommonHelper   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 84
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 84
rs 10
c 0
b 0
f 0
wmc 6
lcom 0
cbo 1

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A setTranslator() 0 4 1
A gtypeLabels() 0 14 2
A stateLabels() 0 13 2
1
<?php
2
3
/*
4
 * This file is part of the Zikula package.
5
 *
6
 * Copyright Zikula Foundation - http://zikula.org/
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Zikula\GroupsModule\Helper;
13
14
use Zikula\Common\Translator\TranslatorInterface;
15
use Zikula\Common\Translator\TranslatorTrait;
16
17
/**
18
 * Common helper functions and constants.
19
 */
20
class CommonHelper
21
{
22
    use TranslatorTrait;
23
    /**
24
     * Constant value for core type groups.
25
     */
26
    const GTYPE_CORE = 0;
27
28
    /**
29
     * Constant value for public type groups.
30
     */
31
    const GTYPE_PUBLIC = 1;
32
33
    /**
34
     * Constant value for private type groups.
35
     */
36
    const GTYPE_PRIVATE = 2;
37
38
    /**
39
     * Constant value for groups in the Closed state (not accepting members).
40
     */
41
    const STATE_CLOSED = 0;
42
43
    /**
44
     * Constant value for groups in the Open state (accepting members).
45
     */
46
    const STATE_OPEN = 1;
47
48
    /**
49
     * Constructs an instance of this helper class.
50
     */
51
    public function __construct(TranslatorInterface $translator)
52
    {
53
        $this->setTranslator($translator);
54
    }
55
56
    public function setTranslator($translator)
57
    {
58
        $this->translator = $translator;
59
    }
60
61
    /**
62
     * Return the standard set of labels for Group types.
63
     *
64
     * @staticvar array $gtypeLabels The array of standard group type labels.
65
     *
66
     * @return array An associative array of group type labels indexed by group type constants
67
     */
68
    public function gtypeLabels()
69
    {
70
        static $gtypeLabels;
71
72
        if (!isset($gtypeLabels)) {
73
            $gtypeLabels = [
74
                self::GTYPE_CORE => $this->__('Core'),
75
                self::GTYPE_PUBLIC => $this->__('Public'),
76
                self::GTYPE_PRIVATE => $this->__('Private')
77
            ];
78
        }
79
80
        return $gtypeLabels;
81
    }
82
83
    /**
84
     * Return the standard set of labels for Group states.
85
     *
86
     * @staticvar array $stateLabels The array of standard state labels.
87
     *
88
     * @return array An associative array of state labels indexed by state constants
89
     */
90
    public function stateLabels()
91
    {
92
        static $stateLabels;
93
94
        if (!isset($stateLabels)) {
95
            $stateLabels = [
96
                self::STATE_CLOSED => $this->__('Closed'),
97
                self::STATE_OPEN => $this->__('Open')
98
            ];
99
        }
100
101
        return $stateLabels;
102
    }
103
}
104