Skip to content

Commit

Permalink
Improve codestyle
Browse files Browse the repository at this point in the history
  • Loading branch information
nohponex committed Feb 14, 2016
1 parent 2667e10 commit 3e1bf12
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 22 deletions.
9 changes: 2 additions & 7 deletions src/Filter.php
Original file line number Diff line number Diff line change
Expand Up @@ -425,13 +425,8 @@ public static function parseFromParameters($parameters, $modelClass)
*/
public function __get($name)
{
switch ($name) {
case 'primary':
return $this->primary;
case 'relationships':
return $this->relationships;
case 'attributes':
return $this->attributes;
if (in_array($name, ['primary', 'relationships', 'attributes'])) {
return $this->{$name};
}

throw new \Exception(sprintf(
Expand Down
17 changes: 4 additions & 13 deletions src/Relationship.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
* @property-read int $type
* @property-read string|null $recordDataAttribute
* @property-read object $callbacks
* @property-read int $flags
* @property int $flags
*/
class Relationship
{
Expand Down Expand Up @@ -191,17 +191,8 @@ public function __construct(
*/
public function __get($name)
{
switch ($name) {
case 'modelClass':
return $this->modelClass;
case 'type':
return $this->type;
case 'recordDataAttribute':
return $this->recordDataAttribute;
case 'callbacks':
return $this->callbacks;
case 'flags':
return $this->flags;
if (in_array($name, ['modelClass', 'type', 'recordDataAttribute', 'callbacks', 'flags'])) {
return $this->{$name};
}

throw new \Exception(sprintf(
Expand All @@ -217,7 +208,7 @@ public function __get($name)
* @throws \Exception
*/
public function __set($name, $value) {
if (in_array($name, ['flag'])) {
if (in_array($name, ['flags'])) {
$this->{$name} = $value;
return $this;
}
Expand Down
4 changes: 2 additions & 2 deletions tests/src/RelationshipTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,9 @@ public function testGetFailure()
*/
public function testSet()
{
$this->relationship->{'flag'} = Relationship::FLAG_INCLUDE_BY_DEFAULT;
$this->relationship->{'flags'} = Relationship::FLAG_INCLUDE_BY_DEFAULT;

$this->assertSame(Relationship::FLAG_INCLUDE_BY_DEFAULT, $this->relationship->{'flag'});
$this->assertSame(Relationship::FLAG_INCLUDE_BY_DEFAULT, $this->relationship->{'flags'});
}

/**
Expand Down

0 comments on commit 3e1bf12

Please sign in to comment.