Skip to content

Commit

Permalink
don't use property_exists
Browse files Browse the repository at this point in the history
  • Loading branch information
key2peace authored Nov 12, 2022
1 parent ee222bf commit b633930
Showing 1 changed file with 20 additions and 20 deletions.
40 changes: 20 additions & 20 deletions src/Discord/Parts/Interactions/Command/Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,17 +125,17 @@ public function getCreatableAttributes(): array
];

$attributes = [
'name'
'description',
'type',
'options',
'dm_permission', // Guild command might omit this fillable
'nsfw',
'name' => true,
'description' => true,
'type' => true,
'options' => false,
'dm_permission' => true, // Guild command might omit this fillable
'nsfw' => true,
];

foreach($attributes as $attribute) {
foreach($attributes as $attribute => $fromObject) {
if (array_key_exists($attribute, $this->attributes)) {
$value = property_exists($this, $attribute) ? $this->{$attribute} : $this->attributes[$attribute];
$value = $fromObject ? $this->{$attribute} : $this->attributes[$attribute];
$attr[$attribute] = $value;
}
}
Expand All @@ -153,21 +153,21 @@ public function getUpdatableAttributes(): array
$attr = [];

$attributes = [
'name'
'description',
'default_member_permissions',
'type',
'options',
'name_localizations',
'description_localizations',
'default_permission', // Soon to be deprecated
'dm_permission', // Guild command might omit this fillable
'nsfw',
'name' => true,
'description' => true,
'default_member_permissions' => true,
'type' => true,
'options' => false,
'name_localizations' => true,
'description_localizations' => true,
'default_permission' => true, // Soon to be deprecated
'dm_permission' => true, // Guild command might omit this fillable
'nsfw' => true,
];

foreach($attributes as $attribute) {
foreach($attributes as $attribute => $fromObject) {
if (array_key_exists($attribute, $this->attributes)) {
$attr[$attribute] = property_exists($this, $attribute) ? $this->{$attribute} : $this->attributes[$attribute];
$attr[$attribute] = $fromObject ? $this->{$attribute} : $this->attributes[$attribute];
}
}

Expand Down

0 comments on commit b633930

Please sign in to comment.