Completed
Push — master ( ea28d3...1760c1 )
by Dennis
04:45
created

MslsOptionsQueryMonth::has_value()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 14
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 9
nc 2
nop 1
dl 0
loc 14
rs 9.4285
c 0
b 0
f 0
1
<?php
2
/**
3
 * MslsOptionsQueryMonth
4
 * @author Dennis Ploetner <[email protected]>
5
 * @since 0.9.8
6
 */
7
8
namespace lloc\Msls;
9
10
/**
11
 * OptionsQueryMonth
12
 *
13
 * @package Msls
14
 */
15
class MslsOptionsQueryMonth 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
	 * @return bool
22
	 */
23
	public function has_value( $language ) {
24
		if ( ! isset( $this->arr[ $language ] ) ) {
25
			$cache = MslsSqlCacher::init( __CLASS__ )->set_params( $this->args );
26
27
			$this->arr[ $language ] = $cache->get_var(
28
				$cache->prepare(
29
					"SELECT count(ID) FROM {$cache->posts} WHERE YEAR(post_date) = %d AND MONTH(post_date) = %d AND post_status = 'publish'",
30
					$this->get_arg( 0, 0 ),
31
					$this->get_arg( 1, 0 )
32
				)
33
			);
34
		}
35
		return (bool) $this->arr[ $language ];
36
	}
37
38
	/**
39
	 * Get current link
40
	 *
41
	 * @return string
42
	 */
43
	public function get_current_link() {
44
		return get_month_link( $this->get_arg( 0, 0 ), $this->get_arg( 1, 0 ) );
45
	}
46
47
}
48