<commit_before><?php
/**
 * Created by PhpStorm.
 * User: krona
 * Date: 6/11/14
 * Time: 1:14 PM
 */

namespace Arilas\KronaBundle\Mapping;

use Arilas\KronaBundle\Mvc\AccessDeniedException;
use Arilas\KronaBundle\Mvc\Controller\AbstractActionController;
use Doctrine\Common\Annotations\Annotation\Target;
use ReflectionMethod;

/**
 * Class Identity
 * @package Arilas\KronaBundle\Mapping
 * @Annotation
 * @Target("METHOD")
 */
class Identity implements AnnotationInterface
{
    protected $criteria;

    protected $redirect;

    public function __construct($value)
    {
        if (is_array($value)) {
            $this->criteria = $value['value'];
            $this->redirect = (isset($value['redirect'])) ? $value['redirect'] : null;
        }
    }

    public function check(AbstractActionController $controller, ReflectionMethod $reflectionMethod)
    {
        $identity = $controller->identity();
        if (is_null($identity)) {
            $exception = new AccessDeniedException(
                'You must be authenticated to proceed to this action'
            );
            if (!is_null($this->redirect)) {
                $exception->setRedirect($this->redirect);
            }
            throw $exception;
        }<commit_msg>fix for empty Identity<commit_after><?php
/**
 * Created by PhpStorm.
 * User: krona
 * Date: 6/11/14
 * Time: 1:14 PM
 */

namespace Arilas\KronaBundle\Mapping;

use Arilas\KronaBundle\Mvc\AccessDeniedException;
use Arilas\KronaBundle\Mvc\Controller\AbstractActionController;
use Doctrine\Common\Annotations\Annotation\Target;
use ReflectionMethod;

/**
 * Class Identity
 * @package Arilas\KronaBundle\Mapping
 * @Annotation
 * @Target("METHOD")
 */
class Identity implements AnnotationInterface
{
    protected $criteria;

    protected $redirect;

    public function __construct($value)
    {
        if (is_array($value)) {
            $this->criteria = (isset($value['value'])) ? $value['value'] : [];
            $this->redirect = (isset($value['redirect'])) ? $value['redirect'] : null;
        }
    }

    public function check(AbstractActionController $controller, ReflectionMethod $reflectionMethod)
    {
        $identity = $controller->identity();
        if (is_null($identity)) {
            $exception = new AccessDeniedException(
                'You must be authenticated to proceed to this action'
            );
            if (!is_null($this->redirect)) {
                $exception->setRedirect($this->redirect);
            }
            throw $exception;
        }
{'fraction_non_alphanumeric': 0.12632821723730814, 'fraction_numerical': 0.006296733569460842, 'mean_word_length': 2.8168168168168166, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 15, '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': '1427516', 'n_tokens_mistral': 732, 'n_tokens_neox': 714, 'n_words': 150}