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

Requests::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 5
nc 1
nop 0
dl 0
loc 7
rs 10
c 1
b 0
f 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
\defined('\XOOPS_ROOT_PATH') || die('Restricted access');
29
30
/**
31
 * Class Object Requests
32
 */
33
class Requests extends \XoopsObject
0 ignored issues
show
Bug introduced by
The type XoopsObject 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...
34
{
35
	/**
36
	 * Constructor
37
	 *
38
	 * @param null
39
	 */
40
	public function __construct()
41
	{
42
		$this->initVar('req_id', \XOBJ_DTYPE_INT);
0 ignored issues
show
Bug introduced by
The constant XOBJ_DTYPE_INT was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
43
		$this->initVar('req_request', \XOBJ_DTYPE_TXTBOX);
0 ignored issues
show
Bug introduced by
The constant XOBJ_DTYPE_TXTBOX was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
44
		$this->initVar('req_result', \XOBJ_DTYPE_TXTBOX);
45
		$this->initVar('req_datecreated', \XOBJ_DTYPE_INT);
46
		$this->initVar('req_submitter', \XOBJ_DTYPE_INT);
47
	}
48
49
	/**
50
	 * @static function &getInstance
51
	 *
52
	 * @param null
53
	 */
54
	public static function getInstance()
55
	{
56
		static $instance = false;
57
		if (!$instance) {
58
			$instance = new self();
59
		}
60
	}
61
62
	/**
63
	 * The new inserted $Id
64
	 * @return inserted id
0 ignored issues
show
Bug introduced by
The type XoopsModules\Wggithub\inserted 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...
65
	 */
66
	public function getNewInsertedIdRequests()
67
	{
68
		$newInsertedId = $GLOBALS['xoopsDB']->getInsertId();
69
		return $newInsertedId;
70
	}
71
72
	/**
73
	 * @public function getForm
74
	 * @param bool $action
75
	 * @return \XoopsThemeForm
76
	 */
77
	public function getFormRequests($action = false)
78
	{
79
		$helper = \XoopsModules\Wggithub\Helper::getInstance();
0 ignored issues
show
Unused Code introduced by
The assignment to $helper is dead and can be removed.
Loading history...
80
		if (!$action) {
81
			$action = $_SERVER['REQUEST_URI'];
82
		}
83
		$isAdmin = $GLOBALS['xoopsUser']->isAdmin($GLOBALS['xoopsModule']->mid());
0 ignored issues
show
Unused Code introduced by
The assignment to $isAdmin is dead and can be removed.
Loading history...
84
		// Title
85
		$title = $this->isNew() ? \sprintf(\_AM_WGGITHUB_REQUEST_ADD) : \sprintf(\_AM_WGGITHUB_REQUEST_EDIT);
0 ignored issues
show
Bug introduced by
The constant _AM_WGGITHUB_REQUEST_ADD was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
Bug introduced by
The constant _AM_WGGITHUB_REQUEST_EDIT was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
86
		// Get Theme Form
87
		\xoops_load('XoopsFormLoader');
0 ignored issues
show
Bug introduced by
The function xoops_load was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

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

87
		/** @scrutinizer ignore-call */ 
88
  \xoops_load('XoopsFormLoader');
Loading history...
88
		$form = new \XoopsThemeForm($title, 'form', $action, 'post', true);
0 ignored issues
show
Bug introduced by
The type XoopsThemeForm 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...
89
		$form->setExtra('enctype="multipart/form-data"');
90
		// Form Text reqRequest
91
		$form->addElement(new \XoopsFormText(\_AM_WGGITHUB_REQUEST_REQUEST, 'req_request', 50, 255, $this->getVar('req_request')), true);
0 ignored issues
show
Bug introduced by
The constant _AM_WGGITHUB_REQUEST_REQUEST was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
Bug introduced by
The type XoopsFormText 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...
92
		// Form Text reqResult
93
		$form->addElement(new \XoopsFormText(\_AM_WGGITHUB_REQUEST_RESULT, 'req_result', 50, 255, $this->getVar('req_result')));
0 ignored issues
show
Bug introduced by
The constant _AM_WGGITHUB_REQUEST_RESULT was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
94
		// Form Text Date Select reqDatecreated
95
		$reqDatecreated = $this->isNew() ?: $this->getVar('req_datecreated');
96
		$form->addElement(new \XoopsFormTextDateSelect(\_AM_WGGITHUB_REQUEST_DATECREATED, 'req_datecreated', '', $reqDatecreated));
0 ignored issues
show
Bug introduced by
The constant _AM_WGGITHUB_REQUEST_DATECREATED was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
Bug introduced by
The type XoopsFormTextDateSelect 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...
97
		// Form Select User reqSubmitter
98
		$form->addElement(new \XoopsFormSelectUser(\_AM_WGGITHUB_REQUEST_SUBMITTER, 'req_submitter', false, $this->getVar('req_submitter')));
0 ignored issues
show
Bug introduced by
The type XoopsFormSelectUser 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...
Bug introduced by
The constant _AM_WGGITHUB_REQUEST_SUBMITTER was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
99
		// To Save
100
		$form->addElement(new \XoopsFormHidden('op', 'save'));
0 ignored issues
show
Bug introduced by
The type XoopsFormHidden 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...
101
		$form->addElement(new \XoopsFormButtonTray('', _SUBMIT, 'submit', '', false));
0 ignored issues
show
Bug introduced by
The type XoopsFormButtonTray 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...
Bug introduced by
The constant XoopsModules\Wggithub\_SUBMIT was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
102
		return $form;
103
	}
104
105
	/**
106
	 * Get Values
107
	 * @param null $keys
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $keys is correct as it would always require null to be passed?
Loading history...
108
	 * @param null $format
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $format is correct as it would always require null to be passed?
Loading history...
109
	 * @param null $maxDepth
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $maxDepth is correct as it would always require null to be passed?
Loading history...
110
	 * @return array
111
	 */
112
	public function getValuesRequests($keys = null, $format = null, $maxDepth = null)
113
	{
114
		$ret = $this->getValues($keys, $format, $maxDepth);
115
		$ret['id']          = $this->getVar('req_id');
116
		$ret['request']     = $this->getVar('req_request');
117
		$ret['result']      = $this->getVar('req_result');
118
		$ret['datecreated'] = \formatTimestamp($this->getVar('req_datecreated'), 's');
0 ignored issues
show
Bug introduced by
The function formatTimestamp was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

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

118
		$ret['datecreated'] = /** @scrutinizer ignore-call */ \formatTimestamp($this->getVar('req_datecreated'), 's');
Loading history...
119
		$ret['submitter']   = \XoopsUser::getUnameFromId($this->getVar('req_submitter'));
0 ignored issues
show
Bug introduced by
The type XoopsUser 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...
120
		return $ret;
121
	}
122
123
	/**
124
	 * Returns an array representation of the object
125
	 *
126
	 * @return array
127
	 */
128
	public function toArrayRequests()
129
	{
130
		$ret = [];
131
		$vars = $this->getVars();
132
		foreach (\array_keys($vars) as $var) {
133
			$ret[$var] = $this->getVar('"{$var}"');
134
		}
135
		return $ret;
136
	}
137
}
138