-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathObject.php
More file actions
61 lines (56 loc) · 1.53 KB
/
Object.php
File metadata and controls
61 lines (56 loc) · 1.53 KB
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
<?php // vim:ts=3:sts=3:sw=3:et:
/**
* Abstract base object functionality
*
* PHP Version 5
*
* @category PHP
* @package MindFrame2
* @author Bryan C. Geraghty <bryan@ravensight.org>
* @copyright 2005-2011 Bryan C. Geraghty
* @license http://www.gnu.org/licenses/lgpl-3.0.txt GNU LGPL
* @link https://github.com/archwisp/MindFrame2
*/
/**
* Abstract base object functionality
*
* @category PHP
* @package MindFrame2
* @author Bryan C. Geraghty <bryan@ravensight.org>
* @license http://www.gnu.org/licenses/lgpl-3.0.txt GNU LGPL
* @link https://github.com/archwisp/MindFrame2
*/
abstract class MindFrame2_Object
{
/**
* Returns the PHP resource id for the object
*
* @return int
*/
public function getObjectId()
{
$object_id = spl_object_hash($this);
return $object_id;
}
/**
* Asserts that the specified object property is not empty. This is
* especially useful when implementing template objects with protected
* properties to be defined in sub-classes.
*
* @param string $property_name Property to be validated
*
* @return void
*
* @throws UnexpectedValueException If the specified property is empty
*/
protected function assertPropertyIsNotEmpty($property_name)
{
$value = isset($this->$property_name)
? trim($this->$property_name) : NULL;
if (empty($value))
{
throw new UnexpectedValueException(sprintf(
'Object property, "%s" cannot be empty', $property_name));
}
}
}