id
int32
0
241k
repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
238,900
bishopb/vanilla
library/core/class.applicationmanager.php
Gdn_ApplicationManager.AvailableApplications
public function AvailableApplications() { if (!is_array($this->_AvailableApplications)) { $ApplicationInfo = array(); $AppFolders = Gdn_FileSystem::Folders(PATH_APPLICATIONS); // Get an array of all application folders $ApplicationAboutFiles = Gdn_FileSystem::FindAll(PATH_APPLICATIONS, 'settings' . DS . 'about.php', $AppFolders); // Now look for about files within them. // Include them all right here and fill the application info array $ApplicationCount = count($ApplicationAboutFiles); for ($i = 0; $i < $ApplicationCount; ++$i) { include($ApplicationAboutFiles[$i]); // Define the folder name for the newly added item foreach ($ApplicationInfo as $ApplicationName => $Info) { if (array_key_exists('Folder', $ApplicationInfo[$ApplicationName]) === FALSE) { $Folder = substr($ApplicationAboutFiles[$i], strlen(PATH_APPLICATIONS)); if (substr($Folder, 0, 1) == DS) $Folder = substr($Folder, 1); $Folder = substr($Folder, 0, strpos($Folder, DS)); $ApplicationInfo[$ApplicationName]['Folder'] = $Folder; } } } // Add all of the indexes to the applications. foreach ($ApplicationInfo as $Index => &$Info) { $Info['Index'] = $Index; } $this->_AvailableApplications = $ApplicationInfo; } return $this->_AvailableApplications; }
php
public function AvailableApplications() { if (!is_array($this->_AvailableApplications)) { $ApplicationInfo = array(); $AppFolders = Gdn_FileSystem::Folders(PATH_APPLICATIONS); // Get an array of all application folders $ApplicationAboutFiles = Gdn_FileSystem::FindAll(PATH_APPLICATIONS, 'settings' . DS . 'about.php', $AppFolders); // Now look for about files within them. // Include them all right here and fill the application info array $ApplicationCount = count($ApplicationAboutFiles); for ($i = 0; $i < $ApplicationCount; ++$i) { include($ApplicationAboutFiles[$i]); // Define the folder name for the newly added item foreach ($ApplicationInfo as $ApplicationName => $Info) { if (array_key_exists('Folder', $ApplicationInfo[$ApplicationName]) === FALSE) { $Folder = substr($ApplicationAboutFiles[$i], strlen(PATH_APPLICATIONS)); if (substr($Folder, 0, 1) == DS) $Folder = substr($Folder, 1); $Folder = substr($Folder, 0, strpos($Folder, DS)); $ApplicationInfo[$ApplicationName]['Folder'] = $Folder; } } } // Add all of the indexes to the applications. foreach ($ApplicationInfo as $Index => &$Info) { $Info['Index'] = $Index; } $this->_AvailableApplications = $ApplicationInfo; } return $this->_AvailableApplications; }
[ "public", "function", "AvailableApplications", "(", ")", "{", "if", "(", "!", "is_array", "(", "$", "this", "->", "_AvailableApplications", ")", ")", "{", "$", "ApplicationInfo", "=", "array", "(", ")", ";", "$", "AppFolders", "=", "Gdn_FileSystem", "::", "Folders", "(", "PATH_APPLICATIONS", ")", ";", "// Get an array of all application folders", "$", "ApplicationAboutFiles", "=", "Gdn_FileSystem", "::", "FindAll", "(", "PATH_APPLICATIONS", ",", "'settings'", ".", "DS", ".", "'about.php'", ",", "$", "AppFolders", ")", ";", "// Now look for about files within them.", "// Include them all right here and fill the application info array", "$", "ApplicationCount", "=", "count", "(", "$", "ApplicationAboutFiles", ")", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "$", "ApplicationCount", ";", "++", "$", "i", ")", "{", "include", "(", "$", "ApplicationAboutFiles", "[", "$", "i", "]", ")", ";", "// Define the folder name for the newly added item", "foreach", "(", "$", "ApplicationInfo", "as", "$", "ApplicationName", "=>", "$", "Info", ")", "{", "if", "(", "array_key_exists", "(", "'Folder'", ",", "$", "ApplicationInfo", "[", "$", "ApplicationName", "]", ")", "===", "FALSE", ")", "{", "$", "Folder", "=", "substr", "(", "$", "ApplicationAboutFiles", "[", "$", "i", "]", ",", "strlen", "(", "PATH_APPLICATIONS", ")", ")", ";", "if", "(", "substr", "(", "$", "Folder", ",", "0", ",", "1", ")", "==", "DS", ")", "$", "Folder", "=", "substr", "(", "$", "Folder", ",", "1", ")", ";", "$", "Folder", "=", "substr", "(", "$", "Folder", ",", "0", ",", "strpos", "(", "$", "Folder", ",", "DS", ")", ")", ";", "$", "ApplicationInfo", "[", "$", "ApplicationName", "]", "[", "'Folder'", "]", "=", "$", "Folder", ";", "}", "}", "}", "// Add all of the indexes to the applications.", "foreach", "(", "$", "ApplicationInfo", "as", "$", "Index", "=>", "&", "$", "Info", ")", "{", "$", "Info", "[", "'Index'", "]", "=", "$", "Index", ";", "}", "$", "this", "->", "_AvailableApplications", "=", "$", "ApplicationInfo", ";", "}", "return", "$", "this", "->", "_AvailableApplications", ";", "}" ]
Looks through the root Garden directory for valid applications and returns them as an associative array of "Application Name" => "Application Info Array". It also adds a "Folder" definition to the Application Info Array for each application.
[ "Looks", "through", "the", "root", "Garden", "directory", "for", "valid", "applications", "and", "returns", "them", "as", "an", "associative", "array", "of", "Application", "Name", "=", ">", "Application", "Info", "Array", ".", "It", "also", "adds", "a", "Folder", "definition", "to", "the", "Application", "Info", "Array", "for", "each", "application", "." ]
8494eb4a4ad61603479015a8054d23ff488364e8
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/library/core/class.applicationmanager.php#L47-L79
238,901
bishopb/vanilla
library/core/class.applicationmanager.php
Gdn_ApplicationManager.EnabledApplications
public function EnabledApplications() { if (!is_array($this->_EnabledApplications)) { $EnabledApplications = Gdn::Config('EnabledApplications', array('Dashboard' => 'dashboard')); // Add some information about the applications to the array. foreach($EnabledApplications as $Name => $Folder) { $EnabledApplications[$Name] = array('Folder' => $Folder); //$EnabledApplications[$Name]['Version'] = Gdn::Config($Name.'.Version', ''); $EnabledApplications[$Name]['Version'] = ''; $EnabledApplications[$Name]['Index'] = $Name; // Get the application version from it's about file. $AboutPath = PATH_APPLICATIONS.'/'.strtolower($Name).'/settings/about.php'; if (file_exists($AboutPath)) { $ApplicationInfo = array(); include $AboutPath; $EnabledApplications[$Name]['Version'] = GetValueR("$Name.Version", $ApplicationInfo, ''); } } $this->_EnabledApplications = $EnabledApplications; } return $this->_EnabledApplications; }
php
public function EnabledApplications() { if (!is_array($this->_EnabledApplications)) { $EnabledApplications = Gdn::Config('EnabledApplications', array('Dashboard' => 'dashboard')); // Add some information about the applications to the array. foreach($EnabledApplications as $Name => $Folder) { $EnabledApplications[$Name] = array('Folder' => $Folder); //$EnabledApplications[$Name]['Version'] = Gdn::Config($Name.'.Version', ''); $EnabledApplications[$Name]['Version'] = ''; $EnabledApplications[$Name]['Index'] = $Name; // Get the application version from it's about file. $AboutPath = PATH_APPLICATIONS.'/'.strtolower($Name).'/settings/about.php'; if (file_exists($AboutPath)) { $ApplicationInfo = array(); include $AboutPath; $EnabledApplications[$Name]['Version'] = GetValueR("$Name.Version", $ApplicationInfo, ''); } } $this->_EnabledApplications = $EnabledApplications; } return $this->_EnabledApplications; }
[ "public", "function", "EnabledApplications", "(", ")", "{", "if", "(", "!", "is_array", "(", "$", "this", "->", "_EnabledApplications", ")", ")", "{", "$", "EnabledApplications", "=", "Gdn", "::", "Config", "(", "'EnabledApplications'", ",", "array", "(", "'Dashboard'", "=>", "'dashboard'", ")", ")", ";", "// Add some information about the applications to the array.", "foreach", "(", "$", "EnabledApplications", "as", "$", "Name", "=>", "$", "Folder", ")", "{", "$", "EnabledApplications", "[", "$", "Name", "]", "=", "array", "(", "'Folder'", "=>", "$", "Folder", ")", ";", "//$EnabledApplications[$Name]['Version'] = Gdn::Config($Name.'.Version', '');", "$", "EnabledApplications", "[", "$", "Name", "]", "[", "'Version'", "]", "=", "''", ";", "$", "EnabledApplications", "[", "$", "Name", "]", "[", "'Index'", "]", "=", "$", "Name", ";", "// Get the application version from it's about file.", "$", "AboutPath", "=", "PATH_APPLICATIONS", ".", "'/'", ".", "strtolower", "(", "$", "Name", ")", ".", "'/settings/about.php'", ";", "if", "(", "file_exists", "(", "$", "AboutPath", ")", ")", "{", "$", "ApplicationInfo", "=", "array", "(", ")", ";", "include", "$", "AboutPath", ";", "$", "EnabledApplications", "[", "$", "Name", "]", "[", "'Version'", "]", "=", "GetValueR", "(", "\"$Name.Version\"", ",", "$", "ApplicationInfo", ",", "''", ")", ";", "}", "}", "$", "this", "->", "_EnabledApplications", "=", "$", "EnabledApplications", ";", "}", "return", "$", "this", "->", "_EnabledApplications", ";", "}" ]
Gets an array of all of the enabled applications. @return array
[ "Gets", "an", "array", "of", "all", "of", "the", "enabled", "applications", "." ]
8494eb4a4ad61603479015a8054d23ff488364e8
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/library/core/class.applicationmanager.php#L85-L106
238,902
laravel-commode/common
src/LaravelCommode/Common/GhostService/GhostService.php
GhostService.prepareService
private function prepareService() { /** * If CommodeCommonServiceProvider is not loaded yet, load it * and mark as registered in GhostServices */ if (!($bound = $this->app->bound(ServiceShortCuts::CORE_INITIALIZED))) { $this->services(['LaravelCommode\Common\CommodeCommonServiceProvider']); } $withGhostServiceDo = function (GhostServices $appServices) use ($bound) { /** * If CommodeCommonServiceProvider is not loaded yet, load it * and mark as registered in GhostServices */ if (!$bound) { $appServices->register('LaravelCommode\Common\CommodeCommonServiceProvider'); } /** * Get and register service providers in ServiceManager */ $services = $appServices->differUnique($this->uses(), true); /** * Register service proviers in laravel app * differing from already used ones */ $this->services(array_diff($services, array_keys($this->app->getLoadedProviders()))); /** * Mark current service as registered */ $appServices->register(get_class($this)); }; $this->with(ServiceShortCuts::GHOST_SERVICE, $withGhostServiceDo); return $this; }
php
private function prepareService() { /** * If CommodeCommonServiceProvider is not loaded yet, load it * and mark as registered in GhostServices */ if (!($bound = $this->app->bound(ServiceShortCuts::CORE_INITIALIZED))) { $this->services(['LaravelCommode\Common\CommodeCommonServiceProvider']); } $withGhostServiceDo = function (GhostServices $appServices) use ($bound) { /** * If CommodeCommonServiceProvider is not loaded yet, load it * and mark as registered in GhostServices */ if (!$bound) { $appServices->register('LaravelCommode\Common\CommodeCommonServiceProvider'); } /** * Get and register service providers in ServiceManager */ $services = $appServices->differUnique($this->uses(), true); /** * Register service proviers in laravel app * differing from already used ones */ $this->services(array_diff($services, array_keys($this->app->getLoadedProviders()))); /** * Mark current service as registered */ $appServices->register(get_class($this)); }; $this->with(ServiceShortCuts::GHOST_SERVICE, $withGhostServiceDo); return $this; }
[ "private", "function", "prepareService", "(", ")", "{", "/**\n * If CommodeCommonServiceProvider is not loaded yet, load it\n * and mark as registered in GhostServices\n */", "if", "(", "!", "(", "$", "bound", "=", "$", "this", "->", "app", "->", "bound", "(", "ServiceShortCuts", "::", "CORE_INITIALIZED", ")", ")", ")", "{", "$", "this", "->", "services", "(", "[", "'LaravelCommode\\Common\\CommodeCommonServiceProvider'", "]", ")", ";", "}", "$", "withGhostServiceDo", "=", "function", "(", "GhostServices", "$", "appServices", ")", "use", "(", "$", "bound", ")", "{", "/**\n * If CommodeCommonServiceProvider is not loaded yet, load it\n * and mark as registered in GhostServices\n */", "if", "(", "!", "$", "bound", ")", "{", "$", "appServices", "->", "register", "(", "'LaravelCommode\\Common\\CommodeCommonServiceProvider'", ")", ";", "}", "/**\n * Get and register service providers in ServiceManager\n */", "$", "services", "=", "$", "appServices", "->", "differUnique", "(", "$", "this", "->", "uses", "(", ")", ",", "true", ")", ";", "/**\n * Register service proviers in laravel app\n * differing from already used ones\n */", "$", "this", "->", "services", "(", "array_diff", "(", "$", "services", ",", "array_keys", "(", "$", "this", "->", "app", "->", "getLoadedProviders", "(", ")", ")", ")", ")", ";", "/**\n * Mark current service as registered\n */", "$", "appServices", "->", "register", "(", "get_class", "(", "$", "this", ")", ")", ";", "}", ";", "$", "this", "->", "with", "(", "ServiceShortCuts", "::", "GHOST_SERVICE", ",", "$", "withGhostServiceDo", ")", ";", "return", "$", "this", ";", "}" ]
Prepares service for launching. If LaravelCommode\Common\CommodeCommonServiceProvider is not registered in your app config, it will be forced to launch. Loads all services used by current GhostService instance. @return $this
[ "Prepares", "service", "for", "launching", ".", "If", "LaravelCommode", "\\", "Common", "\\", "CommodeCommonServiceProvider", "is", "not", "registered", "in", "your", "app", "config", "it", "will", "be", "forced", "to", "launch", ".", "Loads", "all", "services", "used", "by", "current", "GhostService", "instance", "." ]
5c9289c3ce5bbd934281c4ac7537657d32c5a9ec
https://github.com/laravel-commode/common/blob/5c9289c3ce5bbd934281c4ac7537657d32c5a9ec/src/LaravelCommode/Common/GhostService/GhostService.php#L58-L97
238,903
amercier/rectangular-mozaic
src/Generator.php
Generator.generateGrid
protected function generateGrid($tiles, $columns) { [$distribution, $grid] = Distributor::distribute( $tiles, $columns, $this->settings['tallRate'], $this->settings['wideRate'] ); RandomFiller::fill($grid, $distribution, $this->settings['maxFillRetries']); return $grid; }
php
protected function generateGrid($tiles, $columns) { [$distribution, $grid] = Distributor::distribute( $tiles, $columns, $this->settings['tallRate'], $this->settings['wideRate'] ); RandomFiller::fill($grid, $distribution, $this->settings['maxFillRetries']); return $grid; }
[ "protected", "function", "generateGrid", "(", "$", "tiles", ",", "$", "columns", ")", "{", "[", "$", "distribution", ",", "$", "grid", "]", "=", "Distributor", "::", "distribute", "(", "$", "tiles", ",", "$", "columns", ",", "$", "this", "->", "settings", "[", "'tallRate'", "]", ",", "$", "this", "->", "settings", "[", "'wideRate'", "]", ")", ";", "RandomFiller", "::", "fill", "(", "$", "grid", ",", "$", "distribution", ",", "$", "this", "->", "settings", "[", "'maxFillRetries'", "]", ")", ";", "return", "$", "grid", ";", "}" ]
Generate a Grid that contains a given number of columns. @param int $tiles Total number of tiles. @param int $columns Number of columns of the grid. @return Grid A new grid filled with Cell values.
[ "Generate", "a", "Grid", "that", "contains", "a", "given", "number", "of", "columns", "." ]
d026a82c1bc73979308235a7a440665e92ee8525
https://github.com/amercier/rectangular-mozaic/blob/d026a82c1bc73979308235a7a440665e92ee8525/src/Generator.php#L49-L59
238,904
EcomDev/phpspec-file-matcher
src/Extension.php
Extension.load
public function load(ServiceContainer $container, array $params) { $container->define( 'ecomdev.matcher.file', function () { return $this->createFileMatcher(); }, ['matchers'] ); $container->define( 'ecomdev.matcher.file_content', function () { return $this->createFileContentMatcher(); }, ['matchers'] ); $container->define( 'ecomdev.matcher.directory', function () { return $this->createDirectoryMatcher(); }, ['matchers'] ); }
php
public function load(ServiceContainer $container, array $params) { $container->define( 'ecomdev.matcher.file', function () { return $this->createFileMatcher(); }, ['matchers'] ); $container->define( 'ecomdev.matcher.file_content', function () { return $this->createFileContentMatcher(); }, ['matchers'] ); $container->define( 'ecomdev.matcher.directory', function () { return $this->createDirectoryMatcher(); }, ['matchers'] ); }
[ "public", "function", "load", "(", "ServiceContainer", "$", "container", ",", "array", "$", "params", ")", "{", "$", "container", "->", "define", "(", "'ecomdev.matcher.file'", ",", "function", "(", ")", "{", "return", "$", "this", "->", "createFileMatcher", "(", ")", ";", "}", ",", "[", "'matchers'", "]", ")", ";", "$", "container", "->", "define", "(", "'ecomdev.matcher.file_content'", ",", "function", "(", ")", "{", "return", "$", "this", "->", "createFileContentMatcher", "(", ")", ";", "}", ",", "[", "'matchers'", "]", ")", ";", "$", "container", "->", "define", "(", "'ecomdev.matcher.directory'", ",", "function", "(", ")", "{", "return", "$", "this", "->", "createDirectoryMatcher", "(", ")", ";", "}", ",", "[", "'matchers'", "]", ")", ";", "}" ]
Loads matchers into PHPSpec service container @param ServiceContainer $container @param array $params
[ "Loads", "matchers", "into", "PHPSpec", "service", "container" ]
5323bf833774c3d9d763bc01cdc7354a2985b47c
https://github.com/EcomDev/phpspec-file-matcher/blob/5323bf833774c3d9d763bc01cdc7354a2985b47c/src/Extension.php#L18-L43
238,905
EcomDev/phpspec-file-matcher
src/Extension.php
Extension.createCheckMatcher
private function createCheckMatcher($verbs, $nouns, ...$matcherArguments) { return new CheckMatcher( $this->createLexer($verbs, $nouns), ...$matcherArguments ); }
php
private function createCheckMatcher($verbs, $nouns, ...$matcherArguments) { return new CheckMatcher( $this->createLexer($verbs, $nouns), ...$matcherArguments ); }
[ "private", "function", "createCheckMatcher", "(", "$", "verbs", ",", "$", "nouns", ",", "...", "$", "matcherArguments", ")", "{", "return", "new", "CheckMatcher", "(", "$", "this", "->", "createLexer", "(", "$", "verbs", ",", "$", "nouns", ")", ",", "...", "$", "matcherArguments", ")", ";", "}" ]
Create check matcher instance @param string[] $verbs @param string[] $nouns @param array $matcherArguments @return CheckMatcher
[ "Create", "check", "matcher", "instance" ]
5323bf833774c3d9d763bc01cdc7354a2985b47c
https://github.com/EcomDev/phpspec-file-matcher/blob/5323bf833774c3d9d763bc01cdc7354a2985b47c/src/Extension.php#L121-L127
238,906
mpoiriert/draw-test-helper-bundle
Helper/BaseRequestHelper.php
BaseRequestHelper.instantiate
static public function instantiate(RequestHelper $requestHelper) { $objectHash = spl_object_hash($requestHelper); if(static::isSingleInstance()) { if(isset(static::$instances[$objectHash][static::getName()])) { return static::$instances[$objectHash][static::getName()]; } } $instance = new static(); $instance->requestHelper = $requestHelper; $instance->initialize(); $requestHelper->getEventDispatcher() ->dispatch( RequestHelper::EVENT_NEW_HELPER, new RequestHelperEvent($requestHelper, array('helper' => $instance)) ); if(static::isSingleInstance()) { static::$instances[$objectHash][static::getName()] = $instance; } return $instance; }
php
static public function instantiate(RequestHelper $requestHelper) { $objectHash = spl_object_hash($requestHelper); if(static::isSingleInstance()) { if(isset(static::$instances[$objectHash][static::getName()])) { return static::$instances[$objectHash][static::getName()]; } } $instance = new static(); $instance->requestHelper = $requestHelper; $instance->initialize(); $requestHelper->getEventDispatcher() ->dispatch( RequestHelper::EVENT_NEW_HELPER, new RequestHelperEvent($requestHelper, array('helper' => $instance)) ); if(static::isSingleInstance()) { static::$instances[$objectHash][static::getName()] = $instance; } return $instance; }
[ "static", "public", "function", "instantiate", "(", "RequestHelper", "$", "requestHelper", ")", "{", "$", "objectHash", "=", "spl_object_hash", "(", "$", "requestHelper", ")", ";", "if", "(", "static", "::", "isSingleInstance", "(", ")", ")", "{", "if", "(", "isset", "(", "static", "::", "$", "instances", "[", "$", "objectHash", "]", "[", "static", "::", "getName", "(", ")", "]", ")", ")", "{", "return", "static", "::", "$", "instances", "[", "$", "objectHash", "]", "[", "static", "::", "getName", "(", ")", "]", ";", "}", "}", "$", "instance", "=", "new", "static", "(", ")", ";", "$", "instance", "->", "requestHelper", "=", "$", "requestHelper", ";", "$", "instance", "->", "initialize", "(", ")", ";", "$", "requestHelper", "->", "getEventDispatcher", "(", ")", "->", "dispatch", "(", "RequestHelper", "::", "EVENT_NEW_HELPER", ",", "new", "RequestHelperEvent", "(", "$", "requestHelper", ",", "array", "(", "'helper'", "=>", "$", "instance", ")", ")", ")", ";", "if", "(", "static", "::", "isSingleInstance", "(", ")", ")", "{", "static", "::", "$", "instances", "[", "$", "objectHash", "]", "[", "static", "::", "getName", "(", ")", "]", "=", "$", "instance", ";", "}", "return", "$", "instance", ";", "}" ]
Return a instance of himself. Sometime only one helper of a specific type must be set for a request so the same instance can be return if the same request helper is used. This method should always be used instead of the constructor. @param RequestHelper $requestHelper @return static
[ "Return", "a", "instance", "of", "himself", "." ]
cd8bb9cb38f2ee0b333ba1a68152fb20d7d70889
https://github.com/mpoiriert/draw-test-helper-bundle/blob/cd8bb9cb38f2ee0b333ba1a68152fb20d7d70889/Helper/BaseRequestHelper.php#L58-L82
238,907
CodeLoversAt/AclBundle
Handler/AbstractAclHandler.php
AbstractAclHandler.deleteAcl
public function deleteAcl($object) { try { if ($objectIdentity = $this->getObjectIdentity($object)) { $this->aclProvider->deleteAcl($objectIdentity); } } catch (\Exception $e) { // nothing to do } }
php
public function deleteAcl($object) { try { if ($objectIdentity = $this->getObjectIdentity($object)) { $this->aclProvider->deleteAcl($objectIdentity); } } catch (\Exception $e) { // nothing to do } }
[ "public", "function", "deleteAcl", "(", "$", "object", ")", "{", "try", "{", "if", "(", "$", "objectIdentity", "=", "$", "this", "->", "getObjectIdentity", "(", "$", "object", ")", ")", "{", "$", "this", "->", "aclProvider", "->", "deleteAcl", "(", "$", "objectIdentity", ")", ";", "}", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "// nothing to do", "}", "}" ]
delete the ACL for the given object @param object $object
[ "delete", "the", "ACL", "for", "the", "given", "object" ]
024fe2831e81d7ddff071c695b8daec97f25b990
https://github.com/CodeLoversAt/AclBundle/blob/024fe2831e81d7ddff071c695b8daec97f25b990/Handler/AbstractAclHandler.php#L151-L160
238,908
flavorzyb/simple
src/Filesystem/Filesystem.php
Filesystem.files
public function files($directory, $recursive = false) { $result = []; $recursive = boolval($recursive); if ( ! $this->isDirectory($directory)) return []; $items = new FilesystemIterator($directory); foreach ($items as $item) { if ($item->isFile()) { $result[] = $item->getPathname(); } elseif ($recursive && $item->isDir() && ! $item->isLink()) { $subFiles = $this->files($item->getPathname(), $recursive); foreach ($subFiles as $file) { $result[] = $file; } } } return $result; }
php
public function files($directory, $recursive = false) { $result = []; $recursive = boolval($recursive); if ( ! $this->isDirectory($directory)) return []; $items = new FilesystemIterator($directory); foreach ($items as $item) { if ($item->isFile()) { $result[] = $item->getPathname(); } elseif ($recursive && $item->isDir() && ! $item->isLink()) { $subFiles = $this->files($item->getPathname(), $recursive); foreach ($subFiles as $file) { $result[] = $file; } } } return $result; }
[ "public", "function", "files", "(", "$", "directory", ",", "$", "recursive", "=", "false", ")", "{", "$", "result", "=", "[", "]", ";", "$", "recursive", "=", "boolval", "(", "$", "recursive", ")", ";", "if", "(", "!", "$", "this", "->", "isDirectory", "(", "$", "directory", ")", ")", "return", "[", "]", ";", "$", "items", "=", "new", "FilesystemIterator", "(", "$", "directory", ")", ";", "foreach", "(", "$", "items", "as", "$", "item", ")", "{", "if", "(", "$", "item", "->", "isFile", "(", ")", ")", "{", "$", "result", "[", "]", "=", "$", "item", "->", "getPathname", "(", ")", ";", "}", "elseif", "(", "$", "recursive", "&&", "$", "item", "->", "isDir", "(", ")", "&&", "!", "$", "item", "->", "isLink", "(", ")", ")", "{", "$", "subFiles", "=", "$", "this", "->", "files", "(", "$", "item", "->", "getPathname", "(", ")", ",", "$", "recursive", ")", ";", "foreach", "(", "$", "subFiles", "as", "$", "file", ")", "{", "$", "result", "[", "]", "=", "$", "file", ";", "}", "}", "}", "return", "$", "result", ";", "}" ]
get all files in directory @param string $directory @param bool $recursive @return array
[ "get", "all", "files", "in", "directory" ]
8c4c539ae2057217b2637fc72c2a90ba266e8e6c
https://github.com/flavorzyb/simple/blob/8c4c539ae2057217b2637fc72c2a90ba266e8e6c/src/Filesystem/Filesystem.php#L340-L361
238,909
petrofcz/groupie
src/Pcz/Groupie/Groupie.php
Groupie.buildGroups
public function buildGroups($entities, $level = 0) { if(!count($this->groupDefinitions)) { throw new \RuntimeException('There are no groups defined.'); } // Building groups /** @var Group[] $groups */ $groups = []; if(!isset($this->groupDefinitions[$level])) { return []; } $groupDefinition = $this->groupDefinitions[$level]; $entitiesByGroupUid = []; foreach($entities as $entity) { $groupUid = $level . '-' . call_user_func($groupDefinition->getUidRetriever(), $entity); if(!isset($groups[$groupUid])) { $groups[$groupUid] = new Group( $groupUid, call_user_func($groupDefinition->getGroupDataFactory(), $entity), $level, $entity ); $entitiesByGroupUid[$groupUid] = []; } $entitiesByGroupUid[$groupUid][] = $entity; } foreach($entitiesByGroupUid as $groupUid => $iEntities) { $subGroups = $this->buildGroups($iEntities, $level + 1); foreach($subGroups as $subGroup) { $groups[$groupUid]->addChild($subGroup); } } /** @var IColumnData[][] $columnDatasByGroupUid */ $columnDatasByGroupUid = []; foreach($entitiesByGroupUid as $groupUid => $iEntities) { if (!isset($columnDatasByGroupUid[$groupUid])) { $columnDatasByGroupUid[$groupUid] = []; } } $groupDefinition = $this->getGroup($level); foreach($this->getColumnDefinitions() as $columnId => $columnDefinition) { $columnFoundInGroup = false; foreach ($groupDefinition->getColumnDefinitionsWithDataFactories() as $columnDefinitionsWithDataFactory) { list($groupColumnDefinition, $columnDataFactory) = $columnDefinitionsWithDataFactory; if ($columnDefinition->equals($groupColumnDefinition)) { foreach($entitiesByGroupUid as $groupUid => $iEntities) { $columnDatasByGroupUid[$groupUid][] = $columnDataFactory($iEntities); } $columnFoundInGroup = true; break; } } if(!$columnFoundInGroup) { foreach($entitiesByGroupUid as $groupUid => $iEntities) { $columnDatasByGroupUid[$groupUid][] = null; } } } foreach($columnDatasByGroupUid as $groupUid => $columnDatas) { $groups[$groupUid]->setColumnDatas($columnDatas); } $finalGroups = array_values($groups); if(($sortingComparator = $groupDefinition->getSortingComparator()) !== null) { usort($finalGroups, $sortingComparator); } return $finalGroups; }
php
public function buildGroups($entities, $level = 0) { if(!count($this->groupDefinitions)) { throw new \RuntimeException('There are no groups defined.'); } // Building groups /** @var Group[] $groups */ $groups = []; if(!isset($this->groupDefinitions[$level])) { return []; } $groupDefinition = $this->groupDefinitions[$level]; $entitiesByGroupUid = []; foreach($entities as $entity) { $groupUid = $level . '-' . call_user_func($groupDefinition->getUidRetriever(), $entity); if(!isset($groups[$groupUid])) { $groups[$groupUid] = new Group( $groupUid, call_user_func($groupDefinition->getGroupDataFactory(), $entity), $level, $entity ); $entitiesByGroupUid[$groupUid] = []; } $entitiesByGroupUid[$groupUid][] = $entity; } foreach($entitiesByGroupUid as $groupUid => $iEntities) { $subGroups = $this->buildGroups($iEntities, $level + 1); foreach($subGroups as $subGroup) { $groups[$groupUid]->addChild($subGroup); } } /** @var IColumnData[][] $columnDatasByGroupUid */ $columnDatasByGroupUid = []; foreach($entitiesByGroupUid as $groupUid => $iEntities) { if (!isset($columnDatasByGroupUid[$groupUid])) { $columnDatasByGroupUid[$groupUid] = []; } } $groupDefinition = $this->getGroup($level); foreach($this->getColumnDefinitions() as $columnId => $columnDefinition) { $columnFoundInGroup = false; foreach ($groupDefinition->getColumnDefinitionsWithDataFactories() as $columnDefinitionsWithDataFactory) { list($groupColumnDefinition, $columnDataFactory) = $columnDefinitionsWithDataFactory; if ($columnDefinition->equals($groupColumnDefinition)) { foreach($entitiesByGroupUid as $groupUid => $iEntities) { $columnDatasByGroupUid[$groupUid][] = $columnDataFactory($iEntities); } $columnFoundInGroup = true; break; } } if(!$columnFoundInGroup) { foreach($entitiesByGroupUid as $groupUid => $iEntities) { $columnDatasByGroupUid[$groupUid][] = null; } } } foreach($columnDatasByGroupUid as $groupUid => $columnDatas) { $groups[$groupUid]->setColumnDatas($columnDatas); } $finalGroups = array_values($groups); if(($sortingComparator = $groupDefinition->getSortingComparator()) !== null) { usort($finalGroups, $sortingComparator); } return $finalGroups; }
[ "public", "function", "buildGroups", "(", "$", "entities", ",", "$", "level", "=", "0", ")", "{", "if", "(", "!", "count", "(", "$", "this", "->", "groupDefinitions", ")", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "'There are no groups defined.'", ")", ";", "}", "// Building groups", "/** @var Group[] $groups */", "$", "groups", "=", "[", "]", ";", "if", "(", "!", "isset", "(", "$", "this", "->", "groupDefinitions", "[", "$", "level", "]", ")", ")", "{", "return", "[", "]", ";", "}", "$", "groupDefinition", "=", "$", "this", "->", "groupDefinitions", "[", "$", "level", "]", ";", "$", "entitiesByGroupUid", "=", "[", "]", ";", "foreach", "(", "$", "entities", "as", "$", "entity", ")", "{", "$", "groupUid", "=", "$", "level", ".", "'-'", ".", "call_user_func", "(", "$", "groupDefinition", "->", "getUidRetriever", "(", ")", ",", "$", "entity", ")", ";", "if", "(", "!", "isset", "(", "$", "groups", "[", "$", "groupUid", "]", ")", ")", "{", "$", "groups", "[", "$", "groupUid", "]", "=", "new", "Group", "(", "$", "groupUid", ",", "call_user_func", "(", "$", "groupDefinition", "->", "getGroupDataFactory", "(", ")", ",", "$", "entity", ")", ",", "$", "level", ",", "$", "entity", ")", ";", "$", "entitiesByGroupUid", "[", "$", "groupUid", "]", "=", "[", "]", ";", "}", "$", "entitiesByGroupUid", "[", "$", "groupUid", "]", "[", "]", "=", "$", "entity", ";", "}", "foreach", "(", "$", "entitiesByGroupUid", "as", "$", "groupUid", "=>", "$", "iEntities", ")", "{", "$", "subGroups", "=", "$", "this", "->", "buildGroups", "(", "$", "iEntities", ",", "$", "level", "+", "1", ")", ";", "foreach", "(", "$", "subGroups", "as", "$", "subGroup", ")", "{", "$", "groups", "[", "$", "groupUid", "]", "->", "addChild", "(", "$", "subGroup", ")", ";", "}", "}", "/** @var IColumnData[][] $columnDatasByGroupUid */", "$", "columnDatasByGroupUid", "=", "[", "]", ";", "foreach", "(", "$", "entitiesByGroupUid", "as", "$", "groupUid", "=>", "$", "iEntities", ")", "{", "if", "(", "!", "isset", "(", "$", "columnDatasByGroupUid", "[", "$", "groupUid", "]", ")", ")", "{", "$", "columnDatasByGroupUid", "[", "$", "groupUid", "]", "=", "[", "]", ";", "}", "}", "$", "groupDefinition", "=", "$", "this", "->", "getGroup", "(", "$", "level", ")", ";", "foreach", "(", "$", "this", "->", "getColumnDefinitions", "(", ")", "as", "$", "columnId", "=>", "$", "columnDefinition", ")", "{", "$", "columnFoundInGroup", "=", "false", ";", "foreach", "(", "$", "groupDefinition", "->", "getColumnDefinitionsWithDataFactories", "(", ")", "as", "$", "columnDefinitionsWithDataFactory", ")", "{", "list", "(", "$", "groupColumnDefinition", ",", "$", "columnDataFactory", ")", "=", "$", "columnDefinitionsWithDataFactory", ";", "if", "(", "$", "columnDefinition", "->", "equals", "(", "$", "groupColumnDefinition", ")", ")", "{", "foreach", "(", "$", "entitiesByGroupUid", "as", "$", "groupUid", "=>", "$", "iEntities", ")", "{", "$", "columnDatasByGroupUid", "[", "$", "groupUid", "]", "[", "]", "=", "$", "columnDataFactory", "(", "$", "iEntities", ")", ";", "}", "$", "columnFoundInGroup", "=", "true", ";", "break", ";", "}", "}", "if", "(", "!", "$", "columnFoundInGroup", ")", "{", "foreach", "(", "$", "entitiesByGroupUid", "as", "$", "groupUid", "=>", "$", "iEntities", ")", "{", "$", "columnDatasByGroupUid", "[", "$", "groupUid", "]", "[", "]", "=", "null", ";", "}", "}", "}", "foreach", "(", "$", "columnDatasByGroupUid", "as", "$", "groupUid", "=>", "$", "columnDatas", ")", "{", "$", "groups", "[", "$", "groupUid", "]", "->", "setColumnDatas", "(", "$", "columnDatas", ")", ";", "}", "$", "finalGroups", "=", "array_values", "(", "$", "groups", ")", ";", "if", "(", "(", "$", "sortingComparator", "=", "$", "groupDefinition", "->", "getSortingComparator", "(", ")", ")", "!==", "null", ")", "{", "usort", "(", "$", "finalGroups", ",", "$", "sortingComparator", ")", ";", "}", "return", "$", "finalGroups", ";", "}" ]
This method builds the whole structure. @param $entities array Flat array of entities to be grouped. @param int $level Group level index. Levels can be skipped by setting value > 0. @return Group[]
[ "This", "method", "builds", "the", "whole", "structure", "." ]
727773562d4559de5b6c65eb557b867f0b533ba5
https://github.com/petrofcz/groupie/blob/727773562d4559de5b6c65eb557b867f0b533ba5/src/Pcz/Groupie/Groupie.php#L25-L95
238,910
petrofcz/groupie
src/Pcz/Groupie/Groupie.php
Groupie.addGlobalColumn
public function addGlobalColumn(ColumnDefinition $columnDefinition, callable $columnDataFactory) { $this->addColumn($columnDefinition); foreach($this->groupDefinitions as $groupDefinition) { $groupDefinition->addColumn($columnDefinition, $columnDataFactory); } return $this; }
php
public function addGlobalColumn(ColumnDefinition $columnDefinition, callable $columnDataFactory) { $this->addColumn($columnDefinition); foreach($this->groupDefinitions as $groupDefinition) { $groupDefinition->addColumn($columnDefinition, $columnDataFactory); } return $this; }
[ "public", "function", "addGlobalColumn", "(", "ColumnDefinition", "$", "columnDefinition", ",", "callable", "$", "columnDataFactory", ")", "{", "$", "this", "->", "addColumn", "(", "$", "columnDefinition", ")", ";", "foreach", "(", "$", "this", "->", "groupDefinitions", "as", "$", "groupDefinition", ")", "{", "$", "groupDefinition", "->", "addColumn", "(", "$", "columnDefinition", ",", "$", "columnDataFactory", ")", ";", "}", "return", "$", "this", ";", "}" ]
This method adds column to groupie and to all available groups. IT SHOULD BE CALLED AFTER ALL GROUPS ARE ADDED! @param ColumnDefinition $columnDefinition @param $columnDataFactory callable This method should return callback that will construct the IColumnData object (it contains aggregated value to be displayed). Args: [array $entities] @return $this
[ "This", "method", "adds", "column", "to", "groupie", "and", "to", "all", "available", "groups", ".", "IT", "SHOULD", "BE", "CALLED", "AFTER", "ALL", "GROUPS", "ARE", "ADDED!" ]
727773562d4559de5b6c65eb557b867f0b533ba5
https://github.com/petrofcz/groupie/blob/727773562d4559de5b6c65eb557b867f0b533ba5/src/Pcz/Groupie/Groupie.php#L134-L140
238,911
pdenis/travis-client
src/Snide/Travis/Model/Repository.php
Repository.addBuild
public function addBuild(Build $build) { $this->getBuilds(); $build->setRepositoryId($this->getId()); $this->builds[$build->getId()] = $build; }
php
public function addBuild(Build $build) { $this->getBuilds(); $build->setRepositoryId($this->getId()); $this->builds[$build->getId()] = $build; }
[ "public", "function", "addBuild", "(", "Build", "$", "build", ")", "{", "$", "this", "->", "getBuilds", "(", ")", ";", "$", "build", "->", "setRepositoryId", "(", "$", "this", "->", "getId", "(", ")", ")", ";", "$", "this", "->", "builds", "[", "$", "build", "->", "getId", "(", ")", "]", "=", "$", "build", ";", "}" ]
Add build to the list @param Build $build
[ "Add", "build", "to", "the", "list" ]
6925427ac2650a52a03bd23e4809cc9186bb63cd
https://github.com/pdenis/travis-client/blob/6925427ac2650a52a03bd23e4809cc9186bb63cd/src/Snide/Travis/Model/Repository.php#L110-L115
238,912
pdenis/travis-client
src/Snide/Travis/Model/Repository.php
Repository.removeBuild
public function removeBuild(Build $build) { if (isset($this->builds[$build->getId()])) { unset($this->builds[$build->getId()]); } }
php
public function removeBuild(Build $build) { if (isset($this->builds[$build->getId()])) { unset($this->builds[$build->getId()]); } }
[ "public", "function", "removeBuild", "(", "Build", "$", "build", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "builds", "[", "$", "build", "->", "getId", "(", ")", "]", ")", ")", "{", "unset", "(", "$", "this", "->", "builds", "[", "$", "build", "->", "getId", "(", ")", "]", ")", ";", "}", "}" ]
Remove build from the list @param Build $build
[ "Remove", "build", "from", "the", "list" ]
6925427ac2650a52a03bd23e4809cc9186bb63cd
https://github.com/pdenis/travis-client/blob/6925427ac2650a52a03bd23e4809cc9186bb63cd/src/Snide/Travis/Model/Repository.php#L122-L127
238,913
Thuata/FrameworkBundle
Entity/DocumentSerialization.php
DocumentSerialization.jsonDeserialize
public static function jsonDeserialize(array $json): DocumentSerializationInterface { $managerClass = $json['document_serialization']['manager_class']; $data = (array) $json['document_serialization']['data']; return new self($managerClass, $data); }
php
public static function jsonDeserialize(array $json): DocumentSerializationInterface { $managerClass = $json['document_serialization']['manager_class']; $data = (array) $json['document_serialization']['data']; return new self($managerClass, $data); }
[ "public", "static", "function", "jsonDeserialize", "(", "array", "$", "json", ")", ":", "DocumentSerializationInterface", "{", "$", "managerClass", "=", "$", "json", "[", "'document_serialization'", "]", "[", "'manager_class'", "]", ";", "$", "data", "=", "(", "array", ")", "$", "json", "[", "'document_serialization'", "]", "[", "'data'", "]", ";", "return", "new", "self", "(", "$", "managerClass", ",", "$", "data", ")", ";", "}" ]
Deserialize the data @param array $json @return DocumentSerializationInterface
[ "Deserialize", "the", "data" ]
78c38a5103256d829d7f7574b4e15c9087d0cfd9
https://github.com/Thuata/FrameworkBundle/blob/78c38a5103256d829d7f7574b4e15c9087d0cfd9/Entity/DocumentSerialization.php#L87-L93
238,914
dcarbone/helpers
src/JsonToList.php
JsonToList.invoke
public static function invoke($jsonString, $returnNode = false) { $dom = new \DOMDocument('1.0', 'UTF-8'); $jsonString = mb_convert_encoding($jsonString, 'UTF-8', mb_detect_encoding($jsonString)); $jsonDecode = json_decode($jsonString, false); $lastError = json_last_error(); if (JSON_ERROR_NONE === $lastError) { $ul = $dom->createElement('ul'); $ul->setAttribute('class', 'json-list'); $dom->appendChild($ul); if ($jsonDecode instanceof \stdClass) self::objectOutput($jsonDecode, $dom, $ul); else if (is_array($jsonDecode)) self::arrayOutput($jsonDecode, $dom, $ul); if ($returnNode) return $dom; return static::saveHTMLExact($dom, $ul); } throw new \DomainException(sprintf( 'Could not convert input to HTML: "%s"', JsonErrorHelper::invoke(true, $lastError) )); }
php
public static function invoke($jsonString, $returnNode = false) { $dom = new \DOMDocument('1.0', 'UTF-8'); $jsonString = mb_convert_encoding($jsonString, 'UTF-8', mb_detect_encoding($jsonString)); $jsonDecode = json_decode($jsonString, false); $lastError = json_last_error(); if (JSON_ERROR_NONE === $lastError) { $ul = $dom->createElement('ul'); $ul->setAttribute('class', 'json-list'); $dom->appendChild($ul); if ($jsonDecode instanceof \stdClass) self::objectOutput($jsonDecode, $dom, $ul); else if (is_array($jsonDecode)) self::arrayOutput($jsonDecode, $dom, $ul); if ($returnNode) return $dom; return static::saveHTMLExact($dom, $ul); } throw new \DomainException(sprintf( 'Could not convert input to HTML: "%s"', JsonErrorHelper::invoke(true, $lastError) )); }
[ "public", "static", "function", "invoke", "(", "$", "jsonString", ",", "$", "returnNode", "=", "false", ")", "{", "$", "dom", "=", "new", "\\", "DOMDocument", "(", "'1.0'", ",", "'UTF-8'", ")", ";", "$", "jsonString", "=", "mb_convert_encoding", "(", "$", "jsonString", ",", "'UTF-8'", ",", "mb_detect_encoding", "(", "$", "jsonString", ")", ")", ";", "$", "jsonDecode", "=", "json_decode", "(", "$", "jsonString", ",", "false", ")", ";", "$", "lastError", "=", "json_last_error", "(", ")", ";", "if", "(", "JSON_ERROR_NONE", "===", "$", "lastError", ")", "{", "$", "ul", "=", "$", "dom", "->", "createElement", "(", "'ul'", ")", ";", "$", "ul", "->", "setAttribute", "(", "'class'", ",", "'json-list'", ")", ";", "$", "dom", "->", "appendChild", "(", "$", "ul", ")", ";", "if", "(", "$", "jsonDecode", "instanceof", "\\", "stdClass", ")", "self", "::", "objectOutput", "(", "$", "jsonDecode", ",", "$", "dom", ",", "$", "ul", ")", ";", "else", "if", "(", "is_array", "(", "$", "jsonDecode", ")", ")", "self", "::", "arrayOutput", "(", "$", "jsonDecode", ",", "$", "dom", ",", "$", "ul", ")", ";", "if", "(", "$", "returnNode", ")", "return", "$", "dom", ";", "return", "static", "::", "saveHTMLExact", "(", "$", "dom", ",", "$", "ul", ")", ";", "}", "throw", "new", "\\", "DomainException", "(", "sprintf", "(", "'Could not convert input to HTML: \"%s\"'", ",", "JsonErrorHelper", "::", "invoke", "(", "true", ",", "$", "lastError", ")", ")", ")", ";", "}" ]
Invoke the helper @param $jsonString @param bool $returnNode @return \DOMNode|string
[ "Invoke", "the", "helper" ]
43dc122491e38f47f22d1c7634f9c35f987ac545
https://github.com/dcarbone/helpers/blob/43dc122491e38f47f22d1c7634f9c35f987ac545/src/JsonToList.php#L26-L56
238,915
dcarbone/helpers
src/JsonToList.php
JsonToList.objectOutput
protected static function objectOutput(\stdClass $object, \DOMDocument $dom, \DOMElement $parentUL) { foreach($object as $k=>$v) { $li = $dom->createElement('li'); $parentUL->appendChild($li); $strong = $dom->createElement('strong', $k); $li->appendChild($strong); if ($v instanceof \stdClass) { $ul = $dom->createElement('ul'); $li->appendChild($ul); self::objectOutput($v, $dom, $ul); } else if (is_array($v)) { $ul = $dom->createElement('ul'); $li->appendChild($ul); self::arrayOutput($v, $dom, $ul); } else if (is_bool($v)) { switch($v) { case true: $li->appendChild($dom->createTextNode(' TRUE')); break; case false: $li->appendChild($dom->createTextNode(' FALSE')); break; } } else if (is_scalar($v)) { $span = $dom->createElement('span'); $span->appendChild($dom->createTextNode(' '.strval($v))); $li->appendChild($span); } } return $dom; }
php
protected static function objectOutput(\stdClass $object, \DOMDocument $dom, \DOMElement $parentUL) { foreach($object as $k=>$v) { $li = $dom->createElement('li'); $parentUL->appendChild($li); $strong = $dom->createElement('strong', $k); $li->appendChild($strong); if ($v instanceof \stdClass) { $ul = $dom->createElement('ul'); $li->appendChild($ul); self::objectOutput($v, $dom, $ul); } else if (is_array($v)) { $ul = $dom->createElement('ul'); $li->appendChild($ul); self::arrayOutput($v, $dom, $ul); } else if (is_bool($v)) { switch($v) { case true: $li->appendChild($dom->createTextNode(' TRUE')); break; case false: $li->appendChild($dom->createTextNode(' FALSE')); break; } } else if (is_scalar($v)) { $span = $dom->createElement('span'); $span->appendChild($dom->createTextNode(' '.strval($v))); $li->appendChild($span); } } return $dom; }
[ "protected", "static", "function", "objectOutput", "(", "\\", "stdClass", "$", "object", ",", "\\", "DOMDocument", "$", "dom", ",", "\\", "DOMElement", "$", "parentUL", ")", "{", "foreach", "(", "$", "object", "as", "$", "k", "=>", "$", "v", ")", "{", "$", "li", "=", "$", "dom", "->", "createElement", "(", "'li'", ")", ";", "$", "parentUL", "->", "appendChild", "(", "$", "li", ")", ";", "$", "strong", "=", "$", "dom", "->", "createElement", "(", "'strong'", ",", "$", "k", ")", ";", "$", "li", "->", "appendChild", "(", "$", "strong", ")", ";", "if", "(", "$", "v", "instanceof", "\\", "stdClass", ")", "{", "$", "ul", "=", "$", "dom", "->", "createElement", "(", "'ul'", ")", ";", "$", "li", "->", "appendChild", "(", "$", "ul", ")", ";", "self", "::", "objectOutput", "(", "$", "v", ",", "$", "dom", ",", "$", "ul", ")", ";", "}", "else", "if", "(", "is_array", "(", "$", "v", ")", ")", "{", "$", "ul", "=", "$", "dom", "->", "createElement", "(", "'ul'", ")", ";", "$", "li", "->", "appendChild", "(", "$", "ul", ")", ";", "self", "::", "arrayOutput", "(", "$", "v", ",", "$", "dom", ",", "$", "ul", ")", ";", "}", "else", "if", "(", "is_bool", "(", "$", "v", ")", ")", "{", "switch", "(", "$", "v", ")", "{", "case", "true", ":", "$", "li", "->", "appendChild", "(", "$", "dom", "->", "createTextNode", "(", "' TRUE'", ")", ")", ";", "break", ";", "case", "false", ":", "$", "li", "->", "appendChild", "(", "$", "dom", "->", "createTextNode", "(", "' FALSE'", ")", ")", ";", "break", ";", "}", "}", "else", "if", "(", "is_scalar", "(", "$", "v", ")", ")", "{", "$", "span", "=", "$", "dom", "->", "createElement", "(", "'span'", ")", ";", "$", "span", "->", "appendChild", "(", "$", "dom", "->", "createTextNode", "(", "' '", ".", "strval", "(", "$", "v", ")", ")", ")", ";", "$", "li", "->", "appendChild", "(", "$", "span", ")", ";", "}", "}", "return", "$", "dom", ";", "}" ]
Parse through json object @param \stdClass $object @param \DOMDocument $dom @param \DOMElement $parentUL @return \DOMDocument
[ "Parse", "through", "json", "object" ]
43dc122491e38f47f22d1c7634f9c35f987ac545
https://github.com/dcarbone/helpers/blob/43dc122491e38f47f22d1c7634f9c35f987ac545/src/JsonToList.php#L79-L115
238,916
AlphaLabs/FilterEngine
src/Bridge/Doctrine/FilteringRepositoryTrait.php
FilteringRepositoryTrait.applyFilters
public function applyFilters(QueryBuilder $queryBuilder, $alias, FilterBagInterface $filterBag = null) { if (is_null($filterBag)) { return $queryBuilder; } foreach ($filterBag->all() as $filter) { if ($filter instanceof FilterNode) { $this->applyFilter($queryBuilder, $alias, $filter); } } return $queryBuilder; }
php
public function applyFilters(QueryBuilder $queryBuilder, $alias, FilterBagInterface $filterBag = null) { if (is_null($filterBag)) { return $queryBuilder; } foreach ($filterBag->all() as $filter) { if ($filter instanceof FilterNode) { $this->applyFilter($queryBuilder, $alias, $filter); } } return $queryBuilder; }
[ "public", "function", "applyFilters", "(", "QueryBuilder", "$", "queryBuilder", ",", "$", "alias", ",", "FilterBagInterface", "$", "filterBag", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "filterBag", ")", ")", "{", "return", "$", "queryBuilder", ";", "}", "foreach", "(", "$", "filterBag", "->", "all", "(", ")", "as", "$", "filter", ")", "{", "if", "(", "$", "filter", "instanceof", "FilterNode", ")", "{", "$", "this", "->", "applyFilter", "(", "$", "queryBuilder", ",", "$", "alias", ",", "$", "filter", ")", ";", "}", "}", "return", "$", "queryBuilder", ";", "}" ]
Apply filters from a filter bag on the provided query builder @param QueryBuilder $queryBuilder QueryBuilder @param string $alias QueryBuilder root alias @param FilterBagInterface $filterBag Filters to apply @return QueryBuilder
[ "Apply", "filters", "from", "a", "filter", "bag", "on", "the", "provided", "query", "builder" ]
806a7c31e50839033dbf0d41aed34b8d14c347f6
https://github.com/AlphaLabs/FilterEngine/blob/806a7c31e50839033dbf0d41aed34b8d14c347f6/src/Bridge/Doctrine/FilteringRepositoryTrait.php#L31-L44
238,917
AlphaLabs/FilterEngine
src/Bridge/Doctrine/FilteringRepositoryTrait.php
FilteringRepositoryTrait.applyFilter
protected function applyFilter(QueryBuilder $queryBuilder, $alias, FilterNode $filter) { $queryBuilderPatcher = new QueryBuilderPatcher(new QueryExpressionBuilder()); return $queryBuilderPatcher->patch($queryBuilder, $filter, new QueryContext($alias)); }
php
protected function applyFilter(QueryBuilder $queryBuilder, $alias, FilterNode $filter) { $queryBuilderPatcher = new QueryBuilderPatcher(new QueryExpressionBuilder()); return $queryBuilderPatcher->patch($queryBuilder, $filter, new QueryContext($alias)); }
[ "protected", "function", "applyFilter", "(", "QueryBuilder", "$", "queryBuilder", ",", "$", "alias", ",", "FilterNode", "$", "filter", ")", "{", "$", "queryBuilderPatcher", "=", "new", "QueryBuilderPatcher", "(", "new", "QueryExpressionBuilder", "(", ")", ")", ";", "return", "$", "queryBuilderPatcher", "->", "patch", "(", "$", "queryBuilder", ",", "$", "filter", ",", "new", "QueryContext", "(", "$", "alias", ")", ")", ";", "}" ]
Apply one filter to the query builder @param QueryBuilder $queryBuilder QueryBuilder @param string $alias QueryBuilder root alias @param FilterNode $filter Filter to apply @return QueryBuilder
[ "Apply", "one", "filter", "to", "the", "query", "builder" ]
806a7c31e50839033dbf0d41aed34b8d14c347f6
https://github.com/AlphaLabs/FilterEngine/blob/806a7c31e50839033dbf0d41aed34b8d14c347f6/src/Bridge/Doctrine/FilteringRepositoryTrait.php#L55-L60
238,918
SymBB/symbb
src/Symbb/Core/SystemBundle/Api/AbstractApi.php
AbstractApi.addErrorMessage
public function addErrorMessage($message, $params = array()) { $message = $this->trans($message, $params); static::$messages[] = array( 'type' => 'error', 'bootstrapType' => 'danger', 'message' => $message ); static::$success = false; }
php
public function addErrorMessage($message, $params = array()) { $message = $this->trans($message, $params); static::$messages[] = array( 'type' => 'error', 'bootstrapType' => 'danger', 'message' => $message ); static::$success = false; }
[ "public", "function", "addErrorMessage", "(", "$", "message", ",", "$", "params", "=", "array", "(", ")", ")", "{", "$", "message", "=", "$", "this", "->", "trans", "(", "$", "message", ",", "$", "params", ")", ";", "static", "::", "$", "messages", "[", "]", "=", "array", "(", "'type'", "=>", "'error'", ",", "'bootstrapType'", "=>", "'danger'", ",", "'message'", "=>", "$", "message", ")", ";", "static", "::", "$", "success", "=", "false", ";", "}" ]
add a error message to the api call @param $message
[ "add", "a", "error", "message", "to", "the", "api", "call" ]
be25357502e6a51016fa0b128a46c2dc87fa8fb2
https://github.com/SymBB/symbb/blob/be25357502e6a51016fa0b128a46c2dc87fa8fb2/src/Symbb/Core/SystemBundle/Api/AbstractApi.php#L260-L269
238,919
SymBB/symbb
src/Symbb/Core/SystemBundle/Api/AbstractApi.php
AbstractApi.addSuccessMessage
public function addSuccessMessage($message, $params = array()) { $message = $this->trans($message, $params); static::$messages[$message] = array( 'type' => 'success', 'bootstrapType' => 'success', 'message' => $message ); }
php
public function addSuccessMessage($message, $params = array()) { $message = $this->trans($message, $params); static::$messages[$message] = array( 'type' => 'success', 'bootstrapType' => 'success', 'message' => $message ); }
[ "public", "function", "addSuccessMessage", "(", "$", "message", ",", "$", "params", "=", "array", "(", ")", ")", "{", "$", "message", "=", "$", "this", "->", "trans", "(", "$", "message", ",", "$", "params", ")", ";", "static", "::", "$", "messages", "[", "$", "message", "]", "=", "array", "(", "'type'", "=>", "'success'", ",", "'bootstrapType'", "=>", "'success'", ",", "'message'", "=>", "$", "message", ")", ";", "}" ]
add a success message to the api call @param $message
[ "add", "a", "success", "message", "to", "the", "api", "call" ]
be25357502e6a51016fa0b128a46c2dc87fa8fb2
https://github.com/SymBB/symbb/blob/be25357502e6a51016fa0b128a46c2dc87fa8fb2/src/Symbb/Core/SystemBundle/Api/AbstractApi.php#L275-L283
238,920
SymBB/symbb
src/Symbb/Core/SystemBundle/Api/AbstractApi.php
AbstractApi.addInfoMessage
public function addInfoMessage($message, $params = array()) { $message = $this->trans($message, $params); static::$messages[] = array( 'type' => 'info', 'bootstrapType' => 'info', 'message' => $message ); }
php
public function addInfoMessage($message, $params = array()) { $message = $this->trans($message, $params); static::$messages[] = array( 'type' => 'info', 'bootstrapType' => 'info', 'message' => $message ); }
[ "public", "function", "addInfoMessage", "(", "$", "message", ",", "$", "params", "=", "array", "(", ")", ")", "{", "$", "message", "=", "$", "this", "->", "trans", "(", "$", "message", ",", "$", "params", ")", ";", "static", "::", "$", "messages", "[", "]", "=", "array", "(", "'type'", "=>", "'info'", ",", "'bootstrapType'", "=>", "'info'", ",", "'message'", "=>", "$", "message", ")", ";", "}" ]
add a info message to the api call @param $message
[ "add", "a", "info", "message", "to", "the", "api", "call" ]
be25357502e6a51016fa0b128a46c2dc87fa8fb2
https://github.com/SymBB/symbb/blob/be25357502e6a51016fa0b128a46c2dc87fa8fb2/src/Symbb/Core/SystemBundle/Api/AbstractApi.php#L289-L297
238,921
SymBB/symbb
src/Symbb/Core/SystemBundle/Api/AbstractApi.php
AbstractApi.addWarningMessage
public function addWarningMessage($message, $params = array()) { $message = $this->trans($message, $params); static::$messages[] = array( 'type' => 'warning', 'bootstrapType' => 'warning', 'message' => $message ); }
php
public function addWarningMessage($message, $params = array()) { $message = $this->trans($message, $params); static::$messages[] = array( 'type' => 'warning', 'bootstrapType' => 'warning', 'message' => $message ); }
[ "public", "function", "addWarningMessage", "(", "$", "message", ",", "$", "params", "=", "array", "(", ")", ")", "{", "$", "message", "=", "$", "this", "->", "trans", "(", "$", "message", ",", "$", "params", ")", ";", "static", "::", "$", "messages", "[", "]", "=", "array", "(", "'type'", "=>", "'warning'", ",", "'bootstrapType'", "=>", "'warning'", ",", "'message'", "=>", "$", "message", ")", ";", "}" ]
add a warning message to the api @param $message
[ "add", "a", "warning", "message", "to", "the", "api" ]
be25357502e6a51016fa0b128a46c2dc87fa8fb2
https://github.com/SymBB/symbb/blob/be25357502e6a51016fa0b128a46c2dc87fa8fb2/src/Symbb/Core/SystemBundle/Api/AbstractApi.php#L303-L311
238,922
zepi/turbo-base
Zepi/Web/AccessControl/src/EventHandler/DisplayNoAccessMessage.php
DisplayNoAccessMessage.execute
public function execute(Framework $framework, WebRequest $request, Response $response) { $renderedOutput = $this->render('\\Zepi\\Web\\AccessControl\\Templates\\NoAccessMessage'); $response->setOutput($renderedOutput); }
php
public function execute(Framework $framework, WebRequest $request, Response $response) { $renderedOutput = $this->render('\\Zepi\\Web\\AccessControl\\Templates\\NoAccessMessage'); $response->setOutput($renderedOutput); }
[ "public", "function", "execute", "(", "Framework", "$", "framework", ",", "WebRequest", "$", "request", ",", "Response", "$", "response", ")", "{", "$", "renderedOutput", "=", "$", "this", "->", "render", "(", "'\\\\Zepi\\\\Web\\\\AccessControl\\\\Templates\\\\NoAccessMessage'", ")", ";", "$", "response", "->", "setOutput", "(", "$", "renderedOutput", ")", ";", "}" ]
Displays a message if the session has no access to the requested command. @param \Zepi\Turbo\Framework $framework @param \Zepi\Turbo\Request\WebRequest $request @param \Zepi\Turbo\Response\Response $response
[ "Displays", "a", "message", "if", "the", "session", "has", "no", "access", "to", "the", "requested", "command", "." ]
9a36d8c7649317f55f91b2adf386bd1f04ec02a3
https://github.com/zepi/turbo-base/blob/9a36d8c7649317f55f91b2adf386bd1f04ec02a3/Zepi/Web/AccessControl/src/EventHandler/DisplayNoAccessMessage.php#L58-L63
238,923
MarcusFulbright/represent
src/Represent/Handler/PropertyHandler.php
PropertyHandler.getPropertyAnnotation
public function getPropertyAnnotation(\ReflectionProperty $property) { $annot = $this->reader->getPropertyAnnotation($property, '\Represent\Annotations\Property'); if (!$annot) { return false; } return $annot; }
php
public function getPropertyAnnotation(\ReflectionProperty $property) { $annot = $this->reader->getPropertyAnnotation($property, '\Represent\Annotations\Property'); if (!$annot) { return false; } return $annot; }
[ "public", "function", "getPropertyAnnotation", "(", "\\", "ReflectionProperty", "$", "property", ")", "{", "$", "annot", "=", "$", "this", "->", "reader", "->", "getPropertyAnnotation", "(", "$", "property", ",", "'\\Represent\\Annotations\\Property'", ")", ";", "if", "(", "!", "$", "annot", ")", "{", "return", "false", ";", "}", "return", "$", "annot", ";", "}" ]
Returns the property annotation or false if one is not present; @param \ReflectionProperty $property @return bool|Property
[ "Returns", "the", "property", "annotation", "or", "false", "if", "one", "is", "not", "present", ";" ]
f7b624f473a3247a29f05c4a694d04bba4038e59
https://github.com/MarcusFulbright/represent/blob/f7b624f473a3247a29f05c4a694d04bba4038e59/src/Represent/Handler/PropertyHandler.php#L35-L44
238,924
MarcusFulbright/represent
src/Represent/Handler/PropertyHandler.php
PropertyHandler.getSerializedName
public function getSerializedName(\ReflectionProperty $property, Property $annot = null) { if ($annot || $annot = $this->getPropertyAnnotation($property)) { return $annot->getName(); } return $property->getName(); }
php
public function getSerializedName(\ReflectionProperty $property, Property $annot = null) { if ($annot || $annot = $this->getPropertyAnnotation($property)) { return $annot->getName(); } return $property->getName(); }
[ "public", "function", "getSerializedName", "(", "\\", "ReflectionProperty", "$", "property", ",", "Property", "$", "annot", "=", "null", ")", "{", "if", "(", "$", "annot", "||", "$", "annot", "=", "$", "this", "->", "getPropertyAnnotation", "(", "$", "property", ")", ")", "{", "return", "$", "annot", "->", "getName", "(", ")", ";", "}", "return", "$", "property", "->", "getName", "(", ")", ";", "}" ]
Returns the serialized name for this property @param \ReflectionProperty $property @param Property $annot @return string
[ "Returns", "the", "serialized", "name", "for", "this", "property" ]
f7b624f473a3247a29f05c4a694d04bba4038e59
https://github.com/MarcusFulbright/represent/blob/f7b624f473a3247a29f05c4a694d04bba4038e59/src/Represent/Handler/PropertyHandler.php#L53-L61
238,925
MarcusFulbright/represent
src/Represent/Handler/PropertyHandler.php
PropertyHandler.propertyTypeOverride
public function propertyTypeOverride(Property $annot = null, \ReflectionProperty $property = null) { if ($annot || $annot = $this->getPropertyAnnotation($property)) { return $annot->getType(); } return null; }
php
public function propertyTypeOverride(Property $annot = null, \ReflectionProperty $property = null) { if ($annot || $annot = $this->getPropertyAnnotation($property)) { return $annot->getType(); } return null; }
[ "public", "function", "propertyTypeOverride", "(", "Property", "$", "annot", "=", "null", ",", "\\", "ReflectionProperty", "$", "property", "=", "null", ")", "{", "if", "(", "$", "annot", "||", "$", "annot", "=", "$", "this", "->", "getPropertyAnnotation", "(", "$", "property", ")", ")", "{", "return", "$", "annot", "->", "getType", "(", ")", ";", "}", "return", "null", ";", "}" ]
Returns the type this property is changed to during serialization or false if no conversion occurs @param \ReflectionProperty $property @param Property $annot @return null|string
[ "Returns", "the", "type", "this", "property", "is", "changed", "to", "during", "serialization", "or", "false", "if", "no", "conversion", "occurs" ]
f7b624f473a3247a29f05c4a694d04bba4038e59
https://github.com/MarcusFulbright/represent/blob/f7b624f473a3247a29f05c4a694d04bba4038e59/src/Represent/Handler/PropertyHandler.php#L70-L78
238,926
MarcusFulbright/represent
src/Represent/Handler/PropertyHandler.php
PropertyHandler.getConvertedValue
public function getConvertedValue(\ReflectionProperty $property, $original, Property $annot = null) { return $this->handleTypeConversion($this->propertyTypeOverride($annot, $property), $property->getValue($original)); }
php
public function getConvertedValue(\ReflectionProperty $property, $original, Property $annot = null) { return $this->handleTypeConversion($this->propertyTypeOverride($annot, $property), $property->getValue($original)); }
[ "public", "function", "getConvertedValue", "(", "\\", "ReflectionProperty", "$", "property", ",", "$", "original", ",", "Property", "$", "annot", "=", "null", ")", "{", "return", "$", "this", "->", "handleTypeConversion", "(", "$", "this", "->", "propertyTypeOverride", "(", "$", "annot", ",", "$", "property", ")", ",", "$", "property", "->", "getValue", "(", "$", "original", ")", ")", ";", "}" ]
Returns the value used for serialization from a reflection property @param \ReflectionProperty $property @param $original @param Property $annot @return bool|DateTime|int|string
[ "Returns", "the", "value", "used", "for", "serialization", "from", "a", "reflection", "property" ]
f7b624f473a3247a29f05c4a694d04bba4038e59
https://github.com/MarcusFulbright/represent/blob/f7b624f473a3247a29f05c4a694d04bba4038e59/src/Represent/Handler/PropertyHandler.php#L88-L91
238,927
WellCommerce/Form
Formatter/JavascriptFormatter.php
JavascriptFormatter.formatAttributeValue
protected function formatAttributeValue(Attribute $attribute) { $value = $attribute->getValue(); if ($attribute->getType() === Attribute::TYPE_FUNCTION && strlen($value)) { return new Expr($value); } return $value; }
php
protected function formatAttributeValue(Attribute $attribute) { $value = $attribute->getValue(); if ($attribute->getType() === Attribute::TYPE_FUNCTION && strlen($value)) { return new Expr($value); } return $value; }
[ "protected", "function", "formatAttributeValue", "(", "Attribute", "$", "attribute", ")", "{", "$", "value", "=", "$", "attribute", "->", "getValue", "(", ")", ";", "if", "(", "$", "attribute", "->", "getType", "(", ")", "===", "Attribute", "::", "TYPE_FUNCTION", "&&", "strlen", "(", "$", "value", ")", ")", "{", "return", "new", "Expr", "(", "$", "value", ")", ";", "}", "return", "$", "value", ";", "}" ]
Formats attributes value @param Attribute $attribute @return mixed|Expr
[ "Formats", "attributes", "value" ]
dad15dbdcf1d13f927fa86f5198bcb6abed1974a
https://github.com/WellCommerce/Form/blob/dad15dbdcf1d13f927fa86f5198bcb6abed1974a/Formatter/JavascriptFormatter.php#L121-L130
238,928
iwillhappy1314/wenprise-eloquent
src/WP/User.php
User.getAvatarAttribute
public function getAvatarAttribute() { $hash = ! empty($this->email) ? md5(strtolower(trim($this->email))) : ''; return sprintf('//secure.gravatar.com/avatar/%s?d=mm', $hash); }
php
public function getAvatarAttribute() { $hash = ! empty($this->email) ? md5(strtolower(trim($this->email))) : ''; return sprintf('//secure.gravatar.com/avatar/%s?d=mm', $hash); }
[ "public", "function", "getAvatarAttribute", "(", ")", "{", "$", "hash", "=", "!", "empty", "(", "$", "this", "->", "email", ")", "?", "md5", "(", "strtolower", "(", "trim", "(", "$", "this", "->", "email", ")", ")", ")", ":", "''", ";", "return", "sprintf", "(", "'//secure.gravatar.com/avatar/%s?d=mm'", ",", "$", "hash", ")", ";", "}" ]
Get the avatar url from Gravatar @return string
[ "Get", "the", "avatar", "url", "from", "Gravatar" ]
7eb045c7d19aaf5e7438625558a390ce39f1a34e
https://github.com/iwillhappy1314/wenprise-eloquent/blob/7eb045c7d19aaf5e7438625558a390ce39f1a34e/src/WP/User.php#L188-L193
238,929
Schibsted-Tech-Polska/travis-ci-client
src/Stp/TravisClient/Client.php
Client.prepareParametersUrl
private function prepareParametersUrl(array $params, array $allowedParams) { $allowedParams = array_flip($allowedParams); $params = array_intersect_key($params, $allowedParams); $paramsUrlItems = []; foreach ($params as $key => $param) { $paramsUrlItems[] = $key . '=' . urlencode($param); } $paramsUrl = join('&', $paramsUrlItems); if (strlen($paramsUrl) > 0) { $paramsUrl = '?' . $paramsUrl; } return $paramsUrl; }
php
private function prepareParametersUrl(array $params, array $allowedParams) { $allowedParams = array_flip($allowedParams); $params = array_intersect_key($params, $allowedParams); $paramsUrlItems = []; foreach ($params as $key => $param) { $paramsUrlItems[] = $key . '=' . urlencode($param); } $paramsUrl = join('&', $paramsUrlItems); if (strlen($paramsUrl) > 0) { $paramsUrl = '?' . $paramsUrl; } return $paramsUrl; }
[ "private", "function", "prepareParametersUrl", "(", "array", "$", "params", ",", "array", "$", "allowedParams", ")", "{", "$", "allowedParams", "=", "array_flip", "(", "$", "allowedParams", ")", ";", "$", "params", "=", "array_intersect_key", "(", "$", "params", ",", "$", "allowedParams", ")", ";", "$", "paramsUrlItems", "=", "[", "]", ";", "foreach", "(", "$", "params", "as", "$", "key", "=>", "$", "param", ")", "{", "$", "paramsUrlItems", "[", "]", "=", "$", "key", ".", "'='", ".", "urlencode", "(", "$", "param", ")", ";", "}", "$", "paramsUrl", "=", "join", "(", "'&'", ",", "$", "paramsUrlItems", ")", ";", "if", "(", "strlen", "(", "$", "paramsUrl", ")", ">", "0", ")", "{", "$", "paramsUrl", "=", "'?'", ".", "$", "paramsUrl", ";", "}", "return", "$", "paramsUrl", ";", "}" ]
Prepares params url that can be appended to request. @param array $params @param array $allowedParams @return string
[ "Prepares", "params", "url", "that", "can", "be", "appended", "to", "request", "." ]
6c0a67a72e970efe4a8a924eae7119d5c8ab0fac
https://github.com/Schibsted-Tech-Polska/travis-ci-client/blob/6c0a67a72e970efe4a8a924eae7119d5c8ab0fac/src/Stp/TravisClient/Client.php#L203-L219
238,930
browserfs/base
src/EventEmitter.php
EventEmitter.on
public final function on( $eventName, $eventCallback ) { if ( !is_string( $eventName ) ) { throw new \browserfs\Exception('Invalid argument $eventName: string expected'); } else { if ( !strlen( $eventName ) ) { throw new \browserfs\Exception('Invalid argument $eventName: expected non-empty string'); } else { if ( !is_callable( $eventCallback ) ) { throw new \browserfs\Exception('Invalid argument $eventCallback: callable expected' ); } else { $this->events[ $eventName ] = isset( $this->events[ $eventName ] ) ? $this->events[ $eventName ] : []; $this->events[ $eventName ][] = [ 'once' => false, 'callback' => $eventCallback, 'fireId' => 0 ]; } } } }
php
public final function on( $eventName, $eventCallback ) { if ( !is_string( $eventName ) ) { throw new \browserfs\Exception('Invalid argument $eventName: string expected'); } else { if ( !strlen( $eventName ) ) { throw new \browserfs\Exception('Invalid argument $eventName: expected non-empty string'); } else { if ( !is_callable( $eventCallback ) ) { throw new \browserfs\Exception('Invalid argument $eventCallback: callable expected' ); } else { $this->events[ $eventName ] = isset( $this->events[ $eventName ] ) ? $this->events[ $eventName ] : []; $this->events[ $eventName ][] = [ 'once' => false, 'callback' => $eventCallback, 'fireId' => 0 ]; } } } }
[ "public", "final", "function", "on", "(", "$", "eventName", ",", "$", "eventCallback", ")", "{", "if", "(", "!", "is_string", "(", "$", "eventName", ")", ")", "{", "throw", "new", "\\", "browserfs", "\\", "Exception", "(", "'Invalid argument $eventName: string expected'", ")", ";", "}", "else", "{", "if", "(", "!", "strlen", "(", "$", "eventName", ")", ")", "{", "throw", "new", "\\", "browserfs", "\\", "Exception", "(", "'Invalid argument $eventName: expected non-empty string'", ")", ";", "}", "else", "{", "if", "(", "!", "is_callable", "(", "$", "eventCallback", ")", ")", "{", "throw", "new", "\\", "browserfs", "\\", "Exception", "(", "'Invalid argument $eventCallback: callable expected'", ")", ";", "}", "else", "{", "$", "this", "->", "events", "[", "$", "eventName", "]", "=", "isset", "(", "$", "this", "->", "events", "[", "$", "eventName", "]", ")", "?", "$", "this", "->", "events", "[", "$", "eventName", "]", ":", "[", "]", ";", "$", "this", "->", "events", "[", "$", "eventName", "]", "[", "]", "=", "[", "'once'", "=>", "false", ",", "'callback'", "=>", "$", "eventCallback", ",", "'fireId'", "=>", "0", "]", ";", "}", "}", "}", "}" ]
Adds a event listener. @param eventName: string @param eventCallback: callable( $e: \browserfs\Event ) => void @throws \browserfs\Exception
[ "Adds", "a", "event", "listener", "." ]
d98550b5cf6f6e9083f99f39d17fd1b79d61db55
https://github.com/browserfs/base/blob/d98550b5cf6f6e9083f99f39d17fd1b79d61db55/src/EventEmitter.php#L16-L50
238,931
browserfs/base
src/EventEmitter.php
EventEmitter.once
public final function once( $eventName, $eventCallback ) { if ( !is_string( $eventName ) ) { throw new \browserfs\Exception('Invalid argument $eventName: string expected'); } else { if ( !strlen( $eventName ) ) { throw new \browserfs\Exception('Invalid argument $eventName: expected non-empty string'); } else { if ( !is_callable( $eventCallback ) ) { throw new \browserfs\Exception('Invalid argument $eventCallback: callable expected' ); } else { $this->events[ $eventName ] = isset( $this->events[ $eventName ] ) ? $this->events[ $eventName ] : []; $this->events[ $eventName ][] = [ 'once' => true, 'callback' => $eventCallback, 'fireId' => 0 ]; } } } }
php
public final function once( $eventName, $eventCallback ) { if ( !is_string( $eventName ) ) { throw new \browserfs\Exception('Invalid argument $eventName: string expected'); } else { if ( !strlen( $eventName ) ) { throw new \browserfs\Exception('Invalid argument $eventName: expected non-empty string'); } else { if ( !is_callable( $eventCallback ) ) { throw new \browserfs\Exception('Invalid argument $eventCallback: callable expected' ); } else { $this->events[ $eventName ] = isset( $this->events[ $eventName ] ) ? $this->events[ $eventName ] : []; $this->events[ $eventName ][] = [ 'once' => true, 'callback' => $eventCallback, 'fireId' => 0 ]; } } } }
[ "public", "final", "function", "once", "(", "$", "eventName", ",", "$", "eventCallback", ")", "{", "if", "(", "!", "is_string", "(", "$", "eventName", ")", ")", "{", "throw", "new", "\\", "browserfs", "\\", "Exception", "(", "'Invalid argument $eventName: string expected'", ")", ";", "}", "else", "{", "if", "(", "!", "strlen", "(", "$", "eventName", ")", ")", "{", "throw", "new", "\\", "browserfs", "\\", "Exception", "(", "'Invalid argument $eventName: expected non-empty string'", ")", ";", "}", "else", "{", "if", "(", "!", "is_callable", "(", "$", "eventCallback", ")", ")", "{", "throw", "new", "\\", "browserfs", "\\", "Exception", "(", "'Invalid argument $eventCallback: callable expected'", ")", ";", "}", "else", "{", "$", "this", "->", "events", "[", "$", "eventName", "]", "=", "isset", "(", "$", "this", "->", "events", "[", "$", "eventName", "]", ")", "?", "$", "this", "->", "events", "[", "$", "eventName", "]", ":", "[", "]", ";", "$", "this", "->", "events", "[", "$", "eventName", "]", "[", "]", "=", "[", "'once'", "=>", "true", ",", "'callback'", "=>", "$", "eventCallback", ",", "'fireId'", "=>", "0", "]", ";", "}", "}", "}", "}" ]
Adds a event listener that will be fired only once. @param eventName: string @param eventCallback: callable( $e: \browserfs\Event ) => void @throws \browserfs\Exception
[ "Adds", "a", "event", "listener", "that", "will", "be", "fired", "only", "once", "." ]
d98550b5cf6f6e9083f99f39d17fd1b79d61db55
https://github.com/browserfs/base/blob/d98550b5cf6f6e9083f99f39d17fd1b79d61db55/src/EventEmitter.php#L58-L88
238,932
browserfs/base
src/EventEmitter.php
EventEmitter.callbackEquals
private static function callbackEquals( $callback1, $callback2 ) { if ( is_array( $callback1 ) && is_array( $callback2 ) ) { if ( count( $callback1 ) == count( $callback2 ) ) { for ( $i=0, $len = count( $callback1 ); $i<$len; $i++ ) { if ( $callback1[$i] != $callback2[$i] ) { return false; } } return true; } else { return false; } } else { return $callback1 == $callback2; } }
php
private static function callbackEquals( $callback1, $callback2 ) { if ( is_array( $callback1 ) && is_array( $callback2 ) ) { if ( count( $callback1 ) == count( $callback2 ) ) { for ( $i=0, $len = count( $callback1 ); $i<$len; $i++ ) { if ( $callback1[$i] != $callback2[$i] ) { return false; } } return true; } else { return false; } } else { return $callback1 == $callback2; } }
[ "private", "static", "function", "callbackEquals", "(", "$", "callback1", ",", "$", "callback2", ")", "{", "if", "(", "is_array", "(", "$", "callback1", ")", "&&", "is_array", "(", "$", "callback2", ")", ")", "{", "if", "(", "count", "(", "$", "callback1", ")", "==", "count", "(", "$", "callback2", ")", ")", "{", "for", "(", "$", "i", "=", "0", ",", "$", "len", "=", "count", "(", "$", "callback1", ")", ";", "$", "i", "<", "$", "len", ";", "$", "i", "++", ")", "{", "if", "(", "$", "callback1", "[", "$", "i", "]", "!=", "$", "callback2", "[", "$", "i", "]", ")", "{", "return", "false", ";", "}", "}", "return", "true", ";", "}", "else", "{", "return", "false", ";", "}", "}", "else", "{", "return", "$", "callback1", "==", "$", "callback2", ";", "}", "}" ]
Helper to compare if two callbacks are equal. @param callback1 - callable @param callback2 - callable
[ "Helper", "to", "compare", "if", "two", "callbacks", "are", "equal", "." ]
d98550b5cf6f6e9083f99f39d17fd1b79d61db55
https://github.com/browserfs/base/blob/d98550b5cf6f6e9083f99f39d17fd1b79d61db55/src/EventEmitter.php#L95-L121
238,933
browserfs/base
src/EventEmitter.php
EventEmitter.off
public final function off( $eventName, $eventCallback = null ) { if ( is_string( $eventName ) ) { if ( strlen( $eventName ) > 0 ) { if ( isset( $this->events[ $eventName ] ) ) { if ( $eventCallback === null ) { unset( $this->events[ $eventName ] ); } else { for ( $i = count( $this->events[ $eventName ] ) - 1; $i>=0; $i-- ) { if ( self::callbackEquals( $eventCallback, $this->events[ $eventName ][ $i ]['callback'] ) ) { // remove event array_splice( $this->events[ $eventName ], $i, 1 ); if ( count( $this->events[ $eventName ] ) == 0 ) { unset( $this->events[ $eventName ] ); } break; } } } } } else { throw new \browserfs\Exception('Invalid argument $eventName: non-empty string expected!'); } } else { throw new \browserfs\Exception('Invalid argument $eventName: string expected!' ); } }
php
public final function off( $eventName, $eventCallback = null ) { if ( is_string( $eventName ) ) { if ( strlen( $eventName ) > 0 ) { if ( isset( $this->events[ $eventName ] ) ) { if ( $eventCallback === null ) { unset( $this->events[ $eventName ] ); } else { for ( $i = count( $this->events[ $eventName ] ) - 1; $i>=0; $i-- ) { if ( self::callbackEquals( $eventCallback, $this->events[ $eventName ][ $i ]['callback'] ) ) { // remove event array_splice( $this->events[ $eventName ], $i, 1 ); if ( count( $this->events[ $eventName ] ) == 0 ) { unset( $this->events[ $eventName ] ); } break; } } } } } else { throw new \browserfs\Exception('Invalid argument $eventName: non-empty string expected!'); } } else { throw new \browserfs\Exception('Invalid argument $eventName: string expected!' ); } }
[ "public", "final", "function", "off", "(", "$", "eventName", ",", "$", "eventCallback", "=", "null", ")", "{", "if", "(", "is_string", "(", "$", "eventName", ")", ")", "{", "if", "(", "strlen", "(", "$", "eventName", ")", ">", "0", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "events", "[", "$", "eventName", "]", ")", ")", "{", "if", "(", "$", "eventCallback", "===", "null", ")", "{", "unset", "(", "$", "this", "->", "events", "[", "$", "eventName", "]", ")", ";", "}", "else", "{", "for", "(", "$", "i", "=", "count", "(", "$", "this", "->", "events", "[", "$", "eventName", "]", ")", "-", "1", ";", "$", "i", ">=", "0", ";", "$", "i", "--", ")", "{", "if", "(", "self", "::", "callbackEquals", "(", "$", "eventCallback", ",", "$", "this", "->", "events", "[", "$", "eventName", "]", "[", "$", "i", "]", "[", "'callback'", "]", ")", ")", "{", "// remove event", "array_splice", "(", "$", "this", "->", "events", "[", "$", "eventName", "]", ",", "$", "i", ",", "1", ")", ";", "if", "(", "count", "(", "$", "this", "->", "events", "[", "$", "eventName", "]", ")", "==", "0", ")", "{", "unset", "(", "$", "this", "->", "events", "[", "$", "eventName", "]", ")", ";", "}", "break", ";", "}", "}", "}", "}", "}", "else", "{", "throw", "new", "\\", "browserfs", "\\", "Exception", "(", "'Invalid argument $eventName: non-empty string expected!'", ")", ";", "}", "}", "else", "{", "throw", "new", "\\", "browserfs", "\\", "Exception", "(", "'Invalid argument $eventName: string expected!'", ")", ";", "}", "}" ]
Removes a event listener callback binded to eventName @param eventName - string - > the name of the event @param eventCallback -> [ callable( $e: \browserfs\Event ): void ] -> a callable function that was previously added with the "on" or "once" methods. If unspecified, all listeners that were added to eventName will be cleared.
[ "Removes", "a", "event", "listener", "callback", "binded", "to", "eventName" ]
d98550b5cf6f6e9083f99f39d17fd1b79d61db55
https://github.com/browserfs/base/blob/d98550b5cf6f6e9083f99f39d17fd1b79d61db55/src/EventEmitter.php#L130-L177
238,934
browserfs/base
src/EventEmitter.php
EventEmitter.fire
public final function fire( $eventName /* ... $eventArgs: any[] */ ) { if ( !is_string( $eventName ) ) { throw new \browserfs\Exception('Invalid argument $eventName: string expected' ); } else if ( !strlen( $eventName ) ) { throw new \browserfs\Exception('Invalid argument $eventName: non-empty string expected'); } if ( !isset( $this->events[ $eventName ] ) ) { return; } $eventArgs = array_slice( func_get_args(), 1 ); $event = Event::create( $eventName, $eventArgs ); try { $this->fireId++; // run the loop on a copy, in order to allow the $this->off method // to work properly $copy = []; foreach ( $this->events[ $eventName ] as &$subscriber ) { $copy[] = &$subscriber; } foreach ( $copy as &$subscriber ) { $subscriber['fireId'] = $this->fireId; call_user_func( $subscriber['callback'], $event ); if ( $event->isPropagationStopped() ) { break; } } if ( isset( $this->events[ $eventName ] ) ) { // remove the fired "once" listeners for ( $i = count( $this->events[ $eventName ] ) - 1; $i >= 0; $i-- ) { if ( $this->events[ $eventName ][$i]['fireId'] === $this->fireId ) { if ( $this->events[ $eventName ][$i]['once'] === true ) { // remove event array_splice( $this->events[$eventName], $i, 1 ); } } } } } catch ( \Exception $e ) { throw new \browserfs\Exception( "Error firing event " . $eventName, 0, $e ); } return $event; }
php
public final function fire( $eventName /* ... $eventArgs: any[] */ ) { if ( !is_string( $eventName ) ) { throw new \browserfs\Exception('Invalid argument $eventName: string expected' ); } else if ( !strlen( $eventName ) ) { throw new \browserfs\Exception('Invalid argument $eventName: non-empty string expected'); } if ( !isset( $this->events[ $eventName ] ) ) { return; } $eventArgs = array_slice( func_get_args(), 1 ); $event = Event::create( $eventName, $eventArgs ); try { $this->fireId++; // run the loop on a copy, in order to allow the $this->off method // to work properly $copy = []; foreach ( $this->events[ $eventName ] as &$subscriber ) { $copy[] = &$subscriber; } foreach ( $copy as &$subscriber ) { $subscriber['fireId'] = $this->fireId; call_user_func( $subscriber['callback'], $event ); if ( $event->isPropagationStopped() ) { break; } } if ( isset( $this->events[ $eventName ] ) ) { // remove the fired "once" listeners for ( $i = count( $this->events[ $eventName ] ) - 1; $i >= 0; $i-- ) { if ( $this->events[ $eventName ][$i]['fireId'] === $this->fireId ) { if ( $this->events[ $eventName ][$i]['once'] === true ) { // remove event array_splice( $this->events[$eventName], $i, 1 ); } } } } } catch ( \Exception $e ) { throw new \browserfs\Exception( "Error firing event " . $eventName, 0, $e ); } return $event; }
[ "public", "final", "function", "fire", "(", "$", "eventName", "/* ... $eventArgs: any[] */", ")", "{", "if", "(", "!", "is_string", "(", "$", "eventName", ")", ")", "{", "throw", "new", "\\", "browserfs", "\\", "Exception", "(", "'Invalid argument $eventName: string expected'", ")", ";", "}", "else", "if", "(", "!", "strlen", "(", "$", "eventName", ")", ")", "{", "throw", "new", "\\", "browserfs", "\\", "Exception", "(", "'Invalid argument $eventName: non-empty string expected'", ")", ";", "}", "if", "(", "!", "isset", "(", "$", "this", "->", "events", "[", "$", "eventName", "]", ")", ")", "{", "return", ";", "}", "$", "eventArgs", "=", "array_slice", "(", "func_get_args", "(", ")", ",", "1", ")", ";", "$", "event", "=", "Event", "::", "create", "(", "$", "eventName", ",", "$", "eventArgs", ")", ";", "try", "{", "$", "this", "->", "fireId", "++", ";", "// run the loop on a copy, in order to allow the $this->off method", "// to work properly", "$", "copy", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "events", "[", "$", "eventName", "]", "as", "&", "$", "subscriber", ")", "{", "$", "copy", "[", "]", "=", "&", "$", "subscriber", ";", "}", "foreach", "(", "$", "copy", "as", "&", "$", "subscriber", ")", "{", "$", "subscriber", "[", "'fireId'", "]", "=", "$", "this", "->", "fireId", ";", "call_user_func", "(", "$", "subscriber", "[", "'callback'", "]", ",", "$", "event", ")", ";", "if", "(", "$", "event", "->", "isPropagationStopped", "(", ")", ")", "{", "break", ";", "}", "}", "if", "(", "isset", "(", "$", "this", "->", "events", "[", "$", "eventName", "]", ")", ")", "{", "// remove the fired \"once\" listeners", "for", "(", "$", "i", "=", "count", "(", "$", "this", "->", "events", "[", "$", "eventName", "]", ")", "-", "1", ";", "$", "i", ">=", "0", ";", "$", "i", "--", ")", "{", "if", "(", "$", "this", "->", "events", "[", "$", "eventName", "]", "[", "$", "i", "]", "[", "'fireId'", "]", "===", "$", "this", "->", "fireId", ")", "{", "if", "(", "$", "this", "->", "events", "[", "$", "eventName", "]", "[", "$", "i", "]", "[", "'once'", "]", "===", "true", ")", "{", "// remove event", "array_splice", "(", "$", "this", "->", "events", "[", "$", "eventName", "]", ",", "$", "i", ",", "1", ")", ";", "}", "}", "}", "}", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "throw", "new", "\\", "browserfs", "\\", "Exception", "(", "\"Error firing event \"", ".", "$", "eventName", ",", "0", ",", "$", "e", ")", ";", "}", "return", "$", "event", ";", "}" ]
Fires a event, and returns it's generated event object. @param $eventName: string -> the name of the event to be fired @param ...$eventArgs: any[] -> event arguments @return \browserfs\Event -> event object @throws \Exception
[ "Fires", "a", "event", "and", "returns", "it", "s", "generated", "event", "object", "." ]
d98550b5cf6f6e9083f99f39d17fd1b79d61db55
https://github.com/browserfs/base/blob/d98550b5cf6f6e9083f99f39d17fd1b79d61db55/src/EventEmitter.php#L186-L252
238,935
sebardo/ecommerce
EcommerceBundle/Entity/Repository/CategoryRepository.php
CategoryRepository.findNextSubcategory
public function findNextSubcategory($subcategory) { $qb = $this->getQueryBuilder() ->select('c') ->where('c.id > :id') ->andWhere('c.parentCategory = :parentCategory') ->orderBy('c.id', 'asc') ->setMaxResults(1) ->setParameter('id', $subcategory->getId()) ->setParameter('parentCategory', $subcategory->getParentCategory()); // get the first subcategory when there is no next if (0 == count($qb->getQuery()->getResult())) { $qb->where('c.id < :id') ->andWhere('c.parentCategory = :parentCategory') ->setParameter('id', $subcategory->getId()) ->setParameter('parentCategory', $subcategory->getParentCategory()); if (0 == count($qb->getQuery()->getResult())) { return null; } } return $qb->getQuery() ->getSingleResult(); }
php
public function findNextSubcategory($subcategory) { $qb = $this->getQueryBuilder() ->select('c') ->where('c.id > :id') ->andWhere('c.parentCategory = :parentCategory') ->orderBy('c.id', 'asc') ->setMaxResults(1) ->setParameter('id', $subcategory->getId()) ->setParameter('parentCategory', $subcategory->getParentCategory()); // get the first subcategory when there is no next if (0 == count($qb->getQuery()->getResult())) { $qb->where('c.id < :id') ->andWhere('c.parentCategory = :parentCategory') ->setParameter('id', $subcategory->getId()) ->setParameter('parentCategory', $subcategory->getParentCategory()); if (0 == count($qb->getQuery()->getResult())) { return null; } } return $qb->getQuery() ->getSingleResult(); }
[ "public", "function", "findNextSubcategory", "(", "$", "subcategory", ")", "{", "$", "qb", "=", "$", "this", "->", "getQueryBuilder", "(", ")", "->", "select", "(", "'c'", ")", "->", "where", "(", "'c.id > :id'", ")", "->", "andWhere", "(", "'c.parentCategory = :parentCategory'", ")", "->", "orderBy", "(", "'c.id'", ",", "'asc'", ")", "->", "setMaxResults", "(", "1", ")", "->", "setParameter", "(", "'id'", ",", "$", "subcategory", "->", "getId", "(", ")", ")", "->", "setParameter", "(", "'parentCategory'", ",", "$", "subcategory", "->", "getParentCategory", "(", ")", ")", ";", "// get the first subcategory when there is no next", "if", "(", "0", "==", "count", "(", "$", "qb", "->", "getQuery", "(", ")", "->", "getResult", "(", ")", ")", ")", "{", "$", "qb", "->", "where", "(", "'c.id < :id'", ")", "->", "andWhere", "(", "'c.parentCategory = :parentCategory'", ")", "->", "setParameter", "(", "'id'", ",", "$", "subcategory", "->", "getId", "(", ")", ")", "->", "setParameter", "(", "'parentCategory'", ",", "$", "subcategory", "->", "getParentCategory", "(", ")", ")", ";", "if", "(", "0", "==", "count", "(", "$", "qb", "->", "getQuery", "(", ")", "->", "getResult", "(", ")", ")", ")", "{", "return", "null", ";", "}", "}", "return", "$", "qb", "->", "getQuery", "(", ")", "->", "getSingleResult", "(", ")", ";", "}" ]
Find the next subcategory, or the first one if none is found @param Category $subcategory @return Category|null
[ "Find", "the", "next", "subcategory", "or", "the", "first", "one", "if", "none", "is", "found" ]
3e17545e69993f10a1df17f9887810c7378fc7f9
https://github.com/sebardo/ecommerce/blob/3e17545e69993f10a1df17f9887810c7378fc7f9/EcommerceBundle/Entity/Repository/CategoryRepository.php#L234-L259
238,936
sebardo/ecommerce
EcommerceBundle/Entity/Repository/CategoryRepository.php
CategoryRepository.getBrands
public function getBrands($category, $limit = null) { $qb = $this->getQueryBuilder() ->select('DISTINCT b.id, b.name') ->innerJoin('c.products', 'p') ->innerJoin('p.brand', 'b') ->where('p.active = TRUE') ->andWhere('b.available = TRUE'); if ($category->getFamily()) { // this is a category $qb->andWhere('c.parentCategory = :category') ->setParameter('category', $category); } else { // this is a subcategory $qb->andWhere('c = :category') ->setParameter('category', $category); } if (!is_null($limit)) { $qb->setMaxResults($limit); } return $qb->getQuery() ->getResult(); }
php
public function getBrands($category, $limit = null) { $qb = $this->getQueryBuilder() ->select('DISTINCT b.id, b.name') ->innerJoin('c.products', 'p') ->innerJoin('p.brand', 'b') ->where('p.active = TRUE') ->andWhere('b.available = TRUE'); if ($category->getFamily()) { // this is a category $qb->andWhere('c.parentCategory = :category') ->setParameter('category', $category); } else { // this is a subcategory $qb->andWhere('c = :category') ->setParameter('category', $category); } if (!is_null($limit)) { $qb->setMaxResults($limit); } return $qb->getQuery() ->getResult(); }
[ "public", "function", "getBrands", "(", "$", "category", ",", "$", "limit", "=", "null", ")", "{", "$", "qb", "=", "$", "this", "->", "getQueryBuilder", "(", ")", "->", "select", "(", "'DISTINCT b.id, b.name'", ")", "->", "innerJoin", "(", "'c.products'", ",", "'p'", ")", "->", "innerJoin", "(", "'p.brand'", ",", "'b'", ")", "->", "where", "(", "'p.active = TRUE'", ")", "->", "andWhere", "(", "'b.available = TRUE'", ")", ";", "if", "(", "$", "category", "->", "getFamily", "(", ")", ")", "{", "// this is a category", "$", "qb", "->", "andWhere", "(", "'c.parentCategory = :category'", ")", "->", "setParameter", "(", "'category'", ",", "$", "category", ")", ";", "}", "else", "{", "// this is a subcategory", "$", "qb", "->", "andWhere", "(", "'c = :category'", ")", "->", "setParameter", "(", "'category'", ",", "$", "category", ")", ";", "}", "if", "(", "!", "is_null", "(", "$", "limit", ")", ")", "{", "$", "qb", "->", "setMaxResults", "(", "$", "limit", ")", ";", "}", "return", "$", "qb", "->", "getQuery", "(", ")", "->", "getResult", "(", ")", ";", "}" ]
Get brands from their products relationship @param Category $category @param integer|null $limit @return ArrayCollection
[ "Get", "brands", "from", "their", "products", "relationship" ]
3e17545e69993f10a1df17f9887810c7378fc7f9
https://github.com/sebardo/ecommerce/blob/3e17545e69993f10a1df17f9887810c7378fc7f9/EcommerceBundle/Entity/Repository/CategoryRepository.php#L269-L294
238,937
samurai-fw/samurai
src/Samurai/Component/FileSystem/Finder/Finder.php
Finder.find
public function find($paths = null) { if ($paths === null) $paths = $this->paths; // iterator $iterator = $this->getIterator(); // search in target paths foreach ((array)$paths as $path) { $this->searchInPath($iterator, $path); } // clear $this->clear(); return $iterator; }
php
public function find($paths = null) { if ($paths === null) $paths = $this->paths; // iterator $iterator = $this->getIterator(); // search in target paths foreach ((array)$paths as $path) { $this->searchInPath($iterator, $path); } // clear $this->clear(); return $iterator; }
[ "public", "function", "find", "(", "$", "paths", "=", "null", ")", "{", "if", "(", "$", "paths", "===", "null", ")", "$", "paths", "=", "$", "this", "->", "paths", ";", "// iterator", "$", "iterator", "=", "$", "this", "->", "getIterator", "(", ")", ";", "// search in target paths", "foreach", "(", "(", "array", ")", "$", "paths", "as", "$", "path", ")", "{", "$", "this", "->", "searchInPath", "(", "$", "iterator", ",", "$", "path", ")", ";", "}", "// clear", "$", "this", "->", "clear", "(", ")", ";", "return", "$", "iterator", ";", "}" ]
find trigger. @param string|array $paths
[ "find", "trigger", "." ]
7ca3847b13f86e2847a17ab5e8e4e20893021d5a
https://github.com/samurai-fw/samurai/blob/7ca3847b13f86e2847a17ab5e8e4e20893021d5a/src/Samurai/Component/FileSystem/Finder/Finder.php#L115-L131
238,938
samurai-fw/samurai
src/Samurai/Component/FileSystem/Finder/Finder.php
Finder.searchInPath
private function searchInPath(FileSystem\Iterator\IteratorAggregate $iterator, $path, FileSystem\Directory $parent = null, $depth = 0) { // when exists. if (file_exists($path)) { if(is_dir($path)) { $dir = new FileSystem\Directory($path); if ($parent) $dir->setParent($parent); if ($this->validate($dir)) $iterator->add($dir); if ($this->recursive || $depth < 1) { $this->searchInPath($iterator, "{$dir}/*", $dir, $depth + 1); } } else { $file = new FileSystem\File($path); if ($parent) $file->setParent($parent); if ($this->validate($file)) $iterator->add($file); } } // when not exists, then glob. else { foreach (glob($path) as $file) { $this->searchInPath($iterator, $file, $parent, $depth); } } }
php
private function searchInPath(FileSystem\Iterator\IteratorAggregate $iterator, $path, FileSystem\Directory $parent = null, $depth = 0) { // when exists. if (file_exists($path)) { if(is_dir($path)) { $dir = new FileSystem\Directory($path); if ($parent) $dir->setParent($parent); if ($this->validate($dir)) $iterator->add($dir); if ($this->recursive || $depth < 1) { $this->searchInPath($iterator, "{$dir}/*", $dir, $depth + 1); } } else { $file = new FileSystem\File($path); if ($parent) $file->setParent($parent); if ($this->validate($file)) $iterator->add($file); } } // when not exists, then glob. else { foreach (glob($path) as $file) { $this->searchInPath($iterator, $file, $parent, $depth); } } }
[ "private", "function", "searchInPath", "(", "FileSystem", "\\", "Iterator", "\\", "IteratorAggregate", "$", "iterator", ",", "$", "path", ",", "FileSystem", "\\", "Directory", "$", "parent", "=", "null", ",", "$", "depth", "=", "0", ")", "{", "// when exists.", "if", "(", "file_exists", "(", "$", "path", ")", ")", "{", "if", "(", "is_dir", "(", "$", "path", ")", ")", "{", "$", "dir", "=", "new", "FileSystem", "\\", "Directory", "(", "$", "path", ")", ";", "if", "(", "$", "parent", ")", "$", "dir", "->", "setParent", "(", "$", "parent", ")", ";", "if", "(", "$", "this", "->", "validate", "(", "$", "dir", ")", ")", "$", "iterator", "->", "add", "(", "$", "dir", ")", ";", "if", "(", "$", "this", "->", "recursive", "||", "$", "depth", "<", "1", ")", "{", "$", "this", "->", "searchInPath", "(", "$", "iterator", ",", "\"{$dir}/*\"", ",", "$", "dir", ",", "$", "depth", "+", "1", ")", ";", "}", "}", "else", "{", "$", "file", "=", "new", "FileSystem", "\\", "File", "(", "$", "path", ")", ";", "if", "(", "$", "parent", ")", "$", "file", "->", "setParent", "(", "$", "parent", ")", ";", "if", "(", "$", "this", "->", "validate", "(", "$", "file", ")", ")", "$", "iterator", "->", "add", "(", "$", "file", ")", ";", "}", "}", "// when not exists, then glob.", "else", "{", "foreach", "(", "glob", "(", "$", "path", ")", "as", "$", "file", ")", "{", "$", "this", "->", "searchInPath", "(", "$", "iterator", ",", "$", "file", ",", "$", "parent", ",", "$", "depth", ")", ";", "}", "}", "}" ]
search files in target path. @param Samurai\Samurai\Component\FileSystem\Iterator\IteratorAggregate $iterator @param string $path @param Samurai\Samurai\Component\FileSystem\Directory $parent @param int $depth @return array
[ "search", "files", "in", "target", "path", "." ]
7ca3847b13f86e2847a17ab5e8e4e20893021d5a
https://github.com/samurai-fw/samurai/blob/7ca3847b13f86e2847a17ab5e8e4e20893021d5a/src/Samurai/Component/FileSystem/Finder/Finder.php#L143-L166
238,939
samurai-fw/samurai
src/Samurai/Component/FileSystem/Finder/Finder.php
Finder.validate
private function validate(FileSystem\File $file) { $filters = $this->buildFilters(); foreach ($filters as $filter) { if (! $filter->validate($file)) return false; } return true; }
php
private function validate(FileSystem\File $file) { $filters = $this->buildFilters(); foreach ($filters as $filter) { if (! $filter->validate($file)) return false; } return true; }
[ "private", "function", "validate", "(", "FileSystem", "\\", "File", "$", "file", ")", "{", "$", "filters", "=", "$", "this", "->", "buildFilters", "(", ")", ";", "foreach", "(", "$", "filters", "as", "$", "filter", ")", "{", "if", "(", "!", "$", "filter", "->", "validate", "(", "$", "file", ")", ")", "return", "false", ";", "}", "return", "true", ";", "}" ]
validate file. @param Samurai\Samurai\Component\FileSystem\File $file @return boolean
[ "validate", "file", "." ]
7ca3847b13f86e2847a17ab5e8e4e20893021d5a
https://github.com/samurai-fw/samurai/blob/7ca3847b13f86e2847a17ab5e8e4e20893021d5a/src/Samurai/Component/FileSystem/Finder/Finder.php#L175-L183
238,940
samurai-fw/samurai
src/Samurai/Component/FileSystem/Finder/Finder.php
Finder.buildFilters
private function buildFilters() { $filters = array(); // file only ? or direcotry only ? if ($this->file_only) $filters[] = new Filter\FileOnlyFilter(); if ($this->directory_only) $filters[] = new Filter\DirectoryOnlyFilter(); // name match ? foreach ($this->names as $name) { $filters[] = new Filter\NameFilter($name); } return $filters; }
php
private function buildFilters() { $filters = array(); // file only ? or direcotry only ? if ($this->file_only) $filters[] = new Filter\FileOnlyFilter(); if ($this->directory_only) $filters[] = new Filter\DirectoryOnlyFilter(); // name match ? foreach ($this->names as $name) { $filters[] = new Filter\NameFilter($name); } return $filters; }
[ "private", "function", "buildFilters", "(", ")", "{", "$", "filters", "=", "array", "(", ")", ";", "// file only ? or direcotry only ?", "if", "(", "$", "this", "->", "file_only", ")", "$", "filters", "[", "]", "=", "new", "Filter", "\\", "FileOnlyFilter", "(", ")", ";", "if", "(", "$", "this", "->", "directory_only", ")", "$", "filters", "[", "]", "=", "new", "Filter", "\\", "DirectoryOnlyFilter", "(", ")", ";", "// name match ?", "foreach", "(", "$", "this", "->", "names", "as", "$", "name", ")", "{", "$", "filters", "[", "]", "=", "new", "Filter", "\\", "NameFilter", "(", "$", "name", ")", ";", "}", "return", "$", "filters", ";", "}" ]
build filters for validate. @return array
[ "build", "filters", "for", "validate", "." ]
7ca3847b13f86e2847a17ab5e8e4e20893021d5a
https://github.com/samurai-fw/samurai/blob/7ca3847b13f86e2847a17ab5e8e4e20893021d5a/src/Samurai/Component/FileSystem/Finder/Finder.php#L191-L205
238,941
samurai-fw/samurai
src/Samurai/Component/FileSystem/Finder/Finder.php
Finder.fileOnly
public function fileOnly($flag = true) { $this->file_only = $flag; if ($this->file_only) $this->directory_only = false; return $this; }
php
public function fileOnly($flag = true) { $this->file_only = $flag; if ($this->file_only) $this->directory_only = false; return $this; }
[ "public", "function", "fileOnly", "(", "$", "flag", "=", "true", ")", "{", "$", "this", "->", "file_only", "=", "$", "flag", ";", "if", "(", "$", "this", "->", "file_only", ")", "$", "this", "->", "directory_only", "=", "false", ";", "return", "$", "this", ";", "}" ]
set file only flag is true @return Samurai\Samurai\Component\FileSystem\Finder\Finder
[ "set", "file", "only", "flag", "is", "true" ]
7ca3847b13f86e2847a17ab5e8e4e20893021d5a
https://github.com/samurai-fw/samurai/blob/7ca3847b13f86e2847a17ab5e8e4e20893021d5a/src/Samurai/Component/FileSystem/Finder/Finder.php#L250-L255
238,942
samurai-fw/samurai
src/Samurai/Component/FileSystem/Finder/Finder.php
Finder.directoryOnly
public function directoryOnly($flag = true) { $this->directory_only = $flag; if ($this->directory_only) $this->file_only = false; return $this; }
php
public function directoryOnly($flag = true) { $this->directory_only = $flag; if ($this->directory_only) $this->file_only = false; return $this; }
[ "public", "function", "directoryOnly", "(", "$", "flag", "=", "true", ")", "{", "$", "this", "->", "directory_only", "=", "$", "flag", ";", "if", "(", "$", "this", "->", "directory_only", ")", "$", "this", "->", "file_only", "=", "false", ";", "return", "$", "this", ";", "}" ]
set directory only is true. @param boolean $flag @return Samurai\Samurai\Component\FileSystem\Finder\Finder
[ "set", "directory", "only", "is", "true", "." ]
7ca3847b13f86e2847a17ab5e8e4e20893021d5a
https://github.com/samurai-fw/samurai/blob/7ca3847b13f86e2847a17ab5e8e4e20893021d5a/src/Samurai/Component/FileSystem/Finder/Finder.php#L263-L268
238,943
DatingVIP/IRC
src/DatingVIP/IRC/Robot.php
Robot.removeListener
public function removeListener(Listener $listener) { foreach ($this->listeners as $id => $listening) { if ($listener == $listening) { unset($this->listeners[$id]); break; } } }
php
public function removeListener(Listener $listener) { foreach ($this->listeners as $id => $listening) { if ($listener == $listening) { unset($this->listeners[$id]); break; } } }
[ "public", "function", "removeListener", "(", "Listener", "$", "listener", ")", "{", "foreach", "(", "$", "this", "->", "listeners", "as", "$", "id", "=>", "$", "listening", ")", "{", "if", "(", "$", "listener", "==", "$", "listening", ")", "{", "unset", "(", "$", "this", "->", "listeners", "[", "$", "id", "]", ")", ";", "break", ";", "}", "}", "}" ]
Remove a Listener Object @param Listener listener @note must be executed synchronously (in the context that created the Robot)
[ "Remove", "a", "Listener", "Object" ]
c09add1317210cd772529146fc617130db957c16
https://github.com/DatingVIP/IRC/blob/c09add1317210cd772529146fc617130db957c16/src/DatingVIP/IRC/Robot.php#L34-L41
238,944
DatingVIP/IRC
src/DatingVIP/IRC/Robot.php
Robot.login
public function login($nick, $password = null) { if ($password) { if (!$this->connection->send("PASS {$password}")) { throw new \RuntimeException( "failed to send password to {$this->server}"); } } else { if (!$this->connection->send("PASS NOPASS")) { throw new \RuntimeException( "failed to send nopass to {$this->server}"); } } if (!$this->connection->send("NICK {$nick}")) { throw new \RuntimeException( "failed to set nick {$nick} on {$this->server}"); } $this->loop(false); if (!$this->connection->send("USER {$nick} AS IRC BOT")) { throw new \RuntimeException( "failed to set user {$nick} on {$this->server}"); } $this->loop(false); return $this; }
php
public function login($nick, $password = null) { if ($password) { if (!$this->connection->send("PASS {$password}")) { throw new \RuntimeException( "failed to send password to {$this->server}"); } } else { if (!$this->connection->send("PASS NOPASS")) { throw new \RuntimeException( "failed to send nopass to {$this->server}"); } } if (!$this->connection->send("NICK {$nick}")) { throw new \RuntimeException( "failed to set nick {$nick} on {$this->server}"); } $this->loop(false); if (!$this->connection->send("USER {$nick} AS IRC BOT")) { throw new \RuntimeException( "failed to set user {$nick} on {$this->server}"); } $this->loop(false); return $this; }
[ "public", "function", "login", "(", "$", "nick", ",", "$", "password", "=", "null", ")", "{", "if", "(", "$", "password", ")", "{", "if", "(", "!", "$", "this", "->", "connection", "->", "send", "(", "\"PASS {$password}\"", ")", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "\"failed to send password to {$this->server}\"", ")", ";", "}", "}", "else", "{", "if", "(", "!", "$", "this", "->", "connection", "->", "send", "(", "\"PASS NOPASS\"", ")", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "\"failed to send nopass to {$this->server}\"", ")", ";", "}", "}", "if", "(", "!", "$", "this", "->", "connection", "->", "send", "(", "\"NICK {$nick}\"", ")", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "\"failed to set nick {$nick} on {$this->server}\"", ")", ";", "}", "$", "this", "->", "loop", "(", "false", ")", ";", "if", "(", "!", "$", "this", "->", "connection", "->", "send", "(", "\"USER {$nick} AS IRC BOT\"", ")", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "\"failed to set user {$nick} on {$this->server}\"", ")", ";", "}", "$", "this", "->", "loop", "(", "false", ")", ";", "return", "$", "this", ";", "}" ]
Login into server as nick with optional password @param string nick @param string password @return Connection @throws \RuntimeException
[ "Login", "into", "server", "as", "nick", "with", "optional", "password" ]
c09add1317210cd772529146fc617130db957c16
https://github.com/DatingVIP/IRC/blob/c09add1317210cd772529146fc617130db957c16/src/DatingVIP/IRC/Robot.php#L68-L96
238,945
DatingVIP/IRC
src/DatingVIP/IRC/Robot.php
Robot.loop
public function loop($main = true) { if ($main && $this->manager) { $this->manager->onStartup($this); } while (($line = $this->connection->recv())) { if (preg_match("~^ping :(.*)?~i", $line, $pong)) { if (!$this->connection->send("PONG {$pong[1]}")) { throw new \RuntimeException( "failed to send PONG to {$this->server}"); } } else { $message = new Message($line); /* management interface invokation */ if ($main && $this->manager) { switch ($message->getType()) { case Message::join: $this->manager->onJoin($this, $message); break; case Message::part: $this->manager->onPart($this, $message); break; case Message::nick: $this->manager->onNick($this, $message); break; case Message::priv: $this->manager->onPriv($this, $message); break; /* and so on ... */ } } /* listener interface invokation */ foreach ($this->listeners as $listener) { $response = $listener ->onReceive($this->connection, $message); if ($response) { if (($response instanceof Task)) { $this->pool ->submit($response); continue; } throw new \RuntimeException(sprintf( "%s returned an invalid response, ". "expected Task object or nothing", get_class($listener))); } } } if (!$main) break; $this->pool->collect(function($responder) { if ($responder instanceof Task) { return $responder->isGarbage(); } else return true; }); } if ($main && $this->manager) { $this->manager->onShutdown($this); } return $main ? $this->loop($main) : $this; }
php
public function loop($main = true) { if ($main && $this->manager) { $this->manager->onStartup($this); } while (($line = $this->connection->recv())) { if (preg_match("~^ping :(.*)?~i", $line, $pong)) { if (!$this->connection->send("PONG {$pong[1]}")) { throw new \RuntimeException( "failed to send PONG to {$this->server}"); } } else { $message = new Message($line); /* management interface invokation */ if ($main && $this->manager) { switch ($message->getType()) { case Message::join: $this->manager->onJoin($this, $message); break; case Message::part: $this->manager->onPart($this, $message); break; case Message::nick: $this->manager->onNick($this, $message); break; case Message::priv: $this->manager->onPriv($this, $message); break; /* and so on ... */ } } /* listener interface invokation */ foreach ($this->listeners as $listener) { $response = $listener ->onReceive($this->connection, $message); if ($response) { if (($response instanceof Task)) { $this->pool ->submit($response); continue; } throw new \RuntimeException(sprintf( "%s returned an invalid response, ". "expected Task object or nothing", get_class($listener))); } } } if (!$main) break; $this->pool->collect(function($responder) { if ($responder instanceof Task) { return $responder->isGarbage(); } else return true; }); } if ($main && $this->manager) { $this->manager->onShutdown($this); } return $main ? $this->loop($main) : $this; }
[ "public", "function", "loop", "(", "$", "main", "=", "true", ")", "{", "if", "(", "$", "main", "&&", "$", "this", "->", "manager", ")", "{", "$", "this", "->", "manager", "->", "onStartup", "(", "$", "this", ")", ";", "}", "while", "(", "(", "$", "line", "=", "$", "this", "->", "connection", "->", "recv", "(", ")", ")", ")", "{", "if", "(", "preg_match", "(", "\"~^ping :(.*)?~i\"", ",", "$", "line", ",", "$", "pong", ")", ")", "{", "if", "(", "!", "$", "this", "->", "connection", "->", "send", "(", "\"PONG {$pong[1]}\"", ")", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "\"failed to send PONG to {$this->server}\"", ")", ";", "}", "}", "else", "{", "$", "message", "=", "new", "Message", "(", "$", "line", ")", ";", "/* management interface invokation */", "if", "(", "$", "main", "&&", "$", "this", "->", "manager", ")", "{", "switch", "(", "$", "message", "->", "getType", "(", ")", ")", "{", "case", "Message", "::", "join", ":", "$", "this", "->", "manager", "->", "onJoin", "(", "$", "this", ",", "$", "message", ")", ";", "break", ";", "case", "Message", "::", "part", ":", "$", "this", "->", "manager", "->", "onPart", "(", "$", "this", ",", "$", "message", ")", ";", "break", ";", "case", "Message", "::", "nick", ":", "$", "this", "->", "manager", "->", "onNick", "(", "$", "this", ",", "$", "message", ")", ";", "break", ";", "case", "Message", "::", "priv", ":", "$", "this", "->", "manager", "->", "onPriv", "(", "$", "this", ",", "$", "message", ")", ";", "break", ";", "/* and so on ... */", "}", "}", "/* listener interface invokation */", "foreach", "(", "$", "this", "->", "listeners", "as", "$", "listener", ")", "{", "$", "response", "=", "$", "listener", "->", "onReceive", "(", "$", "this", "->", "connection", ",", "$", "message", ")", ";", "if", "(", "$", "response", ")", "{", "if", "(", "(", "$", "response", "instanceof", "Task", ")", ")", "{", "$", "this", "->", "pool", "->", "submit", "(", "$", "response", ")", ";", "continue", ";", "}", "throw", "new", "\\", "RuntimeException", "(", "sprintf", "(", "\"%s returned an invalid response, \"", ".", "\"expected Task object or nothing\"", ",", "get_class", "(", "$", "listener", ")", ")", ")", ";", "}", "}", "}", "if", "(", "!", "$", "main", ")", "break", ";", "$", "this", "->", "pool", "->", "collect", "(", "function", "(", "$", "responder", ")", "{", "if", "(", "$", "responder", "instanceof", "Task", ")", "{", "return", "$", "responder", "->", "isGarbage", "(", ")", ";", "}", "else", "return", "true", ";", "}", ")", ";", "}", "if", "(", "$", "main", "&&", "$", "this", "->", "manager", ")", "{", "$", "this", "->", "manager", "->", "onShutdown", "(", "$", "this", ")", ";", "}", "return", "$", "main", "?", "$", "this", "->", "loop", "(", "$", "main", ")", ":", "$", "this", ";", "}" ]
Enter into IO loop @param boolean main @return Connection @throws \RuntimeException
[ "Enter", "into", "IO", "loop" ]
c09add1317210cd772529146fc617130db957c16
https://github.com/DatingVIP/IRC/blob/c09add1317210cd772529146fc617130db957c16/src/DatingVIP/IRC/Robot.php#L118-L178
238,946
xloit/xloit-bridge-zend-servicemanager
src/ServiceFactory.php
ServiceFactory.createServiceFactory
protected function createServiceFactory( $requestedName, ReflectionClass $reflection, ContainerInterface $container ) { /** @var array $mappings */ $mappings = $this->getServiceMapping($container, $requestedName); if ($reflection->implementsInterface(Factory\FactoryInterface::class)) { $factory = $reflection->newInstance($mappings['namespace'], $mappings['service'], $this->namespace); } else { $factory = $reflection->newInstance(); } $this->lookupCache[$requestedName]['factoryInstance'] = $factory; if ($factory instanceof Factory\FactoryInterface) { /** @var Factory\FactoryInterface $factory */ $factory->setContainer($container); } return $factory($container, $requestedName); }
php
protected function createServiceFactory( $requestedName, ReflectionClass $reflection, ContainerInterface $container ) { /** @var array $mappings */ $mappings = $this->getServiceMapping($container, $requestedName); if ($reflection->implementsInterface(Factory\FactoryInterface::class)) { $factory = $reflection->newInstance($mappings['namespace'], $mappings['service'], $this->namespace); } else { $factory = $reflection->newInstance(); } $this->lookupCache[$requestedName]['factoryInstance'] = $factory; if ($factory instanceof Factory\FactoryInterface) { /** @var Factory\FactoryInterface $factory */ $factory->setContainer($container); } return $factory($container, $requestedName); }
[ "protected", "function", "createServiceFactory", "(", "$", "requestedName", ",", "ReflectionClass", "$", "reflection", ",", "ContainerInterface", "$", "container", ")", "{", "/** @var array $mappings */", "$", "mappings", "=", "$", "this", "->", "getServiceMapping", "(", "$", "container", ",", "$", "requestedName", ")", ";", "if", "(", "$", "reflection", "->", "implementsInterface", "(", "Factory", "\\", "FactoryInterface", "::", "class", ")", ")", "{", "$", "factory", "=", "$", "reflection", "->", "newInstance", "(", "$", "mappings", "[", "'namespace'", "]", ",", "$", "mappings", "[", "'service'", "]", ",", "$", "this", "->", "namespace", ")", ";", "}", "else", "{", "$", "factory", "=", "$", "reflection", "->", "newInstance", "(", ")", ";", "}", "$", "this", "->", "lookupCache", "[", "$", "requestedName", "]", "[", "'factoryInstance'", "]", "=", "$", "factory", ";", "if", "(", "$", "factory", "instanceof", "Factory", "\\", "FactoryInterface", ")", "{", "/** @var Factory\\FactoryInterface $factory */", "$", "factory", "->", "setContainer", "(", "$", "container", ")", ";", "}", "return", "$", "factory", "(", "$", "container", ",", "$", "requestedName", ")", ";", "}" ]
Initiate service factory from the ReflectionClass. @param string $requestedName @param ReflectionClass $reflection @param ContainerInterface $container @return mixed @throws \ReflectionException @throws \Psr\Container\ContainerExceptionInterface @throws \Psr\Container\NotFoundExceptionInterface @throws \Xloit\Std\Exception\RuntimeException
[ "Initiate", "service", "factory", "from", "the", "ReflectionClass", "." ]
f3285842a6fdcb3de0416b98f9bc20dd7a122cc4
https://github.com/xloit/xloit-bridge-zend-servicemanager/blob/f3285842a6fdcb3de0416b98f9bc20dd7a122cc4/src/ServiceFactory.php#L201-L221
238,947
leedave/filehandler
src/File.php
File.iterateFileName
protected static function iterateFileName(string $fileName) { //First remove Extension $arrFileParts = explode(".", $fileName); $extension = array_pop($arrFileParts); $tempFileName = implode(".", $arrFileParts); $arrFileName = explode("_", $tempFileName); if (is_numeric($arrFileName[(count($arrFileName) - 1)])) { $iterator = (int) array_pop($arrFileName); $iterator++; $arrFileName[] = $iterator; $newFileName = implode("_", $arrFileName); return $newFileName . "." . $extension; } return $tempFileName."_1." . $extension; }
php
protected static function iterateFileName(string $fileName) { //First remove Extension $arrFileParts = explode(".", $fileName); $extension = array_pop($arrFileParts); $tempFileName = implode(".", $arrFileParts); $arrFileName = explode("_", $tempFileName); if (is_numeric($arrFileName[(count($arrFileName) - 1)])) { $iterator = (int) array_pop($arrFileName); $iterator++; $arrFileName[] = $iterator; $newFileName = implode("_", $arrFileName); return $newFileName . "." . $extension; } return $tempFileName."_1." . $extension; }
[ "protected", "static", "function", "iterateFileName", "(", "string", "$", "fileName", ")", "{", "//First remove Extension", "$", "arrFileParts", "=", "explode", "(", "\".\"", ",", "$", "fileName", ")", ";", "$", "extension", "=", "array_pop", "(", "$", "arrFileParts", ")", ";", "$", "tempFileName", "=", "implode", "(", "\".\"", ",", "$", "arrFileParts", ")", ";", "$", "arrFileName", "=", "explode", "(", "\"_\"", ",", "$", "tempFileName", ")", ";", "if", "(", "is_numeric", "(", "$", "arrFileName", "[", "(", "count", "(", "$", "arrFileName", ")", "-", "1", ")", "]", ")", ")", "{", "$", "iterator", "=", "(", "int", ")", "array_pop", "(", "$", "arrFileName", ")", ";", "$", "iterator", "++", ";", "$", "arrFileName", "[", "]", "=", "$", "iterator", ";", "$", "newFileName", "=", "implode", "(", "\"_\"", ",", "$", "arrFileName", ")", ";", "return", "$", "newFileName", ".", "\".\"", ".", "$", "extension", ";", "}", "return", "$", "tempFileName", ".", "\"_1.\"", ".", "$", "extension", ";", "}" ]
Puts a number on the end of a file name, prevents overwriting @param string $fileName @return string
[ "Puts", "a", "number", "on", "the", "end", "of", "a", "file", "name", "prevents", "overwriting" ]
924e3fed15861b7d74e8e62aad6dd41b274e777a
https://github.com/leedave/filehandler/blob/924e3fed15861b7d74e8e62aad6dd41b274e777a/src/File.php#L42-L57
238,948
phramework/basic-authentication
src/BasicAuthentication.php
BasicAuthentication.authenticate
public function authenticate($params, $method, $headers) { $email = \Phramework\Validate\EmailValidator::parseStatic($params['email']); $password = $params['password']; $user = call_user_func(Manager::getUserGetByEmailMethod(), $email); if (!$user) { return false; } if (!password_verify($password, $user['password'])) { return false; } /* * Create the token as an array */ $data = [ 'id' => $user['id'] ]; //copy user attributes to jwt's data foreach (Manager::getAttributes() as $attribute) { if (!isset($user[$attribute])) { throw new \Phramework\Exceptions\ServerException(sprintf( 'Attribute "%s" is not set in user object', $attribute )); } $data[$attribute] = $user[$attribute]; } //Convert to object $data = (object)$data; //Call onAuthenticate callback if set if (($callback = Manager::getOnAuthenticateCallback()) !== null) { call_user_func( $callback, $data ); } return [$data]; }
php
public function authenticate($params, $method, $headers) { $email = \Phramework\Validate\EmailValidator::parseStatic($params['email']); $password = $params['password']; $user = call_user_func(Manager::getUserGetByEmailMethod(), $email); if (!$user) { return false; } if (!password_verify($password, $user['password'])) { return false; } /* * Create the token as an array */ $data = [ 'id' => $user['id'] ]; //copy user attributes to jwt's data foreach (Manager::getAttributes() as $attribute) { if (!isset($user[$attribute])) { throw new \Phramework\Exceptions\ServerException(sprintf( 'Attribute "%s" is not set in user object', $attribute )); } $data[$attribute] = $user[$attribute]; } //Convert to object $data = (object)$data; //Call onAuthenticate callback if set if (($callback = Manager::getOnAuthenticateCallback()) !== null) { call_user_func( $callback, $data ); } return [$data]; }
[ "public", "function", "authenticate", "(", "$", "params", ",", "$", "method", ",", "$", "headers", ")", "{", "$", "email", "=", "\\", "Phramework", "\\", "Validate", "\\", "EmailValidator", "::", "parseStatic", "(", "$", "params", "[", "'email'", "]", ")", ";", "$", "password", "=", "$", "params", "[", "'password'", "]", ";", "$", "user", "=", "call_user_func", "(", "Manager", "::", "getUserGetByEmailMethod", "(", ")", ",", "$", "email", ")", ";", "if", "(", "!", "$", "user", ")", "{", "return", "false", ";", "}", "if", "(", "!", "password_verify", "(", "$", "password", ",", "$", "user", "[", "'password'", "]", ")", ")", "{", "return", "false", ";", "}", "/*\n * Create the token as an array\n */", "$", "data", "=", "[", "'id'", "=>", "$", "user", "[", "'id'", "]", "]", ";", "//copy user attributes to jwt's data", "foreach", "(", "Manager", "::", "getAttributes", "(", ")", "as", "$", "attribute", ")", "{", "if", "(", "!", "isset", "(", "$", "user", "[", "$", "attribute", "]", ")", ")", "{", "throw", "new", "\\", "Phramework", "\\", "Exceptions", "\\", "ServerException", "(", "sprintf", "(", "'Attribute \"%s\" is not set in user object'", ",", "$", "attribute", ")", ")", ";", "}", "$", "data", "[", "$", "attribute", "]", "=", "$", "user", "[", "$", "attribute", "]", ";", "}", "//Convert to object", "$", "data", "=", "(", "object", ")", "$", "data", ";", "//Call onAuthenticate callback if set", "if", "(", "(", "$", "callback", "=", "Manager", "::", "getOnAuthenticateCallback", "(", ")", ")", "!==", "null", ")", "{", "call_user_func", "(", "$", "callback", ",", "$", "data", ")", ";", "}", "return", "[", "$", "data", "]", ";", "}" ]
Authenticate a user using JWT authentication method @param array $params Request parameters @param string $method Request method @param array $headers Request headers @return false|array Returns false on failure
[ "Authenticate", "a", "user", "using", "JWT", "authentication", "method" ]
9c2a5b89a589f58a8f2fb0df6c708803e5e7ada3
https://github.com/phramework/basic-authentication/blob/9c2a5b89a589f58a8f2fb0df6c708803e5e7ada3/src/BasicAuthentication.php#L110-L155
238,949
ncrypthic/lla-dci
src/LLA/Dci/ContextTrait.php
ContextTrait.set
public function set($prop, $value) { $class = get_class($this); if(property_exists($class, $prop)) { // Use reflection to set private property $reflection = new \ReflectionProperty($class, $prop); $reflection->setAccessible(true); $reflection->setValue($this, $value); } else { $msg = sprintf("Unexpected data set `%s` on `%s`", $prop, $class); throw new ContextException($msg); } return $this; }
php
public function set($prop, $value) { $class = get_class($this); if(property_exists($class, $prop)) { // Use reflection to set private property $reflection = new \ReflectionProperty($class, $prop); $reflection->setAccessible(true); $reflection->setValue($this, $value); } else { $msg = sprintf("Unexpected data set `%s` on `%s`", $prop, $class); throw new ContextException($msg); } return $this; }
[ "public", "function", "set", "(", "$", "prop", ",", "$", "value", ")", "{", "$", "class", "=", "get_class", "(", "$", "this", ")", ";", "if", "(", "property_exists", "(", "$", "class", ",", "$", "prop", ")", ")", "{", "// Use reflection to set private property", "$", "reflection", "=", "new", "\\", "ReflectionProperty", "(", "$", "class", ",", "$", "prop", ")", ";", "$", "reflection", "->", "setAccessible", "(", "true", ")", ";", "$", "reflection", "->", "setValue", "(", "$", "this", ",", "$", "value", ")", ";", "}", "else", "{", "$", "msg", "=", "sprintf", "(", "\"Unexpected data set `%s` on `%s`\"", ",", "$", "prop", ",", "$", "class", ")", ";", "throw", "new", "ContextException", "(", "$", "msg", ")", ";", "}", "return", "$", "this", ";", "}" ]
Set context data @param string $prop @param mixed $value @return this @throws \Ris\Dci\ContextDataException
[ "Set", "context", "data" ]
c27f46884747d56213f28a64f5537766dc8020c5
https://github.com/ncrypthic/lla-dci/blob/c27f46884747d56213f28a64f5537766dc8020c5/src/LLA/Dci/ContextTrait.php#L16-L29
238,950
jaredtking/jaqb
src/Statement/WhereStatement.php
WhereStatement.addCondition
public function addCondition($field, $value = false, $operator = '=') { if (is_array($field) && !$value) { foreach ($field as $key => $value) { // handles #6 if (is_array($value)) { call_user_func_array([$this, 'addCondition'], $value); // handles #7 } elseif (!is_numeric($key)) { $this->addCondition($key, $value); // handles #8 } else { $this->addCondition($value); } } return $this; } // handles #4 and #5 $condition = [$field]; // handles #1, #2, and #3 if (func_num_args() >= 2) { $condition[] = $operator; $condition[] = $value; } $this->conditions[] = $condition; return $this; }
php
public function addCondition($field, $value = false, $operator = '=') { if (is_array($field) && !$value) { foreach ($field as $key => $value) { // handles #6 if (is_array($value)) { call_user_func_array([$this, 'addCondition'], $value); // handles #7 } elseif (!is_numeric($key)) { $this->addCondition($key, $value); // handles #8 } else { $this->addCondition($value); } } return $this; } // handles #4 and #5 $condition = [$field]; // handles #1, #2, and #3 if (func_num_args() >= 2) { $condition[] = $operator; $condition[] = $value; } $this->conditions[] = $condition; return $this; }
[ "public", "function", "addCondition", "(", "$", "field", ",", "$", "value", "=", "false", ",", "$", "operator", "=", "'='", ")", "{", "if", "(", "is_array", "(", "$", "field", ")", "&&", "!", "$", "value", ")", "{", "foreach", "(", "$", "field", "as", "$", "key", "=>", "$", "value", ")", "{", "// handles #6", "if", "(", "is_array", "(", "$", "value", ")", ")", "{", "call_user_func_array", "(", "[", "$", "this", ",", "'addCondition'", "]", ",", "$", "value", ")", ";", "// handles #7", "}", "elseif", "(", "!", "is_numeric", "(", "$", "key", ")", ")", "{", "$", "this", "->", "addCondition", "(", "$", "key", ",", "$", "value", ")", ";", "// handles #8", "}", "else", "{", "$", "this", "->", "addCondition", "(", "$", "value", ")", ";", "}", "}", "return", "$", "this", ";", "}", "// handles #4 and #5", "$", "condition", "=", "[", "$", "field", "]", ";", "// handles #1, #2, and #3", "if", "(", "func_num_args", "(", ")", ">=", "2", ")", "{", "$", "condition", "[", "]", "=", "$", "operator", ";", "$", "condition", "[", "]", "=", "$", "value", ";", "}", "$", "this", "->", "conditions", "[", "]", "=", "$", "condition", ";", "return", "$", "this", ";", "}" ]
Adds a condition to the statement. Accepts the following forms: 1. Equality comparison: addCondition('username', 'john') 2. Comparison with custom operator: addCondition('balance', 100, '>') 3. IN statement: addCondition('group', ['admin', 'owner']) 4. SQL fragment: addCondition('name LIKE "%john%"') 5. Subquery: addCondition(function(SelectQuery $query) {}) 6. List of conditions to add: addCondition([['balance', 100, '>'], ['user_id', 5]]) 7. Map of equality comparisons: addCondition(['username' => 'john', 'user_id' => 5]) 8. List of SQL fragments: addCondition(['first_name LIKE "%john%"', 'last_name LIKE "%doe%"']) @param array|string $field @param string|bool $value condition value (optional) @param string $operator operator (optional) @return self
[ "Adds", "a", "condition", "to", "the", "statement", "." ]
04a853b530fcc12a9863349d3d0da6377d1b9995
https://github.com/jaredtking/jaqb/blob/04a853b530fcc12a9863349d3d0da6377d1b9995/src/Statement/WhereStatement.php#L75-L106
238,951
jaredtking/jaqb
src/Statement/WhereStatement.php
WhereStatement.addBetweenCondition
public function addBetweenCondition($field, $a, $b) { $this->conditions[] = ['BETWEEN', $field, $a, $b, true]; return $this; }
php
public function addBetweenCondition($field, $a, $b) { $this->conditions[] = ['BETWEEN', $field, $a, $b, true]; return $this; }
[ "public", "function", "addBetweenCondition", "(", "$", "field", ",", "$", "a", ",", "$", "b", ")", "{", "$", "this", "->", "conditions", "[", "]", "=", "[", "'BETWEEN'", ",", "$", "field", ",", "$", "a", ",", "$", "b", ",", "true", "]", ";", "return", "$", "this", ";", "}" ]
Adds a between condition to the query. @param string $field @param mixed $a first between value @param mixed $b second between value @return self
[ "Adds", "a", "between", "condition", "to", "the", "query", "." ]
04a853b530fcc12a9863349d3d0da6377d1b9995
https://github.com/jaredtking/jaqb/blob/04a853b530fcc12a9863349d3d0da6377d1b9995/src/Statement/WhereStatement.php#L130-L135
238,952
jaredtking/jaqb
src/Statement/WhereStatement.php
WhereStatement.addNotBetweenCondition
public function addNotBetweenCondition($field, $a, $b) { $this->conditions[] = ['BETWEEN', $field, $a, $b, false]; return $this; }
php
public function addNotBetweenCondition($field, $a, $b) { $this->conditions[] = ['BETWEEN', $field, $a, $b, false]; return $this; }
[ "public", "function", "addNotBetweenCondition", "(", "$", "field", ",", "$", "a", ",", "$", "b", ")", "{", "$", "this", "->", "conditions", "[", "]", "=", "[", "'BETWEEN'", ",", "$", "field", ",", "$", "a", ",", "$", "b", ",", "false", "]", ";", "return", "$", "this", ";", "}" ]
Adds a not between condition to the query. @param string $field @param mixed $a first between value @param mixed $b second between value @return self
[ "Adds", "a", "not", "between", "condition", "to", "the", "query", "." ]
04a853b530fcc12a9863349d3d0da6377d1b9995
https://github.com/jaredtking/jaqb/blob/04a853b530fcc12a9863349d3d0da6377d1b9995/src/Statement/WhereStatement.php#L146-L151
238,953
jaredtking/jaqb
src/Statement/WhereStatement.php
WhereStatement.buildClause
protected function buildClause(array $cond) { // handle SQL fragments if (count($cond) == 1 && (is_string($cond[0]) || !is_callable($cond[0]))) { return $cond[0]; } // handle EXISTS conditions if ($cond[0] === 'EXISTS') { return $this->buildExists($cond[1], $cond[2]); } // handle BETWEEN conditions if ($cond[0] === 'BETWEEN') { return $this->buildBetween($cond[1], $cond[2], $cond[3], $cond[4]); } // escape an identifier if (is_string($cond[0]) || !is_callable($cond[0])) { $cond[0] = $this->escapeIdentifier($cond[0]); // handle a subquery // NOTE string callables are not supported // as subquery functions } elseif (is_callable($cond[0])) { $cond[0] = $this->buildSubquery($cond[0]); } if (count($cond) === 1 || empty($cond[0])) { return $cond[0]; } // handle NULL values if ($cond[2] === null && in_array($cond[1], ['=', '<>'])) { return $this->buildNull($cond[0], $cond[1] == '='); } // handle IN values if (is_array($cond[2]) && in_array($cond[1], ['=', '<>'])) { return $this->buildIn($cond[0], $cond[2], $cond[1] == '='); } // otherwise parameterize the value $cond[2] = $this->parameterize($cond[2]); return implode(' ', $cond); }
php
protected function buildClause(array $cond) { // handle SQL fragments if (count($cond) == 1 && (is_string($cond[0]) || !is_callable($cond[0]))) { return $cond[0]; } // handle EXISTS conditions if ($cond[0] === 'EXISTS') { return $this->buildExists($cond[1], $cond[2]); } // handle BETWEEN conditions if ($cond[0] === 'BETWEEN') { return $this->buildBetween($cond[1], $cond[2], $cond[3], $cond[4]); } // escape an identifier if (is_string($cond[0]) || !is_callable($cond[0])) { $cond[0] = $this->escapeIdentifier($cond[0]); // handle a subquery // NOTE string callables are not supported // as subquery functions } elseif (is_callable($cond[0])) { $cond[0] = $this->buildSubquery($cond[0]); } if (count($cond) === 1 || empty($cond[0])) { return $cond[0]; } // handle NULL values if ($cond[2] === null && in_array($cond[1], ['=', '<>'])) { return $this->buildNull($cond[0], $cond[1] == '='); } // handle IN values if (is_array($cond[2]) && in_array($cond[1], ['=', '<>'])) { return $this->buildIn($cond[0], $cond[2], $cond[1] == '='); } // otherwise parameterize the value $cond[2] = $this->parameterize($cond[2]); return implode(' ', $cond); }
[ "protected", "function", "buildClause", "(", "array", "$", "cond", ")", "{", "// handle SQL fragments", "if", "(", "count", "(", "$", "cond", ")", "==", "1", "&&", "(", "is_string", "(", "$", "cond", "[", "0", "]", ")", "||", "!", "is_callable", "(", "$", "cond", "[", "0", "]", ")", ")", ")", "{", "return", "$", "cond", "[", "0", "]", ";", "}", "// handle EXISTS conditions", "if", "(", "$", "cond", "[", "0", "]", "===", "'EXISTS'", ")", "{", "return", "$", "this", "->", "buildExists", "(", "$", "cond", "[", "1", "]", ",", "$", "cond", "[", "2", "]", ")", ";", "}", "// handle BETWEEN conditions", "if", "(", "$", "cond", "[", "0", "]", "===", "'BETWEEN'", ")", "{", "return", "$", "this", "->", "buildBetween", "(", "$", "cond", "[", "1", "]", ",", "$", "cond", "[", "2", "]", ",", "$", "cond", "[", "3", "]", ",", "$", "cond", "[", "4", "]", ")", ";", "}", "// escape an identifier", "if", "(", "is_string", "(", "$", "cond", "[", "0", "]", ")", "||", "!", "is_callable", "(", "$", "cond", "[", "0", "]", ")", ")", "{", "$", "cond", "[", "0", "]", "=", "$", "this", "->", "escapeIdentifier", "(", "$", "cond", "[", "0", "]", ")", ";", "// handle a subquery", "// NOTE string callables are not supported", "// as subquery functions", "}", "elseif", "(", "is_callable", "(", "$", "cond", "[", "0", "]", ")", ")", "{", "$", "cond", "[", "0", "]", "=", "$", "this", "->", "buildSubquery", "(", "$", "cond", "[", "0", "]", ")", ";", "}", "if", "(", "count", "(", "$", "cond", ")", "===", "1", "||", "empty", "(", "$", "cond", "[", "0", "]", ")", ")", "{", "return", "$", "cond", "[", "0", "]", ";", "}", "// handle NULL values", "if", "(", "$", "cond", "[", "2", "]", "===", "null", "&&", "in_array", "(", "$", "cond", "[", "1", "]", ",", "[", "'='", ",", "'<>'", "]", ")", ")", "{", "return", "$", "this", "->", "buildNull", "(", "$", "cond", "[", "0", "]", ",", "$", "cond", "[", "1", "]", "==", "'='", ")", ";", "}", "// handle IN values", "if", "(", "is_array", "(", "$", "cond", "[", "2", "]", ")", "&&", "in_array", "(", "$", "cond", "[", "1", "]", ",", "[", "'='", ",", "'<>'", "]", ")", ")", "{", "return", "$", "this", "->", "buildIn", "(", "$", "cond", "[", "0", "]", ",", "$", "cond", "[", "2", "]", ",", "$", "cond", "[", "1", "]", "==", "'='", ")", ";", "}", "// otherwise parameterize the value", "$", "cond", "[", "2", "]", "=", "$", "this", "->", "parameterize", "(", "$", "cond", "[", "2", "]", ")", ";", "return", "implode", "(", "' '", ",", "$", "cond", ")", ";", "}" ]
Builds a parameterized and escaped SQL fragment for a condition that uses our own internal representation. A condition is represented by an array, and can be have one of the following forms: 1. ['SQL fragment'] 2. ['identifier', '=', 'value'] 3. ['BETWEEN', 'identifier', 'value', 'value', true] 4. ['EXISTS', function(SelectQuery $query) {}, true] 5. [function(SelectQuery $query) {}] 6. [function(SelectQuery $query) {}, '=', 'value'] @param array $cond @return string generated SQL fragment
[ "Builds", "a", "parameterized", "and", "escaped", "SQL", "fragment", "for", "a", "condition", "that", "uses", "our", "own", "internal", "representation", "." ]
04a853b530fcc12a9863349d3d0da6377d1b9995
https://github.com/jaredtking/jaqb/blob/04a853b530fcc12a9863349d3d0da6377d1b9995/src/Statement/WhereStatement.php#L230-L276
238,954
jaredtking/jaqb
src/Statement/WhereStatement.php
WhereStatement.buildSubquery
protected function buildSubquery(callable $f) { $query = new SelectQuery(); $query->getSelect()->clearFields(); $f($query); $sql = $query->build(); $this->values = array_merge($this->values, $query->getValues()); return '('.$sql.')'; }
php
protected function buildSubquery(callable $f) { $query = new SelectQuery(); $query->getSelect()->clearFields(); $f($query); $sql = $query->build(); $this->values = array_merge($this->values, $query->getValues()); return '('.$sql.')'; }
[ "protected", "function", "buildSubquery", "(", "callable", "$", "f", ")", "{", "$", "query", "=", "new", "SelectQuery", "(", ")", ";", "$", "query", "->", "getSelect", "(", ")", "->", "clearFields", "(", ")", ";", "$", "f", "(", "$", "query", ")", ";", "$", "sql", "=", "$", "query", "->", "build", "(", ")", ";", "$", "this", "->", "values", "=", "array_merge", "(", "$", "this", "->", "values", ",", "$", "query", "->", "getValues", "(", ")", ")", ";", "return", "'('", ".", "$", "sql", ".", "')'", ";", "}" ]
Builds a subquery. @param callable $f @return string
[ "Builds", "a", "subquery", "." ]
04a853b530fcc12a9863349d3d0da6377d1b9995
https://github.com/jaredtking/jaqb/blob/04a853b530fcc12a9863349d3d0da6377d1b9995/src/Statement/WhereStatement.php#L285-L294
238,955
jaredtking/jaqb
src/Statement/WhereStatement.php
WhereStatement.buildBetween
protected function buildBetween($field, $value1, $value2, $isBetween) { $operator = $isBetween ? 'BETWEEN' : 'NOT BETWEEN'; return $this->escapeIdentifier($field).' '.$operator.' '.$this->parameterize($value1).' AND '.$this->parameterize($value2); }
php
protected function buildBetween($field, $value1, $value2, $isBetween) { $operator = $isBetween ? 'BETWEEN' : 'NOT BETWEEN'; return $this->escapeIdentifier($field).' '.$operator.' '.$this->parameterize($value1).' AND '.$this->parameterize($value2); }
[ "protected", "function", "buildBetween", "(", "$", "field", ",", "$", "value1", ",", "$", "value2", ",", "$", "isBetween", ")", "{", "$", "operator", "=", "$", "isBetween", "?", "'BETWEEN'", ":", "'NOT BETWEEN'", ";", "return", "$", "this", "->", "escapeIdentifier", "(", "$", "field", ")", ".", "' '", ".", "$", "operator", ".", "' '", ".", "$", "this", "->", "parameterize", "(", "$", "value1", ")", ".", "' AND '", ".", "$", "this", "->", "parameterize", "(", "$", "value2", ")", ";", "}" ]
Builds a BETWEEN clause. @param string $field @param mixed $value1 @param mixed $value2 @param bool $isBetween @return string
[ "Builds", "a", "BETWEEN", "clause", "." ]
04a853b530fcc12a9863349d3d0da6377d1b9995
https://github.com/jaredtking/jaqb/blob/04a853b530fcc12a9863349d3d0da6377d1b9995/src/Statement/WhereStatement.php#L321-L326
238,956
jaredtking/jaqb
src/Statement/WhereStatement.php
WhereStatement.buildIn
protected function buildIn($field, array $values, $isIn) { $operator = $isIn ? ' IN ' : ' NOT IN '; return $field.$operator.$this->parameterizeValues($values); }
php
protected function buildIn($field, array $values, $isIn) { $operator = $isIn ? ' IN ' : ' NOT IN '; return $field.$operator.$this->parameterizeValues($values); }
[ "protected", "function", "buildIn", "(", "$", "field", ",", "array", "$", "values", ",", "$", "isIn", ")", "{", "$", "operator", "=", "$", "isIn", "?", "' IN '", ":", "' NOT IN '", ";", "return", "$", "field", ".", "$", "operator", ".", "$", "this", "->", "parameterizeValues", "(", "$", "values", ")", ";", "}" ]
Builds an IN clause. @param string $field @param array $values @param bool $isIn @return string
[ "Builds", "an", "IN", "clause", "." ]
04a853b530fcc12a9863349d3d0da6377d1b9995
https://github.com/jaredtking/jaqb/blob/04a853b530fcc12a9863349d3d0da6377d1b9995/src/Statement/WhereStatement.php#L352-L357
238,957
jaredtking/jaqb
src/Statement/WhereStatement.php
WhereStatement.implodeClauses
protected function implodeClauses(array $clauses) { $str = ''; $op = false; foreach ($clauses as $clause) { // an 'OR' token will change the operator used // when concatenating the next clause if ($clause == 'OR') { $op = ' OR '; continue; } if ($op && $str) { $str .= $op; } $str .= $clause; $op = ' AND '; } return $str; }
php
protected function implodeClauses(array $clauses) { $str = ''; $op = false; foreach ($clauses as $clause) { // an 'OR' token will change the operator used // when concatenating the next clause if ($clause == 'OR') { $op = ' OR '; continue; } if ($op && $str) { $str .= $op; } $str .= $clause; $op = ' AND '; } return $str; }
[ "protected", "function", "implodeClauses", "(", "array", "$", "clauses", ")", "{", "$", "str", "=", "''", ";", "$", "op", "=", "false", ";", "foreach", "(", "$", "clauses", "as", "$", "clause", ")", "{", "// an 'OR' token will change the operator used", "// when concatenating the next clause", "if", "(", "$", "clause", "==", "'OR'", ")", "{", "$", "op", "=", "' OR '", ";", "continue", ";", "}", "if", "(", "$", "op", "&&", "$", "str", ")", "{", "$", "str", ".=", "$", "op", ";", "}", "$", "str", ".=", "$", "clause", ";", "$", "op", "=", "' AND '", ";", "}", "return", "$", "str", ";", "}" ]
Implodes a list of WHERE clauses. @param array $clauses @return string
[ "Implodes", "a", "list", "of", "WHERE", "clauses", "." ]
04a853b530fcc12a9863349d3d0da6377d1b9995
https://github.com/jaredtking/jaqb/blob/04a853b530fcc12a9863349d3d0da6377d1b9995/src/Statement/WhereStatement.php#L366-L387
238,958
nonetallt/jinitialize-core
src/JinitializeCommand.php
JinitializeCommand.export
protected function export(string $key, $value) { $container = JinitializeContainer::getInstance(); $container->getPlugin($this->getPluginName())->getContainer()->set($key, $value); }
php
protected function export(string $key, $value) { $container = JinitializeContainer::getInstance(); $container->getPlugin($this->getPluginName())->getContainer()->set($key, $value); }
[ "protected", "function", "export", "(", "string", "$", "key", ",", "$", "value", ")", "{", "$", "container", "=", "JinitializeContainer", "::", "getInstance", "(", ")", ";", "$", "container", "->", "getPlugin", "(", "$", "this", "->", "getPluginName", "(", ")", ")", "->", "getContainer", "(", ")", "->", "set", "(", "$", "key", ",", "$", "value", ")", ";", "}" ]
Save a value to the application container
[ "Save", "a", "value", "to", "the", "application", "container" ]
284fbd72b7c1d6f5f8f265dfe2589c0d99b6a88f
https://github.com/nonetallt/jinitialize-core/blob/284fbd72b7c1d6f5f8f265dfe2589c0d99b6a88f/src/JinitializeCommand.php#L64-L68
238,959
nonetallt/jinitialize-core
src/JinitializeCommand.php
JinitializeCommand.import
protected function import(string $key) { $container = JinitializeContainer::getInstance(); return $container->getPlugin($this->getPluginName())->getContainer()->get($key); }
php
protected function import(string $key) { $container = JinitializeContainer::getInstance(); return $container->getPlugin($this->getPluginName())->getContainer()->get($key); }
[ "protected", "function", "import", "(", "string", "$", "key", ")", "{", "$", "container", "=", "JinitializeContainer", "::", "getInstance", "(", ")", ";", "return", "$", "container", "->", "getPlugin", "(", "$", "this", "->", "getPluginName", "(", ")", ")", "->", "getContainer", "(", ")", "->", "get", "(", "$", "key", ")", ";", "}" ]
Get a value from the local plugin container
[ "Get", "a", "value", "from", "the", "local", "plugin", "container" ]
284fbd72b7c1d6f5f8f265dfe2589c0d99b6a88f
https://github.com/nonetallt/jinitialize-core/blob/284fbd72b7c1d6f5f8f265dfe2589c0d99b6a88f/src/JinitializeCommand.php#L74-L78
238,960
jooorooo/embed
src/ImageInfo/Curl.php
Curl.getImageInfo
public static function getImageInfo($image, array $config = null) { $finfo = finfo_open(FILEINFO_MIME_TYPE); $img = new static($image['value'], $finfo, $config); $curl = $img->getConnection(); curl_exec($curl); curl_close($curl); $info = $img->getInfo(); finfo_close($finfo); return $info; }
php
public static function getImageInfo($image, array $config = null) { $finfo = finfo_open(FILEINFO_MIME_TYPE); $img = new static($image['value'], $finfo, $config); $curl = $img->getConnection(); curl_exec($curl); curl_close($curl); $info = $img->getInfo(); finfo_close($finfo); return $info; }
[ "public", "static", "function", "getImageInfo", "(", "$", "image", ",", "array", "$", "config", "=", "null", ")", "{", "$", "finfo", "=", "finfo_open", "(", "FILEINFO_MIME_TYPE", ")", ";", "$", "img", "=", "new", "static", "(", "$", "image", "[", "'value'", "]", ",", "$", "finfo", ",", "$", "config", ")", ";", "$", "curl", "=", "$", "img", "->", "getConnection", "(", ")", ";", "curl_exec", "(", "$", "curl", ")", ";", "curl_close", "(", "$", "curl", ")", ";", "$", "info", "=", "$", "img", "->", "getInfo", "(", ")", ";", "finfo_close", "(", "$", "finfo", ")", ";", "return", "$", "info", ";", "}" ]
Get the info of only one image @param string $image @param null|array $config @return array|null
[ "Get", "the", "info", "of", "only", "one", "image" ]
078e70a093f246dc8e10b92f909f9166932c4106
https://github.com/jooorooo/embed/blob/078e70a093f246dc8e10b92f909f9166932c4106/src/ImageInfo/Curl.php#L97-L111
238,961
jooorooo/embed
src/ImageInfo/Curl.php
Curl.writeCallback
public function writeCallback($connection, $string) { $this->content .= $string; if (!$this->mime) { $this->mime = finfo_buffer($this->finfo, $this->content); if (!in_array($this->mime, static::$mimetypes, true)) { $this->mime = null; return -1; } } if (!($info = getimagesizefromstring($this->content))) { return strlen($string); } $this->info = [ 'width' => $info[0], 'height' => $info[1], 'size' => $info[0] * $info[1], 'mime' => $this->mime, ]; return -1; }
php
public function writeCallback($connection, $string) { $this->content .= $string; if (!$this->mime) { $this->mime = finfo_buffer($this->finfo, $this->content); if (!in_array($this->mime, static::$mimetypes, true)) { $this->mime = null; return -1; } } if (!($info = getimagesizefromstring($this->content))) { return strlen($string); } $this->info = [ 'width' => $info[0], 'height' => $info[1], 'size' => $info[0] * $info[1], 'mime' => $this->mime, ]; return -1; }
[ "public", "function", "writeCallback", "(", "$", "connection", ",", "$", "string", ")", "{", "$", "this", "->", "content", ".=", "$", "string", ";", "if", "(", "!", "$", "this", "->", "mime", ")", "{", "$", "this", "->", "mime", "=", "finfo_buffer", "(", "$", "this", "->", "finfo", ",", "$", "this", "->", "content", ")", ";", "if", "(", "!", "in_array", "(", "$", "this", "->", "mime", ",", "static", "::", "$", "mimetypes", ",", "true", ")", ")", "{", "$", "this", "->", "mime", "=", "null", ";", "return", "-", "1", ";", "}", "}", "if", "(", "!", "(", "$", "info", "=", "getimagesizefromstring", "(", "$", "this", "->", "content", ")", ")", ")", "{", "return", "strlen", "(", "$", "string", ")", ";", "}", "$", "this", "->", "info", "=", "[", "'width'", "=>", "$", "info", "[", "0", "]", ",", "'height'", "=>", "$", "info", "[", "1", "]", ",", "'size'", "=>", "$", "info", "[", "0", "]", "*", "$", "info", "[", "1", "]", ",", "'mime'", "=>", "$", "this", "->", "mime", ",", "]", ";", "return", "-", "1", ";", "}" ]
Callback used to save the first bytes of the body content @param resource $connection @param string $string return integer
[ "Callback", "used", "to", "save", "the", "first", "bytes", "of", "the", "body", "content" ]
078e70a093f246dc8e10b92f909f9166932c4106
https://github.com/jooorooo/embed/blob/078e70a093f246dc8e10b92f909f9166932c4106/src/ImageInfo/Curl.php#L165-L191
238,962
gperler/common
src/Civis/Common/File.php
File.delete
public function delete() { if (!$this->exists()) { return false; } if ($this->isDir()) { return rmdir($this->absoluteFileName); } return unlink($this->absoluteFileName); }
php
public function delete() { if (!$this->exists()) { return false; } if ($this->isDir()) { return rmdir($this->absoluteFileName); } return unlink($this->absoluteFileName); }
[ "public", "function", "delete", "(", ")", "{", "if", "(", "!", "$", "this", "->", "exists", "(", ")", ")", "{", "return", "false", ";", "}", "if", "(", "$", "this", "->", "isDir", "(", ")", ")", "{", "return", "rmdir", "(", "$", "this", "->", "absoluteFileName", ")", ";", "}", "return", "unlink", "(", "$", "this", "->", "absoluteFileName", ")", ";", "}" ]
tries to delete a file @return bool
[ "tries", "to", "delete", "a", "file" ]
d9e58e4f52715ef431475700a8ab85aa3c480749
https://github.com/gperler/common/blob/d9e58e4f52715ef431475700a8ab85aa3c480749/src/Civis/Common/File.php#L94-L104
238,963
gperler/common
src/Civis/Common/File.php
File.createDir
public function createDir($mode = 0777) { return is_dir($this->absoluteFileName) || mkdir($this->absoluteFileName, $mode, true); }
php
public function createDir($mode = 0777) { return is_dir($this->absoluteFileName) || mkdir($this->absoluteFileName, $mode, true); }
[ "public", "function", "createDir", "(", "$", "mode", "=", "0777", ")", "{", "return", "is_dir", "(", "$", "this", "->", "absoluteFileName", ")", "||", "mkdir", "(", "$", "this", "->", "absoluteFileName", ",", "$", "mode", ",", "true", ")", ";", "}" ]
creates needed directories recursively @param int $mode @return bool
[ "creates", "needed", "directories", "recursively" ]
d9e58e4f52715ef431475700a8ab85aa3c480749
https://github.com/gperler/common/blob/d9e58e4f52715ef431475700a8ab85aa3c480749/src/Civis/Common/File.php#L141-L144
238,964
gperler/common
src/Civis/Common/File.php
File.scanDir
public function scanDir() { // only possible in directories if (!$this->isDir() || !$this->exists()) { return null; } $fileList = []; $fileNameList = scandir($this->absoluteFileName); foreach ($fileNameList as $fileName) { // do not add . and .. if ($fileName === "." or $fileName === "..") { continue; } $absoluteFileName = $this->absoluteFileName . "/" . $fileName; $fileList [] = new File ($absoluteFileName); } return $fileList; }
php
public function scanDir() { // only possible in directories if (!$this->isDir() || !$this->exists()) { return null; } $fileList = []; $fileNameList = scandir($this->absoluteFileName); foreach ($fileNameList as $fileName) { // do not add . and .. if ($fileName === "." or $fileName === "..") { continue; } $absoluteFileName = $this->absoluteFileName . "/" . $fileName; $fileList [] = new File ($absoluteFileName); } return $fileList; }
[ "public", "function", "scanDir", "(", ")", "{", "// only possible in directories", "if", "(", "!", "$", "this", "->", "isDir", "(", ")", "||", "!", "$", "this", "->", "exists", "(", ")", ")", "{", "return", "null", ";", "}", "$", "fileList", "=", "[", "]", ";", "$", "fileNameList", "=", "scandir", "(", "$", "this", "->", "absoluteFileName", ")", ";", "foreach", "(", "$", "fileNameList", "as", "$", "fileName", ")", "{", "// do not add . and ..", "if", "(", "$", "fileName", "===", "\".\"", "or", "$", "fileName", "===", "\"..\"", ")", "{", "continue", ";", "}", "$", "absoluteFileName", "=", "$", "this", "->", "absoluteFileName", ".", "\"/\"", ".", "$", "fileName", ";", "$", "fileList", "[", "]", "=", "new", "File", "(", "$", "absoluteFileName", ")", ";", "}", "return", "$", "fileList", ";", "}" ]
scans a directory and returns a list of Files @return File[]
[ "scans", "a", "directory", "and", "returns", "a", "list", "of", "Files" ]
d9e58e4f52715ef431475700a8ab85aa3c480749
https://github.com/gperler/common/blob/d9e58e4f52715ef431475700a8ab85aa3c480749/src/Civis/Common/File.php#L150-L169
238,965
gperler/common
src/Civis/Common/File.php
File.findFirstOccurenceOfFile
public function findFirstOccurenceOfFile(string $fileName) { if (!$this->isDir() || !$this->exists()) { return null; } foreach ($this->scanDir() as $file) { if ($file->getFileName() === $fileName) { return $file; } if ($file->isDir()) { $result = $file->findFirstOccurenceOfFile($fileName); if ($result !== null) { return $result; } } } return null; }
php
public function findFirstOccurenceOfFile(string $fileName) { if (!$this->isDir() || !$this->exists()) { return null; } foreach ($this->scanDir() as $file) { if ($file->getFileName() === $fileName) { return $file; } if ($file->isDir()) { $result = $file->findFirstOccurenceOfFile($fileName); if ($result !== null) { return $result; } } } return null; }
[ "public", "function", "findFirstOccurenceOfFile", "(", "string", "$", "fileName", ")", "{", "if", "(", "!", "$", "this", "->", "isDir", "(", ")", "||", "!", "$", "this", "->", "exists", "(", ")", ")", "{", "return", "null", ";", "}", "foreach", "(", "$", "this", "->", "scanDir", "(", ")", "as", "$", "file", ")", "{", "if", "(", "$", "file", "->", "getFileName", "(", ")", "===", "$", "fileName", ")", "{", "return", "$", "file", ";", "}", "if", "(", "$", "file", "->", "isDir", "(", ")", ")", "{", "$", "result", "=", "$", "file", "->", "findFirstOccurenceOfFile", "(", "$", "fileName", ")", ";", "if", "(", "$", "result", "!==", "null", ")", "{", "return", "$", "result", ";", "}", "}", "}", "return", "null", ";", "}" ]
Finds the first occurence of the given filename @param string $fileName @return null|File
[ "Finds", "the", "first", "occurence", "of", "the", "given", "filename" ]
d9e58e4f52715ef431475700a8ab85aa3c480749
https://github.com/gperler/common/blob/d9e58e4f52715ef431475700a8ab85aa3c480749/src/Civis/Common/File.php#L178-L197
238,966
gperler/common
src/Civis/Common/File.php
File.loadAsXSLTProcessor
public function loadAsXSLTProcessor() { $this->checkFileExists(); $xsl = new \XSLTProcessor(); $xsl->importStylesheet($this->loadAsXML()); return $xsl; }
php
public function loadAsXSLTProcessor() { $this->checkFileExists(); $xsl = new \XSLTProcessor(); $xsl->importStylesheet($this->loadAsXML()); return $xsl; }
[ "public", "function", "loadAsXSLTProcessor", "(", ")", "{", "$", "this", "->", "checkFileExists", "(", ")", ";", "$", "xsl", "=", "new", "\\", "XSLTProcessor", "(", ")", ";", "$", "xsl", "->", "importStylesheet", "(", "$", "this", "->", "loadAsXML", "(", ")", ")", ";", "return", "$", "xsl", ";", "}" ]
loads the file as XSLT Processor @return \XSLTProcessor
[ "loads", "the", "file", "as", "XSLT", "Processor" ]
d9e58e4f52715ef431475700a8ab85aa3c480749
https://github.com/gperler/common/blob/d9e58e4f52715ef431475700a8ab85aa3c480749/src/Civis/Common/File.php#L227-L233
238,967
gperler/common
src/Civis/Common/File.php
File.loadAsXML
public function loadAsXML() { $this->checkFileExists(); $xml = new \DomDocument (); libxml_use_internal_errors(true); $result = $xml->load($this->absoluteFileName); if ($result) { return $xml; } $messageObject = ArrayUtil::getFromArray(libxml_get_errors(), 0); $libXMLMessage = ObjectUtil::getFromObject($messageObject, "message"); $message = sprintf(self::EXCEPTION_INVALID_XML, $this->absoluteFileName, $libXMLMessage); $e = new \Exception(libxml_get_errors()[0]->message); libxml_clear_errors(); throw $e; }
php
public function loadAsXML() { $this->checkFileExists(); $xml = new \DomDocument (); libxml_use_internal_errors(true); $result = $xml->load($this->absoluteFileName); if ($result) { return $xml; } $messageObject = ArrayUtil::getFromArray(libxml_get_errors(), 0); $libXMLMessage = ObjectUtil::getFromObject($messageObject, "message"); $message = sprintf(self::EXCEPTION_INVALID_XML, $this->absoluteFileName, $libXMLMessage); $e = new \Exception(libxml_get_errors()[0]->message); libxml_clear_errors(); throw $e; }
[ "public", "function", "loadAsXML", "(", ")", "{", "$", "this", "->", "checkFileExists", "(", ")", ";", "$", "xml", "=", "new", "\\", "DomDocument", "(", ")", ";", "libxml_use_internal_errors", "(", "true", ")", ";", "$", "result", "=", "$", "xml", "->", "load", "(", "$", "this", "->", "absoluteFileName", ")", ";", "if", "(", "$", "result", ")", "{", "return", "$", "xml", ";", "}", "$", "messageObject", "=", "ArrayUtil", "::", "getFromArray", "(", "libxml_get_errors", "(", ")", ",", "0", ")", ";", "$", "libXMLMessage", "=", "ObjectUtil", "::", "getFromObject", "(", "$", "messageObject", ",", "\"message\"", ")", ";", "$", "message", "=", "sprintf", "(", "self", "::", "EXCEPTION_INVALID_XML", ",", "$", "this", "->", "absoluteFileName", ",", "$", "libXMLMessage", ")", ";", "$", "e", "=", "new", "\\", "Exception", "(", "libxml_get_errors", "(", ")", "[", "0", "]", "->", "message", ")", ";", "libxml_clear_errors", "(", ")", ";", "throw", "$", "e", ";", "}" ]
loads the file as XML DOMDocument @return \DomDocument @throws \Exception
[ "loads", "the", "file", "as", "XML", "DOMDocument" ]
d9e58e4f52715ef431475700a8ab85aa3c480749
https://github.com/gperler/common/blob/d9e58e4f52715ef431475700a8ab85aa3c480749/src/Civis/Common/File.php#L240-L255
238,968
neemzy/patchwork-core
src/FeatureContext.php
FeatureContext.elementShouldBeVisible
public function elementShouldBeVisible($selector) { $session = $this->getSession(); $page = $session->getPage(); $element = $page->find('css', $selector); if (!$element) { throw new ElementNotFoundException($session, 'Element "'.$selector.'"'); } \PHPUnit_Framework_TestCase::assertTrue($element->isVisible()); }
php
public function elementShouldBeVisible($selector) { $session = $this->getSession(); $page = $session->getPage(); $element = $page->find('css', $selector); if (!$element) { throw new ElementNotFoundException($session, 'Element "'.$selector.'"'); } \PHPUnit_Framework_TestCase::assertTrue($element->isVisible()); }
[ "public", "function", "elementShouldBeVisible", "(", "$", "selector", ")", "{", "$", "session", "=", "$", "this", "->", "getSession", "(", ")", ";", "$", "page", "=", "$", "session", "->", "getPage", "(", ")", ";", "$", "element", "=", "$", "page", "->", "find", "(", "'css'", ",", "$", "selector", ")", ";", "if", "(", "!", "$", "element", ")", "{", "throw", "new", "ElementNotFoundException", "(", "$", "session", ",", "'Element \"'", ".", "$", "selector", ".", "'\"'", ")", ";", "}", "\\", "PHPUnit_Framework_TestCase", "::", "assertTrue", "(", "$", "element", "->", "isVisible", "(", ")", ")", ";", "}" ]
Checks an element is visible @Then /^"([^"]*)" element should be visible$/ @return void
[ "Checks", "an", "element", "is", "visible" ]
81c31b5c0b3a82a04ed90eb17cefaf2faddee4ee
https://github.com/neemzy/patchwork-core/blob/81c31b5c0b3a82a04ed90eb17cefaf2faddee4ee/src/FeatureContext.php#L46-L57
238,969
neemzy/patchwork-core
src/FeatureContext.php
FeatureContext.elementShouldBeHidden
public function elementShouldBeHidden($selector) { $session = $this->getSession(); $page = $session->getPage(); $element = $page->find('css', $selector); if (!$element) { throw new ElementNotFoundException($session, 'Element "'.$selector.'"'); } \PHPUnit_Framework_TestCase::assertFalse($element->isVisible()); }
php
public function elementShouldBeHidden($selector) { $session = $this->getSession(); $page = $session->getPage(); $element = $page->find('css', $selector); if (!$element) { throw new ElementNotFoundException($session, 'Element "'.$selector.'"'); } \PHPUnit_Framework_TestCase::assertFalse($element->isVisible()); }
[ "public", "function", "elementShouldBeHidden", "(", "$", "selector", ")", "{", "$", "session", "=", "$", "this", "->", "getSession", "(", ")", ";", "$", "page", "=", "$", "session", "->", "getPage", "(", ")", ";", "$", "element", "=", "$", "page", "->", "find", "(", "'css'", ",", "$", "selector", ")", ";", "if", "(", "!", "$", "element", ")", "{", "throw", "new", "ElementNotFoundException", "(", "$", "session", ",", "'Element \"'", ".", "$", "selector", ".", "'\"'", ")", ";", "}", "\\", "PHPUnit_Framework_TestCase", "::", "assertFalse", "(", "$", "element", "->", "isVisible", "(", ")", ")", ";", "}" ]
Checks an element is hidden @Then /^"([^"]*)" element should be hidden$/ @return void
[ "Checks", "an", "element", "is", "hidden" ]
81c31b5c0b3a82a04ed90eb17cefaf2faddee4ee
https://github.com/neemzy/patchwork-core/blob/81c31b5c0b3a82a04ed90eb17cefaf2faddee4ee/src/FeatureContext.php#L68-L79
238,970
neemzy/patchwork-core
src/FeatureContext.php
FeatureContext.elementShouldHaveClass
public function elementShouldHaveClass($selector, $class) { $session = $this->getSession(); $page = $session->getPage(); $element = $page->find('css', $selector); if (!$element) { throw new ElementNotFoundException($session, 'Element "'.$selector.'"'); } \PHPUnit_Framework_TestCase::assertTrue($element->hasClass($class)); }
php
public function elementShouldHaveClass($selector, $class) { $session = $this->getSession(); $page = $session->getPage(); $element = $page->find('css', $selector); if (!$element) { throw new ElementNotFoundException($session, 'Element "'.$selector.'"'); } \PHPUnit_Framework_TestCase::assertTrue($element->hasClass($class)); }
[ "public", "function", "elementShouldHaveClass", "(", "$", "selector", ",", "$", "class", ")", "{", "$", "session", "=", "$", "this", "->", "getSession", "(", ")", ";", "$", "page", "=", "$", "session", "->", "getPage", "(", ")", ";", "$", "element", "=", "$", "page", "->", "find", "(", "'css'", ",", "$", "selector", ")", ";", "if", "(", "!", "$", "element", ")", "{", "throw", "new", "ElementNotFoundException", "(", "$", "session", ",", "'Element \"'", ".", "$", "selector", ".", "'\"'", ")", ";", "}", "\\", "PHPUnit_Framework_TestCase", "::", "assertTrue", "(", "$", "element", "->", "hasClass", "(", "$", "class", ")", ")", ";", "}" ]
Checks an element has a class @Then /^"([^"]*)" element should have class "([^"]*)"$/ @return void
[ "Checks", "an", "element", "has", "a", "class" ]
81c31b5c0b3a82a04ed90eb17cefaf2faddee4ee
https://github.com/neemzy/patchwork-core/blob/81c31b5c0b3a82a04ed90eb17cefaf2faddee4ee/src/FeatureContext.php#L90-L101
238,971
neemzy/patchwork-core
src/FeatureContext.php
FeatureContext.elementShouldNotHaveClass
public function elementShouldNotHaveClass($selector, $class) { $session = $this->getSession(); $page = $session->getPage(); $element = $page->find('css', $selector); if (!$element) { throw new ElementNotFoundException($session, 'Element "'.$selector.'"'); } \PHPUnit_Framework_TestCase::assertFalse($element->hasClass($class)); }
php
public function elementShouldNotHaveClass($selector, $class) { $session = $this->getSession(); $page = $session->getPage(); $element = $page->find('css', $selector); if (!$element) { throw new ElementNotFoundException($session, 'Element "'.$selector.'"'); } \PHPUnit_Framework_TestCase::assertFalse($element->hasClass($class)); }
[ "public", "function", "elementShouldNotHaveClass", "(", "$", "selector", ",", "$", "class", ")", "{", "$", "session", "=", "$", "this", "->", "getSession", "(", ")", ";", "$", "page", "=", "$", "session", "->", "getPage", "(", ")", ";", "$", "element", "=", "$", "page", "->", "find", "(", "'css'", ",", "$", "selector", ")", ";", "if", "(", "!", "$", "element", ")", "{", "throw", "new", "ElementNotFoundException", "(", "$", "session", ",", "'Element \"'", ".", "$", "selector", ".", "'\"'", ")", ";", "}", "\\", "PHPUnit_Framework_TestCase", "::", "assertFalse", "(", "$", "element", "->", "hasClass", "(", "$", "class", ")", ")", ";", "}" ]
Checks an element doesn't have a class @Then /^"([^"]*)" element should not have class "([^"]*)"$/ @return void
[ "Checks", "an", "element", "doesn", "t", "have", "a", "class" ]
81c31b5c0b3a82a04ed90eb17cefaf2faddee4ee
https://github.com/neemzy/patchwork-core/blob/81c31b5c0b3a82a04ed90eb17cefaf2faddee4ee/src/FeatureContext.php#L112-L123
238,972
SocietyCMS/Core
Utilities/AssetManager/JavascriptPipeline/SocietyJavascriptPipeline.php
SocietyJavascriptPipeline.addJs
public function addJs($js) { if (is_array($js)) { foreach ($js as $script) { $this->addJs($script); } return $this; } $this->js->push($js); return $this; }
php
public function addJs($js) { if (is_array($js)) { foreach ($js as $script) { $this->addJs($script); } return $this; } $this->js->push($js); return $this; }
[ "public", "function", "addJs", "(", "$", "js", ")", "{", "if", "(", "is_array", "(", "$", "js", ")", ")", "{", "foreach", "(", "$", "js", "as", "$", "script", ")", "{", "$", "this", "->", "addJs", "(", "$", "script", ")", ";", "}", "return", "$", "this", ";", "}", "$", "this", "->", "js", "->", "push", "(", "$", "js", ")", ";", "return", "$", "this", ";", "}" ]
Add a javascript dependency on the view. @param string $js @throws AssetNotFoundException @return $this
[ "Add", "a", "javascript", "dependency", "on", "the", "view", "." ]
fb6be1b1dd46c89a976c02feb998e9af01ddca54
https://github.com/SocietyCMS/Core/blob/fb6be1b1dd46c89a976c02feb998e9af01ddca54/Utilities/AssetManager/JavascriptPipeline/SocietyJavascriptPipeline.php#L35-L48
238,973
dflydev/dflydev-composer-autoload
src/Dflydev/Composer/Autoload/ClassLoaderLocator.php
ClassLoaderLocator.getClassLoaders
public function getClassLoaders() { if (null !== static::$classLoaders) { return static::$classLoaders; } static::$classLoaders = array(); foreach (spl_autoload_functions() as $function) { if (is_array($function) && count($function[0]) > 0 && is_object($function[0]) && 'Composer\Autoload\ClassLoader' === get_class($function[0])) { static::$classLoaders[] = $function[0]; } } return static::$classLoaders; }
php
public function getClassLoaders() { if (null !== static::$classLoaders) { return static::$classLoaders; } static::$classLoaders = array(); foreach (spl_autoload_functions() as $function) { if (is_array($function) && count($function[0]) > 0 && is_object($function[0]) && 'Composer\Autoload\ClassLoader' === get_class($function[0])) { static::$classLoaders[] = $function[0]; } } return static::$classLoaders; }
[ "public", "function", "getClassLoaders", "(", ")", "{", "if", "(", "null", "!==", "static", "::", "$", "classLoaders", ")", "{", "return", "static", "::", "$", "classLoaders", ";", "}", "static", "::", "$", "classLoaders", "=", "array", "(", ")", ";", "foreach", "(", "spl_autoload_functions", "(", ")", "as", "$", "function", ")", "{", "if", "(", "is_array", "(", "$", "function", ")", "&&", "count", "(", "$", "function", "[", "0", "]", ")", ">", "0", "&&", "is_object", "(", "$", "function", "[", "0", "]", ")", "&&", "'Composer\\Autoload\\ClassLoader'", "===", "get_class", "(", "$", "function", "[", "0", "]", ")", ")", "{", "static", "::", "$", "classLoaders", "[", "]", "=", "$", "function", "[", "0", "]", ";", "}", "}", "return", "static", "::", "$", "classLoaders", ";", "}" ]
Locate all Composer Autoload ClassLoader instances @return \Composer\Autoload\ClassLoader[]
[ "Locate", "all", "Composer", "Autoload", "ClassLoader", "instances" ]
fcdc111b7f2f7301ef05c5938a5a07026481b504
https://github.com/dflydev/dflydev-composer-autoload/blob/fcdc111b7f2f7301ef05c5938a5a07026481b504/src/Dflydev/Composer/Autoload/ClassLoaderLocator.php#L68-L83
238,974
samurai-fw/samurai
src/Console/Task/DbTaskList.php
DbTaskList.migrateTask
public function migrateTask(Option $option) { $databases = $this->getDatabases($option); $start = microtime(true); foreach ($databases as $alias => $database) { $manager = $this->getManager($alias, $database); $manager->migrate($this->application->getEnv(), $option->getArg(0)); } $end = microtime(true); $this->sendMessage(''); $this->sendMessage('All Done. Took %.4fs', $end - $start); $this->task('db:schema:dump', $option->copy()); }
php
public function migrateTask(Option $option) { $databases = $this->getDatabases($option); $start = microtime(true); foreach ($databases as $alias => $database) { $manager = $this->getManager($alias, $database); $manager->migrate($this->application->getEnv(), $option->getArg(0)); } $end = microtime(true); $this->sendMessage(''); $this->sendMessage('All Done. Took %.4fs', $end - $start); $this->task('db:schema:dump', $option->copy()); }
[ "public", "function", "migrateTask", "(", "Option", "$", "option", ")", "{", "$", "databases", "=", "$", "this", "->", "getDatabases", "(", "$", "option", ")", ";", "$", "start", "=", "microtime", "(", "true", ")", ";", "foreach", "(", "$", "databases", "as", "$", "alias", "=>", "$", "database", ")", "{", "$", "manager", "=", "$", "this", "->", "getManager", "(", "$", "alias", ",", "$", "database", ")", ";", "$", "manager", "->", "migrate", "(", "$", "this", "->", "application", "->", "getEnv", "(", ")", ",", "$", "option", "->", "getArg", "(", "0", ")", ")", ";", "}", "$", "end", "=", "microtime", "(", "true", ")", ";", "$", "this", "->", "sendMessage", "(", "''", ")", ";", "$", "this", "->", "sendMessage", "(", "'All Done. Took %.4fs'", ",", "$", "end", "-", "$", "start", ")", ";", "$", "this", "->", "task", "(", "'db:schema:dump'", ",", "$", "option", "->", "copy", "(", ")", ")", ";", "}" ]
database migration task. using phinx. usage: $ ./app db:migrate [version] @option database,d=all target database (default is all databases).
[ "database", "migration", "task", ".", "using", "phinx", "." ]
7ca3847b13f86e2847a17ab5e8e4e20893021d5a
https://github.com/samurai-fw/samurai/blob/7ca3847b13f86e2847a17ab5e8e4e20893021d5a/src/Console/Task/DbTaskList.php#L51-L66
238,975
samurai-fw/samurai
src/Console/Task/DbTaskList.php
DbTaskList.seedTask
public function seedTask(Option $option) { $name = $option->getArg(0); $databases = $this->getDatabases($option); $start = microtime(true); foreach ($databases as $alias => $database) { foreach ($this->migrationHelper->getSeeders($alias, $name) as $seeder) { try { $this->sendMessage('seeding... -> %s', $seeder->getName()); $seeder->seed(); } catch (\Exception $e) { $this->sendMessage($e->getMessage()); $this->sendMessage('has error. aborting.'); return; } } } $end = microtime(true); $this->sendMessage(''); $this->sendMessage('All Done. Took %.4fs', $end - $start); }
php
public function seedTask(Option $option) { $name = $option->getArg(0); $databases = $this->getDatabases($option); $start = microtime(true); foreach ($databases as $alias => $database) { foreach ($this->migrationHelper->getSeeders($alias, $name) as $seeder) { try { $this->sendMessage('seeding... -> %s', $seeder->getName()); $seeder->seed(); } catch (\Exception $e) { $this->sendMessage($e->getMessage()); $this->sendMessage('has error. aborting.'); return; } } } $end = microtime(true); $this->sendMessage(''); $this->sendMessage('All Done. Took %.4fs', $end - $start); }
[ "public", "function", "seedTask", "(", "Option", "$", "option", ")", "{", "$", "name", "=", "$", "option", "->", "getArg", "(", "0", ")", ";", "$", "databases", "=", "$", "this", "->", "getDatabases", "(", "$", "option", ")", ";", "$", "start", "=", "microtime", "(", "true", ")", ";", "foreach", "(", "$", "databases", "as", "$", "alias", "=>", "$", "database", ")", "{", "foreach", "(", "$", "this", "->", "migrationHelper", "->", "getSeeders", "(", "$", "alias", ",", "$", "name", ")", "as", "$", "seeder", ")", "{", "try", "{", "$", "this", "->", "sendMessage", "(", "'seeding... -> %s'", ",", "$", "seeder", "->", "getName", "(", ")", ")", ";", "$", "seeder", "->", "seed", "(", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "$", "this", "->", "sendMessage", "(", "$", "e", "->", "getMessage", "(", ")", ")", ";", "$", "this", "->", "sendMessage", "(", "'has error. aborting.'", ")", ";", "return", ";", "}", "}", "}", "$", "end", "=", "microtime", "(", "true", ")", ";", "$", "this", "->", "sendMessage", "(", "''", ")", ";", "$", "this", "->", "sendMessage", "(", "'All Done. Took %.4fs'", ",", "$", "end", "-", "$", "start", ")", ";", "}" ]
database seeding task. usage: # all seeding files import. $ ./app db:seed # target seeding file import. $ ./app db:seed [name] --database=base seeder file: App/Database/Seed/[database alias]/[name]Seeder.php @option database,d=all target database (default is all databases).
[ "database", "seeding", "task", "." ]
7ca3847b13f86e2847a17ab5e8e4e20893021d5a
https://github.com/samurai-fw/samurai/blob/7ca3847b13f86e2847a17ab5e8e4e20893021d5a/src/Console/Task/DbTaskList.php#L147-L169
238,976
samurai-fw/samurai
src/Console/Task/DbTaskList.php
DbTaskList.statusTask
public function statusTask(Option $option) { $databases = $this->getDatabases($option); foreach ($databases as $alias => $database) { $manager = $this->getManager($alias, $database); $manager->printStatus($this->application->getEnv(), $option->get('format')); } }
php
public function statusTask(Option $option) { $databases = $this->getDatabases($option); foreach ($databases as $alias => $database) { $manager = $this->getManager($alias, $database); $manager->printStatus($this->application->getEnv(), $option->get('format')); } }
[ "public", "function", "statusTask", "(", "Option", "$", "option", ")", "{", "$", "databases", "=", "$", "this", "->", "getDatabases", "(", "$", "option", ")", ";", "foreach", "(", "$", "databases", "as", "$", "alias", "=>", "$", "database", ")", "{", "$", "manager", "=", "$", "this", "->", "getManager", "(", "$", "alias", ",", "$", "database", ")", ";", "$", "manager", "->", "printStatus", "(", "$", "this", "->", "application", "->", "getEnv", "(", ")", ",", "$", "option", "->", "get", "(", "'format'", ")", ")", ";", "}", "}" ]
show database mgration status task. using phinx. usage: $ ./app db:status [version] @option format,f output format. (default is text) @option database,d=all target database (default is all databases).
[ "show", "database", "mgration", "status", "task", ".", "using", "phinx", "." ]
7ca3847b13f86e2847a17ab5e8e4e20893021d5a
https://github.com/samurai-fw/samurai/blob/7ca3847b13f86e2847a17ab5e8e4e20893021d5a/src/Console/Task/DbTaskList.php#L181-L189
238,977
deasilworks/cef
src/StatementBuilder/InsertModel.php
InsertModel.setModel
public function setModel($model) { $model->setSerializeNull($this->isSerializeNull()); $this->setJson($model->toJson()); return $this; }
php
public function setModel($model) { $model->setSerializeNull($this->isSerializeNull()); $this->setJson($model->toJson()); return $this; }
[ "public", "function", "setModel", "(", "$", "model", ")", "{", "$", "model", "->", "setSerializeNull", "(", "$", "this", "->", "isSerializeNull", "(", ")", ")", ";", "$", "this", "->", "setJson", "(", "$", "model", "->", "toJson", "(", ")", ")", ";", "return", "$", "this", ";", "}" ]
Set Model. @param EntityDataModel $model @return InsertModel
[ "Set", "Model", "." ]
18c65f2b123512bba2208975dc655354f57670be
https://github.com/deasilworks/cef/blob/18c65f2b123512bba2208975dc655354f57670be/src/StatementBuilder/InsertModel.php#L67-L73
238,978
tenside/core-bundle
src/EventListener/ExceptionListener.php
ExceptionListener.onKernelException
public function onKernelException(GetResponseForExceptionEvent $event) { $exception = $event->getException(); $response = null; switch (true) { case ($exception instanceof NotFoundHttpException): $response = $this->createNotFoundResponse($event->getRequest(), $exception); break; case ($exception instanceof AccessDeniedHttpException): case ($exception instanceof UnauthorizedHttpException): case ($exception instanceof BadRequestHttpException): case ($exception instanceof ServiceUnavailableHttpException): case ($exception instanceof NotAcceptableHttpException): case ($exception instanceof HttpException): /** @var HttpException $exception */ $response = $this->createHttpExceptionResponse($exception); break; case ($exception instanceof AuthenticationCredentialsNotFoundException): $response = $this->createUnauthenticatedResponse($exception); break; default: } if (null === $response) { $response = $this->createInternalServerError($exception); } $event->setResponse($response); }
php
public function onKernelException(GetResponseForExceptionEvent $event) { $exception = $event->getException(); $response = null; switch (true) { case ($exception instanceof NotFoundHttpException): $response = $this->createNotFoundResponse($event->getRequest(), $exception); break; case ($exception instanceof AccessDeniedHttpException): case ($exception instanceof UnauthorizedHttpException): case ($exception instanceof BadRequestHttpException): case ($exception instanceof ServiceUnavailableHttpException): case ($exception instanceof NotAcceptableHttpException): case ($exception instanceof HttpException): /** @var HttpException $exception */ $response = $this->createHttpExceptionResponse($exception); break; case ($exception instanceof AuthenticationCredentialsNotFoundException): $response = $this->createUnauthenticatedResponse($exception); break; default: } if (null === $response) { $response = $this->createInternalServerError($exception); } $event->setResponse($response); }
[ "public", "function", "onKernelException", "(", "GetResponseForExceptionEvent", "$", "event", ")", "{", "$", "exception", "=", "$", "event", "->", "getException", "(", ")", ";", "$", "response", "=", "null", ";", "switch", "(", "true", ")", "{", "case", "(", "$", "exception", "instanceof", "NotFoundHttpException", ")", ":", "$", "response", "=", "$", "this", "->", "createNotFoundResponse", "(", "$", "event", "->", "getRequest", "(", ")", ",", "$", "exception", ")", ";", "break", ";", "case", "(", "$", "exception", "instanceof", "AccessDeniedHttpException", ")", ":", "case", "(", "$", "exception", "instanceof", "UnauthorizedHttpException", ")", ":", "case", "(", "$", "exception", "instanceof", "BadRequestHttpException", ")", ":", "case", "(", "$", "exception", "instanceof", "ServiceUnavailableHttpException", ")", ":", "case", "(", "$", "exception", "instanceof", "NotAcceptableHttpException", ")", ":", "case", "(", "$", "exception", "instanceof", "HttpException", ")", ":", "/** @var HttpException $exception */", "$", "response", "=", "$", "this", "->", "createHttpExceptionResponse", "(", "$", "exception", ")", ";", "break", ";", "case", "(", "$", "exception", "instanceof", "AuthenticationCredentialsNotFoundException", ")", ":", "$", "response", "=", "$", "this", "->", "createUnauthenticatedResponse", "(", "$", "exception", ")", ";", "break", ";", "default", ":", "}", "if", "(", "null", "===", "$", "response", ")", "{", "$", "response", "=", "$", "this", "->", "createInternalServerError", "(", "$", "exception", ")", ";", "}", "$", "event", "->", "setResponse", "(", "$", "response", ")", ";", "}" ]
Maps known exceptions to HTTP exceptions. @param GetResponseForExceptionEvent $event The event object. @return void @SuppressWarnings(PHPMD.CyclomaticComplexity)
[ "Maps", "known", "exceptions", "to", "HTTP", "exceptions", "." ]
a7ffad3649cddac1e5594b4f8b65a5504363fccd
https://github.com/tenside/core-bundle/blob/a7ffad3649cddac1e5594b4f8b65a5504363fccd/src/EventListener/ExceptionListener.php#L77-L106
238,979
tenside/core-bundle
src/EventListener/ExceptionListener.php
ExceptionListener.createNotFoundResponse
private function createNotFoundResponse($request, $exception) { $message = $exception->getMessage(); if (empty($message)) { $message = 'Uri ' . $request->getRequestUri() . ' could not be found'; } return new JsonResponse( [ 'status' => 'ERROR', 'message' => $message ], JsonResponse::HTTP_NOT_FOUND ); }
php
private function createNotFoundResponse($request, $exception) { $message = $exception->getMessage(); if (empty($message)) { $message = 'Uri ' . $request->getRequestUri() . ' could not be found'; } return new JsonResponse( [ 'status' => 'ERROR', 'message' => $message ], JsonResponse::HTTP_NOT_FOUND ); }
[ "private", "function", "createNotFoundResponse", "(", "$", "request", ",", "$", "exception", ")", "{", "$", "message", "=", "$", "exception", "->", "getMessage", "(", ")", ";", "if", "(", "empty", "(", "$", "message", ")", ")", "{", "$", "message", "=", "'Uri '", ".", "$", "request", "->", "getRequestUri", "(", ")", ".", "' could not be found'", ";", "}", "return", "new", "JsonResponse", "(", "[", "'status'", "=>", "'ERROR'", ",", "'message'", "=>", "$", "message", "]", ",", "JsonResponse", "::", "HTTP_NOT_FOUND", ")", ";", "}" ]
Create a 404 response. @param Request $request The http request. @param \Exception $exception The exception. @return JsonResponse @SuppressWarnings(PHPMD.UnusedPrivateMethod)
[ "Create", "a", "404", "response", "." ]
a7ffad3649cddac1e5594b4f8b65a5504363fccd
https://github.com/tenside/core-bundle/blob/a7ffad3649cddac1e5594b4f8b65a5504363fccd/src/EventListener/ExceptionListener.php#L119-L133
238,980
tenside/core-bundle
src/EventListener/ExceptionListener.php
ExceptionListener.createHttpExceptionResponse
private function createHttpExceptionResponse(HttpException $exception) { return new JsonResponse( [ 'status' => 'ERROR', 'message' => $exception->getMessage() ], $exception->getStatusCode(), $exception->getHeaders() ); }
php
private function createHttpExceptionResponse(HttpException $exception) { return new JsonResponse( [ 'status' => 'ERROR', 'message' => $exception->getMessage() ], $exception->getStatusCode(), $exception->getHeaders() ); }
[ "private", "function", "createHttpExceptionResponse", "(", "HttpException", "$", "exception", ")", "{", "return", "new", "JsonResponse", "(", "[", "'status'", "=>", "'ERROR'", ",", "'message'", "=>", "$", "exception", "->", "getMessage", "(", ")", "]", ",", "$", "exception", "->", "getStatusCode", "(", ")", ",", "$", "exception", "->", "getHeaders", "(", ")", ")", ";", "}" ]
Create a http response. @param HttpException $exception The exception to create a response for. @return JsonResponse
[ "Create", "a", "http", "response", "." ]
a7ffad3649cddac1e5594b4f8b65a5504363fccd
https://github.com/tenside/core-bundle/blob/a7ffad3649cddac1e5594b4f8b65a5504363fccd/src/EventListener/ExceptionListener.php#L142-L152
238,981
tenside/core-bundle
src/EventListener/ExceptionListener.php
ExceptionListener.createInternalServerError
private function createInternalServerError(\Exception $exception) { $message = sprintf( '%s: %s (uncaught exception) at %s line %s', get_class($exception), $exception->getMessage(), $exception->getFile(), $exception->getLine() ); $this->logger->error($message, array('exception' => $exception)); $response = [ 'status' => 'ERROR', 'message' => JsonResponse::$statusTexts[JsonResponse::HTTP_INTERNAL_SERVER_ERROR] ]; if ($this->debug) { $response['exception'] = $this->formatException($exception); } return new JsonResponse($response, JsonResponse::HTTP_INTERNAL_SERVER_ERROR); }
php
private function createInternalServerError(\Exception $exception) { $message = sprintf( '%s: %s (uncaught exception) at %s line %s', get_class($exception), $exception->getMessage(), $exception->getFile(), $exception->getLine() ); $this->logger->error($message, array('exception' => $exception)); $response = [ 'status' => 'ERROR', 'message' => JsonResponse::$statusTexts[JsonResponse::HTTP_INTERNAL_SERVER_ERROR] ]; if ($this->debug) { $response['exception'] = $this->formatException($exception); } return new JsonResponse($response, JsonResponse::HTTP_INTERNAL_SERVER_ERROR); }
[ "private", "function", "createInternalServerError", "(", "\\", "Exception", "$", "exception", ")", "{", "$", "message", "=", "sprintf", "(", "'%s: %s (uncaught exception) at %s line %s'", ",", "get_class", "(", "$", "exception", ")", ",", "$", "exception", "->", "getMessage", "(", ")", ",", "$", "exception", "->", "getFile", "(", ")", ",", "$", "exception", "->", "getLine", "(", ")", ")", ";", "$", "this", "->", "logger", "->", "error", "(", "$", "message", ",", "array", "(", "'exception'", "=>", "$", "exception", ")", ")", ";", "$", "response", "=", "[", "'status'", "=>", "'ERROR'", ",", "'message'", "=>", "JsonResponse", "::", "$", "statusTexts", "[", "JsonResponse", "::", "HTTP_INTERNAL_SERVER_ERROR", "]", "]", ";", "if", "(", "$", "this", "->", "debug", ")", "{", "$", "response", "[", "'exception'", "]", "=", "$", "this", "->", "formatException", "(", "$", "exception", ")", ";", "}", "return", "new", "JsonResponse", "(", "$", "response", ",", "JsonResponse", "::", "HTTP_INTERNAL_SERVER_ERROR", ")", ";", "}" ]
Create a 500 response. @param \Exception $exception The exception to log. @return JsonResponse
[ "Create", "a", "500", "response", "." ]
a7ffad3649cddac1e5594b4f8b65a5504363fccd
https://github.com/tenside/core-bundle/blob/a7ffad3649cddac1e5594b4f8b65a5504363fccd/src/EventListener/ExceptionListener.php#L179-L201
238,982
tenside/core-bundle
src/EventListener/ExceptionListener.php
ExceptionListener.formatStackFrame
private function formatStackFrame($frame) { return [ 'file' => isset($frame['file']) ? $frame['file'] : 'unknown', 'line' => isset($frame['line']) ? $frame['line'] : 'unknown', 'function' => (isset($frame['class']) ? $frame['class'] . $frame['type'] : '') . $frame['function'], 'arguments' => $this->formatArguments($frame['args']) ]; }
php
private function formatStackFrame($frame) { return [ 'file' => isset($frame['file']) ? $frame['file'] : 'unknown', 'line' => isset($frame['line']) ? $frame['line'] : 'unknown', 'function' => (isset($frame['class']) ? $frame['class'] . $frame['type'] : '') . $frame['function'], 'arguments' => $this->formatArguments($frame['args']) ]; }
[ "private", "function", "formatStackFrame", "(", "$", "frame", ")", "{", "return", "[", "'file'", "=>", "isset", "(", "$", "frame", "[", "'file'", "]", ")", "?", "$", "frame", "[", "'file'", "]", ":", "'unknown'", ",", "'line'", "=>", "isset", "(", "$", "frame", "[", "'line'", "]", ")", "?", "$", "frame", "[", "'line'", "]", ":", "'unknown'", ",", "'function'", "=>", "(", "isset", "(", "$", "frame", "[", "'class'", "]", ")", "?", "$", "frame", "[", "'class'", "]", ".", "$", "frame", "[", "'type'", "]", ":", "''", ")", ".", "$", "frame", "[", "'function'", "]", ",", "'arguments'", "=>", "$", "this", "->", "formatArguments", "(", "$", "frame", "[", "'args'", "]", ")", "]", ";", "}" ]
Convert a stack frame to array. @param array $frame The stack frame to convert. @return array
[ "Convert", "a", "stack", "frame", "to", "array", "." ]
a7ffad3649cddac1e5594b4f8b65a5504363fccd
https://github.com/tenside/core-bundle/blob/a7ffad3649cddac1e5594b4f8b65a5504363fccd/src/EventListener/ExceptionListener.php#L242-L250
238,983
tenside/core-bundle
src/EventListener/ExceptionListener.php
ExceptionListener.formatArguments
private function formatArguments($arguments) { $result = []; foreach ($arguments as $key => $argument) { if (is_object($argument)) { $result[$key] = get_class($argument); continue; } if (is_array($argument)) { $result[$key] = $this->formatArguments($argument); continue; } $result[$key] = $argument; } return $result; }
php
private function formatArguments($arguments) { $result = []; foreach ($arguments as $key => $argument) { if (is_object($argument)) { $result[$key] = get_class($argument); continue; } if (is_array($argument)) { $result[$key] = $this->formatArguments($argument); continue; } $result[$key] = $argument; } return $result; }
[ "private", "function", "formatArguments", "(", "$", "arguments", ")", "{", "$", "result", "=", "[", "]", ";", "foreach", "(", "$", "arguments", "as", "$", "key", "=>", "$", "argument", ")", "{", "if", "(", "is_object", "(", "$", "argument", ")", ")", "{", "$", "result", "[", "$", "key", "]", "=", "get_class", "(", "$", "argument", ")", ";", "continue", ";", "}", "if", "(", "is_array", "(", "$", "argument", ")", ")", "{", "$", "result", "[", "$", "key", "]", "=", "$", "this", "->", "formatArguments", "(", "$", "argument", ")", ";", "continue", ";", "}", "$", "result", "[", "$", "key", "]", "=", "$", "argument", ";", "}", "return", "$", "result", ";", "}" ]
Reformat an argument list. @param array $arguments The arguments to reformat. @return mixed
[ "Reformat", "an", "argument", "list", "." ]
a7ffad3649cddac1e5594b4f8b65a5504363fccd
https://github.com/tenside/core-bundle/blob/a7ffad3649cddac1e5594b4f8b65a5504363fccd/src/EventListener/ExceptionListener.php#L259-L277
238,984
wigedev/simple-mvc
src/Core.php
Core._init
public static function _init(): Core { static::$framework = new Core(); static::$framework->createDIContainer(); try { static::$framework->fireEvent('initialized'); } catch (\Exception $e) { echo('Unable to fire initialization.'); exit(); } $router = new Router(); $mcl = new ModuleControllerLoader(); static::$framework->response = new Response($router, $mcl); return static::$framework; }
php
public static function _init(): Core { static::$framework = new Core(); static::$framework->createDIContainer(); try { static::$framework->fireEvent('initialized'); } catch (\Exception $e) { echo('Unable to fire initialization.'); exit(); } $router = new Router(); $mcl = new ModuleControllerLoader(); static::$framework->response = new Response($router, $mcl); return static::$framework; }
[ "public", "static", "function", "_init", "(", ")", ":", "Core", "{", "static", "::", "$", "framework", "=", "new", "Core", "(", ")", ";", "static", "::", "$", "framework", "->", "createDIContainer", "(", ")", ";", "try", "{", "static", "::", "$", "framework", "->", "fireEvent", "(", "'initialized'", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "echo", "(", "'Unable to fire initialization.'", ")", ";", "exit", "(", ")", ";", "}", "$", "router", "=", "new", "Router", "(", ")", ";", "$", "mcl", "=", "new", "ModuleControllerLoader", "(", ")", ";", "static", "::", "$", "framework", "->", "response", "=", "new", "Response", "(", "$", "router", ",", "$", "mcl", ")", ";", "return", "static", "::", "$", "framework", ";", "}" ]
Function initializes the framework object. @return Core
[ "Function", "initializes", "the", "framework", "object", "." ]
b722eff02c5dcd8c6f09c8d78f72bc71cb9e1a94
https://github.com/wigedev/simple-mvc/blob/b722eff02c5dcd8c6f09c8d78f72bc71cb9e1a94/src/Core.php#L153-L167
238,985
wigedev/simple-mvc
src/Core.php
Core.registerServiceManager
public function registerServiceManager(string $name, ServiceManager $service_manager): Core { $this->service_managers->register($name, $service_manager); return $this; }
php
public function registerServiceManager(string $name, ServiceManager $service_manager): Core { $this->service_managers->register($name, $service_manager); return $this; }
[ "public", "function", "registerServiceManager", "(", "string", "$", "name", ",", "ServiceManager", "$", "service_manager", ")", ":", "Core", "{", "$", "this", "->", "service_managers", "->", "register", "(", "$", "name", ",", "$", "service_manager", ")", ";", "return", "$", "this", ";", "}" ]
Register a service manager. @param string $name The name of the service manager for use in retrieving a reference to it @param ServiceManager $service_manager @return Core
[ "Register", "a", "service", "manager", "." ]
b722eff02c5dcd8c6f09c8d78f72bc71cb9e1a94
https://github.com/wigedev/simple-mvc/blob/b722eff02c5dcd8c6f09c8d78f72bc71cb9e1a94/src/Core.php#L273-L277
238,986
wigedev/simple-mvc
src/Core.php
Core.on
public function on(string $event, $class_or_obj, string $method, array $arguments = []): Core { $this->registerEventHandler(new EventHandler($event, $class_or_obj, $method, $arguments)); return $this; }
php
public function on(string $event, $class_or_obj, string $method, array $arguments = []): Core { $this->registerEventHandler(new EventHandler($event, $class_or_obj, $method, $arguments)); return $this; }
[ "public", "function", "on", "(", "string", "$", "event", ",", "$", "class_or_obj", ",", "string", "$", "method", ",", "array", "$", "arguments", "=", "[", "]", ")", ":", "Core", "{", "$", "this", "->", "registerEventHandler", "(", "new", "EventHandler", "(", "$", "event", ",", "$", "class_or_obj", ",", "$", "method", ",", "$", "arguments", ")", ")", ";", "return", "$", "this", ";", "}" ]
Create an event handler to be called when a specified event is fired by the framework or a library within the Framework. @param string $event The name of the event to listen for @param mixed $class_or_obj The object or class the method belongs to @param string $method The method to call @param array $arguments Optional parameters to pass to the method @return Core @throws \Exception
[ "Create", "an", "event", "handler", "to", "be", "called", "when", "a", "specified", "event", "is", "fired", "by", "the", "framework", "or", "a", "library", "within", "the", "Framework", "." ]
b722eff02c5dcd8c6f09c8d78f72bc71cb9e1a94
https://github.com/wigedev/simple-mvc/blob/b722eff02c5dcd8c6f09c8d78f72bc71cb9e1a94/src/Core.php#L306-L310
238,987
wigedev/simple-mvc
src/Core.php
Core.fireEvent
public function fireEvent(string $event): void { $this->log->debug('Event {event} has been fired.', ['event' => $event]); foreach ($this->event_handlers as $handler) { /** @var EventHandler $handler */ if ($event === $handler->getEvent()) { $handler->execute(); } } }
php
public function fireEvent(string $event): void { $this->log->debug('Event {event} has been fired.', ['event' => $event]); foreach ($this->event_handlers as $handler) { /** @var EventHandler $handler */ if ($event === $handler->getEvent()) { $handler->execute(); } } }
[ "public", "function", "fireEvent", "(", "string", "$", "event", ")", ":", "void", "{", "$", "this", "->", "log", "->", "debug", "(", "'Event {event} has been fired.'", ",", "[", "'event'", "=>", "$", "event", "]", ")", ";", "foreach", "(", "$", "this", "->", "event_handlers", "as", "$", "handler", ")", "{", "/** @var EventHandler $handler */", "if", "(", "$", "event", "===", "$", "handler", "->", "getEvent", "(", ")", ")", "{", "$", "handler", "->", "execute", "(", ")", ";", "}", "}", "}" ]
Register a callback to be run before the renderer is called @param string $event The name of the event being fired @throws \Exception
[ "Register", "a", "callback", "to", "be", "run", "before", "the", "renderer", "is", "called" ]
b722eff02c5dcd8c6f09c8d78f72bc71cb9e1a94
https://github.com/wigedev/simple-mvc/blob/b722eff02c5dcd8c6f09c8d78f72bc71cb9e1a94/src/Core.php#L319-L328
238,988
wigedev/simple-mvc
src/Core.php
Core.getRemoteIP
public function getRemoteIP(): string { if (null === $this->remote_ip) { $ip = $_SERVER['REMOTE_ADDR']; if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { $ip = $_SERVER['HTTP_X_FORWARDED_FOR']; $ip = explode(',', $ip); $ip = trim($ip[0]); } $this->remote_ip = $ip; } return $this->remote_ip; }
php
public function getRemoteIP(): string { if (null === $this->remote_ip) { $ip = $_SERVER['REMOTE_ADDR']; if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { $ip = $_SERVER['HTTP_X_FORWARDED_FOR']; $ip = explode(',', $ip); $ip = trim($ip[0]); } $this->remote_ip = $ip; } return $this->remote_ip; }
[ "public", "function", "getRemoteIP", "(", ")", ":", "string", "{", "if", "(", "null", "===", "$", "this", "->", "remote_ip", ")", "{", "$", "ip", "=", "$", "_SERVER", "[", "'REMOTE_ADDR'", "]", ";", "if", "(", "!", "empty", "(", "$", "_SERVER", "[", "'HTTP_X_FORWARDED_FOR'", "]", ")", ")", "{", "$", "ip", "=", "$", "_SERVER", "[", "'HTTP_X_FORWARDED_FOR'", "]", ";", "$", "ip", "=", "explode", "(", "','", ",", "$", "ip", ")", ";", "$", "ip", "=", "trim", "(", "$", "ip", "[", "0", "]", ")", ";", "}", "$", "this", "->", "remote_ip", "=", "$", "ip", ";", "}", "return", "$", "this", "->", "remote_ip", ";", "}" ]
Get the IP address of the user @return string The remote IP address. If the user passes through a proxy, this will attempt to return the origin IP address.
[ "Get", "the", "IP", "address", "of", "the", "user" ]
b722eff02c5dcd8c6f09c8d78f72bc71cb9e1a94
https://github.com/wigedev/simple-mvc/blob/b722eff02c5dcd8c6f09c8d78f72bc71cb9e1a94/src/Core.php#L354-L366
238,989
jails/li3_access
security/Access.php
Access.check
public static function check($name, $user, $request, $options = []) { if (($config = static::_config($name)) === null) { throw new ConfigException("Configuration `{$name}` has not been defined."); } $filter = function($self, $params) use ($name) { $user = $params['user']; $request = $params['request']; $options = $params['options']; return $self::adapter($name)->check($user, $request, $options); }; $params = compact('user', 'request', 'options'); return static::_filter(__FUNCTION__, $params, $filter, (array) $config['filters']); }
php
public static function check($name, $user, $request, $options = []) { if (($config = static::_config($name)) === null) { throw new ConfigException("Configuration `{$name}` has not been defined."); } $filter = function($self, $params) use ($name) { $user = $params['user']; $request = $params['request']; $options = $params['options']; return $self::adapter($name)->check($user, $request, $options); }; $params = compact('user', 'request', 'options'); return static::_filter(__FUNCTION__, $params, $filter, (array) $config['filters']); }
[ "public", "static", "function", "check", "(", "$", "name", ",", "$", "user", ",", "$", "request", ",", "$", "options", "=", "[", "]", ")", "{", "if", "(", "(", "$", "config", "=", "static", "::", "_config", "(", "$", "name", ")", ")", "===", "null", ")", "{", "throw", "new", "ConfigException", "(", "\"Configuration `{$name}` has not been defined.\"", ")", ";", "}", "$", "filter", "=", "function", "(", "$", "self", ",", "$", "params", ")", "use", "(", "$", "name", ")", "{", "$", "user", "=", "$", "params", "[", "'user'", "]", ";", "$", "request", "=", "$", "params", "[", "'request'", "]", ";", "$", "options", "=", "$", "params", "[", "'options'", "]", ";", "return", "$", "self", "::", "adapter", "(", "$", "name", ")", "->", "check", "(", "$", "user", ",", "$", "request", ",", "$", "options", ")", ";", "}", ";", "$", "params", "=", "compact", "(", "'user'", ",", "'request'", ",", "'options'", ")", ";", "return", "static", "::", "_filter", "(", "__FUNCTION__", ",", "$", "params", ",", "$", "filter", ",", "(", "array", ")", "$", "config", "[", "'filters'", "]", ")", ";", "}" ]
Performs an access check. @param string $name The name of the adapter to check against. @param mixed $user The user data array or a user instance. @param action\Request $request A `Request` instace. @param array $options An array of options. @return boolean `true` if access is granted, `false otherwise`.
[ "Performs", "an", "access", "check", "." ]
aded70dca872ea9237e3eb709099730348008321
https://github.com/jails/li3_access/blob/aded70dca872ea9237e3eb709099730348008321/security/Access.php#L39-L51
238,990
firstcomputer/seeme
src/Api/Caller.php
Caller.call
protected function call(array $params) { $defaultParams = [ 'key' => $this->apiKey, 'format' => 'json', 'apiVersion' => self::VERSION, ]; $params = array_merge($defaultParams, $params); $url = sprintf('%s?%s', self::ENDPOINT, http_build_query($params)); $response = $this->adapter->get($url); $result = json_decode($response->getBody()->getContents(), true); if ($result['result'] == 'ERR') { throw new ApiException($result['message'], $result['code']); } return $result; }
php
protected function call(array $params) { $defaultParams = [ 'key' => $this->apiKey, 'format' => 'json', 'apiVersion' => self::VERSION, ]; $params = array_merge($defaultParams, $params); $url = sprintf('%s?%s', self::ENDPOINT, http_build_query($params)); $response = $this->adapter->get($url); $result = json_decode($response->getBody()->getContents(), true); if ($result['result'] == 'ERR') { throw new ApiException($result['message'], $result['code']); } return $result; }
[ "protected", "function", "call", "(", "array", "$", "params", ")", "{", "$", "defaultParams", "=", "[", "'key'", "=>", "$", "this", "->", "apiKey", ",", "'format'", "=>", "'json'", ",", "'apiVersion'", "=>", "self", "::", "VERSION", ",", "]", ";", "$", "params", "=", "array_merge", "(", "$", "defaultParams", ",", "$", "params", ")", ";", "$", "url", "=", "sprintf", "(", "'%s?%s'", ",", "self", "::", "ENDPOINT", ",", "http_build_query", "(", "$", "params", ")", ")", ";", "$", "response", "=", "$", "this", "->", "adapter", "->", "get", "(", "$", "url", ")", ";", "$", "result", "=", "json_decode", "(", "$", "response", "->", "getBody", "(", ")", "->", "getContents", "(", ")", ",", "true", ")", ";", "if", "(", "$", "result", "[", "'result'", "]", "==", "'ERR'", ")", "{", "throw", "new", "ApiException", "(", "$", "result", "[", "'message'", "]", ",", "$", "result", "[", "'code'", "]", ")", ";", "}", "return", "$", "result", ";", "}" ]
Sends a call to the API @param array $params @return array @throws ApiException If the API call fails
[ "Sends", "a", "call", "to", "the", "API" ]
09954a110e44afe34bb03c87d2a7cbf0a3be86b3
https://github.com/firstcomputer/seeme/blob/09954a110e44afe34bb03c87d2a7cbf0a3be86b3/src/Api/Caller.php#L33-L54
238,991
fabsgc/framework
Core/Config/Config.php
Config._parseLang
protected function _parseLang($src = null, $lang) { if ($src == null) { $file = APP_RESOURCE_LANG_PATH . $lang . '.xml'; $src = 'app'; } else { $file = SRC_PATH . $src . '/' . SRC_RESOURCE_LANG_PATH . $lang . '.xml'; } $this->config['lang']['' . $src . '']['' . $lang . ''] = []; if (file_exists($file)) { if ($xml = simplexml_load_file($file)) { $values = $xml->xpath('//lang'); /** @var SimpleXMLElement[] $value */ foreach ($values as $value) { $data = null; foreach ($this->_langAttribute as $attribute) { $attributeType = $attribute['name']; if (is_object($value[$attributeType])) { $data[$attributeType] = $value[$attributeType]->__toString(); } else { $data[$attributeType] = ''; } /** @var SimpleXMLElement $value */ $data['content'] = $value->__toString(); } $data = $this->_parseParent($value, $data, $this->_langAttribute); $this->config['lang']['' . $src . '']['' . $lang . '']['' . $data['name'] . ''] = $data; $this->config['lang']['' . $src . '']['' . $lang . '']['' . $data['name'] . ''] = $this->config['lang']['' . $src . '']['' . $lang . '']['' . $data['name'] . '']['content']; } } else { throw new MissingConfigException('can\'t read file "' . $file . '"'); } } else { throw new MissingConfigException('can\'t open file "' . $file . '"'); } }
php
protected function _parseLang($src = null, $lang) { if ($src == null) { $file = APP_RESOURCE_LANG_PATH . $lang . '.xml'; $src = 'app'; } else { $file = SRC_PATH . $src . '/' . SRC_RESOURCE_LANG_PATH . $lang . '.xml'; } $this->config['lang']['' . $src . '']['' . $lang . ''] = []; if (file_exists($file)) { if ($xml = simplexml_load_file($file)) { $values = $xml->xpath('//lang'); /** @var SimpleXMLElement[] $value */ foreach ($values as $value) { $data = null; foreach ($this->_langAttribute as $attribute) { $attributeType = $attribute['name']; if (is_object($value[$attributeType])) { $data[$attributeType] = $value[$attributeType]->__toString(); } else { $data[$attributeType] = ''; } /** @var SimpleXMLElement $value */ $data['content'] = $value->__toString(); } $data = $this->_parseParent($value, $data, $this->_langAttribute); $this->config['lang']['' . $src . '']['' . $lang . '']['' . $data['name'] . ''] = $data; $this->config['lang']['' . $src . '']['' . $lang . '']['' . $data['name'] . ''] = $this->config['lang']['' . $src . '']['' . $lang . '']['' . $data['name'] . '']['content']; } } else { throw new MissingConfigException('can\'t read file "' . $file . '"'); } } else { throw new MissingConfigException('can\'t open file "' . $file . '"'); } }
[ "protected", "function", "_parseLang", "(", "$", "src", "=", "null", ",", "$", "lang", ")", "{", "if", "(", "$", "src", "==", "null", ")", "{", "$", "file", "=", "APP_RESOURCE_LANG_PATH", ".", "$", "lang", ".", "'.xml'", ";", "$", "src", "=", "'app'", ";", "}", "else", "{", "$", "file", "=", "SRC_PATH", ".", "$", "src", ".", "'/'", ".", "SRC_RESOURCE_LANG_PATH", ".", "$", "lang", ".", "'.xml'", ";", "}", "$", "this", "->", "config", "[", "'lang'", "]", "[", "''", ".", "$", "src", ".", "''", "]", "[", "''", ".", "$", "lang", ".", "''", "]", "=", "[", "]", ";", "if", "(", "file_exists", "(", "$", "file", ")", ")", "{", "if", "(", "$", "xml", "=", "simplexml_load_file", "(", "$", "file", ")", ")", "{", "$", "values", "=", "$", "xml", "->", "xpath", "(", "'//lang'", ")", ";", "/** @var SimpleXMLElement[] $value */", "foreach", "(", "$", "values", "as", "$", "value", ")", "{", "$", "data", "=", "null", ";", "foreach", "(", "$", "this", "->", "_langAttribute", "as", "$", "attribute", ")", "{", "$", "attributeType", "=", "$", "attribute", "[", "'name'", "]", ";", "if", "(", "is_object", "(", "$", "value", "[", "$", "attributeType", "]", ")", ")", "{", "$", "data", "[", "$", "attributeType", "]", "=", "$", "value", "[", "$", "attributeType", "]", "->", "__toString", "(", ")", ";", "}", "else", "{", "$", "data", "[", "$", "attributeType", "]", "=", "''", ";", "}", "/** @var SimpleXMLElement $value */", "$", "data", "[", "'content'", "]", "=", "$", "value", "->", "__toString", "(", ")", ";", "}", "$", "data", "=", "$", "this", "->", "_parseParent", "(", "$", "value", ",", "$", "data", ",", "$", "this", "->", "_langAttribute", ")", ";", "$", "this", "->", "config", "[", "'lang'", "]", "[", "''", ".", "$", "src", ".", "''", "]", "[", "''", ".", "$", "lang", ".", "''", "]", "[", "''", ".", "$", "data", "[", "'name'", "]", ".", "''", "]", "=", "$", "data", ";", "$", "this", "->", "config", "[", "'lang'", "]", "[", "''", ".", "$", "src", ".", "''", "]", "[", "''", ".", "$", "lang", ".", "''", "]", "[", "''", ".", "$", "data", "[", "'name'", "]", ".", "''", "]", "=", "$", "this", "->", "config", "[", "'lang'", "]", "[", "''", ".", "$", "src", ".", "''", "]", "[", "''", ".", "$", "lang", ".", "''", "]", "[", "''", ".", "$", "data", "[", "'name'", "]", ".", "''", "]", "[", "'content'", "]", ";", "}", "}", "else", "{", "throw", "new", "MissingConfigException", "(", "'can\\'t read file \"'", ".", "$", "file", ".", "'\"'", ")", ";", "}", "}", "else", "{", "throw", "new", "MissingConfigException", "(", "'can\\'t open file \"'", ".", "$", "file", ".", "'\"'", ")", ";", "}", "}" ]
parse lang files and put data in an array @access protected @param $src string @param $lang string @return void @since 3.0 @throws \Gcs\Framework\Core\Exception\MissingConfigException if lang config file doesn't exist @package Gcs\Framework\Core\Config
[ "parse", "lang", "files", "and", "put", "data", "in", "an", "array" ]
45e58182aba6a3c6381970a1fd3c17662cff2168
https://github.com/fabsgc/framework/blob/45e58182aba6a3c6381970a1fd3c17662cff2168/Core/Config/Config.php#L214-L260
238,992
fabsgc/framework
Core/Config/Config.php
Config._parseParent
protected function _parseParent($child, $data, $attributes) { $parent = $child->xpath("parent::*"); if (is_object($parent[0]['name'])) { foreach ($attributes as $attribute) { $name = $attribute['name']; if (is_object($parent[0][$name])) { /** @var SimpleXMLElement $element */ $element = $parent[0][$name]; if ($attribute['concatenate'] == true) { if ($data[$name] != '') { $data[$name] = $element->__toString() . $attribute['separator'] . $data[$name]; } else { $data[$name] = $element->__toString(); } } else { if ($data[$name] == '') { $data[$name] = $element->__toString(); } } } } $data = $this->_parseParent($parent[0], $data, $attributes); } return $data; }
php
protected function _parseParent($child, $data, $attributes) { $parent = $child->xpath("parent::*"); if (is_object($parent[0]['name'])) { foreach ($attributes as $attribute) { $name = $attribute['name']; if (is_object($parent[0][$name])) { /** @var SimpleXMLElement $element */ $element = $parent[0][$name]; if ($attribute['concatenate'] == true) { if ($data[$name] != '') { $data[$name] = $element->__toString() . $attribute['separator'] . $data[$name]; } else { $data[$name] = $element->__toString(); } } else { if ($data[$name] == '') { $data[$name] = $element->__toString(); } } } } $data = $this->_parseParent($parent[0], $data, $attributes); } return $data; }
[ "protected", "function", "_parseParent", "(", "$", "child", ",", "$", "data", ",", "$", "attributes", ")", "{", "$", "parent", "=", "$", "child", "->", "xpath", "(", "\"parent::*\"", ")", ";", "if", "(", "is_object", "(", "$", "parent", "[", "0", "]", "[", "'name'", "]", ")", ")", "{", "foreach", "(", "$", "attributes", "as", "$", "attribute", ")", "{", "$", "name", "=", "$", "attribute", "[", "'name'", "]", ";", "if", "(", "is_object", "(", "$", "parent", "[", "0", "]", "[", "$", "name", "]", ")", ")", "{", "/** @var SimpleXMLElement $element */", "$", "element", "=", "$", "parent", "[", "0", "]", "[", "$", "name", "]", ";", "if", "(", "$", "attribute", "[", "'concatenate'", "]", "==", "true", ")", "{", "if", "(", "$", "data", "[", "$", "name", "]", "!=", "''", ")", "{", "$", "data", "[", "$", "name", "]", "=", "$", "element", "->", "__toString", "(", ")", ".", "$", "attribute", "[", "'separator'", "]", ".", "$", "data", "[", "$", "name", "]", ";", "}", "else", "{", "$", "data", "[", "$", "name", "]", "=", "$", "element", "->", "__toString", "(", ")", ";", "}", "}", "else", "{", "if", "(", "$", "data", "[", "$", "name", "]", "==", "''", ")", "{", "$", "data", "[", "$", "name", "]", "=", "$", "element", "->", "__toString", "(", ")", ";", "}", "}", "}", "}", "$", "data", "=", "$", "this", "->", "_parseParent", "(", "$", "parent", "[", "0", "]", ",", "$", "data", ",", "$", "attributes", ")", ";", "}", "return", "$", "data", ";", "}" ]
parse parent node @access protected @param $child \SimpleXMLElement @param $data [] @param $attributes array @return array @since 3.0 @package Gcs\Framework\Core\Config
[ "parse", "parent", "node" ]
45e58182aba6a3c6381970a1fd3c17662cff2168
https://github.com/fabsgc/framework/blob/45e58182aba6a3c6381970a1fd3c17662cff2168/Core/Config/Config.php#L273-L304
238,993
yii2-tools/yii2-base
traits/AjaxValidationTrait.php
AjaxValidationTrait.performAjaxValidation
protected function performAjaxValidation($model) { $result = ($model instanceof Model) ? ActiveForm::validate($model) : ActiveForm::validateMultiple($model); $response = Yii::$app->getResponse(); if (!empty($result) && $ajaxRedirect = Yii::$app->getSession()->get('site_ajax_redirect')) { $response = $response->redirect($ajaxRedirect); Yii::$app->getSession()->remove('site_ajax_redirect'); } else { $response->format = Response::FORMAT_JSON; $response->data = $result; } return $response; }
php
protected function performAjaxValidation($model) { $result = ($model instanceof Model) ? ActiveForm::validate($model) : ActiveForm::validateMultiple($model); $response = Yii::$app->getResponse(); if (!empty($result) && $ajaxRedirect = Yii::$app->getSession()->get('site_ajax_redirect')) { $response = $response->redirect($ajaxRedirect); Yii::$app->getSession()->remove('site_ajax_redirect'); } else { $response->format = Response::FORMAT_JSON; $response->data = $result; } return $response; }
[ "protected", "function", "performAjaxValidation", "(", "$", "model", ")", "{", "$", "result", "=", "(", "$", "model", "instanceof", "Model", ")", "?", "ActiveForm", "::", "validate", "(", "$", "model", ")", ":", "ActiveForm", "::", "validateMultiple", "(", "$", "model", ")", ";", "$", "response", "=", "Yii", "::", "$", "app", "->", "getResponse", "(", ")", ";", "if", "(", "!", "empty", "(", "$", "result", ")", "&&", "$", "ajaxRedirect", "=", "Yii", "::", "$", "app", "->", "getSession", "(", ")", "->", "get", "(", "'site_ajax_redirect'", ")", ")", "{", "$", "response", "=", "$", "response", "->", "redirect", "(", "$", "ajaxRedirect", ")", ";", "Yii", "::", "$", "app", "->", "getSession", "(", ")", "->", "remove", "(", "'site_ajax_redirect'", ")", ";", "}", "else", "{", "$", "response", "->", "format", "=", "Response", "::", "FORMAT_JSON", ";", "$", "response", "->", "data", "=", "$", "result", ";", "}", "return", "$", "response", ";", "}" ]
Performs ajax validation @param $model @return \yii\console\Response|\yii\web\Response
[ "Performs", "ajax", "validation" ]
10f6bb6b0b9396c3d942e0f2ec06784fa9bbf72a
https://github.com/yii2-tools/yii2-base/blob/10f6bb6b0b9396c3d942e0f2ec06784fa9bbf72a/traits/AjaxValidationTrait.php#L18-L35
238,994
osflab/cache
OsfCache.php
OsfCache.start
public function start(string $key) { $filteredKey = $this->filterKey($key); $value = $this->get($filteredKey); if ($value === null) { $this->lastKey = $filteredKey; ob_start(); } else { $this->lastKey = null; trigger_error('Cache start failed'); } return $this; }
php
public function start(string $key) { $filteredKey = $this->filterKey($key); $value = $this->get($filteredKey); if ($value === null) { $this->lastKey = $filteredKey; ob_start(); } else { $this->lastKey = null; trigger_error('Cache start failed'); } return $this; }
[ "public", "function", "start", "(", "string", "$", "key", ")", "{", "$", "filteredKey", "=", "$", "this", "->", "filterKey", "(", "$", "key", ")", ";", "$", "value", "=", "$", "this", "->", "get", "(", "$", "filteredKey", ")", ";", "if", "(", "$", "value", "===", "null", ")", "{", "$", "this", "->", "lastKey", "=", "$", "filteredKey", ";", "ob_start", "(", ")", ";", "}", "else", "{", "$", "this", "->", "lastKey", "=", "null", ";", "trigger_error", "(", "'Cache start failed'", ")", ";", "}", "return", "$", "this", ";", "}" ]
Start cache via buffer @param string $key @return $this
[ "Start", "cache", "via", "buffer" ]
523fc6ff64685b390e5019dc0eaabe15b387f0a7
https://github.com/osflab/cache/blob/523fc6ff64685b390e5019dc0eaabe15b387f0a7/OsfCache.php#L174-L186
238,995
osflab/cache
OsfCache.php
OsfCache.stop
public function stop(float $timeout = 0.0): self { if ($this->lastKey !== null) { $this->set($this->lastKey, ob_get_clean(), $timeout); } $this->lastKey = null; return $this; }
php
public function stop(float $timeout = 0.0): self { if ($this->lastKey !== null) { $this->set($this->lastKey, ob_get_clean(), $timeout); } $this->lastKey = null; return $this; }
[ "public", "function", "stop", "(", "float", "$", "timeout", "=", "0.0", ")", ":", "self", "{", "if", "(", "$", "this", "->", "lastKey", "!==", "null", ")", "{", "$", "this", "->", "set", "(", "$", "this", "->", "lastKey", ",", "ob_get_clean", "(", ")", ",", "$", "timeout", ")", ";", "}", "$", "this", "->", "lastKey", "=", "null", ";", "return", "$", "this", ";", "}" ]
Stop buffer and put it in cache @param float $timeout @return $this
[ "Stop", "buffer", "and", "put", "it", "in", "cache" ]
523fc6ff64685b390e5019dc0eaabe15b387f0a7
https://github.com/osflab/cache/blob/523fc6ff64685b390e5019dc0eaabe15b387f0a7/OsfCache.php#L193-L200
238,996
osflab/cache
OsfCache.php
OsfCache.cleanAll
public function cleanAll(): int { $cpt = 0; $keys = $this->getRedis()->keys($this->namespace . ':*'); if ($keys) { foreach ($keys as $key) { $this->getRedis()->del($key); $cpt++; } } return $cpt; }
php
public function cleanAll(): int { $cpt = 0; $keys = $this->getRedis()->keys($this->namespace . ':*'); if ($keys) { foreach ($keys as $key) { $this->getRedis()->del($key); $cpt++; } } return $cpt; }
[ "public", "function", "cleanAll", "(", ")", ":", "int", "{", "$", "cpt", "=", "0", ";", "$", "keys", "=", "$", "this", "->", "getRedis", "(", ")", "->", "keys", "(", "$", "this", "->", "namespace", ".", "':*'", ")", ";", "if", "(", "$", "keys", ")", "{", "foreach", "(", "$", "keys", "as", "$", "key", ")", "{", "$", "this", "->", "getRedis", "(", ")", "->", "del", "(", "$", "key", ")", ";", "$", "cpt", "++", ";", "}", "}", "return", "$", "cpt", ";", "}" ]
Clean all values of the current namespace @return int Number of deleted fields
[ "Clean", "all", "values", "of", "the", "current", "namespace" ]
523fc6ff64685b390e5019dc0eaabe15b387f0a7
https://github.com/osflab/cache/blob/523fc6ff64685b390e5019dc0eaabe15b387f0a7/OsfCache.php#L206-L217
238,997
osflab/cache
OsfCache.php
OsfCache.getZendStorage
public function getZendStorage(string $namespace = 'default') { static $storages = []; if (!isset($storages[$namespace])) { $rrm = new RedisResourceManager(); $rrm->setResource('default', $this->getRedis()); $rrm->setLibOption('default', Redis::OPT_SERIALIZER, $this->redis->getOption(Redis::OPT_SERIALIZER)); $options = new RedisOptions(); $options->setResourceManager($rrm); $storages[$namespace] = new RedisAdapter($options); } return $storages[$namespace]; }
php
public function getZendStorage(string $namespace = 'default') { static $storages = []; if (!isset($storages[$namespace])) { $rrm = new RedisResourceManager(); $rrm->setResource('default', $this->getRedis()); $rrm->setLibOption('default', Redis::OPT_SERIALIZER, $this->redis->getOption(Redis::OPT_SERIALIZER)); $options = new RedisOptions(); $options->setResourceManager($rrm); $storages[$namespace] = new RedisAdapter($options); } return $storages[$namespace]; }
[ "public", "function", "getZendStorage", "(", "string", "$", "namespace", "=", "'default'", ")", "{", "static", "$", "storages", "=", "[", "]", ";", "if", "(", "!", "isset", "(", "$", "storages", "[", "$", "namespace", "]", ")", ")", "{", "$", "rrm", "=", "new", "RedisResourceManager", "(", ")", ";", "$", "rrm", "->", "setResource", "(", "'default'", ",", "$", "this", "->", "getRedis", "(", ")", ")", ";", "$", "rrm", "->", "setLibOption", "(", "'default'", ",", "Redis", "::", "OPT_SERIALIZER", ",", "$", "this", "->", "redis", "->", "getOption", "(", "Redis", "::", "OPT_SERIALIZER", ")", ")", ";", "$", "options", "=", "new", "RedisOptions", "(", ")", ";", "$", "options", "->", "setResourceManager", "(", "$", "rrm", ")", ";", "$", "storages", "[", "$", "namespace", "]", "=", "new", "RedisAdapter", "(", "$", "options", ")", ";", "}", "return", "$", "storages", "[", "$", "namespace", "]", ";", "}" ]
Build and return a zend cache storage using OSF cache configuration @staticvar array $storages @param string $namespace @return \Zend\Cache\Storage\Adapter\Redis
[ "Build", "and", "return", "a", "zend", "cache", "storage", "using", "OSF", "cache", "configuration" ]
523fc6ff64685b390e5019dc0eaabe15b387f0a7
https://github.com/osflab/cache/blob/523fc6ff64685b390e5019dc0eaabe15b387f0a7/OsfCache.php#L255-L268
238,998
osflab/cache
OsfCache.php
OsfCache.filterTtl
protected function filterTtl(&$ttl): void { if ($ttl !== null) { if ($ttl instanceof \DateInterval) { $ttl = (int) $ttl->format('%s'); } $ttl = (int) $ttl; } }
php
protected function filterTtl(&$ttl): void { if ($ttl !== null) { if ($ttl instanceof \DateInterval) { $ttl = (int) $ttl->format('%s'); } $ttl = (int) $ttl; } }
[ "protected", "function", "filterTtl", "(", "&", "$", "ttl", ")", ":", "void", "{", "if", "(", "$", "ttl", "!==", "null", ")", "{", "if", "(", "$", "ttl", "instanceof", "\\", "DateInterval", ")", "{", "$", "ttl", "=", "(", "int", ")", "$", "ttl", "->", "format", "(", "'%s'", ")", ";", "}", "$", "ttl", "=", "(", "int", ")", "$", "ttl", ";", "}", "}" ]
Mixed ttl to seconds @param mixed $ttl @return void
[ "Mixed", "ttl", "to", "seconds" ]
523fc6ff64685b390e5019dc0eaabe15b387f0a7
https://github.com/osflab/cache/blob/523fc6ff64685b390e5019dc0eaabe15b387f0a7/OsfCache.php#L310-L318
238,999
BapCat/Services
src/ServiceContainer.php
ServiceContainer.register
public function register($serviceClass): void { try { $class = new ReflectionClass($serviceClass); } catch(ReflectionException $e) { throw new RuntimeException('Service class not found', 0, $e); } if(!$class->implementsInterface(ServiceProvider::class)) { throw new InvalidArgumentException("[$serviceClass] is not a service provider"); } if($class->hasConstant('requires')) { $requirements = array_flip($class->getConstant('requires')); foreach($this->services as $service_name => $service) { if(array_key_exists($service_name, $requirements)) { unset($requirements[$service_name]); } } if(count($requirements) !== 0) { $this->queue[$serviceClass] = array_flip($requirements); return; } } $service = $this->ioc->make($serviceClass); $service->register(); if(!$class->hasConstant('provides')) { $this->services[] = $service; } else { $provides = $class->getConstant('provides'); $this->services[$provides] = $service; foreach($this->queue as $queued_name => &$queued) { if(in_array($provides, $queued, true)) { unset($this->queue[$queued_name]); $this->register($queued_name); } } } }
php
public function register($serviceClass): void { try { $class = new ReflectionClass($serviceClass); } catch(ReflectionException $e) { throw new RuntimeException('Service class not found', 0, $e); } if(!$class->implementsInterface(ServiceProvider::class)) { throw new InvalidArgumentException("[$serviceClass] is not a service provider"); } if($class->hasConstant('requires')) { $requirements = array_flip($class->getConstant('requires')); foreach($this->services as $service_name => $service) { if(array_key_exists($service_name, $requirements)) { unset($requirements[$service_name]); } } if(count($requirements) !== 0) { $this->queue[$serviceClass] = array_flip($requirements); return; } } $service = $this->ioc->make($serviceClass); $service->register(); if(!$class->hasConstant('provides')) { $this->services[] = $service; } else { $provides = $class->getConstant('provides'); $this->services[$provides] = $service; foreach($this->queue as $queued_name => &$queued) { if(in_array($provides, $queued, true)) { unset($this->queue[$queued_name]); $this->register($queued_name); } } } }
[ "public", "function", "register", "(", "$", "serviceClass", ")", ":", "void", "{", "try", "{", "$", "class", "=", "new", "ReflectionClass", "(", "$", "serviceClass", ")", ";", "}", "catch", "(", "ReflectionException", "$", "e", ")", "{", "throw", "new", "RuntimeException", "(", "'Service class not found'", ",", "0", ",", "$", "e", ")", ";", "}", "if", "(", "!", "$", "class", "->", "implementsInterface", "(", "ServiceProvider", "::", "class", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "\"[$serviceClass] is not a service provider\"", ")", ";", "}", "if", "(", "$", "class", "->", "hasConstant", "(", "'requires'", ")", ")", "{", "$", "requirements", "=", "array_flip", "(", "$", "class", "->", "getConstant", "(", "'requires'", ")", ")", ";", "foreach", "(", "$", "this", "->", "services", "as", "$", "service_name", "=>", "$", "service", ")", "{", "if", "(", "array_key_exists", "(", "$", "service_name", ",", "$", "requirements", ")", ")", "{", "unset", "(", "$", "requirements", "[", "$", "service_name", "]", ")", ";", "}", "}", "if", "(", "count", "(", "$", "requirements", ")", "!==", "0", ")", "{", "$", "this", "->", "queue", "[", "$", "serviceClass", "]", "=", "array_flip", "(", "$", "requirements", ")", ";", "return", ";", "}", "}", "$", "service", "=", "$", "this", "->", "ioc", "->", "make", "(", "$", "serviceClass", ")", ";", "$", "service", "->", "register", "(", ")", ";", "if", "(", "!", "$", "class", "->", "hasConstant", "(", "'provides'", ")", ")", "{", "$", "this", "->", "services", "[", "]", "=", "$", "service", ";", "}", "else", "{", "$", "provides", "=", "$", "class", "->", "getConstant", "(", "'provides'", ")", ";", "$", "this", "->", "services", "[", "$", "provides", "]", "=", "$", "service", ";", "foreach", "(", "$", "this", "->", "queue", "as", "$", "queued_name", "=>", "&", "$", "queued", ")", "{", "if", "(", "in_array", "(", "$", "provides", ",", "$", "queued", ",", "true", ")", ")", "{", "unset", "(", "$", "this", "->", "queue", "[", "$", "queued_name", "]", ")", ";", "$", "this", "->", "register", "(", "$", "queued_name", ")", ";", "}", "}", "}", "}" ]
Registers a Service Provider to be loaded when the framework boots If a service provider depends on other services that have not been registered yet, it may be queued, rather than registered. Once all services it relies on have been registered, it will be registered. @param string $serviceClass The Service Provider to register
[ "Registers", "a", "Service", "Provider", "to", "be", "loaded", "when", "the", "framework", "boots" ]
7318092a316f8f8f2ce9f09598fb5e750119dd30
https://github.com/BapCat/Services/blob/7318092a316f8f8f2ce9f09598fb5e750119dd30/src/ServiceContainer.php#L44-L87