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 | <?php
/**
* Author: Markus Diersbock <markus@swingnote.com>
*/
class Vehicle {
public $make;
public $model;
public $type;
public $year;
public function __construct(array $initializers = null) {
if ($initializers) {
// set properties or throw if invalid
foreach ($initializers as $property => $value)
$this->{$property} = $value;
}
}
public function __set($name, $value) {
throw new Exception("Unknown Property {$name}");
}
};
$lead->addVehicle(new Vehicle(array(
"make" => "Lexus",
"model" => "RX 300",
"type" => "SUV",
"year" => "1999"))
);
|