<?php
namespace App\Bsp\Hot230\Lines\Types; class DateAuto extends \App\Utils\BaseParser\TextParser\Types\Date { public function __construct($options, $parent = null) { if (!$options['fmt'] && !$options['fmts']) { $options['fmts'] = ['DDMMM', 'DDMMMYY', 'YYMMDD', ]; $options['allowSpaces'] = true; } parent::__construct($options, $parent); $this->extractRegexp = "/^(?P<rawData>({$this->subregexp})|([\s]{{$this->options['len']}}))/"; } public function getSubregexpForSpecificFmt($fmt, $options) { $subregexp = parent::getSubregexpForSpecificFmt($fmt, $options); if ($options['len'] && ($options['len'] - strlen($fmt))>0) { $subregexp.= sprintf("[\s]{%d}", $options['len'] - strlen($fmt)); } return $subregexp; } public function getDate($matches, $options, $renamedPatternNames) { if (trim($matches['rawData'])==='' || trim($matches['rawData'], '0')==='') { return null; } return parent::getDate($matches, $options, $renamedPatternNames); } } 