Skip to content

Commit 2c45b79

Browse files
committed
Add magic methods for properties
1 parent 28a3068 commit 2c45b79

File tree

1 file changed

+31
-3
lines changed

1 file changed

+31
-3
lines changed

src/Model.php

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1617,6 +1617,34 @@ public function __get($name)
16171617
return null;
16181618
}
16191619

1620+
/**
1621+
* ORM isset property
1622+
*
1623+
* @param string $name
1624+
* @return void
1625+
*/
1626+
public function __isset($name) {
1627+
1628+
if (isset($this->_writeProperties[$name])) {
1629+
1630+
return true;
1631+
}
1632+
1633+
return isset($this->_readProperties[$name]);
1634+
}
1635+
1636+
/**
1637+
* ORM unset property
1638+
*
1639+
* @param string $name
1640+
* @return void
1641+
*/
1642+
public function __unset($name) {
1643+
1644+
unset($this->_writeProperties[$name]);
1645+
unset($this->_readProperties[$name]);
1646+
}
1647+
16201648
/**
16211649
* ArrayAccess offsetSet
16221650
*
@@ -1626,7 +1654,7 @@ public function __get($name)
16261654
*/
16271655
public function offsetSet($offset, $value) {
16281656

1629-
$this->_writeProperties[$offset] = $value;
1657+
return $this->__set($offset, $value);
16301658
}
16311659

16321660
/**
@@ -1637,7 +1665,7 @@ public function offsetSet($offset, $value) {
16371665
*/
16381666
public function offsetExists($offset) {
16391667

1640-
return isset($this->_readProperties[$offset]);
1668+
return $this->__isset($offset);
16411669
}
16421670

16431671
/**
@@ -1648,7 +1676,7 @@ public function offsetExists($offset) {
16481676
*/
16491677
public function offsetUnset($offset) {
16501678

1651-
unset($this->_writeProperties[$offset]);
1679+
return $this->__unset($offset);
16521680
}
16531681

16541682
/**

0 commit comments

Comments
 (0)