<?php
namespace App\Galileo\NDCLineParser\Types;

/**
 * Data line
 * @author Lucian Sirbu
 */
class Data_OtherAncillaries extends \App\Galileo\LineParser\Types\GalileoBase
{
    // NOTE: be VERY carefoul about the following regexp, it needs to be as specific as possible in order to NOT match the Ancillaries data lines
    protected $extractRegexp = "/^(?P<rawData>FT-#TAS[0-9]+#DAS\/P[0-9\-\,\.]+\/S[0-9\-\,\.]+\/.+(?!SEAT).+)/";
    protected $useCustomRegexp = true;

    /**
     * Children elements
     */
    protected $children = [
        [ 'key'=>'FT',  	                     'type'=>'Constant',        			 'val'=> 'FT-',                           'label'=>'DOCI-FREETEXT-#' ],
        [ 'key'=>'TAS',                          'type'=>'Constant',                     'val'=> '#TAS', ],
        [ 'key'=>'fareNumber',                   'type'=>'Integer',          'len' => 2, ],
        [ 'key'=>'separator',                    'type'=>'Constant',                     'val'=> '#', ],

        [ 'key'=>'DAS',                          'type'=>'Constant',                     'val'=> 'DAS', ],
        [ 'key'=>'passengerIdentifier',          'type'=>'Constant',                     'val'=> '/P', ],
        [ 'key'=>'passengerIdentifier',          'type'=>'Association', ],
        [ 'key'=>'segmentNumber',                'type'=>'Constant',                     'val'=> '/S', ],
        [ 'key'=>'segmentNumber',                'type'=>'Association', ],
        [ 'key'=>'separator',                    'type'=>'Constant',                     'val'=> '/', ],
        [ 'key'=>'serviceName',                  'type'=>'StringDelimitedByChar',        'val'=> '/', ],
        [ 'key'=>'separator',                    'type'=>'Constant',                     'val'=> '/', ],
        [ 'key'=>'unitCost',                     'type'=>'Price',                     ],
        [ 'key'=>'separator',                    'type'=>'Constant',                     'val'=> '/', ],
        [ 'key'=>'numberOfUnits',                'type'=>'Integer', ],
    ];
}
