<commit_before><?php
/**
 * Created by PhpStorm.
 * User: manuelmeister
 * Date: 14.05.15
 * Time: 00:25
 */

namespace ThePost\Controller\Output;

use ThePost\Model\Entity\User;
use ThePost\Model\Model;
use ThePost\Model\Repository\EntryRepository;
use ThePost\View\FrontView;
use ThePost\View\View;

/**
 * Class MainController
 * @package ThePost\Controller
 */
class MainController {

    /**
     * @var Model
     */
    protected $model;

    /**
     * @var View
     */
    public $view;

    /**
     * @var array
     */
    protected $options_array = array();

    /**
     * @var User
     */
    protected $authentication;

    /**
     * @param $model
     */
    function __construct($model)
    {
        $this->model = $model;
        $this->get_options();
    }

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

    public function set_vars()
    {
        $this->view->set_render_vars($this->options_array,$this->authentication);
    }

    public function get_options()
    {
        $stmt = $this->model->pdo->prepare('SELECT * FROM Options;');
        $stmt->execute();
        $options = $stmt->fetchAll(\PDO::FETCH_CLASS | \PDO::FETCH_PROPS_LATE, 'ThePost\Model\Entity\Options');

        foreach ($options as $option) {
            /** @var ThePost/Model/Entity/Options $option */
            $this->options_array[$option->getKey()] = $option->getValue();
        }
    }

    /**
     * @param $param
     */
    public function frontpage($param){
        $entry_repository = new EntryRepository($this->model->pdo);
        $entries = $entry_repository->findAll();
        $this->view = new FrontView($entries);
        $this->view->add_render_vars(array("site"=>array("home"=>true)));
    }

}<commit_msg>Use OptionRepository and added PHPDocs<commit_after><?php
/**
 * Created by PhpStorm.
 * User: manuelmeister
 * Date: 14.05.15
 * Time: 00:25
 */

namespace ThePost\Controller\Output;

use ThePost\Model\Entity\User;
use ThePost\Model\Model;
use ThePost\Model\Repository\EntryRepository;
use ThePost\Model\Repository\OptionRepository;
use ThePost\View\FrontView;
use ThePost\View\View;

/**
 * Class MainController
 * @package ThePost\Controller
 */
class MainController {

    /**
     * @var Model
     */
    protected $model;

    /**
     * @var View
     */
    public $view;

    /**
     * @var array
     */
    protected $options_array = array();

    /**
     * @var User
     */
    protected $authentication;

    /**
     * @param $model
     */
    function __construct($model)
    {
        $this->model = $model;
        $this->get_options();
    }

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

    public function view_set_vars()
    {
        $this->view->set_render_vars($this->options_array,$this->authentication);
    }

    /**
     * Gets all Settings(Options) from Repository and fills it in an associative array like:
     *
     *      array(
     *          key1 => value1
     *          key2 => value2
     *      )
     *
     */
    public function get_options()
    {
        $options_repository = new OptionRepository($this->model->pdo);
        $options = $options_repository->findAll();

        foreach ($options as $option) {
            $this->options_array[$option->getKey()] = $option->getValue();
        }
    }

    /**
     * @param $param
     */
    public function frontpage($param){
        $entry_repository = new EntryRepository($this->model->pdo);
        $entries = $entry_repository->findAll();
        $this->view = new FrontView($entries);
        $this->view->add_render_vars(array("site"=>array("home"=>true)));
    }

}
{'fraction_non_alphanumeric': 0.14984391259105098, 'fraction_numerical': 0.006243496357960458, 'mean_word_length': 2.3347788378143974, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 49, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '403392', 'n_tokens_mistral': 1198, 'n_tokens_neox': 1163, 'n_words': 213}