<?php
namespace App\Galileo\LineParser\Types; class Data_A12 extends \App\Galileo\LineParser\Types\GalileoBase { protected $children = [ [ 'key'=>'A12SEC', 'type'=>'Constant', 'len'=>3, 'val'=>'A12', 'label'=>'SECTION LABEL "A12"' ], [ 'key'=>'A12CTY', 'type'=>'StringRaw', 'len'=>3, 'label'=>'CITY CODE' ], [ 'key'=>'A12LOC', 'type'=>'StringTrim','len'=>[1,2], 'label'=>'LOCATION TYPE' ], [ 'key'=>'A12PHN', 'type'=>'StringRaw', 'req'=>false, 'label'=>'FREEFORM PHONE DATA' ], ]; protected function postExtract(\App\Utils\BaseParser\TextParser\ExtractedBlock $ret) { if ($ret->extractedData['A12LOC']=='E') { if ($xtr = $this->getExtractor()->findAndStore('/\*(?P<email>.+)$/', $ret->extractedData['A12PHN'])) { $ret->extractedData['A12PHN_'] = [ 'email' => str_replace('//', '@', $xtr->email), ]; } } elseif ($ret->extractedData['A12LOC']=='N') { if ($xtr = $this->getExtractor()->findAndStore('/\*(?P<telephone>.+)$/', $ret->extractedData['A12PHN'])) { $ret->extractedData['A12PHN_'] = [ 'telephone' => $xtr->telephone, ]; } } return $ret; } } 