<?php

namespace Illuminate\Translation;
// set namespace
class ArrayLoader implements LoaderInterface
{// a arrayloader to implements loader Interface
    /**
     * All of the translation messages.
     *
     * @var array
     */
    protected $messages = [];// the big store to save the message

    /**
     * Load the messages for the given locale.
     *
     * @param  string  $locale
     * @param  string  $group
     * @param  string  $namespace
     * @return array
     */
    public function load($locale, $group, $namespace = null)
    {// load the messages for the given locale.
        $namespace = $namespace ?: '*';//set the default namespace

        if (isset($this->messages[$namespace][$locale][$group])) {// if set then return it
            return $this->messages[$namespace][$locale][$group];
        }

        return [];//default return null
    }

    /**
     * Add a new namespace to the loader.
     *
     * @param  string  $namespace
     * @param  string  $hint
     * @return void
     */
    public function addNamespace($namespace, $hint)
    {
        //
    }//Add a new namespace to the loader

    /**
     * Add messages to the loader.
     *
     * @param  string  $locale
     * @param  string  $group
     * @param  array  $messages
     * @param  string|null  $namespace
     * @return $this
     */
    public function addMessages($locale, $group, array $messages, $namespace = null)
    {// Add messages to the loader
        $namespace = $namespace ?: '*';//set the default namespace

        $this->messages[$namespace][$locale][$group] = $messages;// set the message

        return $this;// return this instance
    }
}