Completed
Push — develop ( dd1349...b32a8d )
by David
04:25
created

Wordlift_Post_Adapter::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
1
<?php
2
/**
3
 * An adapter to access and manipulate single post data for WordLift needs
4
 *
5
 * @since      3.14.0
6
 * @package    Wordlift
7
 * @subpackage Wordlift/admin
8
 */
9
10
/**
11
 * Define the {@link Wordlift_Post_Adatpter}.
12
 *
13
 * @since      3.14.0
14
 * @package    Wordlift
15
 * @subpackage Wordlift/admin
16
 */
17
class Wordlift_Post_Adapter {
18
19
	/**
20
	 * The post id to which the adopter relates.
21
	 *
22
	 * @since 3.14.0
23
	 *
24
	 * @var integer $post_id .
25
	 */
26
	private $post_id;
27
28
	/**
29
	 * Create the {@link Wordlift_Post_Adatpter} instance.
30
	 *
31
	 * @since 3.14.0
32
	 *
33
	 * @param integer $post_id the post ID of the post the adopter relates to.
34
	 */
35
	function __construct( $post_id ) {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
36
37
		$this->post_id = $post_id;
38
39
	}
40
41
	/**
42
	 * Get the word count of the post content.
43
	 *
44
	 * The count is calculated over the post content after stripping shortcodes and html tags.
45
	 *
46
	 * @since 3.14.0
47
	 *
48
	 * @return integer the number of words in the content after stripping shortcodes and html tags..
49
	 */
50
	public function word_count() {
51
52
		$post = get_post( $this->post_id );
53
54
		return str_word_count( strip_tags( strip_shortcodes( $post->post_content ) ) );
55
	}
56
57
}
58