/**
  * Returns report in text format.
  * 
  * @return string
  */
 public function toText()
 {
     // Let's collect each line of the report as an array element
     $lines = array();
     // Report head
     $header = sprintf('Transactions Report for "%s" (ID: %d)', $this->merchant->getName(), $this->merchant->getId());
     $lines[] = $header;
     $lines[] = str_repeat('=', strlen($header));
     // Blank line
     $lines[] = '';
     // Transactions count
     $lines[] = sprintf('Total: %d transaction(s) found.', $this->count());
     // Blank line
     $lines[] = '';
     // Table headers
     $lines[] = sprintf('%s %s', str_pad(self::DATE_HEADER, self::DATE_LENGTH, ' '), str_pad(self::AMOUNT_HEADER, self::AMOUNT_LENGTH, ' '));
     $lines[] = sprintf('%s %s', str_repeat('-', self::DATE_LENGTH), str_repeat('-', self::AMOUNT_LENGTH));
     // Table rows
     /* @var $transaction \Application\Model\Transaction */
     foreach ($this->collection as $transaction) {
         $lines[] = sprintf('%s %s', str_pad($this->getTransactionDate($transaction), self::DATE_LENGTH, ' ', STR_PAD_BOTH), str_pad($this->getTransactionAmount($transaction), self::AMOUNT_LENGTH + 1, ' ', STR_PAD_LEFT));
     }
     // Glue all lines with a line break
     $text = implode(PHP_EOL, $lines) . PHP_EOL;
     return $text;
 }
 /**
  * @covers Application\Model\Merchant::removeTransaction
  */
 public function testRemoveTransaction()
 {
     $merchant = new Merchant();
     $transaction = new Transaction();
     $merchant->addTransaction($transaction);
     $this->assertEquals(1, $merchant->getTransactions()->count());
     $merchant->removeTransaction($transaction);
     $this->assertEquals(0, $merchant->getTransactions()->count());
 }
 /**
  * {@inheritDoc}
  */
 public function getTransactions()
 {
     $this->__initializer__ && $this->__initializer__->__invoke($this, 'getTransactions', array());
     return parent::getTransactions();
 }