63 lines
1.8 KiB
PHP
63 lines
1.8 KiB
PHP
<?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): bool|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): bool|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;
|
|
}
|