/** * {@inheritDoc} */ public function getAccounts(Bank $bank) { if (!$this->logged) { throw new \RuntimeException('Call login() first'); } $accounts = array(); $browser = $this->getBrowser(); $response = $browser->request()->getBody(); $dom = new \DomDocument(); @$dom->loadHTML($response); $xpath = new \DomXPath($dom); foreach ($xpath->query("//div[@class='dv']") as $div) { $xmlAccount = $xpath->query("a", $div); if ($xmlAccount->length > 0) { $id = preg_replace('/(.*)<br *\\/>(\\d*)<div.*/', '$2', $dom->saveXml($div)); $balance = str_replace(',', '.', $xpath->query("div", $div)->item(0)->textContent); $balance = preg_replace("/[\\xA0\\xC2 €]/", '', $balance); $account = new Account(); $account->setBank($bank)->setId($id)->setLabel($xmlAccount->item(0)->textContent)->setLink($xmlAccount->item(0)->getAttribute('href'))->setBalance($balance); $accounts[$account->getId()] = $account; } } return $accounts; }