Skip to content

Commit

Permalink
Adds a simple Repository abstract with some contracts
Browse files Browse the repository at this point in the history
Adds 3 contracts:

1. `Deleteable`
2. `Insertable`
3. `Updateable`
  • Loading branch information
borkweb committed Feb 16, 2023
1 parent 92a8a79 commit f7e840b
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/Models/Repositories/Contracts/Deleteable.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

namespace StellarWP\Models\Repositories\Contracts;

use StellarWP\Models\Model;

interface Deleteable {
/**
* Inserts a model record.
*
* @since 1.0.0
*
* @param Model $model
*
* @return bool
*/
public function delete( Model $model ) : bool;
}
18 changes: 18 additions & 0 deletions src/Models/Repositories/Contracts/Insertable.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

namespace StellarWP\Models\Repositories\Contracts;

use StellarWP\Models\Model;

interface Insertable {
/**
* Inserts a model record.
*
* @since 1.0.0
*
* @param Model $model
*
* @return Model
*/
public function insert( Model $model ) : Model;
}
18 changes: 18 additions & 0 deletions src/Models/Repositories/Contracts/Updateable.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

namespace StellarWP\Models\Repositories\Contracts;

use StellarWP\Models\Model;

interface Updateable {
/**
* Inserts a model record.
*
* @since 1.0.0
*
* @param Model $model
*
* @return Model
*/
public function update( Model $model ) : Model;
}
16 changes: 16 additions & 0 deletions src/Models/Repositories/Repository.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

namespace StellarWP\Models\Repositories;

use StellarWP\Models\ModelQueryBuilder;

abstract class Repository {
/**
* Prepare a query builder for the repository.
*
* @since 1.0.0
*
* @return ModelQueryBuilder
*/
abstract function prepareQuery() : ModelQueryBuilder;
}

0 comments on commit f7e840b

Please sign in to comment.