1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
<?php
/*
* This file is part of the ICanBoogie package.
*
* (c) Olivier Laviale <olivier.laviale@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace ICanBoogie\Accessor;
/**
* Interface for classes implementing the accessor pattern.
*/
interface HasAccessor
{
const ACCESSOR_TYPE_GETTER = "get";
const ACCESSOR_TYPE_SETTER = "set";
const ACCESSOR_IS_LAZY = 'lazy';
const ACCESSOR_IS_NOT_LAZY = '';
/**
* Formats an accessor method name.
*
* @param string $property A property.
* @param string $type One of {@link ACCESSOR_TYPE_GETTER} and {@link ACCESSOR_TYPE_SETTER}.
* @param string $lazy One of {@link ACCESSOR_IS_NOT_LAZY} and {@link ACCESSOR_IS_LAZY}.
* Defaults to {@link ACCESSOR_IS_NOT_LAZY}.
*
* @return mixed
*/
static public function accessor_format($property, $type, $lazy = self::ACCESSOR_IS_NOT_LAZY);
/**
* Returns the value of a property.
*
* @param string $property
*
* @return mixed
*
* @throws \ICanBoogie\PropertyNotDefined when the property is not defined.
* @throws \ICanBoogie\PropertyNotReadable when the property is not accessible or is write-only
* (the property is not defined and only a setter is available).
*/
public function __get($property);
/**
* Sets the value of a property.
*
* @param string $property
* @param mixed $value
*
* @throws \ICanBoogie\PropertyNotWritable when the property doesn't exists, has no lazy
* getter and is not public; or when only a getter is implemented.
*/
public function __set($property, $value);
/**
* Whether an object has a property.
*
* @param string $property
*
* @return bool `true` if the object has a property, `false` otherwise.
*/
public function has_property($property);
/**
* Whether an object has a method.
*
* @param string $method
*
* @return bool `true` if the object has a method, `false` otherwise.
*/
public function has_method($method);
}