Issues (1358)

modules/Blogs/Helpers.php (4 issues)

1
<?php
2
/**
3
 * @package  Blogs
4
 * @category modules
5
 * @author   Nazar Mokrynskyi <[email protected]>
6
 * @license  0BSD
7
 */
8
namespace cs\modules\Blogs;
9
use
10
	cs\Config,
11
	cs\Language\Prefix,
12
	cs\Page,
13
	h;
14
15
class Helpers {
16
	/**
17
	 * Return HTML with posts list
18
	 *
19
	 * @param int[]  $posts
20
	 * @param int    $posts_count
21
	 * @param int    $page
22
	 * @param string $base_url
23
	 */
24
	public static function show_posts_list ($posts, $posts_count, $page, $base_url) {
25
		$module_data = Config::instance()->module('Blogs');
26
		$L           = new Prefix('blogs_');
27
		$Page        = Page::instance();
28
		$Page->content(
29
			h::cs_blogs_head_actions()
0 ignored issues
show
The method cs_blogs_head_actions() does not exist on h. Since you implemented __callStatic, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

29
			h::/** @scrutinizer ignore-call */ 
30
      cs_blogs_head_actions()
Loading history...
30
		);
31
		if (!$posts) {
32
			$Page->content(
33
				h::{'p.cs-text-center'}($L->no_posts_yet)
0 ignored issues
show
Bug Best Practice introduced by
The property no_posts_yet does not exist on cs\Language\Prefix. Since you implemented __get, consider adding a @property annotation.
Loading history...
34
			);
35
			return;
36
		}
37
		$Page->content(
38
			h::{'cs-blogs-posts script[type=application/ld+json]'}(
39
				json_encode(
40
					Posts::instance()->get_as_json_ld($posts),
41
					JSON_UNESCAPED_UNICODE
42
				)
43
			).
44
			h::{'.cs-block-margin.cs-text-center.cs-margin cs-pagination'}(
45
				pages(
46
					$page,
47
					ceil($posts_count / $module_data->posts_per_page),
0 ignored issues
show
Bug Best Practice introduced by
The property posts_per_page does not exist on cs\Config\Module_Properties. Since you implemented __get, consider adding a @property annotation.
Loading history...
ceil($posts_count / $module_data->posts_per_page) of type double is incompatible with the type integer expected by parameter $total of pages(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

47
					/** @scrutinizer ignore-type */ ceil($posts_count / $module_data->posts_per_page),
Loading history...
48
					function ($page) use ($base_url) {
49
						return $base_url.($page > 1 ? "/$page" : '');
50
					},
51
					true
52
				)
53
			)
54
		);
55
	}
56
}
57