<commit_before><?php
/**
 * Created by PhpStorm.
 * User: bmeism
 * Date: 13.05.2015
 * Time: 16:44
 */

namespace ThePost\Controller\Output;

use ThePost\Controller\CRUD\CreateController;
use ThePost\Controller\CRUD\CRUDController;
use ThePost\Model\Repository\EntryRepository;
use ThePost\View\EntryErrorView;
use ThePost\View\EntryView;
use ThePost\View\PreviewView;

/**
 * Class MainController
 * @package ThePost\Controller
 */
class EntryController extends MainController
{
    /**
     * @param $input
     * @throws \Exception
     */
    public function index($input)
    {
        $param = (isset($input['slug'])) ? $input['slug'] : $input['id'];
        $entries_repository = new EntryRepository($this->model->pdo);
        if ($entry = $entries_repository->findByParam($param)) {
            $this->view = new PreviewView($entry);
        } else {
            throw new \Exception("Entry $param not found!");
        }
    }

    public function edit($input)
    {
        $param = (isset($input['slug'])) ? $input['slug'] : $input['id'];
        $entries_repository = new EntryRepository($this->model->pdo);
        if ($entry = $entries_repository->findByParam($param)) {
            $this->view = new EntryView();
            $this->view->read($entry);
        } else {
            throw new \Exception("Entry $param not found!");
        }
    }

    public function create($param)
    {
        try {
            if($this->authentication->isLogin()){

                switch ($param['type']){
                    case 'entry':
                        $this->view = new EntryView();
                        $this->view->create();

                        break;
                    /*case 'setting':
                        $key = $param['slug'];
                        $value = $_POST['value'];
                        $options_repository = new OptionRepository($this->model->pdo);
                        $options_repository->update($key, $value);
                        break;*/
                    default:
                        throw new \Exception("Cannot add ".$param["type"]);
                }
                //TODO remove wait time
                sleep(1);

            }else{
                throw new \Exception("You are not logged in.");
            }

        } catch (\Exception $e) {
            header("HTTP/1.0 404 Not Found");
            throw new \Exception($e->getMessage());
        }
    }

}<commit_msg>Added PHPDocs<commit_after><?php

namespace ThePost\Controller\Output;

use ThePost\Controller\CRUD\CreateController;
use ThePost\Controller\CRUD\CRUDController;
use ThePost\Model\Repository\EntryRepository;
use ThePost\View\EntryErrorView;
use ThePost\View\EntryView;
use ThePost\View\PreviewView;

/**
 * Class MainController
 * @package ThePost\Controller
 */
class EntryController extends MainController
{
    /**
     * Displays
     * @param $input Array it stores params given via url
     * @throws \Exception
     */
    public function index($input)
    {
        $param = (isset($input['slug'])) ? $input['slug'] : $input['id'];
        $entries_repository = new EntryRepository($this->model->pdo);
        if ($entry = $entries_repository->findByParam($param)) {
            $this->view = new PreviewView($entry);
        } else {
            throw new \Exception("Entry $param not found!");
        }
    }

    /**
     * Displays the EditView of the entry if given
     * @param $input Array it stores params given via url
     * @throws \Exception
     */
    public function edit($input)
    {
        $param = (isset($input['slug'])) ? $input['slug'] : $input['id'];
        $entries_repository = new EntryRepository($this->model->pdo);
        if ($entry = $entries_repository->findByParam($param)) {
            $this->view = new EntryView();
            $this->view->read($entry);
        } else {
            throw new \Exception("Entry $param not found!");
        }
    }

    /**
     * Displays the entry creation view
     * @param $param Array it stores params given via url
     * @throws \Exception
     */
    public function create($param)
    {
        try {
            if($this->authentication->isLogin()){

                switch ($param['type']){
                    case 'entry':
                        $this->view = new EntryView();
                        $this->view->create();

                        break;
                    default:
                        throw new \Exception("Cannot add ".$param["type"]);
                }
                //TODO remove wait time
                sleep(1);

            }else{
                throw new \Exception("You are not logged in.");
            }

        } catch (\Exception $e) {
            header("HTTP/1.0 404 Not Found");
            throw new \Exception($e->getMessage());
        }
    }

}
{'fraction_non_alphanumeric': 0.1334398721534159, 'fraction_numerical': 0.004794246903715541, 'mean_word_length': 1.6338769068911099, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 38, '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': '2392517', 'n_tokens_mistral': 1372, 'n_tokens_neox': 1280, 'n_words': 299}