1
0
Fork 0
mirror of synced 2024-06-23 08:40:58 +12:00

Merge pull request #2014 from Asmit2952/master

refactor-1968-fixed-PSR-issues-in-utopia-library
This commit is contained in:
Christy Jacob 2021-10-19 11:12:53 +05:30 committed by GitHub
commit 1d3a87e347
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
40 changed files with 201 additions and 188 deletions

View file

@ -2,7 +2,8 @@
namespace Appwrite\Utopia\Response;
abstract class Filter {
abstract class Filter
{
/**
* Parse the content to another format.
@ -12,6 +13,5 @@ abstract class Filter {
*
* @return array
*/
abstract function parse(array $content, string $model): array;
abstract public function parse(array $content, string $model): array;
}

View file

@ -12,11 +12,12 @@ use Exception;
use Utopia\Config\Config;
use Utopia\Locale\Locale as Locale;
class V06 extends Filter {
class V06 extends Filter
{
// Convert 0.7 Data format to 0.6 format
public function parse(array $content, string $model): array {
public function parse(array $content, string $model): array
{
$parsedResponse = [];
switch ($model) {

View file

@ -5,19 +5,25 @@ namespace Appwrite\Utopia\Response\Filters;
use Appwrite\Utopia\Response;
use Appwrite\Utopia\Response\Filter;
use Exception;
class V07 extends Filter {
class V07 extends Filter
{
// Convert 0.8 Data format to 0.7 format
public function parse(array $content, string $model): array {
public function parse(array $content, string $model): array
{
$parsedResponse = [];
switch ($model) {
case Response::MODEL_DOCUMENT_LIST: /** ANY was replaced by DOCUMENT in 0.8.x but this is backward compatible with 0.7.x */
// no break
case Response::MODEL_DOCUMENT: /** ANY was replaced by DOCUMENT in 0.8.x but this is backward compatible with 0.7.x */
// no break
case Response::MODEL_USER_LIST: /** [FIELDS ADDED in 0.8.x] passwordUpdate */
// no break
case Response::MODEL_USER: /** [FIELDS ADDED in 0.8.x] passwordUpdate */
// no break
case Response::MODEL_COLLECTION_LIST:
case Response::MODEL_COLLECTION:
case Response::MODEL_FILE_LIST:
@ -31,7 +37,9 @@ class V07 extends Filter {
case Response::MODEL_MEMBERSHIP_LIST:
case Response::MODEL_MEMBERSHIP:
case Response::MODEL_SESSION_LIST: /** [FIELDS ADDED in 0.8.x] provider, providerUid, providerToken */
// no break
case Response::MODEL_SESSION: /** [FIELDS ADDED in 0.8.x] provider, providerUid, providerToken */
// no break
case Response::MODEL_JWT:
case Response::MODEL_LOG:
case Response::MODEL_LOG_LIST:
@ -63,6 +71,7 @@ class V07 extends Filter {
case Response::MODEL_MOCK:
case Response::MODEL_ANY:
case Response::MODEL_PREFERENCES: /** ANY was replaced by PREFERENCES in 0.8.x but this is backward compatible with 0.7.x */
// no break
case Response::MODEL_NONE:
case Response::MODEL_ERROR:
case Response::MODEL_ERROR_DEV:
@ -81,13 +90,15 @@ class V07 extends Filter {
return $parsedResponse;
}
protected function parseFunction(array $content) {
protected function parseFunction(array $content)
{
$content['env'] = $content['runtime'];
unset($content['runtime']);
return $content;
}
protected function parseFunctionList(array $content){
protected function parseFunctionList(array $content)
{
$functions = $content['functions'];
$parsedResponse = [];
foreach ($functions as $function) {
@ -96,5 +107,4 @@ class V07 extends Filter {
$content['functions'] = $parsedResponse;
return $content;
}
}

View file

@ -6,12 +6,12 @@ use Appwrite\Utopia\Response;
use Appwrite\Utopia\Response\Filter;
use Exception;
class V08 extends Filter {
class V08 extends Filter
{
// Convert 0.9 Data format to 0.8 format
public function parse(array $content, string $model): array {
public function parse(array $content, string $model): array
{
$parsedResponse = [];
switch ($model) {
@ -83,13 +83,15 @@ class V08 extends Filter {
return $parsedResponse;
}
protected function parseFunction(array $content) {
protected function parseFunction(array $content)
{
$content['env'] = $content['runtime'];
unset($content['runtime']);
return $content;
}
protected function parseFunctionList(array $content){
protected function parseFunctionList(array $content)
{
$functions = $content['functions'];
$parsedResponse = [];
foreach ($functions as $function) {