php require_once dirname __FILE__ DIRECTORY_SEPARATOR object php class

 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
<?php
require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'object.php';
class ClassObject extends Object
{
protected function __construct($realClassName)
{
parent::__construct();
if (is_string($realClassName) && class_exists($realClassName))
{
$this->__ClassObject_RealClassName = $realClassName;
}
else
{
throw new InvalidArgumentException();
}
}
//
public function getRealClassName()
{
return $this->__ClassObject_RealClassName;
}
public function getClassName()
{
return $this->__ClassObject_ClassName;
}
public function setClassName($className)
{
if (is_null($this->__ClassObject_ClassName))
{
if (is_string($className))
{
$this->__ClassObject_ClassName = $className;
}
else
{
throw new InvalidArgumentException();
}
}
else
{
throw new RuntimeException();
}
}
public function toString()
{
return is_null($this->getClassName()) ? $this->getRealClassName() : $this->getClassName();
}
//
private $__ClassObject_RealClassName = Null;
private $__ClassObject_ClassName = Null;
//
public static function getClassObjectForName($className)
{
return new ClassObject($className);
}
}