<?php

namespace App\Amadeus\FileParser;

/**
 * 4.XXX. F - Offer Air
 *
 * This line is used to transmit the data contained in the Offer Air segment.
 */
class Line_F extends \App\Amadeus\FileParser\LineAbstract
{
    /**
     * Structure of the F line
     *
     * @var array
     */
    protected $structure = [
        ['name' => 'MSGTAG', 'type' => 'AN',     'req' => 'M',  'val' => 'F-', 'len' => 2,                                   ], // Message Tag (F-)
        ['name' => '_extra', 'type' => 'custom',                                                                             ],
    ];

    protected function parseFromStructure($structure, $content)
    {
        $header = $structure[0];
        if (preg_match("/^{$header['val']}/", $content)) {
            $tree = [];
            $tree[$structure[1]['name']] = substr($content, strlen($header['val']));
            return $tree;
        }
        return [];
    }

}
