Completed
Push — add/sync-rest-2 ( ada61b...a7dbc1 )
by
unknown
09:34
created

Jetpack_Post::is_public()   A

Complexity

Conditions 4
Paths 4

Size

Total Lines 14
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 14
rs 9.2
cc 4
eloc 9
nc 4
nop 0
1
<?php
2
3
/*
4
 * WARNING: This file is distributed verbatim in Jetpack.
5
 * There should be nothing WordPress.com specific in this file.
6
 *
7
 * @hide-in-jetpack
8
 */
9
10
class Jetpack_Post extends SAL_Post {
11
	public function get_like_count() {
12
		return 0;
13
	}
14
15
	public function is_liked() {
16
		return false;
17
	}
18
19
	public function is_reblogged() {
20
		return false;
21
	}
22
23
	public function is_following() {
24
		return false;
25
	}
26
27
	public function get_global_id() {
28
		return '';
29
	}
30
31
	public function get_geo() {
32
		return false;
33
	}
34
35
	public function is_public() {
36
		if ( 0 < strlen( $this->get_password() ) ) {
37
			return false;
38
		}
39
		if ( ! in_array( $this->get_type(), get_post_types( array( 'public' => true ) ) ) ) {
40
			return false;
41
		}
42
		$post_status = get_post_status( $this->ID ); // Inherited status is resolved here.
0 ignored issues
show
Documentation introduced by
The property ID does not exist on object<Jetpack_Post>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
43
		if ( ! in_array( $post_status, get_post_stati( array( 'public' => true ) ) ) ) {
44
			return false;
45
		}
46
47
		return true;
48
	}
49
50
	public function is_excluded_from_search() {
51
		return get_post_type_object( $this->get_type() )->exclude_from_search;
52
	}
53
54
	public function get_taxonomies() {
55
		$tax = array();
56
		$taxonomies  = get_object_taxonomies( $this );
57
		foreach ( $taxonomies as $taxonomy ) {
58
			$terms = get_object_term_cache( $this->ID, $taxonomy );
0 ignored issues
show
Documentation introduced by
The property ID does not exist on object<Jetpack_Post>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
59
			if ( empty( $terms ) ) {
60
				$terms = wp_get_object_terms( $this->ID, $taxonomy );
0 ignored issues
show
Documentation introduced by
The property ID does not exist on object<Jetpack_Post>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
61
			}
62
			$term_names = array();
63
			foreach ( $terms as $term ) {
64
				$term_names[] = $term->name;
65
			}
66
			$tax[ $taxonomy ] = $term_names;
67
		}
68
		return $tax;
69
	}
70
71
	public function get_meta() {
72
		$meta = array();
73
		$metas = get_post_meta( $this->ID, false );
0 ignored issues
show
Documentation introduced by
The property ID does not exist on object<Jetpack_Post>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
74
		foreach ( $metas as $key => $value ) {
75
			$meta[ $key ] = array_map( 'maybe_unserialize', $value );
76
		}
77
		return $meta;
78
	}
79
}
80