Skip to content

Commit 7777a91

Browse files
committed
Clean code
1 parent 6309773 commit 7777a91

File tree

3 files changed

+12
-19
lines changed

3 files changed

+12
-19
lines changed

src/AbstractStaticEntity.php

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,6 @@ abstract class AbstractStaticEntity implements StaticEntityInterface
77
{
88
protected $id;
99

10-
public function getId()
11-
{
12-
return $this->id;
13-
}
14-
15-
/**
16-
* @param $id
17-
*
18-
* @return $this
19-
*/
2010
static public function get($id): StaticEntityInterface
2111
{
2212
return Provider::get(get_called_class(), $id);
@@ -46,4 +36,9 @@ static public function getIds(): array
4636
{
4737
return Provider::getIds(get_called_class());
4838
}
39+
40+
public function getId()
41+
{
42+
return $this->id;
43+
}
4944
}

src/Provider.php

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ class Provider implements ProviderInterface
1212
* @param mixed $id
1313
*
1414
* @return StaticEntityInterface
15-
* @throws \ReflectionException
1615
*/
1716
static public function get(string $className, $id): StaticEntityInterface
1817
{
@@ -39,7 +38,6 @@ static public function get(string $className, $id): StaticEntityInterface
3938
* @param string $className
4039
*
4140
* @return array
42-
* @throws \ReflectionException
4341
*/
4442
static public function getAll(string $className): array
4543
{
@@ -162,8 +160,6 @@ static private function getDataSet(string $className): array
162160
* @param string $className
163161
* @param mixed $id
164162
* @param array $data
165-
*
166-
* @throws \ReflectionException
167163
*/
168164
static private function build(string $className, $id, array $data): void
169165
{
@@ -182,12 +178,14 @@ static private function build(string $className, $id, array $data): void
182178
/**
183179
* @param StaticEntityInterface $instance
184180
* @param array $data
185-
*
186-
* @throws \ReflectionException
187181
*/
188182
static private function hydrate(StaticEntityInterface $instance, array $data): void
189183
{
190-
$reflectionClass = new \ReflectionClass($instance);
184+
try {
185+
$reflectionClass = new \ReflectionClass($instance);
186+
} catch (\Throwable $e) {
187+
return;
188+
}
191189

192190
foreach ($data as $key => $value) {
193191
if (!$reflectionClass->hasProperty($key)) {

src/StaticEntityInterface.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55

66
interface StaticEntityInterface
77
{
8-
public function getId();
9-
108
static function getDataSet(): array;
9+
10+
public function getId();
1111
}
1212

0 commit comments

Comments
 (0)