-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds a simple Repository abstract with some contracts
Adds 3 contracts: 1. `Deleteable` 2. `Insertable` 3. `Updateable`
- Loading branch information
Showing
4 changed files
with
70 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |