Completed
Push — master ( d24e06...1436e2 )
by Dennis
02:14
created

MslsOptionsPost   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 53
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 6
Bugs 0 Features 1
Metric Value
c 6
b 0
f 1
dl 0
loc 53
rs 10
wmc 7
lcom 1
cbo 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
B get_postlink() 0 24 6
A get_current_link() 0 3 1
1
<?php
2
/**
3
 * MslsOptionsPost
4
 * @author Dennis Ploetner <[email protected]>
5
 * @since 0.9.8
6
 */
7
8
/**
9
 * Post options
10
 * @package Msls
11
 */
12
class MslsOptionsPost extends MslsOptions {
13
14
	/**
15
	 * Separator
16
	 * @var string
17
	 */
18
	protected $sep = '_';
19
20
	/**
21
	 * Autoload
22
	 * @var string
23
	 */
24
	protected $autoload = 'no';
25
26
	/**
27
	 * Get postlink
28
	 * @param string $language
29
	 * @return string
30
	 */
31
	public function get_postlink( $language ) {
32
		if ( ! $this->has_value( $language ) ) {
33
			return '';
34
		}
35
36
		$post = get_post( (int) $this->__get( $language ) );
37
		if ( is_null( $post ) || 'publish' != $post->post_status ) {
38
			return '';
39
		}
40
41
		if ( is_null( $this->with_front ) ) {
42
			$post_object      = get_post_type_object( $post->post_type );
43
			$this->with_front = ! empty( $post_object->rewrite['with_front'] );
44
		}
45
46
		global $current_site;
47
		$blog_id = MslsBlogCollection::instance()->get_blog_id( $language );
48
		if ( $current_site->blog_id != $blog_id ) {
49
			$option = get_blog_option( $blog_id, 'msls' );
0 ignored issues
show
Unused Code introduced by
$option is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
50
			//error_log( print_r( $option, true ) );
51
		}
52
53
		return apply_filters( 'check_url', get_permalink( $post ), $this );
54
	}
55
56
	/**
57
	 * Get current link
58
	 * @return string
59
	 */
60
	public function get_current_link() {
61
		return (string) get_permalink( $this->get_arg( 0, 0 ) );
62
	}
63
64
}
65