MslsOptionsQueryAuthor   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
dl 0
loc 32
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 13 2
A get_current_link() 0 3 1
1
<?php
2
/**
3
 * MslsOptionsQueryAuthor
4
 * @author Dennis Ploetner <[email protected]>
5
 * @since 0.9.8
6
 */
7
8
namespace lloc\Msls;
9
10
/**
11
 * OptionsQueryAuthor
12
 *
13
 * @package Msls
14
 */
15
class MslsOptionsQueryAuthor 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 post_author = %d AND post_status = 'publish'",
30
					$this->get_arg( 0, 0 )
31
				)
32
			);
33
		}
34
		return (bool) $this->arr[ $language ];
35
	}
36
37
	/**
38
	 * Get current link
39
	 *
40
	 * @return string
41
	 */
42
	public function get_current_link() {
43
		return get_author_posts_url( $this->get_arg( 0, 0 ) );
44
	}
45
46
}
47