setWorker( new $worker(null, $config) ); } public function setWorker(RO $worker): self { $this->worker = $worker; return $this; } public function __get($name) { if (property_exists($this, $name)) { return $this->{$name}; } if (property_exists($this->worker, $name)) { return $this->worker->{$name}; } return null; } public function __set($name, $value) { if (property_exists($this->worker, $name)) { return $this->worker->{$name} = $value; } return $this->{$name} = $value; } public function __call($name, $arguments) { try { $result = call_user_func_array([$this->worker, $name], $arguments); } catch (Exception $e) { // ta knihovna ma nejaky rozbity message, ktere to vypisuje v exceptione, takze to tady jen catchnu // a vyhodim nasi FlexiBeeException se spravnou message foreach ($e->getErrorMessages() as $error) { throw new FlexiBeeException( sprintf('%s: %s', $error['code'] ?? 'ERROR', $error['message']), !empty($error['code']) && is_numeric($error['code']) ? (int) $error['code'] : 0, $e ); } throw new FlexiBeeException($e->getMessage(), $e->getCode(), $e); } return $result; } public function __destruct() { if ($this->worker instanceof RW) { $this->worker->disconnect(); } unset($this->worker); } }