mirror of
https://github.com/alextselegidis/easyappointments.git
synced 2024-12-23 15:12:44 +03:00
67 lines
1.8 KiB
PHP
67 lines
1.8 KiB
PHP
<?php
|
|
|
|
/* ----------------------------------------------------------------------------
|
|
* Easy!Appointments - Open Source Web Scheduler
|
|
*
|
|
* @package EasyAppointments
|
|
* @author A.Tselegidis <alextselegidis@gmail.com>
|
|
* @copyright Copyright (c) 2013 - 2020, Alex Tselegidis
|
|
* @license http://opensource.org/licenses/GPL-3.0 - GPLv3
|
|
* @link http://easyappointments.org
|
|
* @since v1.2.0
|
|
* ---------------------------------------------------------------------------- */
|
|
|
|
namespace EA\Engine\Api\V1\Parsers;
|
|
|
|
/**
|
|
* Categories Parser
|
|
*
|
|
* This class will handle the encoding and decoding from the API requests.
|
|
*
|
|
* @deprecated
|
|
*/
|
|
class Categories implements ParsersInterface {
|
|
/**
|
|
* Encode Response Array
|
|
*
|
|
* @param array &$response The response to be encoded.
|
|
*/
|
|
public function encode(array &$response)
|
|
{
|
|
$encoded_response = [
|
|
'id' => $response['id'] !== NULL ? (int)$response['id'] : NULL,
|
|
'name' => $response['name'],
|
|
'description' => $response['description']
|
|
];
|
|
|
|
$response = $encoded_response;
|
|
}
|
|
|
|
/**
|
|
* Decode Request
|
|
*
|
|
* @param array &$request The request to be decoded.
|
|
* @param array $base Optional (null), if provided it will be used as a base array.
|
|
*/
|
|
public function decode(array &$request, array $base = NULL)
|
|
{
|
|
$decoded_request = $base ?: [];
|
|
|
|
if ( ! empty($request['id']))
|
|
{
|
|
$decoded_request['id'] = $request['id'];
|
|
}
|
|
|
|
if ( ! empty($request['name']))
|
|
{
|
|
$decoded_request['name'] = $request['name'];
|
|
}
|
|
|
|
if ( ! empty($request['description']))
|
|
{
|
|
$decoded_request['description'] = $request['description'];
|
|
}
|
|
|
|
$request = $decoded_request;
|
|
}
|
|
}
|