MslsOptionsQueryYear   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
dl 0
loc 34
rs 10
c 0
b 0
f 0
wmc 3
lcom 1
cbo 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A has_value() 0 14 2
A get_current_link() 0 3 1
1
<?php
2
/**
3
 * MslsOptionsQueryYear
4
 * @author Dennis Ploetner <[email protected]>
5
 * @since 0.9.8
6
 */
7
8
namespace lloc\Msls;
9
10
/**
11
 * OptionsQueryYear
12
 *
13
 * @package Msls
14
 */
15
class MslsOptionsQueryYear extends MslsOptionsQuery {
16
17
	/**
18
	 * Check if the array has an non empty item which has $language as a key
19
	 *
20
	 * @param string $language
21
	 *
22
	 * @return bool
23
	 */
24
	public function has_value( $language ) {
25
		if ( ! isset( $this->arr[ $language ] ) ) {
26
			$cache = MslsSqlCacher::init( __CLASS__ )->set_params( $this->args );
27
28
			$this->arr[ $language ] = $cache->get_var(
29
				$cache->prepare(
30
					"SELECT count(ID) FROM {$cache->posts} WHERE YEAR(post_date) = %d AND post_status = 'publish'",
31
					$this->get_arg( 0, 0 )
32
				)
33
			);
34
		}
35
36
		return (bool) $this->arr[ $language ];
37
	}
38
39
	/**
40
	 * Get current link
41
	 *
42
	 * @return string
43
	 */
44
	public function get_current_link() {
45
		return get_year_link( $this->get_arg( 0, 0 ) );
46
	}
47
48
}
49