Skip to content

Commit

Permalink
Applied fixes from StyleCI
Browse files Browse the repository at this point in the history
  • Loading branch information
nohponex authored and StyleCIBot committed Feb 5, 2016
1 parent 0983044 commit 5a0798a
Show file tree
Hide file tree
Showing 15 changed files with 6 additions and 25 deletions.
2 changes: 1 addition & 1 deletion src/Fields.php
Expand Up @@ -146,7 +146,7 @@ public static function parseFromParameters($parameters, $primaryResourceModelCla
if ($primaryResourceModelClass::getType() == $resourceType) {
//check if $resourceType allowed (primary)
$modelClass = $primaryResourceModelClass;
} else if($primaryResourceModelClass::relationshipExists($resourceType)) {
} elseif ($primaryResourceModelClass::relationshipExists($resourceType)) {
//check if $resourceType allowed (primary's relationships)
$modelClass = $primaryResourceModelClass::getRelationship($resourceType)->modelClass;
} else {
Expand Down
3 changes: 0 additions & 3 deletions src/Filter.php
Expand Up @@ -114,7 +114,6 @@ public function __construct(
$relationshipKey
));
}

}

if (!Util::isArrayOf($filterAttributes, FilterAttribute::class)) {
Expand Down Expand Up @@ -193,7 +192,6 @@ public function validate($modelClass)
$filterable = $modelClass::getFilterable();

foreach ($this->attributes as $filterAttribute) {

$isJSONFilter = ($filterAttribute instanceof FilterJSONAttribute);

if (!property_exists($filterable, $filterAttribute->attribute)) {
Expand Down Expand Up @@ -316,7 +314,6 @@ public static function parseFromParameters($parameters, $modelClass)
$filterAttributes = [];

foreach ($parameters->filter as $filterKey => $filterValue) {

if ($filterKey === $modelClass::getType()) { //Filter primary data
//Check filter value type
if (!is_string($filterValue) && !is_integer($filterValue)) {
Expand Down
4 changes: 1 addition & 3 deletions src/Model/Directives.php
Expand Up @@ -205,7 +205,6 @@ protected static function handleFilter(
$additionalQuery = [];

if ($filter !== null) {

$filter->validate(static::class);

if (count($filter->primary)) {
Expand Down Expand Up @@ -297,7 +296,7 @@ protected static function handleFilter(
Operator::OPERATOR_NOT_IN_ARRAY => '= ANY' // External not
];

$additionalQuery[] = sprintf( //$operand ANY (array)
$additionalQuery[] = sprintf(//$operand ANY (array)
'%s %s (\'%s\' %s("%s"."%s")) ',
($hasWhere ? 'AND' : 'WHERE'),
(
Expand Down Expand Up @@ -367,7 +366,6 @@ protected static function handleFilter(

//Apply filters only for JSON attributes
foreach ($filter->attributes as $filterValue) {

if (!($filterValue instanceof FilterJSONAttribute)) {
continue;
}
Expand Down
10 changes: 4 additions & 6 deletions src/Resource.php
Expand Up @@ -157,10 +157,10 @@ public static function parseFromRecord(
return null;
}

$flagAttributes = ($flags & Resource::PARSE_ATTRIBUTES ) != 0;
$flagLinks = ($flags & Resource::PARSE_LINKS ) != 0;
$flagRelationships = ($flags & Resource::PARSE_RELATIONSHIP ) != 0;
$flagRelationshipsLinks = ($flags & Resource::PARSE_RELATIONSHIP_LINKS ) != 0;
$flagAttributes = ($flags & Resource::PARSE_ATTRIBUTES) != 0;
$flagLinks = ($flags & Resource::PARSE_LINKS) != 0;
$flagRelationships = ($flags & Resource::PARSE_RELATIONSHIP) != 0;
$flagRelationshipsLinks = ($flags & Resource::PARSE_RELATIONSHIP_LINKS) != 0;

//Work with objects
if (!is_object($record) && is_array($record)) {
Expand Down Expand Up @@ -220,7 +220,6 @@ public static function parseFromRecord(

//Attach relationship links
if ($flagRelationshipsLinks) {

$relationshipEntry->links = [
'self' => $modelClass::getSelfLink(
$resource->id . '/relationships/' . $relationshipKey
Expand Down Expand Up @@ -258,7 +257,6 @@ public static function parseFromRecord(
};

if ($relationshipType == Relationship::TYPE_TO_ONE) {

$relationshipEntryResource = null;

if (isset($record->{$recordDataAttribute}) && $record->{$recordDataAttribute}) { //preloaded
Expand Down
1 change: 0 additions & 1 deletion src/Sort.php
Expand Up @@ -117,7 +117,6 @@ public static function parseFromParameters($parameters, $modelClass)
? false
: true
);

} else {
throw new RequestException(
'Invalid value for sort'
Expand Down
1 change: 0 additions & 1 deletion tests/src/ControllerTest.php
Expand Up @@ -39,7 +39,6 @@ protected function setUp()
*/
protected function tearDown()
{

}

public function testExtends()
Expand Down
1 change: 0 additions & 1 deletion tests/src/Controllers/DELETETest.php
Expand Up @@ -42,7 +42,6 @@ class DELETETest extends \PHPUnit_Framework_TestCase
*/
protected function setUp()
{

}

protected function prepare()
Expand Down
1 change: 0 additions & 1 deletion tests/src/Controllers/GETByIdTest.php
Expand Up @@ -42,7 +42,6 @@ class GETByIdTest extends \PHPUnit_Framework_TestCase
*/
protected function setUp()
{

}

protected function prepare()
Expand Down
1 change: 0 additions & 1 deletion tests/src/Controllers/GETTest.php
Expand Up @@ -38,7 +38,6 @@ class GETTest extends \PHPUnit_Framework_TestCase
*/
protected function setUp()
{

}

protected function prepare()
Expand Down
1 change: 0 additions & 1 deletion tests/src/Controllers/PATCHTest.php
Expand Up @@ -41,7 +41,6 @@ class PATCHTest extends \PHPUnit_Framework_TestCase
*/
protected function setUp()
{

}

protected function prepare()
Expand Down
1 change: 0 additions & 1 deletion tests/src/Controllers/POSTTest.php
Expand Up @@ -43,7 +43,6 @@ class POSTTest extends \PHPUnit_Framework_TestCase
*/
protected function setUp()
{

}

protected function prepare()
Expand Down
1 change: 0 additions & 1 deletion tests/src/Controllers/RelationshipsTest.php
Expand Up @@ -42,7 +42,6 @@ class RelationshipsTest extends \PHPUnit_Framework_TestCase
*/
protected function setUp()
{

}

protected function prepare()
Expand Down
1 change: 0 additions & 1 deletion tests/src/FilterTest.php
Expand Up @@ -203,7 +203,6 @@ public function testParseFromParameters()
$found2 = false;

foreach ($filter->attributes as $filterAttribute) {

if ($shouldContain1 == $filterAttribute) {
$found1 = true;
} elseif ($shouldContain2 == $filterAttribute) {
Expand Down
1 change: 0 additions & 1 deletion tests/src/Model/CacheTest.php
Expand Up @@ -52,7 +52,6 @@ protected function get($limit = 1, $offset = 0)
*/
public function testInitializeCache()
{

Bootstrap::invokeStaticMethod(
Article::class,
'getCache',
Expand Down
2 changes: 0 additions & 2 deletions tests/src/ModelTest.php
Expand Up @@ -119,7 +119,6 @@ public function testGetSortable($modelClass)

$this->assertInternalType('array', $fields);
$this->assertTrue(Util::isArrayOf($fields, 'string'));

}

/**
Expand All @@ -133,7 +132,6 @@ public function testGetFields($modelClass)

$this->assertInternalType('array', $fields);
$this->assertTrue(Util::isArrayOf($fields, 'string'));

}

/**
Expand Down

0 comments on commit 5a0798a

Please sign in to comment.