<?php

namespace SCF\Core;

class Breadcrumb {

    /**
     * @var string
     */
    private $pageTitle;

    /**
     * @var string
     */
    private $subTitle;

    /**
     * @var array
     */
    private $breadcrumb = [];

    /**
     * @var array
     */
    private $pageHeader = [];

    /**
     * @param $pageTitle
     */
    public function setPageTitle($pageTitle)
    {
        $this->pageTitle = $pageTitle;
    }

    /**
     * @param string $subTitle
     */
    public function setSubTitle($subTitle)
    {
        $this->subTitle = $subTitle;
    }

    /**
     * @return string
     */
    public function getPageTitle()
    {
        return $this->pageTitle;
    }

    /**
     * @return string
     */
    public function getSubTitle()
    {
        return $this->subTitle;
    }

    /**
     * @param array $breadcrumb
     */
    public function setBreadcrumb($breadcrumb)
    {
        $this->generateBreadcrumb($breadcrumb);
    }

    /**
     * @param array $breadcrumb
     */
    private function generateBreadcrumb($breadcrumb)
    {

        foreach ($breadcrumb as $key=>$value) {
            $this->breadcrumb[$value] = $key;
        }
    }

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

    /**
     * @param array $pageHeaderArray
     */
    public function setPageHeader(array $pageHeaderArray)
    {
        $this->pageHeader = $this->genPageHeader($pageHeaderArray);
    }

    /**
     * @return array
     */
    public function getPageHeader(): array
    {
        return $this->pageHeader;
    }

    /**
     * @param array $pageHeaderArray
     * @return array
     */
    private function genPageHeader(array $pageHeaderArray)
    {
            $temp = [
                'pageTitle' => $pageHeaderArray[0],
                'subTitle' => $pageHeaderArray[1]
            ];

            return $temp;
    }
}