Skip to content

Commit

Permalink
Update code style
Browse files Browse the repository at this point in the history
  • Loading branch information
Art4 committed Nov 28, 2023
1 parent 5b94439 commit 73b67e7
Show file tree
Hide file tree
Showing 25 changed files with 67 additions and 67 deletions.
10 changes: 5 additions & 5 deletions src/Helper/AccessableTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ final public function getKeys(): array
*/
final public function has($key): bool
{
if (! is_int($key) && ! is_string($key) && (! is_object($key) || ! $key instanceof AccessKey)) {
if (!is_int($key) && !is_string($key) && (!is_object($key) || !$key instanceof AccessKey)) {
trigger_error(sprintf(
'%s::has(): Providing Argument #1 ($key) as `%s` is deprecated since 1.2.0, please provide as `int|string` instead.',
get_class($this),
Expand All @@ -74,14 +74,14 @@ final public function has($key): bool
return array_key_exists($string, $this->data);
}

if (! array_key_exists($string, $this->data)) {
if (!array_key_exists($string, $this->data)) {
return false;
}

$value = $this->getValue($string);

// #TODO Handle other objects and arrays
if (! $value instanceof Accessable) {
if (!$value instanceof Accessable) {
// throw new AccessException('The existance for the key "' . $key->raw . '" could\'nt be checked.');
return false;
}
Expand All @@ -98,7 +98,7 @@ final public function has($key): bool
*/
public function get($key)
{
if (! is_int($key) && ! is_string($key) && (! is_object($key) || ! $key instanceof AccessKey)) {
if (!is_int($key) && !is_string($key) && (!is_object($key) || !$key instanceof AccessKey)) {
trigger_error(sprintf(
'%s::get(): Providing Argument #1 ($key) as `%s` is deprecated since 1.2.0, please provide as `int|string` instead.',
get_class($this),
Expand All @@ -120,7 +120,7 @@ public function get($key)
}

// #TODO Handle other objects and arrays
if (! $value instanceof Accessable) {
if (!$value instanceof Accessable) {
throw new AccessException('Could not get the value for the key "' . $key->raw . '".');
}

Expand Down
2 changes: 1 addition & 1 deletion src/Input/RequestStringInput.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function getAsObject(): \stdClass
{
$data = $this->decodeJson($this->rawString);

if (! $data instanceof \stdClass) {
if (!$data instanceof \stdClass) {
throw new InputException('JSON must contain an object (e.g. `{}`).');
}

Expand Down
2 changes: 1 addition & 1 deletion src/Input/ResponseStringInput.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function getAsObject(): \stdClass
{
$data = $this->decodeJson($this->rawString);

if (! $data instanceof \stdClass) {
if (!$data instanceof \stdClass) {
throw new InputException('JSON must contain an object (e.g. `{}`).');
}

Expand Down
2 changes: 1 addition & 1 deletion src/Input/StringInputTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ trait StringInputTrait
*/
final public function prepareString($string): string
{
if (! is_string($string)) {
if (!is_string($string)) {
throw new InputException(sprintf(
'$string must be a string, "%s" given.',
gettype($string)
Expand Down
2 changes: 1 addition & 1 deletion src/Serializer/ArraySerializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public function serialize(Accessable $data): ?array
*/
private function objectTransform($val)
{
if (! is_object($val)) {
if (!is_object($val)) {
return $val;
} elseif ($val instanceof Accessable) {
return $this->serialize($val);
Expand Down
2 changes: 1 addition & 1 deletion src/V1/Attributes.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ final class Attributes extends AbstractElement
*/
protected function parse($object): void
{
if (! is_object($object)) {
if (!is_object($object)) {
throw new ValidationException('Attributes has to be an object, "' . gettype($object) . '" given.');
}

Expand Down
8 changes: 4 additions & 4 deletions src/V1/Document.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ final class Document extends AbstractElement
*/
protected function parse($object): void
{
if (! is_object($object)) {
if (!is_object($object)) {
throw new ValidationException('Document has to be an object, "' . gettype($object) . '" given.');
}

if (! property_exists($object, 'data') and ! property_exists($object, 'meta') and ! property_exists($object, 'errors')) {
if (!property_exists($object, 'data') and !property_exists($object, 'meta') and !property_exists($object, 'errors')) {
throw new ValidationException('Document MUST contain at least one of the following properties: data, errors, meta');
}

Expand All @@ -55,7 +55,7 @@ protected function parse($object): void
}

if (property_exists($object, 'included')) {
if (! property_exists($object, 'data')) {
if (!property_exists($object, 'data')) {
throw new ValidationException('If Document does not contain a `data` property, the `included` property MUST NOT be present either.');
}

Expand Down Expand Up @@ -104,7 +104,7 @@ private function parseData($data): Accessable
return $this->create('ResourceCollection', $data);
}

if (! is_object($data)) {
if (!is_object($data)) {
throw new ValidationException('Data value has to be null or an object, "' . gettype($data) . '" given.');
}

Expand Down
10 changes: 5 additions & 5 deletions src/V1/DocumentLink.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ final class DocumentLink extends AbstractElement
*/
protected function parse($object): void
{
if (! is_object($object)) {
if (!is_object($object)) {
throw new ValidationException(
'DocumentLink has to be an object, "' . gettype($object) . '" given.'
);
Expand All @@ -43,7 +43,7 @@ protected function parse($object): void
$links = get_object_vars($object);

if (array_key_exists('self', $links)) {
if (! is_string($links['self']) and ! is_object($links['self'])) {
if (!is_string($links['self']) and !is_object($links['self'])) {
throw new ValidationException(
'property "self" has to be a string or object, "' .
gettype($links['self']) . '" given.'
Expand All @@ -56,7 +56,7 @@ protected function parse($object): void
}

if (array_key_exists('related', $links)) {
if (! is_string($links['related']) and ! is_object($links['related'])) {
if (!is_string($links['related']) and !is_object($links['related'])) {
throw new ValidationException(
'property "related" has to be a string or object, "' .
gettype($links['related']) . '" given.'
Expand Down Expand Up @@ -125,7 +125,7 @@ public function get($key)
*/
private function setPaginationLink(string $name, $value): void
{
if (! is_object($value) and ! is_string($value) and ! is_null($value)) {
if (!is_object($value) and !is_string($value) and !is_null($value)) {
throw new ValidationException(
'property "' . $name . '" has to be an object, a string or null, "' .
gettype($value) . '" given.'
Expand All @@ -147,7 +147,7 @@ private function setPaginationLink(string $name, $value): void
*/
private function setLink(string $name, $link): void
{
if (! is_string($link) and ! is_object($link)) {
if (!is_string($link) and !is_object($link)) {
throw new ValidationException(
'Link attribute has to be an object or string, "' .
gettype($link) . '" given.'
Expand Down
12 changes: 6 additions & 6 deletions src/V1/Error.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ final class Error extends AbstractElement
*/
protected function parse($object): void
{
if (! is_object($object)) {
if (!is_object($object)) {
throw new ValidationException(
'Error has to be an object, "' . gettype($object) . '" given.'
);
}

if (property_exists($object, 'id')) {
if (! is_string($object->id)) {
if (!is_string($object->id)) {
throw new ValidationException(
'property "id" has to be a string, "' .
gettype($object->id) . '" given.'
Expand All @@ -51,7 +51,7 @@ protected function parse($object): void
}

if (property_exists($object, 'status')) {
if (! is_string($object->status)) {
if (!is_string($object->status)) {
throw new ValidationException(
'property "status" has to be a string, "' .
gettype($object->status) . '" given.'
Expand All @@ -62,7 +62,7 @@ protected function parse($object): void
}

if (property_exists($object, 'code')) {
if (! is_string($object->code)) {
if (!is_string($object->code)) {
throw new ValidationException(
'property "code" has to be a string, "' .
gettype($object->code) . '" given.'
Expand All @@ -73,7 +73,7 @@ protected function parse($object): void
}

if (property_exists($object, 'title')) {
if (! is_string($object->title)) {
if (!is_string($object->title)) {
throw new ValidationException(
'property "title" has to be a string, "' .
gettype($object->title) . '" given.'
Expand All @@ -84,7 +84,7 @@ protected function parse($object): void
}

if (property_exists($object, 'detail')) {
if (! is_string($object->detail)) {
if (!is_string($object->detail)) {
throw new ValidationException(
'property "detail" has to be a string, "' .
gettype($object->detail) . '" given.'
Expand Down
2 changes: 1 addition & 1 deletion src/V1/ErrorCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ final class ErrorCollection extends AbstractElement
*/
protected function parse($object): void
{
if (! is_array($object)) {
if (!is_array($object)) {
throw new ValidationException('Errors for a collection has to be in an array, "' . gettype($object) . '" given.');
}

Expand Down
8 changes: 4 additions & 4 deletions src/V1/ErrorLink.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,17 @@ final class ErrorLink extends AbstractElement
*/
protected function parse($object): void
{
if (! is_object($object)) {
if (!is_object($object)) {
throw new ValidationException('Link has to be an object, "' . gettype($object) . '" given.');
}

$links = get_object_vars($object);

if (! array_key_exists('about', $links)) {
if (!array_key_exists('about', $links)) {
throw new ValidationException('ErrorLink MUST contain these properties: about');
}

if (! is_string($links['about']) and ! is_object($links['about'])) {
if (!is_string($links['about']) and !is_object($links['about'])) {
throw new ValidationException('Link has to be an object or string, "' . gettype($links['about']) . '" given.');
}

Expand Down Expand Up @@ -85,7 +85,7 @@ public function get($key)
*/
private function setLink(string $name, $link): void
{
if (! is_string($link) and ! is_object($link)) {
if (!is_string($link) and !is_object($link)) {
throw new ValidationException('Link attribute has to be an object or string, "' . gettype($link) . '" given.');
}

Expand Down
6 changes: 3 additions & 3 deletions src/V1/ErrorSource.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,20 @@ final class ErrorSource extends AbstractElement
*/
protected function parse($object): void
{
if (! is_object($object)) {
if (!is_object($object)) {
throw new ValidationException('ErrorSource has to be an object, "' . gettype($object) . '" given.');
}

if (property_exists($object, 'pointer')) {
if (! is_string($object->pointer)) {
if (!is_string($object->pointer)) {
throw new ValidationException('property "pointer" has to be a string, "' . gettype($object->pointer) . '" given.');
}

$this->set('pointer', strval($object->pointer));
}

if (property_exists($object, 'parameter')) {
if (! is_string($object->parameter)) {
if (!is_string($object->parameter)) {
throw new ValidationException('property "parameter" has to be a string, "' . gettype($object->parameter) . '" given.');
}

Expand Down
4 changes: 2 additions & 2 deletions src/V1/Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,15 @@ public function __construct(array $overload = [])
*/
public function make(string $name, array $args = []): Accessable
{
if (! isset($this->classes[$name])) {
if (!isset($this->classes[$name])) {
throw new FactoryException('"' . $name . '" is not a registered class');
}

$class = new \ReflectionClass($this->classes[$name]);

$object = $class->newInstanceArgs($args);

if (! $object instanceof Accessable) {
if (!$object instanceof Accessable) {
throw new FactoryException(sprintf(
'%s must be instance of `%s`',
$this->classes[$name],
Expand Down
2 changes: 1 addition & 1 deletion src/V1/Jsonapi.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ final class Jsonapi extends AbstractElement
*/
protected function parse($object): void
{
if (! is_object($object)) {
if (!is_object($object)) {
throw new ValidationException('Jsonapi has to be an object, "' . gettype($object) . '" given.');
}

Expand Down
6 changes: 3 additions & 3 deletions src/V1/Link.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ final class Link extends AbstractElement
*/
protected function parse($object): void
{
if (! is_object($object)) {
if (!is_object($object)) {
throw new ValidationException('Link has to be an object or string, "' . gettype($object) . '" given.');
}

if (! property_exists($object, 'href')) {
if (!property_exists($object, 'href')) {
throw new ValidationException('Link must have a "href" attribute.');
}

Expand Down Expand Up @@ -72,7 +72,7 @@ private function setAsLink(string $name, $link): void
}

// every link must be an URL
if (! is_string($link)) {
if (!is_string($link)) {
throw new ValidationException('Every link attribute has to be a string, "' . gettype($link) . '" given.');
}

Expand Down
2 changes: 1 addition & 1 deletion src/V1/Meta.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ final class Meta extends AbstractElement
*/
protected function parse($object): void
{
if (! is_object($object)) {
if (!is_object($object)) {
throw new ValidationException('Meta has to be an object, "' . gettype($object) . '" given.');
}

Expand Down
4 changes: 2 additions & 2 deletions src/V1/Relationship.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ final class Relationship extends AbstractElement
*/
protected function parse($object): void
{
if (! is_object($object)) {
if (!is_object($object)) {
throw new ValidationException('Relationship has to be an object, "' . gettype($object) . '" given.');
}

if (! property_exists($object, 'links') and ! property_exists($object, 'data') and ! property_exists($object, 'meta')) {
if (!property_exists($object, 'links') and !property_exists($object, 'data') and !property_exists($object, 'meta')) {
throw new ValidationException('A Relationship object MUST contain at least one of the following properties: links, data, meta');
}

Expand Down
2 changes: 1 addition & 1 deletion src/V1/RelationshipCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ final class RelationshipCollection extends AbstractElement
*/
protected function parse($object): void
{
if (! is_object($object)) {
if (!is_object($object)) {
throw new ValidationException('Relationships has to be an object, "' . gettype($object) . '" given.');
}

Expand Down
Loading

0 comments on commit 73b67e7

Please sign in to comment.