protected function getLink() { if (!$this->db) { throw new WrongStateException('Expected setted db'); } if (!$this->db->isConnected()) { $this->db->connect(); } return $this->db->getLink(); }