<?php

/*
 * This file is part of the AuthStack project.
 *
 * (c) Buckhill Ltd <development@buckhill.co.uk>
 *
 * This source file is subject to the Buckhill license that is bundled
 * with this source code in the file LICENSE.
 */

namespace AuthStack\TwoFactor\Verifier\Traits;


trait TraitFetchFromMetadata
{
    protected $metadata = [];

    public function __construct(array $keyMetadata)
    {
        $this->metadata = $keyMetadata;
    }

    /**
     * @return array
     */
    public function getMetadata()
    {
        return $this->metadata;
    }

    /**
     * @param $key
     * @param null $default
     * @return mixed
     */
    public function fromMetadata($key, $default = null)
    {
        return isset($this->metadata[$key]) ? $this->metadata[$key] : $default;
    }
}