Skip to content

Commit 087dbaa

Browse files
committed
refactor: use array functions
1 parent 1bb2c24 commit 087dbaa

File tree

1 file changed

+4
-18
lines changed

1 file changed

+4
-18
lines changed

src/LibraryStarterKit/Answers.php

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
use ReflectionObject;
2828
use ReflectionProperty;
2929

30+
use function array_keys;
31+
use function array_values;
3032
use function json_decode;
3133
use function json_encode;
3234
use function property_exists;
@@ -86,14 +88,7 @@ public function __construct(string $saveToPath, Filesystem $filesystem)
8688
*/
8789
public function getTokens(): array
8890
{
89-
$tokens = [];
90-
91-
$reflected = new ReflectionObject($this);
92-
foreach ($reflected->getProperties(ReflectionProperty::IS_PUBLIC) as $property) {
93-
$tokens[] = $property->getName();
94-
}
95-
96-
return $tokens;
91+
return array_keys($this->getArrayCopy());
9792
}
9893

9994
/**
@@ -103,16 +98,7 @@ public function getTokens(): array
10398
*/
10499
public function getValues(): array
105100
{
106-
$values = [];
107-
108-
$reflected = new ReflectionObject($this);
109-
foreach ($reflected->getProperties(ReflectionProperty::IS_PUBLIC) as $property) {
110-
/** @var string | string[] | bool | null $value */
111-
$value = $property->getValue($this);
112-
$values[] = $value;
113-
}
114-
115-
return $values;
101+
return array_values($this->getArrayCopy());
116102
}
117103

118104
/**

0 commit comments

Comments
 (0)