Skip to content

Commit

Permalink
Fix codestyle
Browse files Browse the repository at this point in the history
  • Loading branch information
nohponex committed Oct 6, 2016
1 parent 710c8fb commit f9474cb
Show file tree
Hide file tree
Showing 58 changed files with 229 additions and 232 deletions.
5 changes: 2 additions & 3 deletions src/Controller/Controller.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
declare(strict_types=1);
/**
/*
* Copyright 2015-2016 Xenofon Spafaridis
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -220,8 +220,7 @@ function ($d) {

if ($parsed !== null) {
//overwrite
if (
$overwrite
if ($overwrite
&& (
$key = array_search(
$directiveClass,
Expand Down
6 changes: 3 additions & 3 deletions src/Controller/Delete.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
declare(strict_types=1);
/**
/*
* Copyright 2015-2016 Xenofon Spafaridis
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -41,7 +41,7 @@ public static function handleDelete(
array $validationCallbacks = [],
callable $viewCallback = null,
int $bulkLimit = null,
array $directives
array $directives = []
) : ResponseInterface {
//Validate id using model's validator
$id = $model->getIdAttributeValidator()->parse($id);
Expand All @@ -63,4 +63,4 @@ public static function handleDelete(

//204 or view callback
}
}
}
7 changes: 3 additions & 4 deletions src/Controller/Get.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
declare(strict_types=1);
/**
/*
* Copyright 2015-2016 Xenofon Spafaridis
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -48,8 +48,7 @@ public static function handleGet(
ResponseInterface $response,
ResourceModel $model,
array $directives = []
) : ResponseInterface
{
) : ResponseInterface {
//Parse request related directives from request
$directives = Controller::parseDirectives(
[
Expand Down Expand Up @@ -96,4 +95,4 @@ public static function handleGet(
)
);
}
}
}
4 changes: 2 additions & 2 deletions src/Controller/GetById.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
declare(strict_types=1);
/**
/*
* Copyright 2015-2016 Xenofon Spafaridis
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -91,4 +91,4 @@ public static function handleGetById(
)
);
}
}
}
4 changes: 2 additions & 2 deletions src/Controller/Helper/RequestBodyQueue.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
declare(strict_types=1);
/**
/*
* Copyright 2015-2016 Xenofon Spafaridis
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -55,4 +55,4 @@ public static function handleResource(

return new ResourceQueueItem($attributes, $relationships);
}
}
}
4 changes: 1 addition & 3 deletions src/Controller/Helper/ResourceQueueItem.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
declare(strict_types=1);
/**
/*
* Copyright 2015-2016 Xenofon Spafaridis
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -62,6 +62,4 @@ public function getRelationships() : \stdClass
{
return $this->relationships;
}


}
6 changes: 3 additions & 3 deletions src/Controller/Patch.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
declare(strict_types=1);
/**
/*
* Copyright 2015-2016 Xenofon Spafaridis
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -42,7 +42,7 @@ public static function handlePatch(
array $validationCallbacks = [],
callable $viewCallback = null,
int $bulkLimit = null,
array $directives
array $directives = []
) : ResponseInterface {
//Validate id using model's validator
$id = $model->getIdAttributeValidator()->parse($id);
Expand All @@ -64,4 +64,4 @@ public static function handlePatch(

//204 or view callback
}
}
}
11 changes: 5 additions & 6 deletions src/Controller/Post.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
declare(strict_types=1);
/**
/*
* Copyright 2015-2016 Xenofon Spafaridis
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -62,8 +62,7 @@ public static function handlePost(
$isBulk = true;

//Treat all request data (bulk or not) as an array of resources
if (
is_object($data)
if (is_object($data)
|| (is_array($data) && Util::isArrayAssoc($data))
) {
$isBulk = false;
Expand Down Expand Up @@ -195,15 +194,15 @@ public static function handlePost(
);
}

if (count($ids) === 1) {
/*if (count($ids) === 1) {
//Prepare response with 201 Created status code
return Response::created(
$response,
'link' . $ids[0] // location
);
}
}*/ //see https://stackoverflow.com/questions/11309444/can-the-location-header-be-used-for-multiple-resource-locations-in-a-201-created

//Return 204 No Content
return Response::noContent($response);
}
}
}
6 changes: 3 additions & 3 deletions src/Controller/Put.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
declare(strict_types=1);
/**
/*
* Copyright 2015-2016 Xenofon Spafaridis
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -41,7 +41,7 @@ public static function handlePut(
array $validationCallbacks = [],
callable $viewCallback = null,
int $bulkLimit = null,
array $directives
array $directives = []
) : ResponseInterface {
//Validate id using model's validator
$id = $model->getIdAttributeValidator()->parse($id);
Expand All @@ -63,4 +63,4 @@ public static function handlePut(

//204 or view callback
}
}
}
4 changes: 2 additions & 2 deletions src/Controller/Relationship.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
declare(strict_types=1);
/**
/*
* Copyright 2015-2016 Xenofon Spafaridis
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -24,4 +24,4 @@
*/
trait Relationship
{
}
}
2 changes: 1 addition & 1 deletion src/Controller/Response.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
declare(strict_types=1);
/**
/*
* Copyright 2015-2016 Xenofon Spafaridis
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 1 addition & 1 deletion src/DataSource/DataSource.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
declare(strict_types=1);
/**
/*
* Copyright 2015-2016 Xenofon Spafaridis
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
18 changes: 9 additions & 9 deletions src/DataSource/DatabaseDataSource.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
declare(strict_types=1);
/**
/*
* Copyright 2015-2016 Xenofon Spafaridis
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -145,7 +145,7 @@ public function requireTableSetting() : string
public function handleGet(
string $query,
bool $queryHasWhere = false,
array $directives
array $directives = []
) {
$model = $this->resourceModel;

Expand Down Expand Up @@ -223,10 +223,10 @@ private function handleSort(
);*/

$replace = "\n" . sprintf(
'ORDER BY "%s" %s',
$sortAttribute,
($sort->getAttribute() ? 'ASC' : 'DESC')
);
'ORDER BY "%s" %s',
$sortAttribute,
($sort->getAttribute() ? 'ASC' : 'DESC')
);
}

$query = str_replace(
Expand Down Expand Up @@ -289,9 +289,9 @@ private function handleFilterParseIn(array $array)
return implode(
',',
array_map(
/**
* Apply single quotes around key
*/
/**
* Apply single quotes around key
*/
function ($key) {
return '\'' . $key . '\'';
},
Expand Down
2 changes: 1 addition & 1 deletion src/Directive/AdditionalParameters.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
declare(strict_types=1);
/**
/*
* Copyright 2015-2016 Xenofon Spafaridis
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 1 addition & 1 deletion src/Directive/AdditionalRelationshipParameters.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
declare(strict_types=1);
/**
/*
* Copyright 2015-2016 Xenofon Spafaridis
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
5 changes: 2 additions & 3 deletions src/Directive/Directive.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
declare(strict_types=1);
/**
/*
* Copyright 2015-2016 Xenofon Spafaridis
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -106,8 +106,7 @@ function ($d) {

if ($parsed !== null) {
//overwrite
if (
$overwrite
if ($overwrite
&& (
$key = array_search(
$directiveClass,
Expand Down
2 changes: 1 addition & 1 deletion src/Directive/Fields.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
declare(strict_types=1);
/**
/*
* Copyright 2015-2016 Xenofon Spafaridis
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
8 changes: 5 additions & 3 deletions src/Directive/Filter.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
declare(strict_types=1);
/**
/*
* Copyright 2015-2016 Xenofon Spafaridis
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -274,7 +274,8 @@ public function validate(ResourceModel $model) : bool
} elseif ($validationModel
&& isset(
$validationModel->attributes,
$validationModel->attributes->properties->{$attribute})
$validationModel->attributes->properties->{$attribute}
)
) { //Then attempt to use attribute validation resourceModel first
$attributeValidator =
$validationModel->attributes->properties->{$attribute};
Expand All @@ -297,7 +298,8 @@ public function validate(ResourceModel $model) : bool
}

//Check if operator is allowed
if (!$isJSONFilter && !in_array(
if (!$isJSONFilter
&& !in_array(
$operator,
Operator::getByClassFlags($operatorClass)
)
Expand Down
3 changes: 1 addition & 2 deletions src/Directive/FilterAttribute.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
declare(strict_types=1);
/**
/*
* Copyright 2015-2016 Xenofon Spafaridis
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -166,5 +166,4 @@ public function getOperand()
{
return $this->operand;
}

}
3 changes: 1 addition & 2 deletions src/Directive/FilterJSONAttribute.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
declare(strict_types=1);
/**
/*
* Copyright 2015-2016 Xenofon Spafaridis
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -59,5 +59,4 @@ public function getKey()
{
return $this->key;
}

}
2 changes: 1 addition & 1 deletion src/Directive/IncludeResources.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
declare(strict_types=1);
/**
/*
* Copyright 2015-2016 Xenofon Spafaridis
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 1 addition & 1 deletion src/Directive/Page.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
declare(strict_types=1);
/**
/*
* Copyright 2015-2016 Xenofon Spafaridis
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand Down

0 comments on commit f9474cb

Please sign in to comment.