/** * {@inheritDoc} */ public function getAccounts(Bank $bank) { // We need to be logged for this if (!$this->logged) { throw new \RuntimeException('Call login() first'); } // Get the accounts list $browser = $this->getBrowser(); $crawler = $browser->request('GET', $this->getUri('show-synthese')); // Loop on each of them $accounts = array(); $xmlAccounts = $crawler->filter('table#comptesEpargne tbody tr, table#comptes tbody tr'); foreach ($xmlAccounts as $account) { // Reset the crawler for further re-use $crawler->clear(); $crawler->add($account); // Crawl the account informations $cell1 = $crawler->filter('td.bdrT'); $cell2 = $crawler->filter('td.bdrL.num')->first(); $cell3 = $crawler->filter('td.bdrL.num')->eq(1); // Build a new account $account = new Account(); $account->setBank($bank); $account->setId($cell2->text()); $account->setLabel($cell1->text()); $account->setLink(str_replace('../..', $this->getUri('prefix'), $cell1->filter('a')->attr('href'))); $account->setBalance($this->parseAmount($cell3->text())); $accounts[] = $account; } return $accounts; }