Skip to content

Commit

Permalink
changed static to self
Browse files Browse the repository at this point in the history
  • Loading branch information
mkorkmaz committed Nov 29, 2018
1 parent 4d747da commit 44c421f
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
7 changes: 4 additions & 3 deletions src/EntityTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

namespace Selami\Entity;

use stdClass;
use Selami\Entity\Interfaces\EntityInterface;
use stdClass;
use Selami\Entity\Exception\SettingValueForInvalidPropertyException;
use Selami\Entity\Exception\OverridingIdentityOfEntityException;
use Selami\Entity\Exception\CouldNotFindJSONSchemaFileException;
Expand All @@ -13,6 +13,7 @@
trait EntityTrait
{
use ObjectTrait;

public function __construct(Model $model, string $id, ?stdClass $data = null)
{
$this->model = $model;
Expand Down Expand Up @@ -47,12 +48,12 @@ public static function createFromJsonFile(string $jsonFilePath, string $id) : En
);
}
$json = file_get_contents($jsonFilePath);
return static::createFromJson($json, $id);
return self::createFromJson($json, $id);
}

public static function createFromJson(string $json, string $id) : EntityInterface
{
return new static(new Model($json), $id);
return new self(new Model($json), $id);
}

public function entityId() : string
Expand Down
4 changes: 2 additions & 2 deletions src/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,11 @@ public function getSchema(?stdClass $model = null) : Schema
return new Schema($this->model);
}

public static function createFromJsonFile(string $filePath) : Model
public static function createFromJsonFile(string $filePath) : self
{
if (!file_exists($filePath)) {
throw new InvalidArgumentException(sprintf('Model definition file (%s) does not exist!', $filePath));
}
return new static(file_get_contents($filePath));
return new self(file_get_contents($filePath));
}
}
4 changes: 2 additions & 2 deletions src/ValueObjectBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ private function __construct(string $jsonSchema)
$this->properties = (new Model($jsonSchema))->getProperties();
}

public static function createFromJsonFile(string $jsonFilePath) : ValueObjectBuilder
public static function createFromJsonFile(string $jsonFilePath) : self
{
if (!file_exists($jsonFilePath)) {
throw new CouldNotFindJSONSchemaFileException(
Expand All @@ -32,7 +32,7 @@ public static function createFromJsonFile(string $jsonFilePath) : ValueObjectBui
return self::createFromJsonString(file_get_contents($jsonFilePath));
}

public static function createFromJsonString(string $jsonString) : ValueObjectBuilder
public static function createFromJsonString(string $jsonString) : self
{
return new self($jsonString);
}
Expand Down
4 changes: 2 additions & 2 deletions src/ValueObjectTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ public static function createFromJsonFile(string $filePath, stdClass $data) : Va
throw new InvalidArgumentException(sprintf('Model definition file (%s) does not exist!', $filePath));
}
$json = file_get_contents($filePath);
return static::createFromJson($json, $data);
return self::createFromJson($json, $data);
}

public static function createFromJson(string $json, stdClass $data) : ValueObjectInterface
{
return new static(new Model($json), $data);
return new self(new Model($json), $data);
}
}

0 comments on commit 44c421f

Please sign in to comment.