library base-model
The world's simplest base model, with support for custom getters and setters.
monooso/base-model
The world's simplest base model, with support for custom getters and setters.
- Wednesday, September 21, 2016
- by monooso
- Repository
- 1 Watchers
- 0 Stars
- 57 Installations
- PHP
- 0 Dependents
- 0 Suggesters
- 0 Forks
- 0 Open issues
- 2 Versions
- 16 % Grown
Base Model
The world's simplest base model, with support for custom getters and setters., (*1)
Installation
Install Base Model using Composer, as follows:, (*2)
$ composer require monooso/base-model
Usage
In the following example model, the simple property will be set and retrieved directly, and the fancy property will be set and retrieved using the custom getter and setter methods., (*3)
<?php namespace MyProject
use InvalidArgumentException;
use Monooso\BaseModel\Model;
class Example extends Model
{
protected $fancy;
protected $simple;
/**
* Prepends a string to the 'fancy' property, before returning it.
*
* @return string
*/
public function getFancy()
{
return 'fancy-' . $this->fancy;
}
/**
* Validates that the 'fancy' property is a string.
*
* @param mixed $val
*
* @throws InvalidArgumentException
*/
public function setFancy($val)
{
if (!is_string($val)) {
throw new InvalidArgumentException('Value must be a string');
}
$this->fancy = $val;
}
}
dev-master
9999999-dev
The world's simplest base model, with support for custom getters and setters.
Sources
Download
MIT
The Development Requires
by
Stephen Lewis
0.1.0
0.1.0.0
The world's simplest base model, with support for custom getters and setters.
Sources
Download
MIT
The Development Requires
by
Stephen Lewis