Passed
Push — master ( 3d7fba...dbde9b )
by Goffy
03:57
created

RequestsHandler   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 91
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 16
dl 0
loc 91
rs 10
c 1
b 0
f 1
wmc 7

7 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A create() 0 3 1
A getInsertId() 0 3 1
A getAllRequests() 0 5 1
A getRequestsCriteria() 0 7 1
A get() 0 3 1
A getCountRequests() 0 5 1
1
<?php
2
3
namespace XoopsModules\Wggithub;
4
5
/*
6
 You may not change or alter any portion of this comment or credits
7
 of supporting developers from this source code or any supporting source code
8
 which is considered copyrighted (c) material of the original comment or credit authors.
9
10
 This program is distributed in the hope that it will be useful,
11
 but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13
*/
14
15
/**
16
 * wgGitHub module for xoops
17
 *
18
 * @copyright      2020 XOOPS Project (https://xooops.org)
19
 * @license        GPL 2.0 or later
20
 * @package        wggithub
21
 * @since          1.0
22
 * @min_xoops      2.5.10
23
 * @author         TDM XOOPS - Email:<[email protected]> - Website:<https://wedega.com>
24
 */
25
26
use XoopsModules\Wggithub;
27
28
29
/**
30
 * Class Object Handler Requests
31
 */
32
class RequestsHandler extends \XoopsPersistableObjectHandler
0 ignored issues
show
Bug introduced by
The type XoopsPersistableObjectHandler was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
33
{
34
	/**
35
	 * Constructor
36
	 *
37
	 * @param \XoopsDatabase $db
38
	 */
39
	public function __construct(\XoopsDatabase $db)
0 ignored issues
show
Bug introduced by
The type XoopsDatabase was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
40
	{
41
		parent::__construct($db, 'wggithub_requests', Requests::class, 'req_id', 'req_request');
42
	}
43
44
	/**
45
	 * @param bool $isNew
46
	 *
47
	 * @return object
48
	 */
49
	public function create($isNew = true)
50
	{
51
		return parent::create($isNew);
52
	}
53
54
	/**
55
	 * retrieve a field
56
	 *
57
	 * @param int $i field id
58
	 * @param null fields
0 ignored issues
show
Bug introduced by
The type XoopsModules\Wggithub\fields was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
59
	 * @return mixed reference to the {@link Get} object
60
	 */
61
	public function get($i = null, $fields = null)
62
	{
63
		return parent::get($i, $fields);
64
	}
65
66
	/**
67
	 * get inserted id
68
	 *
69
	 * @param null
70
	 * @return int reference to the {@link Get} object
71
	 */
72
	public function getInsertId()
73
	{
74
		return $this->db->getInsertId();
75
	}
76
77
	/**
78
	 * Get Count Requests in the database
79
	 * @param int    $start
80
	 * @param int    $limit
81
	 * @param string $sort
82
	 * @param string $order
83
	 * @return int
84
	 */
85
	public function getCountRequests($start = 0, $limit = 0, $sort = 'req_id ASC, req_request', $order = 'ASC')
86
	{
87
		$crCountRequests = new \CriteriaCompo();
0 ignored issues
show
Bug introduced by
The type CriteriaCompo was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
88
		$crCountRequests = $this->getRequestsCriteria($crCountRequests, $start, $limit, $sort, $order);
89
		return $this->getCount($crCountRequests);
90
	}
91
92
	/**
93
	 * Get All Requests in the database
94
	 * @param int    $start
95
	 * @param int    $limit
96
	 * @param string $sort
97
	 * @param string $order
98
	 * @return array
99
	 */
100
	public function getAllRequests($start = 0, $limit = 0, $sort = 'req_id ASC, req_request', $order = 'ASC')
101
	{
102
		$crAllRequests = new \CriteriaCompo();
103
		$crAllRequests = $this->getRequestsCriteria($crAllRequests, $start, $limit, $sort, $order);
104
		return $this->getAll($crAllRequests);
105
	}
106
107
	/**
108
	 * Get Criteria Requests
109
	 * @param        $crRequests
110
	 * @param int    $start
111
	 * @param int    $limit
112
	 * @param string $sort
113
	 * @param string $order
114
	 * @return int
115
	 */
116
	private function getRequestsCriteria($crRequests, $start, $limit, $sort, $order)
117
	{
118
		$crRequests->setStart($start);
119
		$crRequests->setLimit($limit);
120
		$crRequests->setSort($sort);
121
		$crRequests->setOrder($order);
122
		return $crRequests;
123
	}
124
}
125