Fix isset($response->field) syntax (#34)
This commit is contained in:
parent
e6ba6d1155
commit
dbbd4a71ee
@ -121,6 +121,18 @@ class ApiResponse implements \ArrayAccess
|
|||||||
return $this->response[$name];
|
return $this->response[$name];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Allow to check if the property exists through object property
|
||||||
|
*
|
||||||
|
* @param string $name property name
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function __isset($name)
|
||||||
|
{
|
||||||
|
return isset($this->response[$name]);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Offset set
|
* Offset set
|
||||||
*
|
*
|
||||||
|
@ -230,4 +230,22 @@ class ApiResponseTest extends TestCase
|
|||||||
$response = new ApiResponse(201, '{ "success": true }');
|
$response = new ApiResponse(201, '{ "success": true }');
|
||||||
unset($response['sssssssuccess']);
|
unset($response['sssssssuccess']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group unit
|
||||||
|
*/
|
||||||
|
public function testMagicIsset()
|
||||||
|
{
|
||||||
|
$response = new ApiResponse(201, '{ "success": true }');
|
||||||
|
|
||||||
|
$this->assertTrue(
|
||||||
|
isset($response->success),
|
||||||
|
'Response object returns property existing'
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->assertFalse(
|
||||||
|
isset($response->suess),
|
||||||
|
'Response object returns property existing'
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user