Clean code

This commit is contained in:
Laurent Destailleur 2024-01-26 03:35:00 +01:00
parent 3a6468dd33
commit f39a439895
2 changed files with 11 additions and 12 deletions

View file

@ -423,7 +423,7 @@ class Members extends DolibarrApi
* Validate fields before creating an object
*
* @param array|null $data Data to validate
* @return array
* @return array Return array with validated mandatory fields and their value
*
* @throws RestException
*/
@ -443,8 +443,8 @@ class Members extends DolibarrApi
/**
* Clean sensible object datas
*
* @param Object $object Object to clean
* @return Object Object with cleaned properties
* @param Object $object Object to clean
* @return Object Object with cleaned properties
*/
protected function _cleanObjectDatas($object)
{

View file

@ -70,7 +70,8 @@ class Categories extends DolibarrApi
*/
public function __construct()
{
global $db, $conf;
global $db;
$this->db = $db;
$this->category = new Categorie($this->db);
}
@ -133,8 +134,6 @@ class Categories extends DolibarrApi
*/
public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $type = '', $sqlfilters = '', $properties = '')
{
global $db, $conf;
$obj_ret = array();
if (!DolibarrApiAccess::$user->rights->categorie->lire) {
@ -198,8 +197,8 @@ class Categories extends DolibarrApi
throw new RestException(401);
}
// Check mandatory fields
$result = $this->_validate($request_data);
// Check mandatory fields (throw an exception if wrong)
$this->_validate($request_data);
foreach ($request_data as $field => $value) {
if ($field === 'caller') {
@ -666,8 +665,8 @@ class Categories extends DolibarrApi
/**
* Clean sensible object datas
*
* @param Categorie $object Object to clean
* @return Object Object with cleaned properties
* @param Categorie $object Object to clean
* @return Object Object with cleaned properties
*/
protected function _cleanObjectDatas($object)
{
@ -722,8 +721,8 @@ class Categories extends DolibarrApi
/**
* Validate fields before create or update object
*
* @param array|null $data Data to validate
* @return array
* @param array|null $data Data to validate
* @return array Return array with validated mandatory fields and their value
*
* @throws RestException
*/