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

MslsOptionsQueryDay::get_current_link()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * MslsOptionsQueryDay
4
 * @author Dennis Ploetner <[email protected]>
5
 * @since 0.9.8
6
 */
7
8
namespace lloc\Msls;
9
10
/**
11
 * OptionsQueryDay
12
 *
13
 * @package Msls
14
 */
15
class MslsOptionsQueryDay 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
			$date  = new \DateTime();
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 DATE(post_date) = %s AND post_status = 'publish'",
31
					$date->setDate( $this->get_arg( 0, 0 ), $this->get_arg( 1, 0 ), $this->get_arg( 2, 0 ) )->format( 'Y-m-d' )
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_day_link( $this->get_arg( 0, 0 ), $this->get_arg( 1, 0 ), $this->get_arg( 2, 0 ) );
45
	}
46
47
}
48