Skip to content

Commit a91d253

Browse files
committed
add magic methods
1 parent 32d8125 commit a91d253

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

src/Model.php

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,24 @@ public function __construct(array $attributes = [])
2525
/**
2626
* Get an attribute.
2727
*/
28-
public function __get(string $value): mixed
28+
public function __get(string $name): mixed
2929
{
30-
return $this->attributes[$value] ?? null;
30+
return $this->attributes[$name] ?? null;
31+
}
32+
33+
/**
34+
* Set an attribute.
35+
*/
36+
public function __set(string $name, mixed $value): void
37+
{
38+
$this->attributes[$name] = $value;
39+
}
40+
41+
/**
42+
* Check if an attribute is set.
43+
*/
44+
public function __isset(string $name): bool
45+
{
46+
return isset($this->attributes[$name]);
3147
}
3248
}

0 commit comments

Comments
 (0)