Beispiel #1
0
 /**
  * @return Array
  */
 public function provideParsedLines()
 {
     $parser = new FileParser();
     $lines = array();
     for ($i = 0; $i < $parser->getLines(); $i++) {
         $line = $parser->readLine($i);
         $blz = mb_substr($line, 0, 8, 'UTF-8');
         $type = mb_substr($line, FileParser::TYPE_OFFSET, FileParser::TYPE_LENGTH, 'UTF-8');
         $lines[] = array($blz, $type);
     }
     return $lines;
 }
Beispiel #2
0
 /**
  * Validates a bundesbank file.
  *
  * @param string $file bundesbank file.
  * @throws FileValidatorException
  */
 public function validate($file)
 {
     $parser = new FileParser($file);
     // file size is normally around 3 MB. Less than 1.5 is not valid
     $size = filesize($file);
     if ($size < self::FILESIZE) {
         throw new InvalidFilesizeException("Get updated BAV version:" . " file size should not be less than " . self::FILESIZE . " but was {$size}.");
     }
     // check line length
     $minLength = FileParser::SUCCESSOR_OFFSET + FileParser::SUCCESSOR_LENGTH;
     if ($parser->getLineLength() < $minLength) {
         throw new InvalidLineLengthException("Get updated BAV version:" . " Line length shouldn't be less than {$minLength} but was {$parser->getLineLength()}.");
     }
     // rough check that line length is constant.
     if ($size % $parser->getLineLength() != 0) {
         throw new InvalidLineLengthException("Get updated BAV version: Line length is not constant.");
     }
     $firstLine = $parser->readLine(0);
     if (!preg_match("/^100000001Bundesbank/", $firstLine)) {
         throw new FieldException("Get updated BAV version: first line has unexpected content: {$firstLine}");
     }
 }
Beispiel #3
0
 /**
  * Read all agencies from the bundesbank file.
  * 
  * @return Agency[]
  */
 private function provideAgencies()
 {
     $parser = new FileParser();
     $databackend = new FileDataBackend($parser->getFile());
     $agencies = array();
     for ($line = 0; $line < $parser->getLines(); $line++) {
         $data = $parser->readLine($line);
         $bank = $parser->getBank($databackend, $data);
         $agency = $parser->getAgency($bank, $data);
         $agencies[$agency->getID()] = $agency;
     }
     return $agencies;
 }
Beispiel #4
0
 /**
  * Tests readLine()
  * 
  * @see FileParser::readLine()
  * @dataProvider provideTestReadLine
  */
 public function testReadLine($file, $line, $expectedData)
 {
     $parser = new FileParser($file);
     $data = $parser->readLine($line);
     $this->assertEquals($expectedData, $data);
 }