: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
* Magic getter method, allows $model->property access to data.
* @param string $property The property to get.
* @return mixed The value of the property
public function __get( $property ) {
$value = $this->orm->get( $property );
if ( $value !== null && \in_array( $property, $this->boolean_columns, true ) ) {
if ( $value !== null && \in_array( $property, $this->int_columns, true ) ) {
if ( $value !== null && \in_array( $property, $this->float_columns, true ) ) {
* Magic setter method, allows $model->property = 'value' access to data.
* @param string $property The property to set.
* @param string $value The value to set.
public function __set( $property, $value ) {
if ( $value !== null && \in_array( $property, $this->boolean_columns, true ) ) {
$value = ( $value ) ? '1' : '0';
if ( $value !== null && \in_array( $property, $this->int_columns, true ) ) {
$value = (string) $value;
if ( $value !== null && \in_array( $property, $this->float_columns, true ) ) {
$value = (string) $value;
$this->orm->set( $property, $value );
* Magic unset method, allows unset($model->property)
* @param string $property The property to unset.
public function __unset( $property ) {
$this->orm->__unset( $property );
* @return array The data of this object.
public function jsonSerialize() {
return $this->orm->as_array();
* Strips all nested dependencies from the debug info.
public function __debugInfo() {
return $this->orm->as_array();
* Magic isset method, allows isset($model->property) to work correctly.
* @param string $property The property to check.
* @return bool True when value is set.
public function __isset( $property ) {
return $this->orm->__isset( $property );
* Getter method, allows $model->get('property') access to data
* @param string $property The property to get.
* @return string The value of a property.
public function get( $property ) {
return $this->orm->get( $property );
* Setter method, allows $model->set('property', 'value') access to data.
* @param string|array $property The property to set.
* @param string|null $value The value to give.
* @return static Current object.
public function set( $property, $value = null ) {
$this->orm->set( $property, $value );
* Setter method, allows $model->set_expr('property', 'value') access to data.
* @param string|array $property The property to set.
* @param string|null $value The value to give.
* @return static Current object.
public function set_expr( $property, $value = null ) {
$this->orm->set_expr( $property, $value );
* Check whether the given property has changed since the object was created or saved.
* @param string $property The property to check.
* @return bool True when field is changed.
public function is_dirty( $property ) {
return $this->orm->is_dirty( $property );
* Check whether the model was the result of a call to create() or not.
* @return bool True when is new.
public function is_new() {
return $this->orm->is_new();
* Wrapper for Idiorm's as_array method.
* @return array The models data as array.
public function as_array() {
$args = \func_get_args();
return \call_user_func_array( [ $this->orm, 'as_array' ], $args );
* Save the data associated with this model instance to the database.
* @return bool True on success.
if ( $this->uses_timestamps ) {
if ( ! $this->created_at ) {
$this->created_at = \gmdate( 'Y-m-d H:i:s' );
$this->updated_at = \gmdate( 'Y-m-d H:i:s' );
return $this->orm->save();
* Delete the database row associated with this model instance.
* @return bool|int Response of wpdb::query.
public function delete() {
return $this->orm->delete();
* Get the database ID of this model instance.
* @return int The database ID of the models instance.
* @throws Exception When the ID is a null value.
* Hydrate this model instance with an associative array of data.
* WARNING: The keys in the array MUST match with columns in the
* corresponding database table. If any keys are supplied which
* do not match up with columns, the database will throw an error.
* @param array $data The data to pass to the ORM.
public function hydrate( $data ) {
$this->orm->hydrate( $data )->force_all_dirty();
* Calls static methods directly on the ORM
* @param string $method The method to call.
* @param array $arguments The arguments to use.
* @return array Result of the static call.
public static function __callStatic( $method, $arguments ) {
if ( ! \function_exists( 'get_called_class' ) ) {
$model = static::factory( static::class );
return \call_user_func_array( [ $model, $method ], $arguments );