Files
This commit is contained in:
62
common/Define/Model.php
Normal file
62
common/Define/Model.php
Normal file
@ -0,0 +1,62 @@
|
||||
<?php
|
||||
namespace Incoviba\API\Common\Define;
|
||||
|
||||
use Incoviba\API\Common\Factory\Model as ModelFactory;
|
||||
|
||||
interface Model {
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getTable(): string;
|
||||
|
||||
/**
|
||||
* @param ModelFactory $factory
|
||||
* @return Model
|
||||
*/
|
||||
public function setFactory(ModelFactory $factory): Model;
|
||||
|
||||
/**
|
||||
* Get all children models of class {$child_class}
|
||||
* @param string $child_class Class of child model
|
||||
* @param array $definitions array of conditions for connecting to the child table
|
||||
* @return array|null
|
||||
*/
|
||||
public function parentOf(string $child_class, array $definitions): ?array;
|
||||
|
||||
/**
|
||||
* Get parent model of class {$parent_class}
|
||||
* @param string $parent_class Class of parent model
|
||||
* @param array $definitions array of conditions for connecting to the parent table
|
||||
* @return Model|null
|
||||
*/
|
||||
public function childOf(string $parent_class, array $definitions): ?Model;
|
||||
|
||||
/**
|
||||
* Get all siblings of class {$sibling_class}
|
||||
* @param string $sibling_class Class of sibling model
|
||||
* @param string $connecting_table table connecting both models
|
||||
* @param array $definitions array of conditions for connecting to the sibling and connecting tables
|
||||
* @return array|null
|
||||
*/
|
||||
public function siblingOf(string $sibling_class, string $connecting_table, array $definitions): ?array;
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function toArray(): array;
|
||||
|
||||
/**
|
||||
* Add a new model of this type to the database, parsing {$input} data
|
||||
* @param ModelFactory $factory Factory object for connecting to the database
|
||||
* @param array $input Input data
|
||||
* @return Model|null
|
||||
*/
|
||||
public static function add(ModelFactory $factory, array $input): ?Model;
|
||||
|
||||
/**
|
||||
* Edit current model parsing {$input} data
|
||||
* @param array $input Input data
|
||||
* @return array|null
|
||||
*/
|
||||
public function edit(array $input): ?array;
|
||||
}
|
Reference in New Issue
Block a user