db = $db; } public function getMapper($name) { if (!isset($this->mappers[$name])) { $class = $name . 'Mapper'; if (class_exists($class)) { $mapper = new $class($this); if (!($mapper instanceof DataMapper)) throw new Exception('"' . $name . 'Mapper" должен быть наследником класса DataMapper'); $this->mappers[$name] = $mapper; } else throw new Exception('Невозможно найти класс "' . $name . 'Mapper"'); } return $this->mappers[$name]; } public function getDatabase() { return $this->db; } }