Passed
Pull Request — develop (#922)
by Tito
07:09
created

RedcoreTableWebservice_History_Log   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 145
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
eloc 37
c 1
b 0
f 0
dl 0
loc 145
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A check() 0 36 3
A __construct() 0 5 1
1
<?php
2
/**
3
 * @package     Redcore.Backend
4
 * @subpackage  Tables
5
 *
6
 * @copyright   Copyright (C) 2008 - 2016 redCOMPONENT.com. All rights reserved.
7
 * @license     GNU General Public License version 2 or later, see LICENSE.
8
 */
9
10
defined('_JEXEC') or die;
11
12
/**
13
 * Webservice table.
14
 *
15
 * @package     Redcore.Backend
16
 * @subpackage  Tables
17
 * @since       1.4
18
 */
19
class RedcoreTableWebservice_History_Log extends RTable
20
{
21
	/**
22
	 * @var  int
23
	 */
24
	public $id;
25
26
	/**
27
	 * @var  string
28
	 */
29
	public $webservice_name;
30
31
	/**
32
	 * @var  string
33
	 */
34
	public $webservice_version;
35
36
	/**
37
	 * @var  string
38
	 */
39
	public $webservice_client;
40
41
	/**
42
	 * @var  string
43
	 */
44
	public $url;
45
46
	/**
47
	 * @var string
48
	 */
49
	public $authentication;
50
51
	/**
52
	 * @var string
53
	 */
54
	public $authentication_user;
55
56
	/**
57
	 * @var string
58
	 */
59
	public $operation;
60
61
	/**
62
	 * @var string
63
	 */
64
	public $method;
65
66
	/**
67
	 * @var int
68
	 */
69
	public $using_soap;
70
71
	/**
72
	 * @var int
73
	 */
74
	public $execution_time;
75
76
	/**
77
	 * @var int
78
	 */
79
	public $execution_memory;
80
81
	/**
82
	 * @var string
83
	 */
84
	public $messages;
85
86
	/**
87
	 * @var string
88
	 */
89
	public $file_name;
90
91
	/**
92
	 * @var string
93
	 */
94
	public $status;
95
96
	/**
97
	 * @var int
98
	 */
99
	public $created_by;
100
101
	/**
102
	 * @var string
103
	 */
104
	public $created_date;
105
106
	/**
107
	 * Constructor
108
	 *
109
	 * @param   JDatabase  &$db  A database connector object
110
	 *
111
	 * @throws  UnexpectedValueException
112
	 */
113
	public function __construct(&$db)
114
	{
115
		$this->_tableName = 'redcore_webservice_history_log';
116
117
		parent::__construct($db);
118
	}
119
120
	/**
121
	 * Checks that the object is valid and able to be stored.
122
	 *
123
	 * This method checks that the parent_id is non-zero and exists in the database.
124
	 * Note that the root node (parent_id = 0) cannot be manipulated with this class.
125
	 *
126
	 * @return  boolean  True if all checks pass.
127
	 */
128
	public function check()
129
	{
130
		$this->webservice_client  = trim($this->webservice_client);
131
		$this->webservice_name    = trim($this->webservice_name);
132
		$this->webservice_version = trim($this->webservice_version);
133
134
		$version = '1.0.0';
135
136
		if (!empty($this->webservice_version))
137
		{
138
			$matches = array();
139
140
			// Major
141
			$versionPattern = '/^(?<version>[0-9]+\.[0-9]+\.[0-9]+)$/';
142
143
			// Match the possible parts of a SemVer
144
			$matched = preg_match(
145
				$versionPattern,
146
				$this->webservice_version,
147
				$matches
148
			);
149
150
			// No match, invalid
151
			if (!$matched)
152
			{
153
				$this->setError(JText::_('COM_REDCORE_WEBSERVICE_VERSION_WRONG_FORMAT'));
0 ignored issues
show
Deprecated Code introduced by
The function JObject::setError() has been deprecated: 12.3 JError has been deprecated ( Ignorable by Annotation )

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

153
				/** @scrutinizer ignore-deprecated */ $this->setError(JText::_('COM_REDCORE_WEBSERVICE_VERSION_WRONG_FORMAT'));

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
154
155
				return false;
156
			}
157
158
			$version = $matches['version'];
159
		}
160
161
		$this->webservice_version = $version;
162
163
		return true;
164
	}
165
}
166