PHP code example of monooso / base-model

1. Go to this page and download the library: Download monooso/base-model library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

monooso / base-model example snippets


 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;
    }
}