Skip to content

Commit

Permalink
SerializableInterface moved back to DbModel from Model
Browse files Browse the repository at this point in the history
  • Loading branch information
kapxapot committed Nov 24, 2020
1 parent eb23619 commit 580f62e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 7 additions & 1 deletion src/Models/Basic/DbModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@
use BadMethodCallException;
use Plasticode\Hydrators\Interfaces\HydratorInterface;
use Plasticode\Models\Interfaces\DbModelInterface;
use Plasticode\Models\Interfaces\SerializableInterface;
use Plasticode\ObjectProxy;
use Plasticode\Util\Classes;
use Plasticode\Util\Pluralizer;
use Plasticode\Util\Strings;
use Webmozart\Assert\Assert;

abstract class DbModel extends Model implements DbModelInterface
abstract class DbModel extends Model implements DbModelInterface, SerializableInterface
{
private const NOT_HYDRATED = 1;
private const BEING_HYDRATED = 2;
Expand Down Expand Up @@ -197,6 +198,11 @@ public function equals(?DbModelInterface $model) : bool
&& (get_class($model) == static::class);
}

public function serialize() : array
{
return $this->toArray();
}

public function toString() : string
{
return '[' . $this->getId() . '] ' . static::class;
Expand Down
8 changes: 1 addition & 7 deletions src/Models/Basic/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,14 @@
use JsonSerializable;
use Plasticode\Exceptions\InvalidConfigurationException;
use Plasticode\Interfaces\ArrayableInterface;
use Plasticode\Models\Interfaces\SerializableInterface;
use Plasticode\Traits\Convert\ToBit;
use Plasticode\Traits\Convert\ToBool;
use Plasticode\Traits\Convert\ToIso;
use Plasticode\Traits\PropertyAccess;
use Plasticode\Util\Strings;
use Webmozart\Assert\Assert;

class Model implements ArrayableInterface, ArrayAccess, JsonSerializable, SerializableInterface
class Model implements ArrayableInterface, ArrayAccess, JsonSerializable
{
use PropertyAccess;
use ToBit;
Expand Down Expand Up @@ -108,11 +107,6 @@ public function toString() : string
}

public function jsonSerialize()
{
return $this->serialize();
}

public function serialize() : array
{
return $this->toArray();
}
Expand Down

0 comments on commit 580f62e

Please sign in to comment.