1 | <?php |
||
15 | class MslsBlog { |
||
16 | |||
17 | /** |
||
18 | * WordPress generates such an object |
||
19 | * @var \StdClass |
||
20 | */ |
||
21 | private $obj; |
||
22 | |||
23 | /** |
||
24 | * Language-code eg. de_DE |
||
25 | * @var string |
||
26 | */ |
||
27 | private $language; |
||
28 | |||
29 | /** |
||
30 | * Description eg. Deutsch |
||
31 | * @var string |
||
32 | */ |
||
33 | private $description; |
||
34 | |||
35 | /** |
||
36 | * Constructor |
||
37 | * |
||
38 | * @param \StdClass $obj |
||
39 | * @param string $description |
||
40 | */ |
||
41 | public function __construct( $obj, $description ) { |
||
49 | |||
50 | /** |
||
51 | * Get a member of the \StdClass-object by name |
||
52 | * |
||
53 | * The method return <em>null</em> if the requested member does not exists. |
||
54 | * |
||
55 | * @param string $key |
||
56 | * |
||
57 | * @return mixed|null |
||
58 | */ |
||
59 | final public function __get( $key ) { |
||
62 | |||
63 | /** |
||
64 | * Get the description stored in this object |
||
65 | * |
||
66 | * The method returns the stored language if the description is empty. |
||
67 | * @return string |
||
68 | */ |
||
69 | public function get_description() { |
||
76 | |||
77 | /** |
||
78 | * Get the language stored in this object |
||
79 | * |
||
80 | * This method returns the string 'us' if there is an empty value in language. |
||
81 | * @return string |
||
82 | */ |
||
83 | public function get_language() { |
||
86 | |||
87 | /** |
||
88 | * Get the alpha2-part of the language-code |
||
89 | * |
||
90 | * This method returns the string 'en' if the language-code contains just 'us'. |
||
91 | * @return string |
||
92 | */ |
||
93 | public function get_alpha2() { |
||
98 | |||
99 | /** |
||
100 | * Sort objects helper |
||
101 | * |
||
102 | * @param string $a |
||
103 | * @param string $b |
||
104 | * |
||
105 | * @return int |
||
106 | */ |
||
107 | public static function _cmp( $a, $b ) { |
||
114 | |||
115 | /** |
||
116 | * Sort objects by language |
||
117 | * |
||
118 | * @param MslsBlog $a |
||
119 | * @param MslsBlog $b |
||
120 | * |
||
121 | * @return int |
||
122 | */ |
||
123 | public static function language( MslsBlog $a, MslsBlog $b ) { |
||
126 | |||
127 | /** |
||
128 | * Sort objects by description |
||
129 | * |
||
130 | * @param MslsBlog $a |
||
131 | * @param MslsBlog $b |
||
132 | * |
||
133 | * @return int |
||
134 | */ |
||
135 | public static function description( MslsBlog $a, MslsBlog $b ) { |
||
138 | |||
139 | } |
||
140 |