blob: e8d3a84b686823ef1f1302cbd330143282d31b1e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
<?php
namespace ipl\Orm\Common;
use Closure;
use Traversable;
trait PropertiesWithDefaults
{
use \ipl\Stdlib\Properties {
\ipl\Stdlib\Properties::getProperty as private parentGetProperty;
}
protected function getProperty($key)
{
if (isset($this->properties[$key]) && $this->properties[$key] instanceof Closure) {
$this->setProperty($key, $this->properties[$key]($this, $key));
}
return $this->parentGetProperty($key);
}
public function getIterator(): Traversable
{
foreach ($this->properties as $key => $value) {
if (! $value instanceof Closure) {
yield $key => $value;
}
}
}
}
|