Beispiel #1
0
 public function run(CollectionAbstract $filter, AbstractBuilder $builder)
 {
     $table = new Table('files/KLADR.DBF', null, 'CP866');
     $lookOnlyAbbr = false;
     $errors = 0;
     /** @var Scheme $row */
     while ($row = $table->nextRecord()) {
         if ($lookOnlyAbbr && $row->socr != $lookOnlyAbbr) {
             continue;
         }
         try {
             $abbr = new Abbreviation($row->socr);
             $code = new Code($row->code);
             $name = new Name($row->name, $abbr);
             if ($filter->isAllowed($name, $code)) {
                 $builder->buildPart($name, $code);
             }
         } catch (UnknownAbbrException $e) {
             $lookOnlyAbbr = $row->socr;
             $errors++;
             echo $row->code . ' ' . $row->socr . ' ' . $row->name . PHP_EOL;
         }
     }
     if ($errors) {
         echo 'Total items: ' . $errors . PHP_EOL;
     }
     echo $builder->getAsJson();
 }
Beispiel #2
0
 private static function getTableName(Table $table)
 {
     return pathinfo($table->getName(), PATHINFO_FILENAME);
 }