<commit_before><?php
/*
 * Fusio
 * A web-application to create dynamically RESTful APIs
 *
 * Copyright (C) 2015-2016 <NAME> <<EMAIL>>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

namespace Fusio\Engine;

use Fusio\Engine\Model;

/**
 * Context
 *
 * @author  <NAME> <<EMAIL>>
 * @license http://www.gnu.org/licenses/agpl-3.0
 * @link    http://fusio-project.org
 */
class Context implements ContextInterface
{
    /**
     * @var integer
     */
    protected $routeId;

    /**
     * @var \Fusio\Engine\Model\AppInterface
     */
    protected $app;

    /**
     * @var \Fusio\Engine\Model\UserInterface
     */
    protected $user;

    /**
     * @var \Fusio\Engine\Model\ActionInterface|null
     */
    protected $action;

    /**
     * @var mixed
     */
    protected $connection;

    /**
     * @param integer $routeId
     * @param \Fusio\Engine\Model\AppInterface $app
     * @param \Fusio\Engine\Model\UserInterface $user
     * @param \Fusio\Engine\Model\ActionInterface|null $action
     */
    public function __construct($routeId, Model\AppInterface $app, Model\UserInterface $user, Model\ActionInterface $action = null)
    {
        $this->routeId = $routeId;
        $this->app     = $app;
        $this->user    = $user;
        $this->action  = $action;
    }

    /**
     * Returns the id of the route
     *
     * @return integer
     */
    public function getRouteId()
    {
        return $this->routeId;
    }

    /**
     * Returns the app which was used for this request. Can also be an anonymous
     * app if authorization is not required for the endpoint
     *<commit_msg>add base url<commit_after><?php
/*
 * Fusio
 * A web-application to create dynamically RESTful APIs
 *
 * Copyright (C) 2015-2016 <NAME> <<EMAIL>>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

namespace Fusio\Engine;

use Fusio\Engine\Model;

/**
 * Context
 *
 * @author  <NAME> <<EMAIL>>
 * @license http://www.gnu.org/licenses/agpl-3.0
 * @link    http://fusio-project.org
 */
class Context implements ContextInterface
{
    /**
     * @var integer
     */
    protected $routeId;

    /**
     * @var string
     */
    protected $baseUrl;

    /**
     * @var \Fusio\Engine\Model\AppInterface
     */
    protected $app;

    /**
     * @var \Fusio\Engine\Model\UserInterface
     */
    protected $user;

    /**
     * @var \Fusio\Engine\Model\ActionInterface|null
     */
    protected $action;

    /**
     * @var mixed
     */
    protected $connection;

    /**
     * @param integer $routeId
     * @param string $baseUrl
     * @param \Fusio\Engine\Model\AppInterface $app
     * @param \Fusio\Engine\Model\UserInterface $user
     */
    public function __construct($routeId, $baseUrl, Model\AppInterface $app, Model\UserInterface $user)
    {
        $this->routeId = $routeId;
        $this->baseUrl = $baseUrl;
        $this->app     = $app;
        $this->user    = $user;
    }

    /**
     * Returns the id of the route
     *
     * @return integer
     */
    public function getRouteId()
    {
        return $this->routeId;
    }

    /**
     * Returns the base url of the system to generate i.e. HATEOAS links. The 
     * url has a trailing slash
     * 
     * @return string
     */
    public function getBaseUrl()
    {
        return $this->baseUrl;
    }

    /**
     * Returns the app which was used for this request. Can also be an anonymous
     * app if authorization is not required for the endpoint
     *
{'fraction_non_alphanumeric': 0.11035218783351121, 'fraction_numerical': 0.004695837780149413, 'mean_word_length': 2.3882863340563993, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 28, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, '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': '5126186', 'n_tokens_mistral': 1411, 'n_tokens_neox': 1367, 'n_words': 459}