code
stringlengths
1
2.01M
language
stringclasses
1 value
<?php class Asar_Sniffs_WhiteSpace_ScopeClosingBraceSniff implements PHP_CodeSniffer_Sniff { /** * Returns an array of tokens this test wants to listen for. * * @return array */ public function register() { return PHP_CodeSniffer_Tokens::$scopeOpeners; }//end register() ...
PHP
<?php /** * PEAR_Sniffs_Functions_FunctionCallSignatureSniff. * * PHP version 5 * * @category PHP * @package PHP_CodeSniffer * @author Greg Sherwood <gsherwood@squiz.net> * @author Marc McIntyre <mmcintyre@squiz.net> * @copyright 2006 Squiz Pty Ltd (ABN 77 084 670 600) * @license http://matrix.squi...
PHP
<?php if (class_exists('PHP_CodeSniffer_Standards_CodingStandard', true) === false) { throw new PHP_CodeSniffer_Exception('Class PHP_CodeSniffer_Standards_CodingStandard not found'); } class PHP_CodeSniffer_Standards_Asar_AsarCodingStandard extends PHP_CodeSniffer_Standards_CodingStandard { function getIncludedSn...
PHP
<?php class Asar_TempFilesManager { private $temp_dir; function __construct($dir) { if (!file_exists($dir)) { throw new Asar_TempFilesManager_Exception( "The directory specified ($dir) as temporary directory does not exist." ); } $this->temp_dir = $dir; } function getPa...
PHP
<?php class Asar_TestServerManager { private static $can_connect_to_test_server; private $test_data_path; function __construct($test_data_path) { $this->test_data_path = $test_data_path; } private function constructPath() { $args = func_get_args(); return implode(DIRECTORY_SEPARATOR, $ar...
PHP
<?php class Asar_TempFilesManager_Exception extends Exception {}
PHP
<?php require_once 'Asar/Toolset.php'; class Asar { private static $paths = array(), $instance; private $toolset; private function getPath($key, $path) { if (!isset(self::$paths[$key])) { self::$paths[$key] = $this->getFrameworkPath() . $path; } return self::$paths[$key]; } privat...
PHP
<?php class Asar_Request extends Asar_Message implements Asar_Request_Interface { private $path = '/', $method = 'GET', $params = array(); protected $headers = array('Accept' => 'text/html'), $content; function __construct($options = array()) { parent::__construct($option...
PHP
<?php interface Asar_PathDiscover_Interface { function getPermaPath($path_params = array()); }
PHP
<?php class Asar_ClassLoader { private $searcher, $includer; function __construct( Asar_FileSearcher_Interface $searcher, Asar_FileIncludeManager_Interface $includer ) { $this->searcher = $searcher; $this->includer = $includer; } function getSearcher() { return $this->searcher; ...
PHP
<?php class Asar_Message implements Asar_Message_Interface { protected $headers = array(), $content = ''; function __construct($options = array()) { $this->setIfExists('content', $options, 'setContent'); $this->setIfExists('headers', $options, 'setHeaders'); } protected function setIfExists($k...
PHP
<?php class Asar_Router_Default implements Asar_Router_Interface { private $resource_factory, $resource_lister, $debug; function __construct( Asar_ResourceFactory $resource_factory, Asar_ResourceLister_Interface $resource_lister, Asar_Debug $debug = null ) { $this->resource_factory = $resou...
PHP
<?php class Asar_Router_Exception_ResourceNotFound extends Asar_Router_Exception {}
PHP
<?php class Asar_Router_Exception extends Asar_Exception {}
PHP
<?php interface Asar_Router_Interface { function route($app_name, $path, $map); }
PHP
<?php class Asar_FileHelper { function create($filename, $contents) { try { return Asar_File::create($filename)->write($contents)->save(); } catch (Asar_File_Exception_FileAlreadyExists $e) { throw new Asar_FileHelper_Exception_FileAlreadyExists( "The file '$filename' already exists." ...
PHP
<?php interface Asar_Configurable_Interface { function setConfig($key, $value); function getConfig($key); }
PHP
<?php class Asar_MessageFilter_Development implements Asar_RequestFilter_Interface, Asar_ResponseFilter_Interface { private $config, $debug, $exec_start, $printers = array(), $output_types = array( 'text/plain' => 'txt' ); function __construct(Asar_Config_Interface $config, Asa...
PHP
<?php class Asar_MessageFilter_Standard implements Asar_RequestFilter_Interface, Asar_ResponseFilter_Interface { private $config; function __construct(Asar_Config_Interface $config) { $this->config = $config; } function filterRequest(Asar_Request_Interface $request) { $this->removeInternalHead...
PHP
<?php class Asar_Client_Exception_UnknownServerType extends Asar_Client_Exception {}
PHP
<?php class Asar_Client_Exception extends Asar_Exception {}
PHP
<?php class Asar_Resource implements Asar_Resource_Interface, Asar_Config_Interface, Asar_PathDiscover_Interface { protected $request, $config_bag, $path_template, $config = array(); protected static $redirect_codes = array( 'multiple' => 300, 'permanent' => 301, 'b...
PHP
<?php interface Asar_FileIncludeManager_Interface { function requireFileOnce($file); function includeFile($file); }
PHP
<?php class Asar_EnvironmentHelper_Cli { private $cli, $argv, $tasklists = array(), $task_file_loader; function __construct($cli, $argv, $tasklists, $task_file_loader) { $this->cli = $cli; $this->argv = $argv; $this->tasklists = $tasklists; $this->task_file_loader = $task_file_loader; } fu...
PHP
<?php class Asar_EnvironmentHelper_Bootstrap { private $class_loader; function __construct($class_loader) { $this->class_loader = $class_loader; } function run() { $this->loadClassLoader(); } private function loadClassLoader() { spl_autoload_register(array($this->class_loader, 'load')); }...
PHP
<?php class Asar_Resource_Exception_ForwardRequest extends Asar_Resource_Exception { private $payload = array('request' => null); function setPayload($payload) { $this->payload = array_merge($this->payload, $payload); } function getPayload() { return $this->payload; } }
PHP
<?php class Asar_Resource_Exception_Redirect extends Asar_Resource_Exception { private $payload = array('location' => null); function setPayload($payload) { $this->payload = array_merge($this->payload, $payload); } function getPayload() { return $this->payload; } }
PHP
<?php class Asar_Resource_Exception_MethodUndefined extends Asar_Resource_Exception {}
PHP
<?php class Asar_Resource_Exception_NotFound extends Asar_Resource_Exception {}
PHP
<?php class Asar_Resource_Exception extends Asar_Exception {}
PHP
<?php interface Asar_Resource_Interface { function handleRequest(Asar_Request_Interface $request); }
PHP
<?php /** * A wrapper class for simplifying file creation and access * * EXAMPLE - File Creation * The following code creates a file named 'filename.ext' * with the content 'Hello World!' and saves it. * * Asar_File::create('filename.ext')->write('Hello World!')->save(); * * The following code creates a ...
PHP
<?php require_once 'IncludePathManager.php'; class Asar_Toolset { private $include_path_manager; function getIncludePathManager() { if (!$this->include_path_manager) { $this->include_path_manager = new Asar_IncludePathManager; } return $this->include_path_manager; } }
PHP
<?php class Asar_TemplateLFactory { private $locator, $factory; function __construct( Asar_TemplateLocator $locator, Asar_TemplateFactory $factory ) { $this->locator = $locator; $this->factory = $factory; } function getTemplatesFor($resource_name, Asar_Request_Interface $request) { ...
PHP
<?php require 'ClassLoader.php'; require 'FileSearcher.php'; require 'FileIncludeManager.php'; require 'EnvironmentHelper.php'; require 'EnvironmentHelper/Bootstrap.php'; class Asar_Injector { private static $cli; static function injectEnvironmentHelper(Asar_EnvironmentScope $env_scope) { //($request_fa...
PHP
<?php require_once 'FileIncludeManager/Interface.php'; class Asar_FileIncludeManager implements Asar_FileIncludeManager_Interface { private $required_once = array(); function requireFileOnce($file) { // TODO: see if this performs better than require_once(); if (in_array($file, $this->required_once))...
PHP
<?php class Asar_Debug implements Iterator { private $data = array(), $valid = FALSE; function __construct() { } function set($key, $value) { $this->data[$key] = $value; } function get($key) { if (isset($this->data[$key])) { return $this->data[$key]; } return null; ...
PHP
<?php interface Asar_ResourceLister_Interface { function getResourceListFor($app_name); }
PHP
<?php class Asar_Client { function sendRequest($server, $request) { if ($server instanceof Asar_Resource_Interface) { return $server->handleRequest($request); } throw new Asar_Client_Exception_UnknownServerType; } private function sendRequestByMethod($server, $options, $method) { $reque...
PHP
<?php class Asar_Response extends Asar_Message implements Asar_Response_Interface { private $status = 200; private static $reason_phrases = array( 100 => 'Continue', 101 => 'Switching Protocols', 200 => 'OK', 201 => 'Created', 202 => 'Accepted', 203 => 'Non-Authoritative Information', ...
PHP
<?php class Asar_TemplateSimpleRenderer { function renderTemplate( $template, $vars, $layout = null ) { if (!$template instanceof Asar_Template_Interface) { return null; } $output = $template->render($vars); if (!$template->getConfig('no_layout') && $layout instanceof Asar_Template...
PHP
<?php class Asar_Utility_Cli_Command { private $caller, $namespace, $command, $flags = array(), $arguments = array(); function __construct(array $options = array()) { if (array_key_exists('caller', $options)) { $this->caller = $options['caller']; } if (array_key_exists(...
PHP
<?php class Asar_Utility_Cli_TaskFileLoader { private $cwd, $file_peek, $tasks_file, $cli; function __construct( $cwd, Asar_Utility_ClassFilePeek $file_peek, Asar_Utility_Cli $cli ) { $this->cwd = $cwd; $this->file_peek = $file_peek; $this->tasks_file = $this->cwd . DIRECTORY_SEPARATOR . 't...
PHP
<?php class Asar_Utility_Cli_Exception_UndefinedTask extends Asar_Utility_Cli_Exception {}
PHP
<?php interface Asar_Utility_Cli_Executor_Interface { function registerTasks(Asar_Utility_CLI_Interface $tasklist, $namespace = null); function execute(Asar_Utility_Cli_Command $command); function getRegisteredTasks(); }
PHP
<?php class Asar_Utility_Cli_BaseTasks implements Asar_Utility_Cli_Interface { private $controller; private $asar = null; function setController(Asar_Utility_Cli $controller) { $this->controller = $controller; } private function getAsar() { if (!$this->asar) { $this->asar = new Asar; ...
PHP
<?php class Asar_Utility_Cli_Executor implements Asar_Utility_Cli_Executor_Interface { private $tasklists = array(), $tasklists_n = array(); function registerTasks(Asar_Utility_CLI_Interface $tasklist, $namespace = null) { if ($namespace) { $this->tasklists_n[$namespace] = $tasklist; } else { ...
PHP
<?php class Asar_Utility_Cli_Interpreter { function interpret(array $args) { $result = array(); $result['caller'] = array_shift($args); $flags = array(); $arguments = array(); $is_command_found = false; foreach ($args as $arg) { if ($is_command_found) { $arguments[] = $arg; ...
PHP
<?php class Asar_Utility_Cli_Exception extends Asar_Exception {}
PHP
<?php interface Asar_Utility_Cli_Interface { function setController(Asar_Utility_Cli $controller); function getTaskNamespace(); }
PHP
<?php class Asar_Utility_Cli_FrameworkTasks implements Asar_Utility_Cli_Interface { private $controller, $file_helper, $cwd; function __construct(Asar_FileHelper $file_helper) { $this->file_helper = $file_helper; } function setController(Asar_Utility_Cli $controller) { $this->controller = $con...
PHP
<?php class Asar_Utility_Cli { private $interpreter, $executor, $cwd, $out_first; function __construct( Asar_Utility_Cli_Interpreter $interpreter, Asar_Utility_Cli_Executor_Interface $executor, $cwd ) { $this->interpreter = $interpreter; $this->executor = $executor; $this->cwd = $cw...
PHP
<?php class Asar_Utility_ClassFilePeek { function getDefinedClasses($file) { $php_code = file_get_contents($file); $classes = $this->get_php_classes($php_code); return $classes; } private function get_php_classes($php_code) { $classes = array(); $tokens = token_get_all($php_code); $co...
PHP
<?php class Asar_Utility_String { static function dashCamelCase($string) { return str_replace(' ', '-', self::ucwordsLower($string)); } static function dashLowerCase($string) { return self::uncamelize($string, '-'); } private static function uncamelize($string, $splitter="_") { $string = pre...
PHP
<?php class Asar_HttpServer_Fsocket implements Asar_Resource_Interface { private $host; function __construct($host) { $this->host = $host; } function handleRequest(Asar_Request_Interface $request) { $rstr = $this->createRawHttpRequestString($request); if ($rstr) { return $this->exp...
PHP
<?php class Asar_HttpServer_Exception extends Asar_Exception {}
PHP
<?php // TODO: This object seems to have too much responsibility. Refactor. class Asar_Templater implements Asar_Resource_Interface, Asar_Config_Interface, Asar_PathDiscover_Interface { private $resource, $renderer, $config; function __construct( Asar_Resource_Interface $resource, Asar_TemplateR...
PHP
<?php class Asar_Template_Exception_FileNotFound extends Asar_Template_Exception {}
PHP
<?php class Asar_Template_Exception extends Asar_Exception {}
PHP
<?php interface Asar_Template_Interface extends Asar_Configurable_Interface { function setTemplateFile($file); function getTemplateFile(); function getLayoutVars(); function render($vars=array()); }
PHP
<?php class Asar_DebugPrinter_Null implements Asar_DebugPrinter_Interface { function printDebug(Asar_Debug $debug, $content) { return $content; } }
PHP
<?php interface Asar_DebugPrinter_Interface { function printDebug(Asar_Debug $debug, $content); }
PHP
<?php class Asar_DebugPrinter_Html implements Asar_DebugPrinter_Interface { private $block_elements = array('div', 'table', 'tbody', 'tr'); function printDebug(Asar_Debug $debug, $content) { if (strpos($content, '</body>')) { return str_replace( '</body>', $this->createDebugContent($debug) ...
PHP
<?php class Asar_ApplicationScope { private $app_name, $config, $cache = array(); function __construct($app_name, Asar_Config $config) { $this->app_name = $app_name; $this->config = $config; } function getAppName() { return $this->app_name; } function getConfig() { return $this-...
PHP
<?php interface Asar_ResponseFilter_Interface { function filterResponse(Asar_Response_Interface $response); }
PHP
<?php class Asar_Application implements Asar_Resource_Interface { private $map, $router, $status_messages, $name, $request_filters = array(), $response_filters = array(), $forward_level_max = 20, $forward_recursion = 0; function __construct( $name, Asar_Router_Interface $r...
PHP
<?php interface Asar_Response_StatusMessages_Interface { function getMessage( Asar_Response_Interface $response, Asar_Request_Interface $request ); }
PHP
<?php class Asar_Response_StatusMessages implements Asar_Response_StatusMessages_Interface { static protected $status_messages = array( 404 => 'Sorry, we were unable to find the resource you were looking for (%s). Please check that you got the address or URL correctly. If that is the case, please email the...
PHP
<?php interface Asar_Response_Interface extends Asar_Message_Interface { function setStatus($status); function getStatus(); }
PHP
<?php class Asar_Template implements Asar_Template_Interface { private $file, $layout = array(), $config = array( 'no_layout' => false ); function setTemplateFile($file) { if (!file_exists($file)) { throw new Asar_Template_Exception_FileNotFound( "The file '$file' p...
PHP
<?php class Asar_ResourceFactory { function __construct( Asar_TemplateLFactory $tl_factory, Asar_TemplateSimpleRenderer $ts_renderer, Asar_Config_Interface $config ) { $this->tl_factory = $tl_factory; $this->ts_renderer = $ts_renderer; $this->config = $config; } // TODO: This can ...
PHP
<?php class Asar_Config_Default extends Asar_Config { protected $config = array( 'map' => array('/' => 'Index'), 'template_engines' => array('php' => 'Asar_Template'), 'use_templates' => true, 'default_classes' => array( 'application' => 'Asar_ApplicationBasic', 'con...
PHP
<?php class Asar_Config_Development extends Asar_Config { protected $config = array( 'request_filters' => array( 'standard' => 'Asar_MessageFilter_Standard', 'development' => 'Asar_MessageFilter_Development' ), 'response_filters' => array( 'development' => 'Asar_Mes...
PHP
<?php class Asar_Config_Exception extends Asar_Exception {}
PHP
<?php interface Asar_Config_Interface { function getConfig($key = null); function importConfig(Asar_Config_Interface $config); }
PHP
<?php class Asar_ResourceLister implements Asar_ResourceLister_Interface { private $file_searcher; function __construct(Asar_FileSearcher $file_searcher) { $this->file_searcher = $file_searcher; } // TODO: Possibly make use of directory iterator instead function getResourceListFor($app_name) { ...
PHP
<?php class Asar_File_Exception_DirectoryNotFound extends Asar_File_Exception {}
PHP
<?php class Asar_File_Exception_FileDoesNotExist extends Asar_File_Exception {}
PHP
<?php class Asar_File_Exception_FileAlreadyExists extends Asar_File_Exception {}
PHP
<?php class Asar_File_Exception extends Asar_Exception {}
PHP
<?php class Asar_ApplicationBasic extends Asar_Application { }
PHP
<?php interface Asar_Request_Interface extends Asar_Message_Interface { function setParams(array $params); function getParams(); function setPath($path); function getPath(); function setMethod($method); function getMethod(); }
PHP
<?php // TODO: Refactor this!!! class Asar_ApplicationFactory { private $config, $file_searcher, $loaded_message_filters = array(); function __construct(Asar_Config_Interface $config) { $this->config = $config; } function getApplication($app_name) { $classes = $this->getClasses($a...
PHP
<?php class Asar_Config implements Asar_Config_Interface { protected $config = array(); function __construct($init_config = array()) { if ($init_config) { $this->config = $this->configMerge($init_config, $this->config); } } function getConfig($key = null) { if (is_string($key)) { ...
PHP
<?php class Asar_TemplateLocator { private $app_path, $representation_path, $content_negotiator, $engine_extensions, $mime_types = array( 'application/xhtml+xml' => 'xhtml', 'text/html' => 'html', 'application/xml' => 'xml', 'application/json' => 'json', 'text/ja...
PHP
<?php class Asar_IncludePathManager { function add() { $paths = func_get_args(); foreach ($paths as $path) { if (is_array($path)) { foreach ($path as $p) { $this->add($p); } } else { $this->realAdd($path); } } } private function realAdd($path)...
PHP
<?php class Asar_Representation implements Asar_Resource_Interface, Asar_Config_Interface { protected $resource, $config = array(), $methods = array( 'text/html' => 'Html', 'text/plain' => 'Txt', 'application/xml' => 'Xml', 'application/json' => 'Json', ); ...
PHP
<?php class Asar_ContentNegotiator_Exception extends Asar_Exception {}
PHP
<?php interface Asar_ContentNegotiator_Interface { function negotiateFormat($accept_header, array $available_formats); }
PHP
<?php class Asar_TemplateFactory { private $engines, $debug; function __construct(Asar_Debug $debug = null) { $this->debug = $debug; } //TODO: This should be moved to constructor function registerTemplateEngine($extension, $engine) { $this->engines[$extension] = $engine; } function ge...
PHP
<?php class Asar_ApplicationInjector { private static $loaded_filters = array(); public static function injectApplication(Asar_ApplicationScope $scope) { $app_full_name = self::getApplicationClass($scope); $app = new $app_full_name( $scope->getAppName(), self::injectRouter($scope), ...
PHP
<?php interface Asar_FileSearcher_Interface { function find($file_path); }
PHP
<?php class Asar_TemplateRenderer { private $factory, $renderer; function __construct( Asar_TemplateLFactory $factory, Asar_TemplateSimpleRenderer $renderer ) { $this->factory = $factory; $this->renderer = $renderer; } function renderFor( $resource_name, Asar_Response $response, ...
PHP
<?php class Asar_MessageFilterFactory { private $config, $debug, $filters = array(); function __construct(Asar_Config_Interface $config, Asar_Debug $debug) { $this->config = $config; $this->debug = $this->debug = $debug; } function getFilter($filter_name) { if (!isset($this->filters[$filt...
PHP
<?php class Asar_FileHelper_Exception_ParentDirectoryDoesNotExist extends Asar_FileHelper_Exception {}
PHP
<?php class Asar_FileHelper_Exception_DirectoryAlreadyExists extends Asar_FileHelper_Exception {}
PHP
<?php class Asar_FileHelper_Exception_FileAlreadyExists extends Asar_FileHelper_Exception {}
PHP
<?php class Asar_FileHelper_Exception extends Asar_Exception {}
PHP
<?php class Asar_ApplicationRunner { private $app, $request_factory, $app_factory, $server, $params, $post; function __construct($app, $response_exporter, $app_factory, $server, $params, $post) { $this->app = $app; $this->request_factory = $request_factory; $this->app_factory = $app_factory; $thi...
PHP
<?php class Asar_Representation_Exception_Unavailable extends Asar_Representation_Exception {}
PHP