<commit_before><?php

/**
 * ownCloud - App Framework
 *
 * @author <NAME>
 * @copyright 2012 <NAME> <EMAIL>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
 * License as published by the Free Software Foundation; either
 * version 3 of the License, or any later version.
 *
 * This library 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 library.  If not, see <http://www.gnu.org/licenses/>.
 *
 */


namespace OCA\AppFramework\DependencyInjection;

use OCA\AppFramework\Http\Request;
use OCA\AppFramework\Core\API;
use OCA\AppFramework\Middleware\MiddlewareDispatcher;
use OCA\AppFramework\Middleware\Security\SecurityMiddleware;
use OCA\AppFramework\Middleware\Twig\TwigMiddleware;


require_once __DIR__ . '/../3rdparty/Pimple/Pimple.php';
require_once __DIR__ . '/../3rdparty/Twig/lib/Twig/Autoloader.php';
\Twig_Autoloader::register();


/**
 * This class extends Pimple (http://pimple.sensiolabs.org/) for reusability
 * To use this class, extend your own container from this. Should you require it
 * you can overwrite the dependencies with your own classes by simply redefining
 * a dependency
 */
class DIContainer extends \Pimple {


	/**
	 * Put your class dependencies in here
	 * @param string $appName the name of the app
	 */
	public function __construct($appName){

		$this['AppName'] = $appName;

		$this['API'] = $this->share(function($c){
			return new API($c['AppName']);
		});

		$this['Request'] = $this->share(function($c) {
			$params = json_decode(file_get_contents('php://input'));
			$params = is_null($params) ? array() : $params;
			return new Request(
				array(
					'get' => $_GET,
					'post' => $_POST,
					'files' => $_FILES,
					'server' => $_SERVER,
					'env' => $_ENV,
					'session' => $_SESSION,
					'cookies' => $_COOKIE,
					'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD']))
							? $_SERVER['REQUEST_METHOD']
							: array(),
					'params' => $params,
					'urlParams' => $c['urlParams']
				)
			);
		});


		/**
		 * Twig
		 */
		// use this to specify the template directory
		$this['TwigTemplateDirectory'] = null;

		// if you want to cache the template directory, add this path
		$this['TwigTemplateCacheDirectory'] = null;<commit_msg>Return null if request method is not set<commit_after><?php

/**
 * ownCloud - App Framework
 *
 * @author <NAME>
 * @copyright 2012 <NAME> <EMAIL>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
 * License as published by the Free Software Foundation; either
 * version 3 of the License, or any later version.
 *
 * This library 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 library.  If not, see <http://www.gnu.org/licenses/>.
 *
 */


namespace OCA\AppFramework\DependencyInjection;

use OCA\AppFramework\Http\Request;
use OCA\AppFramework\Core\API;
use OCA\AppFramework\Middleware\MiddlewareDispatcher;
use OCA\AppFramework\Middleware\Security\SecurityMiddleware;
use OCA\AppFramework\Middleware\Twig\TwigMiddleware;


require_once __DIR__ . '/../3rdparty/Pimple/Pimple.php';
require_once __DIR__ . '/../3rdparty/Twig/lib/Twig/Autoloader.php';
\Twig_Autoloader::register();


/**
 * This class extends Pimple (http://pimple.sensiolabs.org/) for reusability
 * To use this class, extend your own container from this. Should you require it
 * you can overwrite the dependencies with your own classes by simply redefining
 * a dependency
 */
class DIContainer extends \Pimple {


	/**
	 * Put your class dependencies in here
	 * @param string $appName the name of the app
	 */
	public function __construct($appName){

		$this['AppName'] = $appName;

		$this['API'] = $this->share(function($c){
			return new API($c['AppName']);
		});

		$this['Request'] = $this->share(function($c) {
			$params = json_decode(file_get_contents('php://input'));
			$params = is_null($params) ? array() : $params;
			return new Request(
				array(
					'get' => $_GET,
					'post' => $_POST,
					'files' => $_FILES,
					'server' => $_SERVER,
					'env' => $_ENV,
					'session' => $_SESSION,
					'cookies' => $_COOKIE,
					'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD']))
							? $_SERVER['REQUEST_METHOD']
							: null,
					'params' => $params,
					'urlParams' => $c['urlParams']
				)
			);
		});


		/**
		 * Twig
		 */
		// use this to specify the template directory
		$this['TwigTemplateDirectory'] = null;

		// if you want to cache the template directory, add this path
		$this['TwigTemplateCacheDirectory'] = null;
{'fraction_non_alphanumeric': 0.1285604311008468, 'fraction_numerical': 0.0026943802925327174, 'mean_word_length': 3.6735611510791366, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 35, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '2996933', 'n_tokens_mistral': 1768, 'n_tokens_neox': 1550, 'n_words': 506}