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
25,500
AnonymPHP/Anonym-Database
Mode/Read.php
Read.join
public function join($join = []) { $this->string['join'] = $this->useBuilder('join')->join($join, $this->getBase()->getTable()); return $this; }
php
public function join($join = []) { $this->string['join'] = $this->useBuilder('join')->join($join, $this->getBase()->getTable()); return $this; }
[ "public", "function", "join", "(", "$", "join", "=", "[", "]", ")", "{", "$", "this", "->", "string", "[", "'join'", "]", "=", "$", "this", "->", "useBuilder", "(", "'join'", ")", "->", "join", "(", "$", "join", ",", "$", "this", "->", "getBase", "(", ")", "->", "getTable", "(", ")", ")", ";", "return", "$", "this", ";", "}" ]
Join komutu ekler @param array $join @return $this
[ "Join", "komutu", "ekler" ]
4d034219e0e3eb2833fa53204e9f52a74a9a7e4b
https://github.com/AnonymPHP/Anonym-Database/blob/4d034219e0e3eb2833fa53204e9f52a74a9a7e4b/Mode/Read.php#L122-L126
25,501
FlexModel/FlexModelBundle
DataCollector/FlexModelDataCollector.php
FlexModelDataCollector.collect
public function collect(Request $request, Response $response, Exception $exception = null) { $objects = array(); $objectNames = $this->flexModel->getObjectNames(); foreach ($objectNames as $objectName) { $fieldNames = $this->flexModel->getFieldNames($objectName); $objects[] = array( 'objectName' => $objectName, 'fieldNames' => $fieldNames, ); } $this->data = array( 'objects' => $objects, ); }
php
public function collect(Request $request, Response $response, Exception $exception = null) { $objects = array(); $objectNames = $this->flexModel->getObjectNames(); foreach ($objectNames as $objectName) { $fieldNames = $this->flexModel->getFieldNames($objectName); $objects[] = array( 'objectName' => $objectName, 'fieldNames' => $fieldNames, ); } $this->data = array( 'objects' => $objects, ); }
[ "public", "function", "collect", "(", "Request", "$", "request", ",", "Response", "$", "response", ",", "Exception", "$", "exception", "=", "null", ")", "{", "$", "objects", "=", "array", "(", ")", ";", "$", "objectNames", "=", "$", "this", "->", "flexModel", "->", "getObjectNames", "(", ")", ";", "foreach", "(", "$", "objectNames", "as", "$", "objectName", ")", "{", "$", "fieldNames", "=", "$", "this", "->", "flexModel", "->", "getFieldNames", "(", "$", "objectName", ")", ";", "$", "objects", "[", "]", "=", "array", "(", "'objectName'", "=>", "$", "objectName", ",", "'fieldNames'", "=>", "$", "fieldNames", ",", ")", ";", "}", "$", "this", "->", "data", "=", "array", "(", "'objects'", "=>", "$", "objects", ",", ")", ";", "}" ]
Collect the specific FlexModel data for the Symfony Profiler. @param Request $request @param Response $response @param Exception $exception
[ "Collect", "the", "specific", "FlexModel", "data", "for", "the", "Symfony", "Profiler", "." ]
7b4720d25b0dc6baf29b1da8ad7c67dfb2686460
https://github.com/FlexModel/FlexModelBundle/blob/7b4720d25b0dc6baf29b1da8ad7c67dfb2686460/DataCollector/FlexModelDataCollector.php#L42-L58
25,502
fxpio/fxp-doctrine-extra
Util/ManagerUtils.php
ManagerUtils.getManager
public static function getManager(ManagerRegistry $or, $class) { $manager = $or->getManagerForClass($class); if (null === $manager) { foreach ($or->getManagers() as $objectManager) { if ($objectManager->getMetadataFactory()->hasMetadataFor($class) && self::isValidManager($objectManager, $class)) { $manager = $objectManager; break; } } } return $manager; }
php
public static function getManager(ManagerRegistry $or, $class) { $manager = $or->getManagerForClass($class); if (null === $manager) { foreach ($or->getManagers() as $objectManager) { if ($objectManager->getMetadataFactory()->hasMetadataFor($class) && self::isValidManager($objectManager, $class)) { $manager = $objectManager; break; } } } return $manager; }
[ "public", "static", "function", "getManager", "(", "ManagerRegistry", "$", "or", ",", "$", "class", ")", "{", "$", "manager", "=", "$", "or", "->", "getManagerForClass", "(", "$", "class", ")", ";", "if", "(", "null", "===", "$", "manager", ")", "{", "foreach", "(", "$", "or", "->", "getManagers", "(", ")", "as", "$", "objectManager", ")", "{", "if", "(", "$", "objectManager", "->", "getMetadataFactory", "(", ")", "->", "hasMetadataFor", "(", "$", "class", ")", "&&", "self", "::", "isValidManager", "(", "$", "objectManager", ",", "$", "class", ")", ")", "{", "$", "manager", "=", "$", "objectManager", ";", "break", ";", "}", "}", "}", "return", "$", "manager", ";", "}" ]
Get the doctrine object manager of the class. @param ManagerRegistry $or The doctrine registry @param string $class The class name or doctrine shortcut class name @return null|ObjectManager
[ "Get", "the", "doctrine", "object", "manager", "of", "the", "class", "." ]
9c672acde7892717958efff0ee3bad723be4a70f
https://github.com/fxpio/fxp-doctrine-extra/blob/9c672acde7892717958efff0ee3bad723be4a70f/Util/ManagerUtils.php#L34-L50
25,503
fxpio/fxp-doctrine-extra
Util/ManagerUtils.php
ManagerUtils.isValidManager
private static function isValidManager(ObjectManager $manager, $class) { $meta = $manager->getClassMetadata($class); return !$meta instanceof OrmClassMetadata || !$meta->isMappedSuperclass; }
php
private static function isValidManager(ObjectManager $manager, $class) { $meta = $manager->getClassMetadata($class); return !$meta instanceof OrmClassMetadata || !$meta->isMappedSuperclass; }
[ "private", "static", "function", "isValidManager", "(", "ObjectManager", "$", "manager", ",", "$", "class", ")", "{", "$", "meta", "=", "$", "manager", "->", "getClassMetadata", "(", "$", "class", ")", ";", "return", "!", "$", "meta", "instanceof", "OrmClassMetadata", "||", "!", "$", "meta", "->", "isMappedSuperclass", ";", "}" ]
Check if the object manager is valid. @param ObjectManager $manager The object manager @param string $class The class name @return bool
[ "Check", "if", "the", "object", "manager", "is", "valid", "." ]
9c672acde7892717958efff0ee3bad723be4a70f
https://github.com/fxpio/fxp-doctrine-extra/blob/9c672acde7892717958efff0ee3bad723be4a70f/Util/ManagerUtils.php#L81-L86
25,504
WideFocus/Feed-Writer
src/ExtractFieldValuesTrait.php
ExtractFieldValuesTrait.extractFieldValues
protected function extractFieldValues( ArrayAccess $item, WriterFieldInterface ...$fields ): array { return array_map( function (WriterFieldInterface $field) use ($item) : string { return $field->getValue($item); }, $fields ); }
php
protected function extractFieldValues( ArrayAccess $item, WriterFieldInterface ...$fields ): array { return array_map( function (WriterFieldInterface $field) use ($item) : string { return $field->getValue($item); }, $fields ); }
[ "protected", "function", "extractFieldValues", "(", "ArrayAccess", "$", "item", ",", "WriterFieldInterface", "...", "$", "fields", ")", ":", "array", "{", "return", "array_map", "(", "function", "(", "WriterFieldInterface", "$", "field", ")", "use", "(", "$", "item", ")", ":", "string", "{", "return", "$", "field", "->", "getValue", "(", "$", "item", ")", ";", "}", ",", "$", "fields", ")", ";", "}" ]
Extract item values from fields. @param ArrayAccess $item @param WriterFieldInterface[] ...$fields @return string[]
[ "Extract", "item", "values", "from", "fields", "." ]
c2698394645c75db06962e5e9d638f0cabe69fe3
https://github.com/WideFocus/Feed-Writer/blob/c2698394645c75db06962e5e9d638f0cabe69fe3/src/ExtractFieldValuesTrait.php#L21-L31
25,505
Talesoft/tale-framework
src/Tale/Event/EmitterTrait.php
EmitterTrait.getEvent
public function getEvent($name) { if (!isset($this->_events)) $this->_events = []; if (!isset($this->_events[$name])) { $className = $this->getEventClassName(); $this->_events[$name] = new $className($name); } return $this->_events[$name]; }
php
public function getEvent($name) { if (!isset($this->_events)) $this->_events = []; if (!isset($this->_events[$name])) { $className = $this->getEventClassName(); $this->_events[$name] = new $className($name); } return $this->_events[$name]; }
[ "public", "function", "getEvent", "(", "$", "name", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "_events", ")", ")", "$", "this", "->", "_events", "=", "[", "]", ";", "if", "(", "!", "isset", "(", "$", "this", "->", "_events", "[", "$", "name", "]", ")", ")", "{", "$", "className", "=", "$", "this", "->", "getEventClassName", "(", ")", ";", "$", "this", "->", "_events", "[", "$", "name", "]", "=", "new", "$", "className", "(", "$", "name", ")", ";", "}", "return", "$", "this", "->", "_events", "[", "$", "name", "]", ";", "}" ]
Returns an event by name. If the event doesnt exist yet, it is created @param $name The name of the event @return \Tale\Event The unique event instance
[ "Returns", "an", "event", "by", "name", ".", "If", "the", "event", "doesnt", "exist", "yet", "it", "is", "created" ]
739a7011c6dad409a51c4bcfbcf4b4ffbc8cba49
https://github.com/Talesoft/tale-framework/blob/739a7011c6dad409a51c4bcfbcf4b4ffbc8cba49/src/Tale/Event/EmitterTrait.php#L38-L51
25,506
Subscribo/omnipay-subscribo-shared
src/Shared/Widget/AbstractWidget.php
AbstractWidget.checkParameters
protected function checkParameters($parameters, $requirements = true) { if (is_array($parameters)) { $parameters = array_replace($this->getParameters(), $parameters); } $obstacles = $this->collectRenderingObstacles($parameters, $requirements); if ($obstacles) { throw new WidgetInvalidRenderingParametersException(reset($obstacles)); } return $parameters; }
php
protected function checkParameters($parameters, $requirements = true) { if (is_array($parameters)) { $parameters = array_replace($this->getParameters(), $parameters); } $obstacles = $this->collectRenderingObstacles($parameters, $requirements); if ($obstacles) { throw new WidgetInvalidRenderingParametersException(reset($obstacles)); } return $parameters; }
[ "protected", "function", "checkParameters", "(", "$", "parameters", ",", "$", "requirements", "=", "true", ")", "{", "if", "(", "is_array", "(", "$", "parameters", ")", ")", "{", "$", "parameters", "=", "array_replace", "(", "$", "this", "->", "getParameters", "(", ")", ",", "$", "parameters", ")", ";", "}", "$", "obstacles", "=", "$", "this", "->", "collectRenderingObstacles", "(", "$", "parameters", ",", "$", "requirements", ")", ";", "if", "(", "$", "obstacles", ")", "{", "throw", "new", "WidgetInvalidRenderingParametersException", "(", "reset", "(", "$", "obstacles", ")", ")", ";", "}", "return", "$", "parameters", ";", "}" ]
Merges provided parameters with those from objects and checks them @param array $parameters @param bool|array $requirements - required parameter names or true for getting them from getRequiredParameters() @return array @throws \Subscribo\Omnipay\Shared\Exception\WidgetInvalidRenderingParametersException
[ "Merges", "provided", "parameters", "with", "those", "from", "objects", "and", "checks", "them" ]
aa9fa115ef8324b50fe5c91d3593d5632f53b669
https://github.com/Subscribo/omnipay-subscribo-shared/blob/aa9fa115ef8324b50fe5c91d3593d5632f53b669/src/Shared/Widget/AbstractWidget.php#L40-L50
25,507
Subscribo/omnipay-subscribo-shared
src/Shared/Widget/AbstractWidget.php
AbstractWidget.collectRenderingObstacles
protected function collectRenderingObstacles($parameters, $requirements = true) { if ( ! is_array($parameters)) { return ['Parameters should be an array']; } if (true === $requirements) { $requirements = $this->getRequiredParameters(); } $obstacles = []; foreach ($requirements as $requiredParameterName) { if (empty($parameters[$requiredParameterName])) { $obstacles[] = "Parameter '".$requiredParameterName."' is required"; } } return $obstacles; }
php
protected function collectRenderingObstacles($parameters, $requirements = true) { if ( ! is_array($parameters)) { return ['Parameters should be an array']; } if (true === $requirements) { $requirements = $this->getRequiredParameters(); } $obstacles = []; foreach ($requirements as $requiredParameterName) { if (empty($parameters[$requiredParameterName])) { $obstacles[] = "Parameter '".$requiredParameterName."' is required"; } } return $obstacles; }
[ "protected", "function", "collectRenderingObstacles", "(", "$", "parameters", ",", "$", "requirements", "=", "true", ")", "{", "if", "(", "!", "is_array", "(", "$", "parameters", ")", ")", "{", "return", "[", "'Parameters should be an array'", "]", ";", "}", "if", "(", "true", "===", "$", "requirements", ")", "{", "$", "requirements", "=", "$", "this", "->", "getRequiredParameters", "(", ")", ";", "}", "$", "obstacles", "=", "[", "]", ";", "foreach", "(", "$", "requirements", "as", "$", "requiredParameterName", ")", "{", "if", "(", "empty", "(", "$", "parameters", "[", "$", "requiredParameterName", "]", ")", ")", "{", "$", "obstacles", "[", "]", "=", "\"Parameter '\"", ".", "$", "requiredParameterName", ".", "\"' is required\"", ";", "}", "}", "return", "$", "obstacles", ";", "}" ]
Returns an array of possible problems for rendering widget or of some widget rendering functionality @param $parameters @param bool|array $requirements - required parameter names or true for getting them from getRequiredParameters() @return array
[ "Returns", "an", "array", "of", "possible", "problems", "for", "rendering", "widget", "or", "of", "some", "widget", "rendering", "functionality" ]
aa9fa115ef8324b50fe5c91d3593d5632f53b669
https://github.com/Subscribo/omnipay-subscribo-shared/blob/aa9fa115ef8324b50fe5c91d3593d5632f53b669/src/Shared/Widget/AbstractWidget.php#L59-L74
25,508
heiglandreas/DateFormatter
src/Formatter/Pdf.php
Pdf.format
public function format(\DateTimeInterface $date) { if ($date->getOffset() == 0) { return $date->format('YmdHis\Z'); } return str_replace(':', '\'', $date->format('YmdHisP')) . '\''; }
php
public function format(\DateTimeInterface $date) { if ($date->getOffset() == 0) { return $date->format('YmdHis\Z'); } return str_replace(':', '\'', $date->format('YmdHisP')) . '\''; }
[ "public", "function", "format", "(", "\\", "DateTimeInterface", "$", "date", ")", "{", "if", "(", "$", "date", "->", "getOffset", "(", ")", "==", "0", ")", "{", "return", "$", "date", "->", "format", "(", "'YmdHis\\Z'", ")", ";", "}", "return", "str_replace", "(", "':'", ",", "'\\''", ",", "$", "date", "->", "format", "(", "'YmdHisP'", ")", ")", ".", "'\\''", ";", "}" ]
Formats the date according to the formatting string @param \DateTimeInterface $date @return string
[ "Formats", "the", "date", "according", "to", "the", "formatting", "string" ]
948737d329e72b74c118dac902d795d6c244a486
https://github.com/heiglandreas/DateFormatter/blob/948737d329e72b74c118dac902d795d6c244a486/src/Formatter/Pdf.php#L43-L49
25,509
capimichi/crawler
src/Crawler/Downloader/Downloader.php
Downloader.getDomXpath
public function getDomXpath($url) { $dom = $this->getDomDocument($url); $xpath = new \DOMXPath($dom); return $xpath; }
php
public function getDomXpath($url) { $dom = $this->getDomDocument($url); $xpath = new \DOMXPath($dom); return $xpath; }
[ "public", "function", "getDomXpath", "(", "$", "url", ")", "{", "$", "dom", "=", "$", "this", "->", "getDomDocument", "(", "$", "url", ")", ";", "$", "xpath", "=", "new", "\\", "DOMXPath", "(", "$", "dom", ")", ";", "return", "$", "xpath", ";", "}" ]
Get the DOMXPath of the downloaded content @param $url @return \DOMXPath
[ "Get", "the", "DOMXPath", "of", "the", "downloaded", "content" ]
e1cd4ba00a9a1da994dc381ee396ba4a5038c986
https://github.com/capimichi/crawler/blob/e1cd4ba00a9a1da994dc381ee396ba4a5038c986/src/Crawler/Downloader/Downloader.php#L94-L99
25,510
ARCANESOFT/Media
src/Http/Controllers/Admin/ApiController.php
ApiController.getAll
public function getAll(Request $request) { $this->authorize(MediasPolicy::PERMISSION_LIST); return $this->jsonResponseSuccess([ 'medias' => $this->media->all( $request->get('location', '/') ), ]); }
php
public function getAll(Request $request) { $this->authorize(MediasPolicy::PERMISSION_LIST); return $this->jsonResponseSuccess([ 'medias' => $this->media->all( $request->get('location', '/') ), ]); }
[ "public", "function", "getAll", "(", "Request", "$", "request", ")", "{", "$", "this", "->", "authorize", "(", "MediasPolicy", "::", "PERMISSION_LIST", ")", ";", "return", "$", "this", "->", "jsonResponseSuccess", "(", "[", "'medias'", "=>", "$", "this", "->", "media", "->", "all", "(", "$", "request", "->", "get", "(", "'location'", ",", "'/'", ")", ")", ",", "]", ")", ";", "}" ]
Get the the media files. @param \Illuminate\Http\Request $request @return \Illuminate\Http\JsonResponse
[ "Get", "the", "the", "media", "files", "." ]
e98aad52f94e6587fcbf79c56f7bf7072929bfc9
https://github.com/ARCANESOFT/Media/blob/e98aad52f94e6587fcbf79c56f7bf7072929bfc9/src/Http/Controllers/Admin/ApiController.php#L65-L74
25,511
ARCANESOFT/Media
src/Http/Controllers/Admin/ApiController.php
ApiController.getDestinations
private function getDestinations($name, $location) { $selected = ($isHome = $location === '/') ? $name : "{$location}/{$name}"; $destinations = $this->media->directories($location) ->pluck('path') ->reject(function ($path) use ($selected) { return $path === $selected; }) ->values(); if ( ! $isHome) $destinations->prepend('..'); return $destinations; }
php
private function getDestinations($name, $location) { $selected = ($isHome = $location === '/') ? $name : "{$location}/{$name}"; $destinations = $this->media->directories($location) ->pluck('path') ->reject(function ($path) use ($selected) { return $path === $selected; }) ->values(); if ( ! $isHome) $destinations->prepend('..'); return $destinations; }
[ "private", "function", "getDestinations", "(", "$", "name", ",", "$", "location", ")", "{", "$", "selected", "=", "(", "$", "isHome", "=", "$", "location", "===", "'/'", ")", "?", "$", "name", ":", "\"{$location}/{$name}\"", ";", "$", "destinations", "=", "$", "this", "->", "media", "->", "directories", "(", "$", "location", ")", "->", "pluck", "(", "'path'", ")", "->", "reject", "(", "function", "(", "$", "path", ")", "use", "(", "$", "selected", ")", "{", "return", "$", "path", "===", "$", "selected", ";", "}", ")", "->", "values", "(", ")", ";", "if", "(", "!", "$", "isHome", ")", "$", "destinations", "->", "prepend", "(", "'..'", ")", ";", "return", "$", "destinations", ";", "}" ]
Get the destinations paths. @param string $name @param string $location @return \Arcanesoft\Media\Entities\DirectoryCollection
[ "Get", "the", "destinations", "paths", "." ]
e98aad52f94e6587fcbf79c56f7bf7072929bfc9
https://github.com/ARCANESOFT/Media/blob/e98aad52f94e6587fcbf79c56f7bf7072929bfc9/src/Http/Controllers/Admin/ApiController.php#L245-L259
25,512
ARCANESOFT/Media
src/Http/Controllers/Admin/ApiController.php
ApiController.performMoveMedia
private function performMoveMedia($type, $location, $oldName, $newName) { $from = "{$location}/{$oldName}"; switch (Str::lower($type)) { case Media::MEDIA_TYPE_FILE: return $this->moveFile($from, $location, $newName); case Media::MEDIA_TYPE_DIRECTORY: return $this->moveDirectory($from, $location, $newName); default: return false; } }
php
private function performMoveMedia($type, $location, $oldName, $newName) { $from = "{$location}/{$oldName}"; switch (Str::lower($type)) { case Media::MEDIA_TYPE_FILE: return $this->moveFile($from, $location, $newName); case Media::MEDIA_TYPE_DIRECTORY: return $this->moveDirectory($from, $location, $newName); default: return false; } }
[ "private", "function", "performMoveMedia", "(", "$", "type", ",", "$", "location", ",", "$", "oldName", ",", "$", "newName", ")", "{", "$", "from", "=", "\"{$location}/{$oldName}\"", ";", "switch", "(", "Str", "::", "lower", "(", "$", "type", ")", ")", "{", "case", "Media", "::", "MEDIA_TYPE_FILE", ":", "return", "$", "this", "->", "moveFile", "(", "$", "from", ",", "$", "location", ",", "$", "newName", ")", ";", "case", "Media", "::", "MEDIA_TYPE_DIRECTORY", ":", "return", "$", "this", "->", "moveDirectory", "(", "$", "from", ",", "$", "location", ",", "$", "newName", ")", ";", "default", ":", "return", "false", ";", "}", "}" ]
Perform the media movement. @param string $type @param string $location @param string $oldName @param string $newName @return bool|string
[ "Perform", "the", "media", "movement", "." ]
e98aad52f94e6587fcbf79c56f7bf7072929bfc9
https://github.com/ARCANESOFT/Media/blob/e98aad52f94e6587fcbf79c56f7bf7072929bfc9/src/Http/Controllers/Admin/ApiController.php#L271-L285
25,513
ARCANESOFT/Media
src/Http/Controllers/Admin/ApiController.php
ApiController.moveDirectory
private function moveDirectory($from, $location, $newName) { $newName = Str::slug($newName); return tap("{$location}/{$newName}", function ($to) use ($from) { $this->media->move($from, $to); }); }
php
private function moveDirectory($from, $location, $newName) { $newName = Str::slug($newName); return tap("{$location}/{$newName}", function ($to) use ($from) { $this->media->move($from, $to); }); }
[ "private", "function", "moveDirectory", "(", "$", "from", ",", "$", "location", ",", "$", "newName", ")", "{", "$", "newName", "=", "Str", "::", "slug", "(", "$", "newName", ")", ";", "return", "tap", "(", "\"{$location}/{$newName}\"", ",", "function", "(", "$", "to", ")", "use", "(", "$", "from", ")", "{", "$", "this", "->", "media", "->", "move", "(", "$", "from", ",", "$", "to", ")", ";", "}", ")", ";", "}" ]
Move directory. @param string $from @param string $location @param string $newName @return string
[ "Move", "directory", "." ]
e98aad52f94e6587fcbf79c56f7bf7072929bfc9
https://github.com/ARCANESOFT/Media/blob/e98aad52f94e6587fcbf79c56f7bf7072929bfc9/src/Http/Controllers/Admin/ApiController.php#L316-L323
25,514
ARCANESOFT/Media
src/Http/Controllers/Admin/ApiController.php
ApiController.performDeleteMedia
private function performDeleteMedia($type, $path) { switch (Str::lower($type)) { case Media::MEDIA_TYPE_FILE: return $this->media->deleteFile($path); case Media::MEDIA_TYPE_DIRECTORY: return $this->media->deleteDirectory(trim($path, '/')); default: return false; } }
php
private function performDeleteMedia($type, $path) { switch (Str::lower($type)) { case Media::MEDIA_TYPE_FILE: return $this->media->deleteFile($path); case Media::MEDIA_TYPE_DIRECTORY: return $this->media->deleteDirectory(trim($path, '/')); default: return false; } }
[ "private", "function", "performDeleteMedia", "(", "$", "type", ",", "$", "path", ")", "{", "switch", "(", "Str", "::", "lower", "(", "$", "type", ")", ")", "{", "case", "Media", "::", "MEDIA_TYPE_FILE", ":", "return", "$", "this", "->", "media", "->", "deleteFile", "(", "$", "path", ")", ";", "case", "Media", "::", "MEDIA_TYPE_DIRECTORY", ":", "return", "$", "this", "->", "media", "->", "deleteDirectory", "(", "trim", "(", "$", "path", ",", "'/'", ")", ")", ";", "default", ":", "return", "false", ";", "}", "}" ]
Perform the media deletion. @param string $type @param string $path @return bool
[ "Perform", "the", "media", "deletion", "." ]
e98aad52f94e6587fcbf79c56f7bf7072929bfc9
https://github.com/ARCANESOFT/Media/blob/e98aad52f94e6587fcbf79c56f7bf7072929bfc9/src/Http/Controllers/Admin/ApiController.php#L333-L345
25,515
SlaxWeb/Bootstrap
src/Service/LoggerProvider.php
LoggerProvider.register
public function register(App $app) { $app["logger.service"] = $app->protect( function (string $loggerName = "") use ($app) { $cacheName = "logger.service-{$loggerName}"; if (isset($app[$cacheName])) { return $app[$cacheName]; } /* * Check the config service has been defined and provides correct * object */ if (isset($app["config.service"]) === false || get_class($app["config.service"]) !== "SlaxWeb\\Config\\Container") { throw new \SlaxWeb\Bootstrap\Exception\LoggerConfigException( "Config component provider must be registered before you can use the Logger component." ); } $config = $app["config.service"]; if ($loggerName === "") { $loggerName = $config["logger.defaultLogger"]; } $logger = new MLogger($loggerName); foreach ($config["logger.loggerSettings"][$loggerName] as $type => $settings) { // load propper handler and instantiate the Monolog\Logger $handler = null; switch ($type) { case Helper::L_TYPE_FILE: $app["temp.logger.settings"] = $settings; $handler = $app["logger.{$type}.service"]; unset($app["temp.logger.settings"]); break; default: throw new \SlaxWeb\Bootstrap\Exception\UnknownLoggerHandlerException( "The handler you are tring to use is not known or not supported." ); } $logger->pushHandler($handler); } return $app[$cacheName] = $logger; } ); $app["logger.StreamHandler.service"] = $app->factory( function (App $cont) { $settings = $cont["temp.logger.settings"]; // if the log file name does not begin with a dir separator, treat // it as relative path and prepend 'logFilePath' if ($settings[0][0] !== DIRECTORY_SEPARATOR) { $settings[0] = ($cont["config.service"]["logger.logFilePath"] ?? "") . $settings[0]; } return new \Monolog\Handler\StreamHandler(...$settings); } ); }
php
public function register(App $app) { $app["logger.service"] = $app->protect( function (string $loggerName = "") use ($app) { $cacheName = "logger.service-{$loggerName}"; if (isset($app[$cacheName])) { return $app[$cacheName]; } /* * Check the config service has been defined and provides correct * object */ if (isset($app["config.service"]) === false || get_class($app["config.service"]) !== "SlaxWeb\\Config\\Container") { throw new \SlaxWeb\Bootstrap\Exception\LoggerConfigException( "Config component provider must be registered before you can use the Logger component." ); } $config = $app["config.service"]; if ($loggerName === "") { $loggerName = $config["logger.defaultLogger"]; } $logger = new MLogger($loggerName); foreach ($config["logger.loggerSettings"][$loggerName] as $type => $settings) { // load propper handler and instantiate the Monolog\Logger $handler = null; switch ($type) { case Helper::L_TYPE_FILE: $app["temp.logger.settings"] = $settings; $handler = $app["logger.{$type}.service"]; unset($app["temp.logger.settings"]); break; default: throw new \SlaxWeb\Bootstrap\Exception\UnknownLoggerHandlerException( "The handler you are tring to use is not known or not supported." ); } $logger->pushHandler($handler); } return $app[$cacheName] = $logger; } ); $app["logger.StreamHandler.service"] = $app->factory( function (App $cont) { $settings = $cont["temp.logger.settings"]; // if the log file name does not begin with a dir separator, treat // it as relative path and prepend 'logFilePath' if ($settings[0][0] !== DIRECTORY_SEPARATOR) { $settings[0] = ($cont["config.service"]["logger.logFilePath"] ?? "") . $settings[0]; } return new \Monolog\Handler\StreamHandler(...$settings); } ); }
[ "public", "function", "register", "(", "App", "$", "app", ")", "{", "$", "app", "[", "\"logger.service\"", "]", "=", "$", "app", "->", "protect", "(", "function", "(", "string", "$", "loggerName", "=", "\"\"", ")", "use", "(", "$", "app", ")", "{", "$", "cacheName", "=", "\"logger.service-{$loggerName}\"", ";", "if", "(", "isset", "(", "$", "app", "[", "$", "cacheName", "]", ")", ")", "{", "return", "$", "app", "[", "$", "cacheName", "]", ";", "}", "/*\n * Check the config service has been defined and provides correct\n * object\n */", "if", "(", "isset", "(", "$", "app", "[", "\"config.service\"", "]", ")", "===", "false", "||", "get_class", "(", "$", "app", "[", "\"config.service\"", "]", ")", "!==", "\"SlaxWeb\\\\Config\\\\Container\"", ")", "{", "throw", "new", "\\", "SlaxWeb", "\\", "Bootstrap", "\\", "Exception", "\\", "LoggerConfigException", "(", "\"Config component provider must be registered before you can use the Logger component.\"", ")", ";", "}", "$", "config", "=", "$", "app", "[", "\"config.service\"", "]", ";", "if", "(", "$", "loggerName", "===", "\"\"", ")", "{", "$", "loggerName", "=", "$", "config", "[", "\"logger.defaultLogger\"", "]", ";", "}", "$", "logger", "=", "new", "MLogger", "(", "$", "loggerName", ")", ";", "foreach", "(", "$", "config", "[", "\"logger.loggerSettings\"", "]", "[", "$", "loggerName", "]", "as", "$", "type", "=>", "$", "settings", ")", "{", "// load propper handler and instantiate the Monolog\\Logger", "$", "handler", "=", "null", ";", "switch", "(", "$", "type", ")", "{", "case", "Helper", "::", "L_TYPE_FILE", ":", "$", "app", "[", "\"temp.logger.settings\"", "]", "=", "$", "settings", ";", "$", "handler", "=", "$", "app", "[", "\"logger.{$type}.service\"", "]", ";", "unset", "(", "$", "app", "[", "\"temp.logger.settings\"", "]", ")", ";", "break", ";", "default", ":", "throw", "new", "\\", "SlaxWeb", "\\", "Bootstrap", "\\", "Exception", "\\", "UnknownLoggerHandlerException", "(", "\"The handler you are tring to use is not known or not supported.\"", ")", ";", "}", "$", "logger", "->", "pushHandler", "(", "$", "handler", ")", ";", "}", "return", "$", "app", "[", "$", "cacheName", "]", "=", "$", "logger", ";", "}", ")", ";", "$", "app", "[", "\"logger.StreamHandler.service\"", "]", "=", "$", "app", "->", "factory", "(", "function", "(", "App", "$", "cont", ")", "{", "$", "settings", "=", "$", "cont", "[", "\"temp.logger.settings\"", "]", ";", "// if the log file name does not begin with a dir separator, treat", "// it as relative path and prepend 'logFilePath'", "if", "(", "$", "settings", "[", "0", "]", "[", "0", "]", "!==", "DIRECTORY_SEPARATOR", ")", "{", "$", "settings", "[", "0", "]", "=", "(", "$", "cont", "[", "\"config.service\"", "]", "[", "\"logger.logFilePath\"", "]", "??", "\"\"", ")", ".", "$", "settings", "[", "0", "]", ";", "}", "return", "new", "\\", "Monolog", "\\", "Handler", "\\", "StreamHandler", "(", "...", "$", "settings", ")", ";", "}", ")", ";", "}" ]
Register Logger Service Provider Method used by the DIC to register a new service provider. This Service Provider defines only the Logger service. @param \Pimple\Container $app Pimple Dependency Injection Container @return void
[ "Register", "Logger", "Service", "Provider" ]
5ec8ef40f357f2c75afa0ad99090a9d2f7021557
https://github.com/SlaxWeb/Bootstrap/blob/5ec8ef40f357f2c75afa0ad99090a9d2f7021557/src/Service/LoggerProvider.php#L32-L91
25,516
Wedeto/HTTP
src/Forms/FormField.php
FormField.setName
public function setName(string $name) { $this->name = $name; while (preg_match('/^(.*)\[([^\]]*)\]$/', $name, $matches) === 1) { if (empty($matches[2])) { if ($this->name_depth > 1) throw new \InvalidArgumentException("Invalid name: {$this->name}"); $this->is_array = true; } else array_unshift($this->name_parts, $matches[2]); $name = $matches[1]; ++$this->name_depth; } array_unshift($this->name_parts, $name); return $this; }
php
public function setName(string $name) { $this->name = $name; while (preg_match('/^(.*)\[([^\]]*)\]$/', $name, $matches) === 1) { if (empty($matches[2])) { if ($this->name_depth > 1) throw new \InvalidArgumentException("Invalid name: {$this->name}"); $this->is_array = true; } else array_unshift($this->name_parts, $matches[2]); $name = $matches[1]; ++$this->name_depth; } array_unshift($this->name_parts, $name); return $this; }
[ "public", "function", "setName", "(", "string", "$", "name", ")", "{", "$", "this", "->", "name", "=", "$", "name", ";", "while", "(", "preg_match", "(", "'/^(.*)\\[([^\\]]*)\\]$/'", ",", "$", "name", ",", "$", "matches", ")", "===", "1", ")", "{", "if", "(", "empty", "(", "$", "matches", "[", "2", "]", ")", ")", "{", "if", "(", "$", "this", "->", "name_depth", ">", "1", ")", "throw", "new", "\\", "InvalidArgumentException", "(", "\"Invalid name: {$this->name}\"", ")", ";", "$", "this", "->", "is_array", "=", "true", ";", "}", "else", "array_unshift", "(", "$", "this", "->", "name_parts", ",", "$", "matches", "[", "2", "]", ")", ";", "$", "name", "=", "$", "matches", "[", "1", "]", ";", "++", "$", "this", "->", "name_depth", ";", "}", "array_unshift", "(", "$", "this", "->", "name_parts", ",", "$", "name", ")", ";", "return", "$", "this", ";", "}" ]
Change the name of the field. @param string $name The name to set. If the name contains [] pairs, the field type will be set to array. @return FormField Provides fluent interface @throws InvalidArgumentException When an invalid names as used. An invalid name is a name with more than one empty array pair, like foo[][]
[ "Change", "the", "name", "of", "the", "field", "." ]
7318eff1b81a3c103c4263466d09b7f3593b70b9
https://github.com/Wedeto/HTTP/blob/7318eff1b81a3c103c4263466d09b7f3593b70b9/src/Forms/FormField.php#L99-L119
25,517
Wedeto/HTTP
src/Forms/FormField.php
FormField.addValidator
public function addValidator($validator) { if ($validator === FormField::TYPE_FILE) { $this->is_file = true; $validator = Type::RESOURCE; } if (!$validator instanceof Validator) { $validator = new Validator($validator, ['unstrict' => true]); } $this->validators[] = $validator; return $this; }
php
public function addValidator($validator) { if ($validator === FormField::TYPE_FILE) { $this->is_file = true; $validator = Type::RESOURCE; } if (!$validator instanceof Validator) { $validator = new Validator($validator, ['unstrict' => true]); } $this->validators[] = $validator; return $this; }
[ "public", "function", "addValidator", "(", "$", "validator", ")", "{", "if", "(", "$", "validator", "===", "FormField", "::", "TYPE_FILE", ")", "{", "$", "this", "->", "is_file", "=", "true", ";", "$", "validator", "=", "Type", "::", "RESOURCE", ";", "}", "if", "(", "!", "$", "validator", "instanceof", "Validator", ")", "{", "$", "validator", "=", "new", "Validator", "(", "$", "validator", ",", "[", "'unstrict'", "=>", "true", "]", ")", ";", "}", "$", "this", "->", "validators", "[", "]", "=", "$", "validator", ";", "return", "$", "this", ";", "}" ]
Change the type of the field @param Validator $validator The validator to add. Provide either one of the constants in Type, or a instantiated Validator. FormField::TYPE_FILE will be transparently converted to a file upload form field. @return FormField Provides fluent interface
[ "Change", "the", "type", "of", "the", "field" ]
7318eff1b81a3c103c4263466d09b7f3593b70b9
https://github.com/Wedeto/HTTP/blob/7318eff1b81a3c103c4263466d09b7f3593b70b9/src/Forms/FormField.php#L129-L144
25,518
Wedeto/HTTP
src/Forms/FormField.php
FormField.removeValidator
public function removeValidator(int $index) { $validators = $this->validators; unset($validators[$index]); $this->validators = array_values($validators); return $this; }
php
public function removeValidator(int $index) { $validators = $this->validators; unset($validators[$index]); $this->validators = array_values($validators); return $this; }
[ "public", "function", "removeValidator", "(", "int", "$", "index", ")", "{", "$", "validators", "=", "$", "this", "->", "validators", ";", "unset", "(", "$", "validators", "[", "$", "index", "]", ")", ";", "$", "this", "->", "validators", "=", "array_values", "(", "$", "validators", ")", ";", "return", "$", "this", ";", "}" ]
Remove a validator with a specific index @param int $index The index to remove @return FormField Provides fluent interface
[ "Remove", "a", "validator", "with", "a", "specific", "index" ]
7318eff1b81a3c103c4263466d09b7f3593b70b9
https://github.com/Wedeto/HTTP/blob/7318eff1b81a3c103c4263466d09b7f3593b70b9/src/Forms/FormField.php#L151-L157
25,519
Wedeto/HTTP
src/Forms/FormField.php
FormField.getErrors
public function getErrors() { if (!empty($this->fixed_error)) return count($this->errors) ? [$this->fixed_error] : []; return $this->errors; }
php
public function getErrors() { if (!empty($this->fixed_error)) return count($this->errors) ? [$this->fixed_error] : []; return $this->errors; }
[ "public", "function", "getErrors", "(", ")", "{", "if", "(", "!", "empty", "(", "$", "this", "->", "fixed_error", ")", ")", "return", "count", "(", "$", "this", "->", "errors", ")", "?", "[", "$", "this", "->", "fixed_error", "]", ":", "[", "]", ";", "return", "$", "this", "->", "errors", ";", "}" ]
Return the error messages produced during validation. Should be called after validation failed, otherwise an non-relevant or empty array will be returned. @return array List of errors. Empty when validation succeeded.
[ "Return", "the", "error", "messages", "produced", "during", "validation", ".", "Should", "be", "called", "after", "validation", "failed", "otherwise", "an", "non", "-", "relevant", "or", "empty", "array", "will", "be", "returned", "." ]
7318eff1b81a3c103c4263466d09b7f3593b70b9
https://github.com/Wedeto/HTTP/blob/7318eff1b81a3c103c4263466d09b7f3593b70b9/src/Forms/FormField.php#L279-L285
25,520
Wedeto/HTTP
src/Forms/FormField.php
FormField.setError
public function setError(array $msg) { if (!isset($msg['msg'])) throw new InvalidArgumentException("Error message does not contain msg key"); $this->errors = [$msg]; $this->fixed_error = $msg; return $this; }
php
public function setError(array $msg) { if (!isset($msg['msg'])) throw new InvalidArgumentException("Error message does not contain msg key"); $this->errors = [$msg]; $this->fixed_error = $msg; return $this; }
[ "public", "function", "setError", "(", "array", "$", "msg", ")", "{", "if", "(", "!", "isset", "(", "$", "msg", "[", "'msg'", "]", ")", ")", "throw", "new", "InvalidArgumentException", "(", "\"Error message does not contain msg key\"", ")", ";", "$", "this", "->", "errors", "=", "[", "$", "msg", "]", ";", "$", "this", "->", "fixed_error", "=", "$", "msg", ";", "return", "$", "this", ";", "}" ]
Set the form field with an error state. This will override the fixed error. @param array $msg The error message. Must contain a 'msg' key. @return FormField provides fluent interface
[ "Set", "the", "form", "field", "with", "an", "error", "state", ".", "This", "will", "override", "the", "fixed", "error", "." ]
7318eff1b81a3c103c4263466d09b7f3593b70b9
https://github.com/Wedeto/HTTP/blob/7318eff1b81a3c103c4263466d09b7f3593b70b9/src/Forms/FormField.php#L318-L326
25,521
Wedeto/HTTP
src/Forms/FormField.php
FormField.getValue
public function getValue(bool $transform = false) { if ($transform && $this->transformer !== null) return $this->transformer->serialize($this->value); return $this->value; }
php
public function getValue(bool $transform = false) { if ($transform && $this->transformer !== null) return $this->transformer->serialize($this->value); return $this->value; }
[ "public", "function", "getValue", "(", "bool", "$", "transform", "=", "false", ")", "{", "if", "(", "$", "transform", "&&", "$", "this", "->", "transformer", "!==", "null", ")", "return", "$", "this", "->", "transformer", "->", "serialize", "(", "$", "this", "->", "value", ")", ";", "return", "$", "this", "->", "value", ";", "}" ]
Returns the value, optionally HTML escaped @param bool $transform Set to true to run the transformer on the value, false to return the raw value. @return mixed The value for the item
[ "Returns", "the", "value", "optionally", "HTML", "escaped" ]
7318eff1b81a3c103c4263466d09b7f3593b70b9
https://github.com/Wedeto/HTTP/blob/7318eff1b81a3c103c4263466d09b7f3593b70b9/src/Forms/FormField.php#L424-L429
25,522
Wedeto/HTTP
src/Forms/FormField.php
FormField.setValue
public function setValue($value, bool $transform = false) { if (null === $value) $this->value = null; elseif ($transform && $this->transformer !== null) $this->value = $this->transformer->deserialize($value); else $this->value = $value; return $this; }
php
public function setValue($value, bool $transform = false) { if (null === $value) $this->value = null; elseif ($transform && $this->transformer !== null) $this->value = $this->transformer->deserialize($value); else $this->value = $value; return $this; }
[ "public", "function", "setValue", "(", "$", "value", ",", "bool", "$", "transform", "=", "false", ")", "{", "if", "(", "null", "===", "$", "value", ")", "$", "this", "->", "value", "=", "null", ";", "elseif", "(", "$", "transform", "&&", "$", "this", "->", "transformer", "!==", "null", ")", "$", "this", "->", "value", "=", "$", "this", "->", "transformer", "->", "deserialize", "(", "$", "value", ")", ";", "else", "$", "this", "->", "value", "=", "$", "value", ";", "return", "$", "this", ";", "}" ]
Change the value for this field. The value is not validated, this is just to be referred to later, for example for showing to the visitor @param mixed $value The value to set @param bool $transform Whether to run the transformer on it before setting @return FormField Provides fluent interface
[ "Change", "the", "value", "for", "this", "field", ".", "The", "value", "is", "not", "validated", "this", "is", "just", "to", "be", "referred", "to", "later", "for", "example", "for", "showing", "to", "the", "visitor" ]
7318eff1b81a3c103c4263466d09b7f3593b70b9
https://github.com/Wedeto/HTTP/blob/7318eff1b81a3c103c4263466d09b7f3593b70b9/src/Forms/FormField.php#L439-L449
25,523
Wedeto/HTTP
src/Forms/FormField.php
FormField.formatErrorMessage
public static function formatErrorMessage(array $error_message) { $msg = $error_message['msg'] ?? ""; $context = $error_message['context'] ?? []; if (class_exists("Wedeto\I18n\I18nShortcut")) { return t($msg, $context); } return WF::fillPlaceholders($msg, $context); }
php
public static function formatErrorMessage(array $error_message) { $msg = $error_message['msg'] ?? ""; $context = $error_message['context'] ?? []; if (class_exists("Wedeto\I18n\I18nShortcut")) { return t($msg, $context); } return WF::fillPlaceholders($msg, $context); }
[ "public", "static", "function", "formatErrorMessage", "(", "array", "$", "error_message", ")", "{", "$", "msg", "=", "$", "error_message", "[", "'msg'", "]", "??", "\"\"", ";", "$", "context", "=", "$", "error_message", "[", "'context'", "]", "??", "[", "]", ";", "if", "(", "class_exists", "(", "\"Wedeto\\I18n\\I18nShortcut\"", ")", ")", "{", "return", "t", "(", "$", "msg", ",", "$", "context", ")", ";", "}", "return", "WF", "::", "fillPlaceholders", "(", "$", "msg", ",", "$", "context", ")", ";", "}" ]
Format the error message into a single string @return string The formatted error message
[ "Format", "the", "error", "message", "into", "a", "single", "string" ]
7318eff1b81a3c103c4263466d09b7f3593b70b9
https://github.com/Wedeto/HTTP/blob/7318eff1b81a3c103c4263466d09b7f3593b70b9/src/Forms/FormField.php#L499-L509
25,524
onoi/callback-container
src/CallbackContainerBuilder.php
CallbackContainerBuilder.registerObject
public function registerObject( $serviceName, $instance ) { if ( !is_string( $serviceName ) ) { throw new InvalidParameterTypeException( "Expected a string" ); } if ( isset( $this->aliases[$serviceName] ) ) { throw new ServiceAliasMismatchException( $serviceName ); } unset( $this->singletons[$serviceName] ); $this->registry[$serviceName] = $instance; $this->singletons[$serviceName]['#'] = $instance; }
php
public function registerObject( $serviceName, $instance ) { if ( !is_string( $serviceName ) ) { throw new InvalidParameterTypeException( "Expected a string" ); } if ( isset( $this->aliases[$serviceName] ) ) { throw new ServiceAliasMismatchException( $serviceName ); } unset( $this->singletons[$serviceName] ); $this->registry[$serviceName] = $instance; $this->singletons[$serviceName]['#'] = $instance; }
[ "public", "function", "registerObject", "(", "$", "serviceName", ",", "$", "instance", ")", "{", "if", "(", "!", "is_string", "(", "$", "serviceName", ")", ")", "{", "throw", "new", "InvalidParameterTypeException", "(", "\"Expected a string\"", ")", ";", "}", "if", "(", "isset", "(", "$", "this", "->", "aliases", "[", "$", "serviceName", "]", ")", ")", "{", "throw", "new", "ServiceAliasMismatchException", "(", "$", "serviceName", ")", ";", "}", "unset", "(", "$", "this", "->", "singletons", "[", "$", "serviceName", "]", ")", ";", "$", "this", "->", "registry", "[", "$", "serviceName", "]", "=", "$", "instance", ";", "$", "this", "->", "singletons", "[", "$", "serviceName", "]", "[", "'#'", "]", "=", "$", "instance", ";", "}" ]
If you are not running PHPUnit or for that matter any other testing environment then you are not suppose to use this function. @since 2.0 {@inheritDoc}
[ "If", "you", "are", "not", "running", "PHPUnit", "or", "for", "that", "matter", "any", "other", "testing", "environment", "then", "you", "are", "not", "suppose", "to", "use", "this", "function", "." ]
70d2266c19b4bf0b4e78672fea340d8fdefb7500
https://github.com/onoi/callback-container/blob/70d2266c19b4bf0b4e78672fea340d8fdefb7500/src/CallbackContainerBuilder.php#L104-L118
25,525
jfadich/json-property
src/JsonPropertyTrait.php
JsonPropertyTrait.saveJsonString
public function saveJsonString($property, $jsonString) { $this->jsonManager()->isJsonProperty($property, true); $this->{$property} = $jsonString; }
php
public function saveJsonString($property, $jsonString) { $this->jsonManager()->isJsonProperty($property, true); $this->{$property} = $jsonString; }
[ "public", "function", "saveJsonString", "(", "$", "property", ",", "$", "jsonString", ")", "{", "$", "this", "->", "jsonManager", "(", ")", "->", "isJsonProperty", "(", "$", "property", ",", "true", ")", ";", "$", "this", "->", "{", "$", "property", "}", "=", "$", "jsonString", ";", "}" ]
Set the raw json string on the model @param string $property @param string $jsonString @throws JsonPropertyException
[ "Set", "the", "raw", "json", "string", "on", "the", "model" ]
3c11ac731a7bc206529058a94047eeafa5827b15
https://github.com/jfadich/json-property/blob/3c11ac731a7bc206529058a94047eeafa5827b15/src/JsonPropertyTrait.php#L34-L39
25,526
jfadich/json-property
src/JsonPropertyTrait.php
JsonPropertyTrait.jsonManager
private function jsonManager() { if($this->jsonManager === null) $this->jsonManager = new JsonManager($this, $this->jsonProperty); return $this->jsonManager; }
php
private function jsonManager() { if($this->jsonManager === null) $this->jsonManager = new JsonManager($this, $this->jsonProperty); return $this->jsonManager; }
[ "private", "function", "jsonManager", "(", ")", "{", "if", "(", "$", "this", "->", "jsonManager", "===", "null", ")", "$", "this", "->", "jsonManager", "=", "new", "JsonManager", "(", "$", "this", ",", "$", "this", "->", "jsonProperty", ")", ";", "return", "$", "this", "->", "jsonManager", ";", "}" ]
Get the JsonManager instance @return JsonManager
[ "Get", "the", "JsonManager", "instance" ]
3c11ac731a7bc206529058a94047eeafa5827b15
https://github.com/jfadich/json-property/blob/3c11ac731a7bc206529058a94047eeafa5827b15/src/JsonPropertyTrait.php#L64-L70
25,527
ekyna/PaymentBundle
Install/PaymentInstaller.php
PaymentInstaller.createImageFolder
private function createImageFolder() { $em = $this->container->get('ekyna_payment.method.manager'); $folderRepository = $this->container->get('ekyna_media.folder.repository'); if (null === $rootFolder = $folderRepository->findRoot()) { throw new \RuntimeException('Can\'t find root folder. Please run MediaBundle installer first.'); } $name = 'Payment method'; $paymentFolder = $folderRepository->findOneBy([ 'name' => $name, 'parent' => $rootFolder, ]); if (null !== $paymentFolder) { return $paymentFolder; } $paymentFolder = new Folder(); $paymentFolder ->setName($name) ->setParent($rootFolder) ; $em->persist($paymentFolder); $em->flush(); return $paymentFolder; }
php
private function createImageFolder() { $em = $this->container->get('ekyna_payment.method.manager'); $folderRepository = $this->container->get('ekyna_media.folder.repository'); if (null === $rootFolder = $folderRepository->findRoot()) { throw new \RuntimeException('Can\'t find root folder. Please run MediaBundle installer first.'); } $name = 'Payment method'; $paymentFolder = $folderRepository->findOneBy([ 'name' => $name, 'parent' => $rootFolder, ]); if (null !== $paymentFolder) { return $paymentFolder; } $paymentFolder = new Folder(); $paymentFolder ->setName($name) ->setParent($rootFolder) ; $em->persist($paymentFolder); $em->flush(); return $paymentFolder; }
[ "private", "function", "createImageFolder", "(", ")", "{", "$", "em", "=", "$", "this", "->", "container", "->", "get", "(", "'ekyna_payment.method.manager'", ")", ";", "$", "folderRepository", "=", "$", "this", "->", "container", "->", "get", "(", "'ekyna_media.folder.repository'", ")", ";", "if", "(", "null", "===", "$", "rootFolder", "=", "$", "folderRepository", "->", "findRoot", "(", ")", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "'Can\\'t find root folder. Please run MediaBundle installer first.'", ")", ";", "}", "$", "name", "=", "'Payment method'", ";", "$", "paymentFolder", "=", "$", "folderRepository", "->", "findOneBy", "(", "[", "'name'", "=>", "$", "name", ",", "'parent'", "=>", "$", "rootFolder", ",", "]", ")", ";", "if", "(", "null", "!==", "$", "paymentFolder", ")", "{", "return", "$", "paymentFolder", ";", "}", "$", "paymentFolder", "=", "new", "Folder", "(", ")", ";", "$", "paymentFolder", "->", "setName", "(", "$", "name", ")", "->", "setParent", "(", "$", "rootFolder", ")", ";", "$", "em", "->", "persist", "(", "$", "paymentFolder", ")", ";", "$", "em", "->", "flush", "(", ")", ";", "return", "$", "paymentFolder", ";", "}" ]
Creates the payment images folder. @return Folder
[ "Creates", "the", "payment", "images", "folder", "." ]
1b4f4103b28e3a4f8dbfac2cbd872d728238f4d1
https://github.com/ekyna/PaymentBundle/blob/1b4f4103b28e3a4f8dbfac2cbd872d728238f4d1/Install/PaymentInstaller.php#L52-L81
25,528
mglaman/toolstack-helper
src/Stacks/Drupal.php
Drupal.getMakefiles
public function getMakefiles($dir) { $finder = new Finder(); $finder->in($dir) ->files() ->depth('< 1') ->name('*.make*'); return $finder; }
php
public function getMakefiles($dir) { $finder = new Finder(); $finder->in($dir) ->files() ->depth('< 1') ->name('*.make*'); return $finder; }
[ "public", "function", "getMakefiles", "(", "$", "dir", ")", "{", "$", "finder", "=", "new", "Finder", "(", ")", ";", "$", "finder", "->", "in", "(", "$", "dir", ")", "->", "files", "(", ")", "->", "depth", "(", "'< 1'", ")", "->", "name", "(", "'*.make*'", ")", ";", "return", "$", "finder", ";", "}" ]
Return Finder with all makefiles in directory. @param $dir @return \Symfony\Component\Finder\Finder
[ "Return", "Finder", "with", "all", "makefiles", "in", "directory", "." ]
1b3b93ac284a6c77286988b5d41c75509dd3dc20
https://github.com/mglaman/toolstack-helper/blob/1b3b93ac284a6c77286988b5d41c75509dd3dc20/src/Stacks/Drupal.php#L41-L49
25,529
mglaman/toolstack-helper
src/Stacks/Drupal.php
Drupal.source
public function source($dir) { // Check if unbuilt Drupal foreach ($this->getMakefiles($dir) as $file) { $f = fopen($file, 'r'); $peek = fread($f, 1000); fclose($f); if (strpos($peek, 'api') !== FALSE && strpos($peek, 'core') !== FALSE) { return true; } } return false; }
php
public function source($dir) { // Check if unbuilt Drupal foreach ($this->getMakefiles($dir) as $file) { $f = fopen($file, 'r'); $peek = fread($f, 1000); fclose($f); if (strpos($peek, 'api') !== FALSE && strpos($peek, 'core') !== FALSE) { return true; } } return false; }
[ "public", "function", "source", "(", "$", "dir", ")", "{", "// Check if unbuilt Drupal", "foreach", "(", "$", "this", "->", "getMakefiles", "(", "$", "dir", ")", "as", "$", "file", ")", "{", "$", "f", "=", "fopen", "(", "$", "file", ",", "'r'", ")", ";", "$", "peek", "=", "fread", "(", "$", "f", ",", "1000", ")", ";", "fclose", "(", "$", "f", ")", ";", "if", "(", "strpos", "(", "$", "peek", ",", "'api'", ")", "!==", "FALSE", "&&", "strpos", "(", "$", "peek", ",", "'core'", ")", "!==", "FALSE", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Checks if Drupal project, but source. @param $dir @return bool
[ "Checks", "if", "Drupal", "project", "but", "source", "." ]
1b3b93ac284a6c77286988b5d41c75509dd3dc20
https://github.com/mglaman/toolstack-helper/blob/1b3b93ac284a6c77286988b5d41c75509dd3dc20/src/Stacks/Drupal.php#L58-L71
25,530
stubbles/stubbles-dbal
src/main/php/config/PropertyBasedDatabaseConfigurations.php
PropertyBasedDatabaseConfigurations.contain
public function contain(string $id): bool { if ($this->properties()->containSection($id)) { return true; } return $this->hasFallback(); }
php
public function contain(string $id): bool { if ($this->properties()->containSection($id)) { return true; } return $this->hasFallback(); }
[ "public", "function", "contain", "(", "string", "$", "id", ")", ":", "bool", "{", "if", "(", "$", "this", "->", "properties", "(", ")", "->", "containSection", "(", "$", "id", ")", ")", "{", "return", "true", ";", "}", "return", "$", "this", "->", "hasFallback", "(", ")", ";", "}" ]
checks whether database configuration for given id exists @param string $id @return bool
[ "checks", "whether", "database", "configuration", "for", "given", "id", "exists" ]
b42a589025a9e511b40a2798ac84df94d6451c36
https://github.com/stubbles/stubbles-dbal/blob/b42a589025a9e511b40a2798ac84df94d6451c36/src/main/php/config/PropertyBasedDatabaseConfigurations.php#L82-L89
25,531
stubbles/stubbles-dbal
src/main/php/config/PropertyBasedDatabaseConfigurations.php
PropertyBasedDatabaseConfigurations.get
public function get(string $id) { if (!$this->properties()->containSection($id)) { if (!$this->hasFallback()) { throw new \OutOfBoundsException('No database configuration known for database requested with id ' . $id); } $id = DatabaseConfiguration::DEFAULT_ID; } if (!$this->properties()->containValue($id, 'dsn')) { throw new \LogicException('Missing dsn property in database configuration with id ' . $id); } return DatabaseConfiguration::fromArray( $id, $this->properties()->value($id, 'dsn'), $this->properties()->section($id) ); }
php
public function get(string $id) { if (!$this->properties()->containSection($id)) { if (!$this->hasFallback()) { throw new \OutOfBoundsException('No database configuration known for database requested with id ' . $id); } $id = DatabaseConfiguration::DEFAULT_ID; } if (!$this->properties()->containValue($id, 'dsn')) { throw new \LogicException('Missing dsn property in database configuration with id ' . $id); } return DatabaseConfiguration::fromArray( $id, $this->properties()->value($id, 'dsn'), $this->properties()->section($id) ); }
[ "public", "function", "get", "(", "string", "$", "id", ")", "{", "if", "(", "!", "$", "this", "->", "properties", "(", ")", "->", "containSection", "(", "$", "id", ")", ")", "{", "if", "(", "!", "$", "this", "->", "hasFallback", "(", ")", ")", "{", "throw", "new", "\\", "OutOfBoundsException", "(", "'No database configuration known for database requested with id '", ".", "$", "id", ")", ";", "}", "$", "id", "=", "DatabaseConfiguration", "::", "DEFAULT_ID", ";", "}", "if", "(", "!", "$", "this", "->", "properties", "(", ")", "->", "containValue", "(", "$", "id", ",", "'dsn'", ")", ")", "{", "throw", "new", "\\", "LogicException", "(", "'Missing dsn property in database configuration with id '", ".", "$", "id", ")", ";", "}", "return", "DatabaseConfiguration", "::", "fromArray", "(", "$", "id", ",", "$", "this", "->", "properties", "(", ")", "->", "value", "(", "$", "id", ",", "'dsn'", ")", ",", "$", "this", "->", "properties", "(", ")", "->", "section", "(", "$", "id", ")", ")", ";", "}" ]
returns database configuration with given id @param string $id @return \stubbles\db\config\DatabaseConfiguration @throws \OutOfBoundsException in case no configuration for given id is found and fallback is disabled @throws \LogicException in case the found configuration misses the dsn property
[ "returns", "database", "configuration", "with", "given", "id" ]
b42a589025a9e511b40a2798ac84df94d6451c36
https://github.com/stubbles/stubbles-dbal/blob/b42a589025a9e511b40a2798ac84df94d6451c36/src/main/php/config/PropertyBasedDatabaseConfigurations.php#L99-L118
25,532
stubbles/stubbles-dbal
src/main/php/config/PropertyBasedDatabaseConfigurations.php
PropertyBasedDatabaseConfigurations.properties
protected function properties(): Properties { if (null === $this->dbProperties) { $this->dbProperties = Properties::fromFile($this->configPath . '/' . $this->descriptor . '.ini'); } return $this->dbProperties; }
php
protected function properties(): Properties { if (null === $this->dbProperties) { $this->dbProperties = Properties::fromFile($this->configPath . '/' . $this->descriptor . '.ini'); } return $this->dbProperties; }
[ "protected", "function", "properties", "(", ")", ":", "Properties", "{", "if", "(", "null", "===", "$", "this", "->", "dbProperties", ")", "{", "$", "this", "->", "dbProperties", "=", "Properties", "::", "fromFile", "(", "$", "this", "->", "configPath", ".", "'/'", ".", "$", "this", "->", "descriptor", ".", "'.ini'", ")", ";", "}", "return", "$", "this", "->", "dbProperties", ";", "}" ]
reads properties if not done yet @return \stubbles\values\Properties
[ "reads", "properties", "if", "not", "done", "yet" ]
b42a589025a9e511b40a2798ac84df94d6451c36
https://github.com/stubbles/stubbles-dbal/blob/b42a589025a9e511b40a2798ac84df94d6451c36/src/main/php/config/PropertyBasedDatabaseConfigurations.php#L125-L132
25,533
SagittariusX/Beluga.IO
src/Beluga/IO/Path.php
Path.RemoveWorkingDir
public static function RemoveWorkingDir( string $path = null ) : string { if ( \is_null( $path ) ) { return ''; } $wd = '~^' . \preg_quote( static::Unixize( \getcwd() ) . '/' ) . '~'; return \preg_replace( $wd, '', static::Unixize( $path ) ); }
php
public static function RemoveWorkingDir( string $path = null ) : string { if ( \is_null( $path ) ) { return ''; } $wd = '~^' . \preg_quote( static::Unixize( \getcwd() ) . '/' ) . '~'; return \preg_replace( $wd, '', static::Unixize( $path ) ); }
[ "public", "static", "function", "RemoveWorkingDir", "(", "string", "$", "path", "=", "null", ")", ":", "string", "{", "if", "(", "\\", "is_null", "(", "$", "path", ")", ")", "{", "return", "''", ";", "}", "$", "wd", "=", "'~^'", ".", "\\", "preg_quote", "(", "static", "::", "Unixize", "(", "\\", "getcwd", "(", ")", ")", ".", "'/'", ")", ".", "'~'", ";", "return", "\\", "preg_replace", "(", "$", "wd", ",", "''", ",", "static", "::", "Unixize", "(", "$", "path", ")", ")", ";", "}" ]
Removes the current working directory from defined path, if it starts with it. @param string $path @return string
[ "Removes", "the", "current", "working", "directory", "from", "defined", "path", "if", "it", "starts", "with", "it", "." ]
c8af09a1b3cc8a955e43c89b70779d11b30ae29e
https://github.com/SagittariusX/Beluga.IO/blob/c8af09a1b3cc8a955e43c89b70779d11b30ae29e/src/Beluga/IO/Path.php#L172-L184
25,534
TiMESPLiNTER/tsFramework
src/ch/timesplinter/core/ErrorHandler.php
ErrorHandler.handlePHPError
public function handlePHPError($error_number, $error, $error_file, $error_line) { // respect the current error_reporting setting if((error_reporting() & $error_number) === 0) return; throw new PHPException($error_number, $error, $error_file, $error_line); }
php
public function handlePHPError($error_number, $error, $error_file, $error_line) { // respect the current error_reporting setting if((error_reporting() & $error_number) === 0) return; throw new PHPException($error_number, $error, $error_file, $error_line); }
[ "public", "function", "handlePHPError", "(", "$", "error_number", ",", "$", "error", ",", "$", "error_file", ",", "$", "error_line", ")", "{", "// respect the current error_reporting setting", "if", "(", "(", "error_reporting", "(", ")", "&", "$", "error_number", ")", "===", "0", ")", "return", ";", "throw", "new", "PHPException", "(", "$", "error_number", ",", "$", "error", ",", "$", "error_file", ",", "$", "error_line", ")", ";", "}" ]
Catches all the PHP errors and convert them into a PHP exception @param int $error_number @param string $error @param string $error_file @param int $error_line @throws PHPException
[ "Catches", "all", "the", "PHP", "errors", "and", "convert", "them", "into", "a", "PHP", "exception" ]
b3b9fd98f6d456a9e571015877ecca203786fd0c
https://github.com/TiMESPLiNTER/tsFramework/blob/b3b9fd98f6d456a9e571015877ecca203786fd0c/src/ch/timesplinter/core/ErrorHandler.php#L34-L41
25,535
TiMESPLiNTER/tsFramework
src/ch/timesplinter/core/ErrorHandler.php
ErrorHandler.handleException
public function handleException(\Exception $e) { $environment = $this->core->getCurrentDomain()->environment; if(isset($this->core->getSettings()->errorhandling->controller->$environment) === true) { $controller = FrameworkUtils::stringToClassName($this->core->getSettings()->errorhandling->controller->$environment); $pc = new $controller->className($this->core, $this->core->getHttpRequest(), new Route()); $httpResponse = call_user_func(array($pc, $controller->methodName), $e); } else { $content = null; $httpErrorCode = ($e instanceof HttpException)?$e->getCode():500; $exceptionStr = null; if($this->core->getSettings()->core->environments->$environment->debug === true) { $exceptionStr = "\n<pre>"; $exceptionStr .= '<b>Uncaught exception' . "\n" . '==================</b>' . "\n"; $exceptionStr .= 'Type: ' . get_class($e) . "\n"; $exceptionStr .= 'Message: ' . $e->getMessage() . ' (Code: ' . $e->getCode() . ')' . "\n"; $exceptionStr .= 'Thrown in: ' . $e->getFile() . ' (Line: ' . $e->getLine() . ")\n\n"; $exceptionStr .= $e->getTraceAsString(); $exceptionStr .= '</pre>'; } $errorStr = $httpErrorCode . ' ' . HttpResponse::getHttpStatusString($httpErrorCode); $content = "<!doctype html>\n<html>\n<head>\n<title>" . $errorStr . "</title>\n</head>\n<body>\n<h1>" . $errorStr . "</h1>" . $exceptionStr . "\n</body>\n</html>"; $httpResponse = new HttpResponse($httpErrorCode, $content); } $httpResponse->send(); exit; }
php
public function handleException(\Exception $e) { $environment = $this->core->getCurrentDomain()->environment; if(isset($this->core->getSettings()->errorhandling->controller->$environment) === true) { $controller = FrameworkUtils::stringToClassName($this->core->getSettings()->errorhandling->controller->$environment); $pc = new $controller->className($this->core, $this->core->getHttpRequest(), new Route()); $httpResponse = call_user_func(array($pc, $controller->methodName), $e); } else { $content = null; $httpErrorCode = ($e instanceof HttpException)?$e->getCode():500; $exceptionStr = null; if($this->core->getSettings()->core->environments->$environment->debug === true) { $exceptionStr = "\n<pre>"; $exceptionStr .= '<b>Uncaught exception' . "\n" . '==================</b>' . "\n"; $exceptionStr .= 'Type: ' . get_class($e) . "\n"; $exceptionStr .= 'Message: ' . $e->getMessage() . ' (Code: ' . $e->getCode() . ')' . "\n"; $exceptionStr .= 'Thrown in: ' . $e->getFile() . ' (Line: ' . $e->getLine() . ")\n\n"; $exceptionStr .= $e->getTraceAsString(); $exceptionStr .= '</pre>'; } $errorStr = $httpErrorCode . ' ' . HttpResponse::getHttpStatusString($httpErrorCode); $content = "<!doctype html>\n<html>\n<head>\n<title>" . $errorStr . "</title>\n</head>\n<body>\n<h1>" . $errorStr . "</h1>" . $exceptionStr . "\n</body>\n</html>"; $httpResponse = new HttpResponse($httpErrorCode, $content); } $httpResponse->send(); exit; }
[ "public", "function", "handleException", "(", "\\", "Exception", "$", "e", ")", "{", "$", "environment", "=", "$", "this", "->", "core", "->", "getCurrentDomain", "(", ")", "->", "environment", ";", "if", "(", "isset", "(", "$", "this", "->", "core", "->", "getSettings", "(", ")", "->", "errorhandling", "->", "controller", "->", "$", "environment", ")", "===", "true", ")", "{", "$", "controller", "=", "FrameworkUtils", "::", "stringToClassName", "(", "$", "this", "->", "core", "->", "getSettings", "(", ")", "->", "errorhandling", "->", "controller", "->", "$", "environment", ")", ";", "$", "pc", "=", "new", "$", "controller", "->", "className", "(", "$", "this", "->", "core", ",", "$", "this", "->", "core", "->", "getHttpRequest", "(", ")", ",", "new", "Route", "(", ")", ")", ";", "$", "httpResponse", "=", "call_user_func", "(", "array", "(", "$", "pc", ",", "$", "controller", "->", "methodName", ")", ",", "$", "e", ")", ";", "}", "else", "{", "$", "content", "=", "null", ";", "$", "httpErrorCode", "=", "(", "$", "e", "instanceof", "HttpException", ")", "?", "$", "e", "->", "getCode", "(", ")", ":", "500", ";", "$", "exceptionStr", "=", "null", ";", "if", "(", "$", "this", "->", "core", "->", "getSettings", "(", ")", "->", "core", "->", "environments", "->", "$", "environment", "->", "debug", "===", "true", ")", "{", "$", "exceptionStr", "=", "\"\\n<pre>\"", ";", "$", "exceptionStr", ".=", "'<b>Uncaught exception'", ".", "\"\\n\"", ".", "'==================</b>'", ".", "\"\\n\"", ";", "$", "exceptionStr", ".=", "'Type: '", ".", "get_class", "(", "$", "e", ")", ".", "\"\\n\"", ";", "$", "exceptionStr", ".=", "'Message: '", ".", "$", "e", "->", "getMessage", "(", ")", ".", "' (Code: '", ".", "$", "e", "->", "getCode", "(", ")", ".", "')'", ".", "\"\\n\"", ";", "$", "exceptionStr", ".=", "'Thrown in: '", ".", "$", "e", "->", "getFile", "(", ")", ".", "' (Line: '", ".", "$", "e", "->", "getLine", "(", ")", ".", "\")\\n\\n\"", ";", "$", "exceptionStr", ".=", "$", "e", "->", "getTraceAsString", "(", ")", ";", "$", "exceptionStr", ".=", "'</pre>'", ";", "}", "$", "errorStr", "=", "$", "httpErrorCode", ".", "' '", ".", "HttpResponse", "::", "getHttpStatusString", "(", "$", "httpErrorCode", ")", ";", "$", "content", "=", "\"<!doctype html>\\n<html>\\n<head>\\n<title>\"", ".", "$", "errorStr", ".", "\"</title>\\n</head>\\n<body>\\n<h1>\"", ".", "$", "errorStr", ".", "\"</h1>\"", ".", "$", "exceptionStr", ".", "\"\\n</body>\\n</html>\"", ";", "$", "httpResponse", "=", "new", "HttpResponse", "(", "$", "httpErrorCode", ",", "$", "content", ")", ";", "}", "$", "httpResponse", "->", "send", "(", ")", ";", "exit", ";", "}" ]
Default stub for print an exception @param \Exception $e
[ "Default", "stub", "for", "print", "an", "exception" ]
b3b9fd98f6d456a9e571015877ecca203786fd0c
https://github.com/TiMESPLiNTER/tsFramework/blob/b3b9fd98f6d456a9e571015877ecca203786fd0c/src/ch/timesplinter/core/ErrorHandler.php#L48-L86
25,536
buildok/validator
src/types/StringValidator.php
StringValidator.maxLength
private function maxLength() { $max = mb_strlen($this->value); if (!$ret = $max <= $this->options->max) { $this->error(1); } return $ret; }
php
private function maxLength() { $max = mb_strlen($this->value); if (!$ret = $max <= $this->options->max) { $this->error(1); } return $ret; }
[ "private", "function", "maxLength", "(", ")", "{", "$", "max", "=", "mb_strlen", "(", "$", "this", "->", "value", ")", ";", "if", "(", "!", "$", "ret", "=", "$", "max", "<=", "$", "this", "->", "options", "->", "max", ")", "{", "$", "this", "->", "error", "(", "1", ")", ";", "}", "return", "$", "ret", ";", "}" ]
Check max length @return boolean
[ "Check", "max", "length" ]
3612ebca7901c84be2f26f641470933e468a0811
https://github.com/buildok/validator/blob/3612ebca7901c84be2f26f641470933e468a0811/src/types/StringValidator.php#L42-L50
25,537
buildok/validator
src/types/StringValidator.php
StringValidator.minLength
private function minLength() { $min = mb_strlen($this->value); if (!$ret = $min >= $this->options->min) { $this->error(2); } return $ret; }
php
private function minLength() { $min = mb_strlen($this->value); if (!$ret = $min >= $this->options->min) { $this->error(2); } return $ret; }
[ "private", "function", "minLength", "(", ")", "{", "$", "min", "=", "mb_strlen", "(", "$", "this", "->", "value", ")", ";", "if", "(", "!", "$", "ret", "=", "$", "min", ">=", "$", "this", "->", "options", "->", "min", ")", "{", "$", "this", "->", "error", "(", "2", ")", ";", "}", "return", "$", "ret", ";", "}" ]
Check min length @return boolean
[ "Check", "min", "length" ]
3612ebca7901c84be2f26f641470933e468a0811
https://github.com/buildok/validator/blob/3612ebca7901c84be2f26f641470933e468a0811/src/types/StringValidator.php#L56-L64
25,538
Wedeto/Util
src/DI/DefaultFactory.php
DefaultFactory.determineArgumentsFor
protected function determineArgumentsFor( ReflectionMethod $method, string $class, string $method_name, array $args, string $selector, Injector $injector ) { $params = $method->getParameters(); $method_args = []; // Determine values for each parameter $used_optional = false; foreach ($params as $param) { $name = $param->getName(); if (array_key_exists($name, $args)) { $method_args[] = $args[$name]; continue; } $pclass = $param->getClass(); if (null !== $pclass) { $instance = $injector->getInstance($pclass->getName(), $selector); $method_args[] = $instance; continue; } if ($param->isDefaultValueAvailable()) { $default = $param->getDefaultValue(); $method_args[] = $default; continue; } if ($param->isOptional()) { // This and all remaining parameters have a default value break; } throw new DIException("Unable to determine value for parameter $name for $method_name of '$class'"); } // There should be a argument for every parameter return $method_args; }
php
protected function determineArgumentsFor( ReflectionMethod $method, string $class, string $method_name, array $args, string $selector, Injector $injector ) { $params = $method->getParameters(); $method_args = []; // Determine values for each parameter $used_optional = false; foreach ($params as $param) { $name = $param->getName(); if (array_key_exists($name, $args)) { $method_args[] = $args[$name]; continue; } $pclass = $param->getClass(); if (null !== $pclass) { $instance = $injector->getInstance($pclass->getName(), $selector); $method_args[] = $instance; continue; } if ($param->isDefaultValueAvailable()) { $default = $param->getDefaultValue(); $method_args[] = $default; continue; } if ($param->isOptional()) { // This and all remaining parameters have a default value break; } throw new DIException("Unable to determine value for parameter $name for $method_name of '$class'"); } // There should be a argument for every parameter return $method_args; }
[ "protected", "function", "determineArgumentsFor", "(", "ReflectionMethod", "$", "method", ",", "string", "$", "class", ",", "string", "$", "method_name", ",", "array", "$", "args", ",", "string", "$", "selector", ",", "Injector", "$", "injector", ")", "{", "$", "params", "=", "$", "method", "->", "getParameters", "(", ")", ";", "$", "method_args", "=", "[", "]", ";", "// Determine values for each parameter", "$", "used_optional", "=", "false", ";", "foreach", "(", "$", "params", "as", "$", "param", ")", "{", "$", "name", "=", "$", "param", "->", "getName", "(", ")", ";", "if", "(", "array_key_exists", "(", "$", "name", ",", "$", "args", ")", ")", "{", "$", "method_args", "[", "]", "=", "$", "args", "[", "$", "name", "]", ";", "continue", ";", "}", "$", "pclass", "=", "$", "param", "->", "getClass", "(", ")", ";", "if", "(", "null", "!==", "$", "pclass", ")", "{", "$", "instance", "=", "$", "injector", "->", "getInstance", "(", "$", "pclass", "->", "getName", "(", ")", ",", "$", "selector", ")", ";", "$", "method_args", "[", "]", "=", "$", "instance", ";", "continue", ";", "}", "if", "(", "$", "param", "->", "isDefaultValueAvailable", "(", ")", ")", "{", "$", "default", "=", "$", "param", "->", "getDefaultValue", "(", ")", ";", "$", "method_args", "[", "]", "=", "$", "default", ";", "continue", ";", "}", "if", "(", "$", "param", "->", "isOptional", "(", ")", ")", "{", "// This and all remaining parameters have a default value", "break", ";", "}", "throw", "new", "DIException", "(", "\"Unable to determine value for parameter $name for $method_name of '$class'\"", ")", ";", "}", "// There should be a argument for every parameter", "return", "$", "method_args", ";", "}" ]
Find arguments for a method
[ "Find", "arguments", "for", "a", "method" ]
0e080251bbaa8e7d91ae8d02eb79c029c976744a
https://github.com/Wedeto/Util/blob/0e080251bbaa8e7d91ae8d02eb79c029c976744a/src/DI/DefaultFactory.php#L115-L165
25,539
squareproton/Bond
src/Bond/Database/Enum.php
Enum.getValues
public function getValues( $name ) { if( !isset( $this->enums[$name] ) ) { throw new UnknownEnumException($name); } return $this->enums[$name]; }
php
public function getValues( $name ) { if( !isset( $this->enums[$name] ) ) { throw new UnknownEnumException($name); } return $this->enums[$name]; }
[ "public", "function", "getValues", "(", "$", "name", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "enums", "[", "$", "name", "]", ")", ")", "{", "throw", "new", "UnknownEnumException", "(", "$", "name", ")", ";", "}", "return", "$", "this", "->", "enums", "[", "$", "name", "]", ";", "}" ]
Public accessor for enum options @param string @return array Allowed values
[ "Public", "accessor", "for", "enum", "options" ]
a04ad9dd1a35adeaec98237716c2a41ce02b4f1a
https://github.com/squareproton/Bond/blob/a04ad9dd1a35adeaec98237716c2a41ce02b4f1a/src/Bond/Database/Enum.php#L36-L42
25,540
squareproton/Bond
src/Bond/Database/Enum.php
Enum.isValid
public function isValid( $name, $value = null ) { if( !isset( $this->enums[$name] ) ) { return false; } elseif( $value === null ) { return true; } return !isset( $value ) || in_array( $value, $this->enums[$name] ); }
php
public function isValid( $name, $value = null ) { if( !isset( $this->enums[$name] ) ) { return false; } elseif( $value === null ) { return true; } return !isset( $value ) || in_array( $value, $this->enums[$name] ); }
[ "public", "function", "isValid", "(", "$", "name", ",", "$", "value", "=", "null", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "enums", "[", "$", "name", "]", ")", ")", "{", "return", "false", ";", "}", "elseif", "(", "$", "value", "===", "null", ")", "{", "return", "true", ";", "}", "return", "!", "isset", "(", "$", "value", ")", "||", "in_array", "(", "$", "value", ",", "$", "this", "->", "enums", "[", "$", "name", "]", ")", ";", "}" ]
Is valid check @param string enum name @param string value @return bool
[ "Is", "valid", "check" ]
a04ad9dd1a35adeaec98237716c2a41ce02b4f1a
https://github.com/squareproton/Bond/blob/a04ad9dd1a35adeaec98237716c2a41ce02b4f1a/src/Bond/Database/Enum.php#L60-L68
25,541
squareproton/Bond
src/Bond/Database/Enum.php
Enum.getRandomValue
public function getRandomValue( $name ) { if( !isset( $this->enums[$name] ) ) { throw new UnknownEnumException($name); } return $this->enums[$name][array_rand($this->enums[$name])]; }
php
public function getRandomValue( $name ) { if( !isset( $this->enums[$name] ) ) { throw new UnknownEnumException($name); } return $this->enums[$name][array_rand($this->enums[$name])]; }
[ "public", "function", "getRandomValue", "(", "$", "name", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "enums", "[", "$", "name", "]", ")", ")", "{", "throw", "new", "UnknownEnumException", "(", "$", "name", ")", ";", "}", "return", "$", "this", "->", "enums", "[", "$", "name", "]", "[", "array_rand", "(", "$", "this", "->", "enums", "[", "$", "name", "]", ")", "]", ";", "}" ]
Get a random value from a enum. Primarily used by the import script @return string
[ "Get", "a", "random", "value", "from", "a", "enum", ".", "Primarily", "used", "by", "the", "import", "script" ]
a04ad9dd1a35adeaec98237716c2a41ce02b4f1a
https://github.com/squareproton/Bond/blob/a04ad9dd1a35adeaec98237716c2a41ce02b4f1a/src/Bond/Database/Enum.php#L74-L80
25,542
eureka-framework/component-http
src/Http/Message/ResponseSender.php
ResponseSender.writeStatus
private function writeStatus() { $string = $this->response->getProtocolVersion() . ' ' . $this->response->getStatusCode() . ' ' . $this->response->getReasonPhrase(); header($string, true, $this->response->getStatusCode()); }
php
private function writeStatus() { $string = $this->response->getProtocolVersion() . ' ' . $this->response->getStatusCode() . ' ' . $this->response->getReasonPhrase(); header($string, true, $this->response->getStatusCode()); }
[ "private", "function", "writeStatus", "(", ")", "{", "$", "string", "=", "$", "this", "->", "response", "->", "getProtocolVersion", "(", ")", ".", "' '", ".", "$", "this", "->", "response", "->", "getStatusCode", "(", ")", ".", "' '", ".", "$", "this", "->", "response", "->", "getReasonPhrase", "(", ")", ";", "header", "(", "$", "string", ",", "true", ",", "$", "this", "->", "response", "->", "getStatusCode", "(", ")", ")", ";", "}" ]
Write response status @return void
[ "Write", "response", "status" ]
698c3b73581a9703a9c932890c57e50f8774607a
https://github.com/eureka-framework/component-http/blob/698c3b73581a9703a9c932890c57e50f8774607a/src/Http/Message/ResponseSender.php#L51-L55
25,543
eureka-framework/component-http
src/Http/Message/ResponseSender.php
ResponseSender.writeHeaders
private function writeHeaders() { $headers = $this->response->getHeaders(); foreach ($headers as $name => $list) { header("$name: " . implode(', ', $list)); } }
php
private function writeHeaders() { $headers = $this->response->getHeaders(); foreach ($headers as $name => $list) { header("$name: " . implode(', ', $list)); } }
[ "private", "function", "writeHeaders", "(", ")", "{", "$", "headers", "=", "$", "this", "->", "response", "->", "getHeaders", "(", ")", ";", "foreach", "(", "$", "headers", "as", "$", "name", "=>", "$", "list", ")", "{", "header", "(", "\"$name: \"", ".", "implode", "(", "', '", ",", "$", "list", ")", ")", ";", "}", "}" ]
Write headers. @return void
[ "Write", "headers", "." ]
698c3b73581a9703a9c932890c57e50f8774607a
https://github.com/eureka-framework/component-http/blob/698c3b73581a9703a9c932890c57e50f8774607a/src/Http/Message/ResponseSender.php#L62-L68
25,544
flextype-components/notification
Notification.php
Notification.get
public static function get(string $key) { return isset(Notification::$notifications[$key]) ? Notification::$notifications[$key] : null; }
php
public static function get(string $key) { return isset(Notification::$notifications[$key]) ? Notification::$notifications[$key] : null; }
[ "public", "static", "function", "get", "(", "string", "$", "key", ")", "{", "return", "isset", "(", "Notification", "::", "$", "notifications", "[", "$", "key", "]", ")", "?", "Notification", "::", "$", "notifications", "[", "$", "key", "]", ":", "null", ";", "}" ]
Returns a specific variable from the Notifications array. echo Notification::get('success'); echo Notification::get('errors'); @param string $key Variable name @return mixed
[ "Returns", "a", "specific", "variable", "from", "the", "Notifications", "array", "." ]
5a813df5a455a06efab672ae19ca1ce106584c16
https://github.com/flextype-components/notification/blob/5a813df5a455a06efab672ae19ca1ce106584c16/Notification.php#L40-L43
25,545
flextype-components/notification
Notification.php
Notification.set
public static function set(string $key, $value) : void { $_SESSION[Notification::SESSION_KEY][$key] = $value; }
php
public static function set(string $key, $value) : void { $_SESSION[Notification::SESSION_KEY][$key] = $value; }
[ "public", "static", "function", "set", "(", "string", "$", "key", ",", "$", "value", ")", ":", "void", "{", "$", "_SESSION", "[", "Notification", "::", "SESSION_KEY", "]", "[", "$", "key", "]", "=", "$", "value", ";", "}" ]
Adds specific variable to the Notifications array. Notification::set('success', 'Data has been saved with success!'); Notification::set('errors', 'Data not saved!'); @param string $key Variable name @param mixed $value Variable value
[ "Adds", "specific", "variable", "to", "the", "Notifications", "array", "." ]
5a813df5a455a06efab672ae19ca1ce106584c16
https://github.com/flextype-components/notification/blob/5a813df5a455a06efab672ae19ca1ce106584c16/Notification.php#L54-L57
25,546
flextype-components/notification
Notification.php
Notification.init
public static function init() : void { if ( ! empty($_SESSION[Notification::SESSION_KEY]) && is_array($_SESSION[Notification::SESSION_KEY])) { Notification::$notifications = $_SESSION[Notification::SESSION_KEY]; } $_SESSION[Notification::SESSION_KEY] = []; }
php
public static function init() : void { if ( ! empty($_SESSION[Notification::SESSION_KEY]) && is_array($_SESSION[Notification::SESSION_KEY])) { Notification::$notifications = $_SESSION[Notification::SESSION_KEY]; } $_SESSION[Notification::SESSION_KEY] = []; }
[ "public", "static", "function", "init", "(", ")", ":", "void", "{", "if", "(", "!", "empty", "(", "$", "_SESSION", "[", "Notification", "::", "SESSION_KEY", "]", ")", "&&", "is_array", "(", "$", "_SESSION", "[", "Notification", "::", "SESSION_KEY", "]", ")", ")", "{", "Notification", "::", "$", "notifications", "=", "$", "_SESSION", "[", "Notification", "::", "SESSION_KEY", "]", ";", "}", "$", "_SESSION", "[", "Notification", "::", "SESSION_KEY", "]", "=", "[", "]", ";", "}" ]
Initializes the Notification service. Notification::init(); This will read notification/flash data from the $_SESSION variable and load it into the $this->previous array.
[ "Initializes", "the", "Notification", "service", "." ]
5a813df5a455a06efab672ae19ca1ce106584c16
https://github.com/flextype-components/notification/blob/5a813df5a455a06efab672ae19ca1ce106584c16/Notification.php#L93-L100
25,547
mpf-soft/admin-widgets
datatable/columns/actions/Basic.php
Basic.getString
public function getString($row, Table $table) { if (!$this->isVisible($row)) { return ""; } $options = $this->htmlOptions; if ($this->title != "") { eval("\$options['title'] = {$this->title};"); } elseif (!isset($options['title'])) { $options['title'] = ''; } if ($this->confirmation && (!$this->post)) { if ($this->jsAction) { $options['onclick'] = "if (confirm('{$this->confirmation}')) {$this->jsAction}({$row->{$this->dataProvider->getPkKey()}}, '{$this->name}', this);"; } else { $options['onclick'] = "return confirm('{$this->confirmation}');"; } } elseif ($this->jsAction) { $options['onclick'] = "return {$this->jsAction}({$row->id}, '{$this->name}', this);"; } if ('#' != $this->url) { eval("\$url = {$this->url};"); } else { $url = '#'; } if (false !== $this->post && is_array($this->post)) { $options['class'] = isset($options['class']) ? $options['class'] . ' mdata-table-post-link' : 'mdata-table-post-link'; $parsed = array(); foreach ($this->post as $name=>$value){ eval('$value = '. $value.';'); if ('{{modelKey}}' == $name){ $name = $table->dataProvider->filtersKey; } $parsed[$name] = $value; } $options['post-data'] = json_encode($parsed); if ($this->confirmation){ $options['post-confirmation'] = $this->confirmation; } } $icon = $this->getIcon($options['title'], $table); return Html::get()->link($url, $icon . $this->label, $options); }
php
public function getString($row, Table $table) { if (!$this->isVisible($row)) { return ""; } $options = $this->htmlOptions; if ($this->title != "") { eval("\$options['title'] = {$this->title};"); } elseif (!isset($options['title'])) { $options['title'] = ''; } if ($this->confirmation && (!$this->post)) { if ($this->jsAction) { $options['onclick'] = "if (confirm('{$this->confirmation}')) {$this->jsAction}({$row->{$this->dataProvider->getPkKey()}}, '{$this->name}', this);"; } else { $options['onclick'] = "return confirm('{$this->confirmation}');"; } } elseif ($this->jsAction) { $options['onclick'] = "return {$this->jsAction}({$row->id}, '{$this->name}', this);"; } if ('#' != $this->url) { eval("\$url = {$this->url};"); } else { $url = '#'; } if (false !== $this->post && is_array($this->post)) { $options['class'] = isset($options['class']) ? $options['class'] . ' mdata-table-post-link' : 'mdata-table-post-link'; $parsed = array(); foreach ($this->post as $name=>$value){ eval('$value = '. $value.';'); if ('{{modelKey}}' == $name){ $name = $table->dataProvider->filtersKey; } $parsed[$name] = $value; } $options['post-data'] = json_encode($parsed); if ($this->confirmation){ $options['post-confirmation'] = $this->confirmation; } } $icon = $this->getIcon($options['title'], $table); return Html::get()->link($url, $icon . $this->label, $options); }
[ "public", "function", "getString", "(", "$", "row", ",", "Table", "$", "table", ")", "{", "if", "(", "!", "$", "this", "->", "isVisible", "(", "$", "row", ")", ")", "{", "return", "\"\"", ";", "}", "$", "options", "=", "$", "this", "->", "htmlOptions", ";", "if", "(", "$", "this", "->", "title", "!=", "\"\"", ")", "{", "eval", "(", "\"\\$options['title'] = {$this->title};\"", ")", ";", "}", "elseif", "(", "!", "isset", "(", "$", "options", "[", "'title'", "]", ")", ")", "{", "$", "options", "[", "'title'", "]", "=", "''", ";", "}", "if", "(", "$", "this", "->", "confirmation", "&&", "(", "!", "$", "this", "->", "post", ")", ")", "{", "if", "(", "$", "this", "->", "jsAction", ")", "{", "$", "options", "[", "'onclick'", "]", "=", "\"if (confirm('{$this->confirmation}')) {$this->jsAction}({$row->{$this->dataProvider->getPkKey()}}, '{$this->name}', this);\"", ";", "}", "else", "{", "$", "options", "[", "'onclick'", "]", "=", "\"return confirm('{$this->confirmation}');\"", ";", "}", "}", "elseif", "(", "$", "this", "->", "jsAction", ")", "{", "$", "options", "[", "'onclick'", "]", "=", "\"return {$this->jsAction}({$row->id}, '{$this->name}', this);\"", ";", "}", "if", "(", "'#'", "!=", "$", "this", "->", "url", ")", "{", "eval", "(", "\"\\$url = {$this->url};\"", ")", ";", "}", "else", "{", "$", "url", "=", "'#'", ";", "}", "if", "(", "false", "!==", "$", "this", "->", "post", "&&", "is_array", "(", "$", "this", "->", "post", ")", ")", "{", "$", "options", "[", "'class'", "]", "=", "isset", "(", "$", "options", "[", "'class'", "]", ")", "?", "$", "options", "[", "'class'", "]", ".", "' mdata-table-post-link'", ":", "'mdata-table-post-link'", ";", "$", "parsed", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "post", "as", "$", "name", "=>", "$", "value", ")", "{", "eval", "(", "'$value = '", ".", "$", "value", ".", "';'", ")", ";", "if", "(", "'{{modelKey}}'", "==", "$", "name", ")", "{", "$", "name", "=", "$", "table", "->", "dataProvider", "->", "filtersKey", ";", "}", "$", "parsed", "[", "$", "name", "]", "=", "$", "value", ";", "}", "$", "options", "[", "'post-data'", "]", "=", "json_encode", "(", "$", "parsed", ")", ";", "if", "(", "$", "this", "->", "confirmation", ")", "{", "$", "options", "[", "'post-confirmation'", "]", "=", "$", "this", "->", "confirmation", ";", "}", "}", "$", "icon", "=", "$", "this", "->", "getIcon", "(", "$", "options", "[", "'title'", "]", ",", "$", "table", ")", ";", "return", "Html", "::", "get", "(", ")", "->", "link", "(", "$", "url", ",", "$", "icon", ".", "$", "this", "->", "label", ",", "$", "options", ")", ";", "}" ]
Final result, a HTML Element for current action; @param Model $row @param \mpf\widgets\datatable\Table $table @return string
[ "Final", "result", "a", "HTML", "Element", "for", "current", "action", ";" ]
92597f9a09d086664268d6b7e0111d5a5586d8c7
https://github.com/mpf-soft/admin-widgets/blob/92597f9a09d086664268d6b7e0111d5a5586d8c7/datatable/columns/actions/Basic.php#L149-L191
25,548
mpf-soft/admin-widgets
datatable/columns/actions/Basic.php
Basic.getIcon
public function getIcon($title, Table $table) { if ($this->icon) { $icon = str_replace(array('%DATATABLE_ASSETS%', '%SIZE%'), array($table->getAssetsURL(), $this->iconSize . 'x' . $this->iconSize), $this->icon); if ('%MPF_ASSETS%' == substr($icon, 0, 12)) { $icon = AssetsPublisher::get()->mpfAssetFile(substr($icon, 12)); } return Html::get()->image($icon, $title); } return ''; }
php
public function getIcon($title, Table $table) { if ($this->icon) { $icon = str_replace(array('%DATATABLE_ASSETS%', '%SIZE%'), array($table->getAssetsURL(), $this->iconSize . 'x' . $this->iconSize), $this->icon); if ('%MPF_ASSETS%' == substr($icon, 0, 12)) { $icon = AssetsPublisher::get()->mpfAssetFile(substr($icon, 12)); } return Html::get()->image($icon, $title); } return ''; }
[ "public", "function", "getIcon", "(", "$", "title", ",", "Table", "$", "table", ")", "{", "if", "(", "$", "this", "->", "icon", ")", "{", "$", "icon", "=", "str_replace", "(", "array", "(", "'%DATATABLE_ASSETS%'", ",", "'%SIZE%'", ")", ",", "array", "(", "$", "table", "->", "getAssetsURL", "(", ")", ",", "$", "this", "->", "iconSize", ".", "'x'", ".", "$", "this", "->", "iconSize", ")", ",", "$", "this", "->", "icon", ")", ";", "if", "(", "'%MPF_ASSETS%'", "==", "substr", "(", "$", "icon", ",", "0", ",", "12", ")", ")", "{", "$", "icon", "=", "AssetsPublisher", "::", "get", "(", ")", "->", "mpfAssetFile", "(", "substr", "(", "$", "icon", ",", "12", ")", ")", ";", "}", "return", "Html", "::", "get", "(", ")", "->", "image", "(", "$", "icon", ",", "$", "title", ")", ";", "}", "return", "''", ";", "}" ]
Get HTML img tag for icon or an empty string if there is no icon @param string $title @param \mpf\widgets\datatable\Table $table @return string
[ "Get", "HTML", "img", "tag", "for", "icon", "or", "an", "empty", "string", "if", "there", "is", "no", "icon" ]
92597f9a09d086664268d6b7e0111d5a5586d8c7
https://github.com/mpf-soft/admin-widgets/blob/92597f9a09d086664268d6b7e0111d5a5586d8c7/datatable/columns/actions/Basic.php#L199-L208
25,549
mpf-soft/admin-widgets
datatable/columns/actions/Basic.php
Basic.isVisible
public function isVisible($row) { if (false === $this->visible) // check if it's visible return false; elseif (is_string($this->visible)) { $visible = true; eval("\$visible = {$this->visible};"); if (false == $visible) return false; } return true; }
php
public function isVisible($row) { if (false === $this->visible) // check if it's visible return false; elseif (is_string($this->visible)) { $visible = true; eval("\$visible = {$this->visible};"); if (false == $visible) return false; } return true; }
[ "public", "function", "isVisible", "(", "$", "row", ")", "{", "if", "(", "false", "===", "$", "this", "->", "visible", ")", "// check if it's visible", "return", "false", ";", "elseif", "(", "is_string", "(", "$", "this", "->", "visible", ")", ")", "{", "$", "visible", "=", "true", ";", "eval", "(", "\"\\$visible = {$this->visible};\"", ")", ";", "if", "(", "false", "==", "$", "visible", ")", "return", "false", ";", "}", "return", "true", ";", "}" ]
Checks if action is visible or not @return boolean
[ "Checks", "if", "action", "is", "visible", "or", "not" ]
92597f9a09d086664268d6b7e0111d5a5586d8c7
https://github.com/mpf-soft/admin-widgets/blob/92597f9a09d086664268d6b7e0111d5a5586d8c7/datatable/columns/actions/Basic.php#L214-L224
25,550
weareunite/unisys-transactions
src/Http/Controllers/HandleTransaction.php
HandleTransaction.allTransactions
public function allTransactions(int $id) { /** @var HasTransactionsInterface $object */ if(!$object = $this->repository->find($id)) { abort(404); } $transactions = $object->getLatestTransactions(); return TransactionResource::collection($transactions); }
php
public function allTransactions(int $id) { /** @var HasTransactionsInterface $object */ if(!$object = $this->repository->find($id)) { abort(404); } $transactions = $object->getLatestTransactions(); return TransactionResource::collection($transactions); }
[ "public", "function", "allTransactions", "(", "int", "$", "id", ")", "{", "/** @var HasTransactionsInterface $object */", "if", "(", "!", "$", "object", "=", "$", "this", "->", "repository", "->", "find", "(", "$", "id", ")", ")", "{", "abort", "(", "404", ")", ";", "}", "$", "transactions", "=", "$", "object", "->", "getLatestTransactions", "(", ")", ";", "return", "TransactionResource", "::", "collection", "(", "$", "transactions", ")", ";", "}" ]
Get latest Transactions Get all transactions order by created desc for given model find by model primary id @param int $id @return AnonymousResourceCollection|TransactionResource[]
[ "Get", "latest", "Transactions" ]
3bfaf6993cc209871298340f5dabbe56f1eeab5d
https://github.com/weareunite/unisys-transactions/blob/3bfaf6993cc209871298340f5dabbe56f1eeab5d/src/Http/Controllers/HandleTransaction.php#L51-L61
25,551
agentmedia/phine-core
src/Core/Logic/Util/ArrayLinesSerializer.php
ArrayLinesSerializer.LinesToArray
function LinesToArray($text) { $result = array(); $lines = Str::SplitLines($text); foreach ($lines as $line) { $line = trim($line); if (!$line) { continue; } $pos = strpos($line, $this->separator); $key = $line; $value = ''; if ($pos !== false) { $key = substr($line, 0, $pos); $value = substr($line, $pos + strlen($this->separator)); } $result[trim($key)] = trim($value); } return $result; }
php
function LinesToArray($text) { $result = array(); $lines = Str::SplitLines($text); foreach ($lines as $line) { $line = trim($line); if (!$line) { continue; } $pos = strpos($line, $this->separator); $key = $line; $value = ''; if ($pos !== false) { $key = substr($line, 0, $pos); $value = substr($line, $pos + strlen($this->separator)); } $result[trim($key)] = trim($value); } return $result; }
[ "function", "LinesToArray", "(", "$", "text", ")", "{", "$", "result", "=", "array", "(", ")", ";", "$", "lines", "=", "Str", "::", "SplitLines", "(", "$", "text", ")", ";", "foreach", "(", "$", "lines", "as", "$", "line", ")", "{", "$", "line", "=", "trim", "(", "$", "line", ")", ";", "if", "(", "!", "$", "line", ")", "{", "continue", ";", "}", "$", "pos", "=", "strpos", "(", "$", "line", ",", "$", "this", "->", "separator", ")", ";", "$", "key", "=", "$", "line", ";", "$", "value", "=", "''", ";", "if", "(", "$", "pos", "!==", "false", ")", "{", "$", "key", "=", "substr", "(", "$", "line", ",", "0", ",", "$", "pos", ")", ";", "$", "value", "=", "substr", "(", "$", "line", ",", "$", "pos", "+", "strlen", "(", "$", "this", "->", "separator", ")", ")", ";", "}", "$", "result", "[", "trim", "(", "$", "key", ")", "]", "=", "trim", "(", "$", "value", ")", ";", "}", "return", "$", "result", ";", "}" ]
Fetches the lines of a text and serializes them to an array of key value pairs @param string $text The text representation of the array @return array Returns the array representation as associative array
[ "Fetches", "the", "lines", "of", "a", "text", "and", "serializes", "them", "to", "an", "array", "of", "key", "value", "pairs" ]
38c1be8d03ebffae950d00a96da3c612aff67832
https://github.com/agentmedia/phine-core/blob/38c1be8d03ebffae950d00a96da3c612aff67832/src/Core/Logic/Util/ArrayLinesSerializer.php#L36-L58
25,552
brunschgi/TerrificComposerBundle
Controller/SearchController.php
SearchController.searchAction
public function searchAction(Request $request) { // get all modules $moduleManager = $this->get('terrific.composer.module.manager'); $modules = $moduleManager->getModules(); // get all pages $pageManager = $this->get('terrific.composer.page.manager'); $pages = $pageManager->getPages(); // merge the results $results = array_merge($modules, $pages); return array('results' => $results); }
php
public function searchAction(Request $request) { // get all modules $moduleManager = $this->get('terrific.composer.module.manager'); $modules = $moduleManager->getModules(); // get all pages $pageManager = $this->get('terrific.composer.page.manager'); $pages = $pageManager->getPages(); // merge the results $results = array_merge($modules, $pages); return array('results' => $results); }
[ "public", "function", "searchAction", "(", "Request", "$", "request", ")", "{", "// get all modules", "$", "moduleManager", "=", "$", "this", "->", "get", "(", "'terrific.composer.module.manager'", ")", ";", "$", "modules", "=", "$", "moduleManager", "->", "getModules", "(", ")", ";", "// get all pages", "$", "pageManager", "=", "$", "this", "->", "get", "(", "'terrific.composer.page.manager'", ")", ";", "$", "pages", "=", "$", "pageManager", "->", "getPages", "(", ")", ";", "// merge the results", "$", "results", "=", "array_merge", "(", "$", "modules", ",", "$", "pages", ")", ";", "return", "array", "(", "'results'", "=>", "$", "results", ")", ";", "}" ]
Displays the terrific component search. @Route("/search", name="composer_search") @Template() @param Request $request @return Response
[ "Displays", "the", "terrific", "component", "search", "." ]
6eef4ace887c19ef166ab6654de385bc1ffbf5f1
https://github.com/brunschgi/TerrificComposerBundle/blob/6eef4ace887c19ef166ab6654de385bc1ffbf5f1/Controller/SearchController.php#L40-L54
25,553
ekyna/Resource
Configuration/Configuration.php
Configuration.getClass
private function getClass($key) { if (!array_key_exists($key, $this->config['classes'])) { throw new \InvalidArgumentException(sprintf('Undefined resource class "%s".', $key)); } return $this->config['classes'][$key]; }
php
private function getClass($key) { if (!array_key_exists($key, $this->config['classes'])) { throw new \InvalidArgumentException(sprintf('Undefined resource class "%s".', $key)); } return $this->config['classes'][$key]; }
[ "private", "function", "getClass", "(", "$", "key", ")", "{", "if", "(", "!", "array_key_exists", "(", "$", "key", ",", "$", "this", "->", "config", "[", "'classes'", "]", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "sprintf", "(", "'Undefined resource class \"%s\".'", ",", "$", "key", ")", ")", ";", "}", "return", "$", "this", "->", "config", "[", "'classes'", "]", "[", "$", "key", "]", ";", "}" ]
Returns the class for the given key. @param string $key @return string
[ "Returns", "the", "class", "for", "the", "given", "key", "." ]
96ee3d28e02bd9513705408e3bb7f88a76e52f56
https://github.com/ekyna/Resource/blob/96ee3d28e02bd9513705408e3bb7f88a76e52f56/Configuration/Configuration.php#L228-L235
25,554
Xiphe/THEWPTOOLS
src/Xiphe/THEWPTOOLS.php
THEWPTOOLS.shorten
public static function shorten($text, $maxlength = 140, $end = '[...]') { $maxlength++; if (mb_strlen($text) > $maxlength) { $subex = mb_substr($text, 0, $maxlength - 5); $exwords = explode(' ', $subex); $excut = - (mb_strlen($exwords[count($exwords)-1])); if ($excut < 0) { $text = mb_substr($subex, 0, $excut); } else { $text = $subex; } $text .= $end; } return $text; }
php
public static function shorten($text, $maxlength = 140, $end = '[...]') { $maxlength++; if (mb_strlen($text) > $maxlength) { $subex = mb_substr($text, 0, $maxlength - 5); $exwords = explode(' ', $subex); $excut = - (mb_strlen($exwords[count($exwords)-1])); if ($excut < 0) { $text = mb_substr($subex, 0, $excut); } else { $text = $subex; } $text .= $end; } return $text; }
[ "public", "static", "function", "shorten", "(", "$", "text", ",", "$", "maxlength", "=", "140", ",", "$", "end", "=", "'[...]'", ")", "{", "$", "maxlength", "++", ";", "if", "(", "mb_strlen", "(", "$", "text", ")", ">", "$", "maxlength", ")", "{", "$", "subex", "=", "mb_substr", "(", "$", "text", ",", "0", ",", "$", "maxlength", "-", "5", ")", ";", "$", "exwords", "=", "explode", "(", "' '", ",", "$", "subex", ")", ";", "$", "excut", "=", "-", "(", "mb_strlen", "(", "$", "exwords", "[", "count", "(", "$", "exwords", ")", "-", "1", "]", ")", ")", ";", "if", "(", "$", "excut", "<", "0", ")", "{", "$", "text", "=", "mb_substr", "(", "$", "subex", ",", "0", ",", "$", "excut", ")", ";", "}", "else", "{", "$", "text", "=", "$", "subex", ";", "}", "$", "text", ".=", "$", "end", ";", "}", "return", "$", "text", ";", "}" ]
Builds an excerpt from a longer text. @param string $text the input text @param integer $maxlength maximal length of the text @param string $end a string that will be attached to the short version of $text @return string
[ "Builds", "an", "excerpt", "from", "a", "longer", "text", "." ]
4d36d99f3f55f87e9a664c66d2bdcd8dedf0d780
https://github.com/Xiphe/THEWPTOOLS/blob/4d36d99f3f55f87e9a664c66d2bdcd8dedf0d780/src/Xiphe/THEWPTOOLS.php#L94-L108
25,555
Xiphe/THEWPTOOLS
src/Xiphe/THEWPTOOLS.php
THEWPTOOLS.get_nav_menu_item_children
function get_nav_menu_item_children( $parent_id, $nav_menu_items, $depth = true ) { $nav_menu_item_list = array(); foreach ( (array) $nav_menu_items as $nav_menu_item ) { if ( $nav_menu_item->menu_item_parent == $parent_id ) { $nav_menu_item_list[] = $nav_menu_item; if ( $depth ) { if ( $children = self::get_nav_menu_item_children( $nav_menu_item->ID, $nav_menu_items ) ) $nav_menu_item_list = array_merge( $nav_menu_item_list, $children ); } } } return $nav_menu_item_list; }
php
function get_nav_menu_item_children( $parent_id, $nav_menu_items, $depth = true ) { $nav_menu_item_list = array(); foreach ( (array) $nav_menu_items as $nav_menu_item ) { if ( $nav_menu_item->menu_item_parent == $parent_id ) { $nav_menu_item_list[] = $nav_menu_item; if ( $depth ) { if ( $children = self::get_nav_menu_item_children( $nav_menu_item->ID, $nav_menu_items ) ) $nav_menu_item_list = array_merge( $nav_menu_item_list, $children ); } } } return $nav_menu_item_list; }
[ "function", "get_nav_menu_item_children", "(", "$", "parent_id", ",", "$", "nav_menu_items", ",", "$", "depth", "=", "true", ")", "{", "$", "nav_menu_item_list", "=", "array", "(", ")", ";", "foreach", "(", "(", "array", ")", "$", "nav_menu_items", "as", "$", "nav_menu_item", ")", "{", "if", "(", "$", "nav_menu_item", "->", "menu_item_parent", "==", "$", "parent_id", ")", "{", "$", "nav_menu_item_list", "[", "]", "=", "$", "nav_menu_item", ";", "if", "(", "$", "depth", ")", "{", "if", "(", "$", "children", "=", "self", "::", "get_nav_menu_item_children", "(", "$", "nav_menu_item", "->", "ID", ",", "$", "nav_menu_items", ")", ")", "$", "nav_menu_item_list", "=", "array_merge", "(", "$", "nav_menu_item_list", ",", "$", "children", ")", ";", "}", "}", "}", "return", "$", "nav_menu_item_list", ";", "}" ]
Returns all child nav_menu_items under a specific parent http://wpsmith.net/2011/wp/how-to-get-all-the-children-of-a-specific-nav-menu-item/ @param int the parent nav_menu_item ID @param array nav_menu_items @param bool gives all children or direct children only @return array returns filtered array of nav_menu_items
[ "Returns", "all", "child", "nav_menu_items", "under", "a", "specific", "parent" ]
4d36d99f3f55f87e9a664c66d2bdcd8dedf0d780
https://github.com/Xiphe/THEWPTOOLS/blob/4d36d99f3f55f87e9a664c66d2bdcd8dedf0d780/src/Xiphe/THEWPTOOLS.php#L217-L229
25,556
Xiphe/THEWPTOOLS
src/Xiphe/THEWPTOOLS.php
THEWPTOOLS.posted_on
public static function posted_on() { return sprintf(__('<span class="sep">Posted on </span><a href="%1$s" title="%2$s" rel="bookmark"><time class="entry-date" datetime="%3$s" pubdate>%4$s</time></a><span class="by-author"> <span class="sep"> by </span> <span class="author vcard"><a class="url fn n" href="%5$s" title="%6$s" rel="author">%7$s</a></span></span>', 'themaster'), esc_url(get_permalink()), esc_attr(get_the_time()), esc_attr(get_the_date('c')), esc_html(get_the_date()), esc_url(get_author_posts_url(get_the_author_meta('ID'))), esc_attr(sprintf(__('View all posts by %s', 'themaster'), get_the_author())), get_the_author() ); }
php
public static function posted_on() { return sprintf(__('<span class="sep">Posted on </span><a href="%1$s" title="%2$s" rel="bookmark"><time class="entry-date" datetime="%3$s" pubdate>%4$s</time></a><span class="by-author"> <span class="sep"> by </span> <span class="author vcard"><a class="url fn n" href="%5$s" title="%6$s" rel="author">%7$s</a></span></span>', 'themaster'), esc_url(get_permalink()), esc_attr(get_the_time()), esc_attr(get_the_date('c')), esc_html(get_the_date()), esc_url(get_author_posts_url(get_the_author_meta('ID'))), esc_attr(sprintf(__('View all posts by %s', 'themaster'), get_the_author())), get_the_author() ); }
[ "public", "static", "function", "posted_on", "(", ")", "{", "return", "sprintf", "(", "__", "(", "'<span class=\"sep\">Posted on </span><a href=\"%1$s\" title=\"%2$s\" rel=\"bookmark\"><time class=\"entry-date\" datetime=\"%3$s\" pubdate>%4$s</time></a><span class=\"by-author\"> <span class=\"sep\"> by </span> <span class=\"author vcard\"><a class=\"url fn n\" href=\"%5$s\" title=\"%6$s\" rel=\"author\">%7$s</a></span></span>'", ",", "'themaster'", ")", ",", "esc_url", "(", "get_permalink", "(", ")", ")", ",", "esc_attr", "(", "get_the_time", "(", ")", ")", ",", "esc_attr", "(", "get_the_date", "(", "'c'", ")", ")", ",", "esc_html", "(", "get_the_date", "(", ")", ")", ",", "esc_url", "(", "get_author_posts_url", "(", "get_the_author_meta", "(", "'ID'", ")", ")", ")", ",", "esc_attr", "(", "sprintf", "(", "__", "(", "'View all posts by %s'", ",", "'themaster'", ")", ",", "get_the_author", "(", ")", ")", ")", ",", "get_the_author", "(", ")", ")", ";", "}" ]
The "Posted by Derp in FooBar" post-meta. Taken from TwentyEleven Wordpress Theme. @return string
[ "The", "Posted", "by", "Derp", "in", "FooBar", "post", "-", "meta", ".", "Taken", "from", "TwentyEleven", "Wordpress", "Theme", "." ]
4d36d99f3f55f87e9a664c66d2bdcd8dedf0d780
https://github.com/Xiphe/THEWPTOOLS/blob/4d36d99f3f55f87e9a664c66d2bdcd8dedf0d780/src/Xiphe/THEWPTOOLS.php#L263-L274
25,557
Xiphe/THEWPTOOLS
src/Xiphe/THEWPTOOLS.php
THEWPTOOLS.get_title
public static function get_title() { global $page, $paged; $r = wp_title('|', false, 'right'); // Add the blog name. $r .= get_bloginfo('name'); // Add the blog description for the home/front page. $site_description = get_bloginfo('description', 'display'); if ($site_description && (is_home() || is_front_page())) { $r .= " | $site_description"; } // Add a page number if necessary: if ($paged >= 2 || $page >= 2) { $r .= ' | ' . sprintf(__('Page %s', 'themaster'), max($paged, $page)); } return $r; }
php
public static function get_title() { global $page, $paged; $r = wp_title('|', false, 'right'); // Add the blog name. $r .= get_bloginfo('name'); // Add the blog description for the home/front page. $site_description = get_bloginfo('description', 'display'); if ($site_description && (is_home() || is_front_page())) { $r .= " | $site_description"; } // Add a page number if necessary: if ($paged >= 2 || $page >= 2) { $r .= ' | ' . sprintf(__('Page %s', 'themaster'), max($paged, $page)); } return $r; }
[ "public", "static", "function", "get_title", "(", ")", "{", "global", "$", "page", ",", "$", "paged", ";", "$", "r", "=", "wp_title", "(", "'|'", ",", "false", ",", "'right'", ")", ";", "// Add the blog name.\r", "$", "r", ".=", "get_bloginfo", "(", "'name'", ")", ";", "// Add the blog description for the home/front page.\r", "$", "site_description", "=", "get_bloginfo", "(", "'description'", ",", "'display'", ")", ";", "if", "(", "$", "site_description", "&&", "(", "is_home", "(", ")", "||", "is_front_page", "(", ")", ")", ")", "{", "$", "r", ".=", "\" | $site_description\"", ";", "}", "// Add a page number if necessary:\r", "if", "(", "$", "paged", ">=", "2", "||", "$", "page", ">=", "2", ")", "{", "$", "r", ".=", "' | '", ".", "sprintf", "(", "__", "(", "'Page %s'", ",", "'themaster'", ")", ",", "max", "(", "$", "paged", ",", "$", "page", ")", ")", ";", "}", "return", "$", "r", ";", "}" ]
A Standard title for Wordpress Pages. Taken from TwentyEleven Wordpress Theme. @access public @return string the title.
[ "A", "Standard", "title", "for", "Wordpress", "Pages", ".", "Taken", "from", "TwentyEleven", "Wordpress", "Theme", "." ]
4d36d99f3f55f87e9a664c66d2bdcd8dedf0d780
https://github.com/Xiphe/THEWPTOOLS/blob/4d36d99f3f55f87e9a664c66d2bdcd8dedf0d780/src/Xiphe/THEWPTOOLS.php#L283-L303
25,558
OxfordInfoLabs/kinikit-core
src/Util/HTTP/HttpRequest.php
HttpRequest.instance
public static function instance($reload = false) { if (HttpRequest::$instance == null || $reload) { HttpRequest::$instance = new HttpRequest (); } return HttpRequest::$instance; }
php
public static function instance($reload = false) { if (HttpRequest::$instance == null || $reload) { HttpRequest::$instance = new HttpRequest (); } return HttpRequest::$instance; }
[ "public", "static", "function", "instance", "(", "$", "reload", "=", "false", ")", "{", "if", "(", "HttpRequest", "::", "$", "instance", "==", "null", "||", "$", "reload", ")", "{", "HttpRequest", "::", "$", "instance", "=", "new", "HttpRequest", "(", ")", ";", "}", "return", "HttpRequest", "::", "$", "instance", ";", "}" ]
Enforce a singleton session object @return HttpRequest
[ "Enforce", "a", "singleton", "session", "object" ]
edc1b2e6ffabd595c4c7d322279b3dd1e59ef359
https://github.com/OxfordInfoLabs/kinikit-core/blob/edc1b2e6ffabd595c4c7d322279b3dd1e59ef359/src/Util/HTTP/HttpRequest.php#L99-L107
25,559
Dhii/iterator-abstract
src/IteratorIteratorTrait.php
IteratorIteratorTrait._advanceTracker
protected function _advanceTracker($tracker) { if (!($tracker instanceof Iterator)) { throw $this->_createInvalidArgumentException($this->__('Can only advance an Iterator tracker'), null, null, $tracker); } $tracker->next(); }
php
protected function _advanceTracker($tracker) { if (!($tracker instanceof Iterator)) { throw $this->_createInvalidArgumentException($this->__('Can only advance an Iterator tracker'), null, null, $tracker); } $tracker->next(); }
[ "protected", "function", "_advanceTracker", "(", "$", "tracker", ")", "{", "if", "(", "!", "(", "$", "tracker", "instanceof", "Iterator", ")", ")", "{", "throw", "$", "this", "->", "_createInvalidArgumentException", "(", "$", "this", "->", "__", "(", "'Can only advance an Iterator tracker'", ")", ",", "null", ",", "null", ",", "$", "tracker", ")", ";", "}", "$", "tracker", "->", "next", "(", ")", ";", "}" ]
Advances the iterator forward. @since [*next-version*] @param Iterator $tracker The iterator used to track the loop. @throws InvalidArgumentException If problem advancing iterator.
[ "Advances", "the", "iterator", "forward", "." ]
576484183865575ffc2a0d586132741329626fb8
https://github.com/Dhii/iterator-abstract/blob/576484183865575ffc2a0d586132741329626fb8/src/IteratorIteratorTrait.php#L28-L35
25,560
Dhii/iterator-abstract
src/IteratorIteratorTrait.php
IteratorIteratorTrait._resetTracker
protected function _resetTracker($tracker) { if (!($tracker instanceof Iterator)) { throw $this->_createInvalidArgumentException($this->__('Can only reset an Iterator tracker'), null, null, $tracker); } $tracker->rewind(); }
php
protected function _resetTracker($tracker) { if (!($tracker instanceof Iterator)) { throw $this->_createInvalidArgumentException($this->__('Can only reset an Iterator tracker'), null, null, $tracker); } $tracker->rewind(); }
[ "protected", "function", "_resetTracker", "(", "$", "tracker", ")", "{", "if", "(", "!", "(", "$", "tracker", "instanceof", "Iterator", ")", ")", "{", "throw", "$", "this", "->", "_createInvalidArgumentException", "(", "$", "this", "->", "__", "(", "'Can only reset an Iterator tracker'", ")", ",", "null", ",", "null", ",", "$", "tracker", ")", ";", "}", "$", "tracker", "->", "rewind", "(", ")", ";", "}" ]
Reset the iterator back to the start. @param Iterator $tracker The iterator used to track the loop. @throws InvalidArgumentException If problem resetting tracker.
[ "Reset", "the", "iterator", "back", "to", "the", "start", "." ]
576484183865575ffc2a0d586132741329626fb8
https://github.com/Dhii/iterator-abstract/blob/576484183865575ffc2a0d586132741329626fb8/src/IteratorIteratorTrait.php#L44-L51
25,561
Dhii/iterator-abstract
src/IteratorIteratorTrait.php
IteratorIteratorTrait._createIterationFromTracker
protected function _createIterationFromTracker($tracker) { if (!($tracker instanceof Iterator)) { throw $this->_createInvalidArgumentException($this->__('Can only create an iteration from an Iterator tracker'), null, null, $tracker); } $key = $this->_calculateKey($tracker); $value = $this->_calculateValue($tracker); return $this->_createIteration($key, $value); }
php
protected function _createIterationFromTracker($tracker) { if (!($tracker instanceof Iterator)) { throw $this->_createInvalidArgumentException($this->__('Can only create an iteration from an Iterator tracker'), null, null, $tracker); } $key = $this->_calculateKey($tracker); $value = $this->_calculateValue($tracker); return $this->_createIteration($key, $value); }
[ "protected", "function", "_createIterationFromTracker", "(", "$", "tracker", ")", "{", "if", "(", "!", "(", "$", "tracker", "instanceof", "Iterator", ")", ")", "{", "throw", "$", "this", "->", "_createInvalidArgumentException", "(", "$", "this", "->", "__", "(", "'Can only create an iteration from an Iterator tracker'", ")", ",", "null", ",", "null", ",", "$", "tracker", ")", ";", "}", "$", "key", "=", "$", "this", "->", "_calculateKey", "(", "$", "tracker", ")", ";", "$", "value", "=", "$", "this", "->", "_calculateValue", "(", "$", "tracker", ")", ";", "return", "$", "this", "->", "_createIteration", "(", "$", "key", ",", "$", "value", ")", ";", "}" ]
Creates a new iteration using an internal iterator. @since [*next-version*] @param Iterator $tracker The iterator used to track the iteration. @return IterationInterface The new iteration.
[ "Creates", "a", "new", "iteration", "using", "an", "internal", "iterator", "." ]
576484183865575ffc2a0d586132741329626fb8
https://github.com/Dhii/iterator-abstract/blob/576484183865575ffc2a0d586132741329626fb8/src/IteratorIteratorTrait.php#L62-L72
25,562
DreadLabs/typo3-cms-phing-helper
Classes/Utility/TYPO3/ArrayUtility.php
ArrayUtility.sortByKeyRecursive
static public function sortByKeyRecursive(array $array) { ksort($array); foreach ($array as $key => $value) { if (is_array($value) && !empty($value)) { $array[$key] = self::sortByKeyRecursive($value); } } return $array; }
php
static public function sortByKeyRecursive(array $array) { ksort($array); foreach ($array as $key => $value) { if (is_array($value) && !empty($value)) { $array[$key] = self::sortByKeyRecursive($value); } } return $array; }
[ "static", "public", "function", "sortByKeyRecursive", "(", "array", "$", "array", ")", "{", "ksort", "(", "$", "array", ")", ";", "foreach", "(", "$", "array", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "is_array", "(", "$", "value", ")", "&&", "!", "empty", "(", "$", "value", ")", ")", "{", "$", "array", "[", "$", "key", "]", "=", "self", "::", "sortByKeyRecursive", "(", "$", "value", ")", ";", "}", "}", "return", "$", "array", ";", "}" ]
Sorts an array recursively by key @param $array Array to sort recursively by key @return array Sorted array
[ "Sorts", "an", "array", "recursively", "by", "key" ]
b6606102c4702a92bc1872eba962febceaa0e645
https://github.com/DreadLabs/typo3-cms-phing-helper/blob/b6606102c4702a92bc1872eba962febceaa0e645/Classes/Utility/TYPO3/ArrayUtility.php#L80-L90
25,563
DreadLabs/typo3-cms-phing-helper
Classes/Utility/TYPO3/ArrayUtility.php
ArrayUtility.renumberKeysToAvoidLeapsIfKeysAreAllNumeric
static public function renumberKeysToAvoidLeapsIfKeysAreAllNumeric(array $array = array(), $level = 0) { $level++; $allKeysAreNumeric = TRUE; foreach (array_keys($array) as $key) { if (is_numeric($key) === FALSE) { $allKeysAreNumeric = FALSE; break; } } $renumberedArray = $array; if ($allKeysAreNumeric === TRUE) { $renumberedArray = array_values($array); } foreach ($renumberedArray as $key => $value) { if (is_array($value)) { $renumberedArray[$key] = self::renumberKeysToAvoidLeapsIfKeysAreAllNumeric($value, $level); } } return $renumberedArray; }
php
static public function renumberKeysToAvoidLeapsIfKeysAreAllNumeric(array $array = array(), $level = 0) { $level++; $allKeysAreNumeric = TRUE; foreach (array_keys($array) as $key) { if (is_numeric($key) === FALSE) { $allKeysAreNumeric = FALSE; break; } } $renumberedArray = $array; if ($allKeysAreNumeric === TRUE) { $renumberedArray = array_values($array); } foreach ($renumberedArray as $key => $value) { if (is_array($value)) { $renumberedArray[$key] = self::renumberKeysToAvoidLeapsIfKeysAreAllNumeric($value, $level); } } return $renumberedArray; }
[ "static", "public", "function", "renumberKeysToAvoidLeapsIfKeysAreAllNumeric", "(", "array", "$", "array", "=", "array", "(", ")", ",", "$", "level", "=", "0", ")", "{", "$", "level", "++", ";", "$", "allKeysAreNumeric", "=", "TRUE", ";", "foreach", "(", "array_keys", "(", "$", "array", ")", "as", "$", "key", ")", "{", "if", "(", "is_numeric", "(", "$", "key", ")", "===", "FALSE", ")", "{", "$", "allKeysAreNumeric", "=", "FALSE", ";", "break", ";", "}", "}", "$", "renumberedArray", "=", "$", "array", ";", "if", "(", "$", "allKeysAreNumeric", "===", "TRUE", ")", "{", "$", "renumberedArray", "=", "array_values", "(", "$", "array", ")", ";", "}", "foreach", "(", "$", "renumberedArray", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "is_array", "(", "$", "value", ")", ")", "{", "$", "renumberedArray", "[", "$", "key", "]", "=", "self", "::", "renumberKeysToAvoidLeapsIfKeysAreAllNumeric", "(", "$", "value", ",", "$", "level", ")", ";", "}", "}", "return", "$", "renumberedArray", ";", "}" ]
Renumber the keys of an array to avoid leaps is keys are all numeric. Is called recursively for nested arrays. Example: Given array(0 => 'Zero' 1 => 'One', 2 => 'Two', 4 => 'Three') as input, it will return array(0 => 'Zero' 1 => 'One', 2 => 'Two', 3 => 'Three') Will treat keys string representations of number (ie. '1') equal to the numeric value (ie. 1). Example: Given array('0' => 'Zero', '1' => 'One' ) it will return array(0 => 'Zero', 1 => 'One') @author Susanne Moog <typo3@susanne-moog.de> @see typo3/sysext/core/Classes/Utility/ArrayUtility.php @param array $array Input array @param integer $level Internal level used for recursion, do *not* set from outside! @return array
[ "Renumber", "the", "keys", "of", "an", "array", "to", "avoid", "leaps", "is", "keys", "are", "all", "numeric", "." ]
b6606102c4702a92bc1872eba962febceaa0e645
https://github.com/DreadLabs/typo3-cms-phing-helper/blob/b6606102c4702a92bc1872eba962febceaa0e645/Classes/Utility/TYPO3/ArrayUtility.php#L120-L141
25,564
bandama-framework/bandama-framework
src/foundation/dependency-injection/Container.php
Container.setInstance
public function setInstance($instance) { $reflection = new ReflectionClass($instance); $name = str_replace('\\', ':', $reflection->getName()); $this->instances[$name] = $instance; }
php
public function setInstance($instance) { $reflection = new ReflectionClass($instance); $name = str_replace('\\', ':', $reflection->getName()); $this->instances[$name] = $instance; }
[ "public", "function", "setInstance", "(", "$", "instance", ")", "{", "$", "reflection", "=", "new", "ReflectionClass", "(", "$", "instance", ")", ";", "$", "name", "=", "str_replace", "(", "'\\\\'", ",", "':'", ",", "$", "reflection", "->", "getName", "(", ")", ")", ";", "$", "this", "->", "instances", "[", "$", "name", "]", "=", "$", "instance", ";", "}" ]
Add new entry in instances. @param string $key Key of entry @param Callable $resolver Callable of entry @return void
[ "Add", "new", "entry", "in", "instances", "." ]
234ed703baf9e31268941c9d5f6d5e004cc53066
https://github.com/bandama-framework/bandama-framework/blob/234ed703baf9e31268941c9d5f6d5e004cc53066/src/foundation/dependency-injection/Container.php#L113-L117
25,565
bandama-framework/bandama-framework
src/foundation/dependency-injection/Container.php
Container.get
public function get($key) { // If the key is in factories the return new instance of class if (isset($this->factories[$key])) { return $this->factories[$key](); } // If the key is not in instances if (!isset($this->instances[$key])) { // If the key is in registry, instanciate the corresponding class and add it in instances if (isset($this->registry[$key])) { $this->instances[$key] = $this->registry[$key](); } else { // If the key is not in registry, instanciate the corresponding class and add it in instances $this->instances[$key] = self::newInstance($key); } } return $this->instances[$key]; }
php
public function get($key) { // If the key is in factories the return new instance of class if (isset($this->factories[$key])) { return $this->factories[$key](); } // If the key is not in instances if (!isset($this->instances[$key])) { // If the key is in registry, instanciate the corresponding class and add it in instances if (isset($this->registry[$key])) { $this->instances[$key] = $this->registry[$key](); } else { // If the key is not in registry, instanciate the corresponding class and add it in instances $this->instances[$key] = self::newInstance($key); } } return $this->instances[$key]; }
[ "public", "function", "get", "(", "$", "key", ")", "{", "// If the key is in factories the return new instance of class", "if", "(", "isset", "(", "$", "this", "->", "factories", "[", "$", "key", "]", ")", ")", "{", "return", "$", "this", "->", "factories", "[", "$", "key", "]", "(", ")", ";", "}", "// If the key is not in instances", "if", "(", "!", "isset", "(", "$", "this", "->", "instances", "[", "$", "key", "]", ")", ")", "{", "// If the key is in registry, instanciate the corresponding class and add it in instances", "if", "(", "isset", "(", "$", "this", "->", "registry", "[", "$", "key", "]", ")", ")", "{", "$", "this", "->", "instances", "[", "$", "key", "]", "=", "$", "this", "->", "registry", "[", "$", "key", "]", "(", ")", ";", "}", "else", "{", "// If the key is not in registry, instanciate the corresponding class and add it in instances", "$", "this", "->", "instances", "[", "$", "key", "]", "=", "self", "::", "newInstance", "(", "$", "key", ")", ";", "}", "}", "return", "$", "this", "->", "instances", "[", "$", "key", "]", ";", "}" ]
Get an entry by key @param string $key Key of entry @return Callable|Object
[ "Get", "an", "entry", "by", "key" ]
234ed703baf9e31268941c9d5f6d5e004cc53066
https://github.com/bandama-framework/bandama-framework/blob/234ed703baf9e31268941c9d5f6d5e004cc53066/src/foundation/dependency-injection/Container.php#L126-L144
25,566
bandama-framework/bandama-framework
src/foundation/dependency-injection/Container.php
Container.newInstance
public static function newInstance($class) { $className = str_replace(':', '\\', $class); $reflectedClass = new ReflectionClass($className); if ($reflectedClass->isInstantiable()) { $constructor = $reflectedClass->getConstructor(); if ($constructor) { $parameters = $constructor->getParameters(); $constructorParameters = array(); foreach ($parameters as $parameter) { if ($parameter->getClass()) { $constructorParameters[] = self::newInstance($parameter->getClass()->getName()); } else { $constructorParameters[] = $parameter->getDefaultValue(); } } return $reflectedClass->newInstanceArgs($constructorParameters); } else { return $reflectedClass->newInstance(); } } else { throw new Exception($class." is not instantiable Class"); } }
php
public static function newInstance($class) { $className = str_replace(':', '\\', $class); $reflectedClass = new ReflectionClass($className); if ($reflectedClass->isInstantiable()) { $constructor = $reflectedClass->getConstructor(); if ($constructor) { $parameters = $constructor->getParameters(); $constructorParameters = array(); foreach ($parameters as $parameter) { if ($parameter->getClass()) { $constructorParameters[] = self::newInstance($parameter->getClass()->getName()); } else { $constructorParameters[] = $parameter->getDefaultValue(); } } return $reflectedClass->newInstanceArgs($constructorParameters); } else { return $reflectedClass->newInstance(); } } else { throw new Exception($class." is not instantiable Class"); } }
[ "public", "static", "function", "newInstance", "(", "$", "class", ")", "{", "$", "className", "=", "str_replace", "(", "':'", ",", "'\\\\'", ",", "$", "class", ")", ";", "$", "reflectedClass", "=", "new", "ReflectionClass", "(", "$", "className", ")", ";", "if", "(", "$", "reflectedClass", "->", "isInstantiable", "(", ")", ")", "{", "$", "constructor", "=", "$", "reflectedClass", "->", "getConstructor", "(", ")", ";", "if", "(", "$", "constructor", ")", "{", "$", "parameters", "=", "$", "constructor", "->", "getParameters", "(", ")", ";", "$", "constructorParameters", "=", "array", "(", ")", ";", "foreach", "(", "$", "parameters", "as", "$", "parameter", ")", "{", "if", "(", "$", "parameter", "->", "getClass", "(", ")", ")", "{", "$", "constructorParameters", "[", "]", "=", "self", "::", "newInstance", "(", "$", "parameter", "->", "getClass", "(", ")", "->", "getName", "(", ")", ")", ";", "}", "else", "{", "$", "constructorParameters", "[", "]", "=", "$", "parameter", "->", "getDefaultValue", "(", ")", ";", "}", "}", "return", "$", "reflectedClass", "->", "newInstanceArgs", "(", "$", "constructorParameters", ")", ";", "}", "else", "{", "return", "$", "reflectedClass", "->", "newInstance", "(", ")", ";", "}", "}", "else", "{", "throw", "new", "Exception", "(", "$", "class", ".", "\" is not instantiable Class\"", ")", ";", "}", "}" ]
An instance factory method @param string $class Full class name with used : as namespace separator @return mixed
[ "An", "instance", "factory", "method" ]
234ed703baf9e31268941c9d5f6d5e004cc53066
https://github.com/bandama-framework/bandama-framework/blob/234ed703baf9e31268941c9d5f6d5e004cc53066/src/foundation/dependency-injection/Container.php#L153-L180
25,567
hamjoint/mustard-media
src/lib/Http/Controllers/ItemController.php
ItemController.postAddPhotos
public function postAddPhotos(Request $request) { if (!$request->hasFile('photos')) { return response('', 400); } foreach ($request->file('photos') as $file) { $photo = Photo::upload($file->getRealPath()); session()->push('photos', [ 'photo_id' => $photo->getKey(), 'filename' => $file->getClientOriginalName(), ]); } }
php
public function postAddPhotos(Request $request) { if (!$request->hasFile('photos')) { return response('', 400); } foreach ($request->file('photos') as $file) { $photo = Photo::upload($file->getRealPath()); session()->push('photos', [ 'photo_id' => $photo->getKey(), 'filename' => $file->getClientOriginalName(), ]); } }
[ "public", "function", "postAddPhotos", "(", "Request", "$", "request", ")", "{", "if", "(", "!", "$", "request", "->", "hasFile", "(", "'photos'", ")", ")", "{", "return", "response", "(", "''", ",", "400", ")", ";", "}", "foreach", "(", "$", "request", "->", "file", "(", "'photos'", ")", "as", "$", "file", ")", "{", "$", "photo", "=", "Photo", "::", "upload", "(", "$", "file", "->", "getRealPath", "(", ")", ")", ";", "session", "(", ")", "->", "push", "(", "'photos'", ",", "[", "'photo_id'", "=>", "$", "photo", "->", "getKey", "(", ")", ",", "'filename'", "=>", "$", "file", "->", "getClientOriginalName", "(", ")", ",", "]", ")", ";", "}", "}" ]
Process and store several photos. @param \Illuminate\Http\Request $request @return \Illuminate\Http\RedirectResponse
[ "Process", "and", "store", "several", "photos", "." ]
d3c799dbc3578e1e1022bb4eccae7a20e285ba06
https://github.com/hamjoint/mustard-media/blob/d3c799dbc3578e1e1022bb4eccae7a20e285ba06/src/lib/Http/Controllers/ItemController.php#L37-L51
25,568
hamjoint/mustard-media
src/lib/Http/Controllers/ItemController.php
ItemController.postDeletePhoto
public function postDeletePhoto(Request $request) { if (session()->has('photos')) { $photos = session('photos'); foreach ($photos as $index => $photo) { if (in_array($request->input('file'), $photo)) { $photo = Photo::find($photo['photo_id']); $photo->delete(); unset($photos[$index]); session('photos', $photos); return response('', 200); } } } return response('', 400); }
php
public function postDeletePhoto(Request $request) { if (session()->has('photos')) { $photos = session('photos'); foreach ($photos as $index => $photo) { if (in_array($request->input('file'), $photo)) { $photo = Photo::find($photo['photo_id']); $photo->delete(); unset($photos[$index]); session('photos', $photos); return response('', 200); } } } return response('', 400); }
[ "public", "function", "postDeletePhoto", "(", "Request", "$", "request", ")", "{", "if", "(", "session", "(", ")", "->", "has", "(", "'photos'", ")", ")", "{", "$", "photos", "=", "session", "(", "'photos'", ")", ";", "foreach", "(", "$", "photos", "as", "$", "index", "=>", "$", "photo", ")", "{", "if", "(", "in_array", "(", "$", "request", "->", "input", "(", "'file'", ")", ",", "$", "photo", ")", ")", "{", "$", "photo", "=", "Photo", "::", "find", "(", "$", "photo", "[", "'photo_id'", "]", ")", ";", "$", "photo", "->", "delete", "(", ")", ";", "unset", "(", "$", "photos", "[", "$", "index", "]", ")", ";", "session", "(", "'photos'", ",", "$", "photos", ")", ";", "return", "response", "(", "''", ",", "200", ")", ";", "}", "}", "}", "return", "response", "(", "''", ",", "400", ")", ";", "}" ]
Delete a photo. @param \Illuminate\Http\Request $request @return \Illuminate\Http\Response
[ "Delete", "a", "photo", "." ]
d3c799dbc3578e1e1022bb4eccae7a20e285ba06
https://github.com/hamjoint/mustard-media/blob/d3c799dbc3578e1e1022bb4eccae7a20e285ba06/src/lib/Http/Controllers/ItemController.php#L60-L81
25,569
black-lamp/blcms-nova-poshta
frontend/controllers/DefaultController.php
DefaultController.actionGetWarehouses
public function actionGetWarehouses() { $street = $_GET['street']; $warehouses = $this->getResponse('AddressGeneral', 'getWarehouses', ['CityName' => $_GET['CityName']]); $warehousesByStreet = []; foreach ($warehouses->data['data'] as $warehouse) { if (substr_count(mb_strtolower($warehouse['Description']), mb_strtolower($street)) != 0 || substr_count(mb_strtolower($warehouse['DescriptionRu']), mb_strtolower($street))) { $warehousesByStreet[] = $warehouse; } } return json_encode($warehousesByStreet); }
php
public function actionGetWarehouses() { $street = $_GET['street']; $warehouses = $this->getResponse('AddressGeneral', 'getWarehouses', ['CityName' => $_GET['CityName']]); $warehousesByStreet = []; foreach ($warehouses->data['data'] as $warehouse) { if (substr_count(mb_strtolower($warehouse['Description']), mb_strtolower($street)) != 0 || substr_count(mb_strtolower($warehouse['DescriptionRu']), mb_strtolower($street))) { $warehousesByStreet[] = $warehouse; } } return json_encode($warehousesByStreet); }
[ "public", "function", "actionGetWarehouses", "(", ")", "{", "$", "street", "=", "$", "_GET", "[", "'street'", "]", ";", "$", "warehouses", "=", "$", "this", "->", "getResponse", "(", "'AddressGeneral'", ",", "'getWarehouses'", ",", "[", "'CityName'", "=>", "$", "_GET", "[", "'CityName'", "]", "]", ")", ";", "$", "warehousesByStreet", "=", "[", "]", ";", "foreach", "(", "$", "warehouses", "->", "data", "[", "'data'", "]", "as", "$", "warehouse", ")", "{", "if", "(", "substr_count", "(", "mb_strtolower", "(", "$", "warehouse", "[", "'Description'", "]", ")", ",", "mb_strtolower", "(", "$", "street", ")", ")", "!=", "0", "||", "substr_count", "(", "mb_strtolower", "(", "$", "warehouse", "[", "'DescriptionRu'", "]", ")", ",", "mb_strtolower", "(", "$", "street", ")", ")", ")", "{", "$", "warehousesByStreet", "[", "]", "=", "$", "warehouse", ";", "}", "}", "return", "json_encode", "(", "$", "warehousesByStreet", ")", ";", "}" ]
Gets warehouses by city and street. @return string
[ "Gets", "warehouses", "by", "city", "and", "street", "." ]
75b7d4b2034dd636c0bd59c87dc695c25de36f59
https://github.com/black-lamp/blcms-nova-poshta/blob/75b7d4b2034dd636c0bd59c87dc695c25de36f59/frontend/controllers/DefaultController.php#L69-L85
25,570
internetofvoice/vsms-core
src/Controller/AbstractLinkController.php
AbstractLinkController.validateRequestParameters
public function validateRequestParameters($request, $amz_client_id) { $errors = array(); $state = $request->getParam('state', false); $redirect_uri = $request->getParam('redirect_uri', false); $client_id = $request->getParam('client_id', false); $scope = $request->getParam('scope', false); $response_type = $request->getParam('response_type', false); if($state === false) { $errors[] = 'state'; } if($redirect_uri === false) { $errors[] = 'redirect_uri'; } if($client_id != $amz_client_id) { $errors[] = 'client_id'; } if($response_type != 'token') { $errors[] = 'response_type'; } if(count($errors)) { throw new InvalidArgumentException('Missing or incorrect parameters: ' . implode(', ', $errors)); } else { return [ 'state' => $state, 'redirect_uri' => $redirect_uri, 'client_id' => $client_id, 'scope' => $scope, 'response_type' => $response_type, ]; } }
php
public function validateRequestParameters($request, $amz_client_id) { $errors = array(); $state = $request->getParam('state', false); $redirect_uri = $request->getParam('redirect_uri', false); $client_id = $request->getParam('client_id', false); $scope = $request->getParam('scope', false); $response_type = $request->getParam('response_type', false); if($state === false) { $errors[] = 'state'; } if($redirect_uri === false) { $errors[] = 'redirect_uri'; } if($client_id != $amz_client_id) { $errors[] = 'client_id'; } if($response_type != 'token') { $errors[] = 'response_type'; } if(count($errors)) { throw new InvalidArgumentException('Missing or incorrect parameters: ' . implode(', ', $errors)); } else { return [ 'state' => $state, 'redirect_uri' => $redirect_uri, 'client_id' => $client_id, 'scope' => $scope, 'response_type' => $response_type, ]; } }
[ "public", "function", "validateRequestParameters", "(", "$", "request", ",", "$", "amz_client_id", ")", "{", "$", "errors", "=", "array", "(", ")", ";", "$", "state", "=", "$", "request", "->", "getParam", "(", "'state'", ",", "false", ")", ";", "$", "redirect_uri", "=", "$", "request", "->", "getParam", "(", "'redirect_uri'", ",", "false", ")", ";", "$", "client_id", "=", "$", "request", "->", "getParam", "(", "'client_id'", ",", "false", ")", ";", "$", "scope", "=", "$", "request", "->", "getParam", "(", "'scope'", ",", "false", ")", ";", "$", "response_type", "=", "$", "request", "->", "getParam", "(", "'response_type'", ",", "false", ")", ";", "if", "(", "$", "state", "===", "false", ")", "{", "$", "errors", "[", "]", "=", "'state'", ";", "}", "if", "(", "$", "redirect_uri", "===", "false", ")", "{", "$", "errors", "[", "]", "=", "'redirect_uri'", ";", "}", "if", "(", "$", "client_id", "!=", "$", "amz_client_id", ")", "{", "$", "errors", "[", "]", "=", "'client_id'", ";", "}", "if", "(", "$", "response_type", "!=", "'token'", ")", "{", "$", "errors", "[", "]", "=", "'response_type'", ";", "}", "if", "(", "count", "(", "$", "errors", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'Missing or incorrect parameters: '", ".", "implode", "(", "', '", ",", "$", "errors", ")", ")", ";", "}", "else", "{", "return", "[", "'state'", "=>", "$", "state", ",", "'redirect_uri'", "=>", "$", "redirect_uri", ",", "'client_id'", "=>", "$", "client_id", ",", "'scope'", "=>", "$", "scope", ",", "'response_type'", "=>", "$", "response_type", ",", "]", ";", "}", "}" ]
Validate request parameters @param \Slim\Http\Request $request Slim request @param string $amz_client_id Client ID as configured in Amazon Developer Console @return array @throws \InvalidArgumentException @access public @author a.schmidt@internet-of-voice.de
[ "Validate", "request", "parameters" ]
bd1eb6ca90a55f4928c35b9f0742a5cc922298ef
https://github.com/internetofvoice/vsms-core/blob/bd1eb6ca90a55f4928c35b9f0742a5cc922298ef/src/Controller/AbstractLinkController.php#L24-L59
25,571
internetofvoice/vsms-core
src/Controller/AbstractLinkController.php
AbstractLinkController.getRedirectLocation
public function getRedirectLocation($parameters, $access_token) { $location = array(); array_push($location, $parameters['redirect_uri'] . '#state=' . $parameters['state']); array_push($location, 'access_token=' . $access_token); array_push($location, 'token_type=Bearer'); return implode('&', $location); }
php
public function getRedirectLocation($parameters, $access_token) { $location = array(); array_push($location, $parameters['redirect_uri'] . '#state=' . $parameters['state']); array_push($location, 'access_token=' . $access_token); array_push($location, 'token_type=Bearer'); return implode('&', $location); }
[ "public", "function", "getRedirectLocation", "(", "$", "parameters", ",", "$", "access_token", ")", "{", "$", "location", "=", "array", "(", ")", ";", "array_push", "(", "$", "location", ",", "$", "parameters", "[", "'redirect_uri'", "]", ".", "'#state='", ".", "$", "parameters", "[", "'state'", "]", ")", ";", "array_push", "(", "$", "location", ",", "'access_token='", ".", "$", "access_token", ")", ";", "array_push", "(", "$", "location", ",", "'token_type=Bearer'", ")", ";", "return", "implode", "(", "'&'", ",", "$", "location", ")", ";", "}" ]
Get redirect location @param array $parameters Amazon parameters (see validateRequestParameters()) @param string $access_token Generated access token @return string @access public @author a.schmidt@internet-of-voice.de
[ "Get", "redirect", "location" ]
bd1eb6ca90a55f4928c35b9f0742a5cc922298ef
https://github.com/internetofvoice/vsms-core/blob/bd1eb6ca90a55f4928c35b9f0742a5cc922298ef/src/Controller/AbstractLinkController.php#L70-L77
25,572
jabernardo/lollipop-php
Library/HTTP/Router.php
Router._registerDispatch
static private function _registerDispatch() { // Register dispatch function $auto_dispatch = !is_null(Config::get('router.auto_dispatch')) ? Config::get('router.auto_dispatch') : true; if (!self::$_dispatch_registered && $auto_dispatch) { // Make sure things ends here... register_shutdown_function(function() { // Get response data from Dispatcher $response = self::dispatch(); }); // Mark as dispatched self::$_dispatch_registered = true; } }
php
static private function _registerDispatch() { // Register dispatch function $auto_dispatch = !is_null(Config::get('router.auto_dispatch')) ? Config::get('router.auto_dispatch') : true; if (!self::$_dispatch_registered && $auto_dispatch) { // Make sure things ends here... register_shutdown_function(function() { // Get response data from Dispatcher $response = self::dispatch(); }); // Mark as dispatched self::$_dispatch_registered = true; } }
[ "static", "private", "function", "_registerDispatch", "(", ")", "{", "// Register dispatch function", "$", "auto_dispatch", "=", "!", "is_null", "(", "Config", "::", "get", "(", "'router.auto_dispatch'", ")", ")", "?", "Config", "::", "get", "(", "'router.auto_dispatch'", ")", ":", "true", ";", "if", "(", "!", "self", "::", "$", "_dispatch_registered", "&&", "$", "auto_dispatch", ")", "{", "// Make sure things ends here...", "register_shutdown_function", "(", "function", "(", ")", "{", "// Get response data from Dispatcher", "$", "response", "=", "self", "::", "dispatch", "(", ")", ";", "}", ")", ";", "// Mark as dispatched", "self", "::", "$", "_dispatch_registered", "=", "true", ";", "}", "}" ]
Register dispatch function on shutdown @access private @return void
[ "Register", "dispatch", "function", "on", "shutdown" ]
004d80b21f7246bb3e08c7b9f74a165b0d3ca0f5
https://github.com/jabernardo/lollipop-php/blob/004d80b21f7246bb3e08c7b9f74a165b0d3ca0f5/Library/HTTP/Router.php#L372-L388
25,573
jabernardo/lollipop-php
Library/HTTP/Router.php
Router._process
static private function _process(\Lollipop\HTTP\Request $req, \Lollipop\HTTP\Response $res) { if (is_null(self::$_kernel)) { $active = self::$_active_route; $top = function(\Lollipop\HTTP\Request $req, \Lollipop\HTTP\Response $res) use ($active) { return Route::resolve($active['callback'], $req, $res, $active['arguments']); }; self::$_kernel = $top; } // Create a new address for the top callable $start = self::$_kernel; // Start dequeue self::$_busy = true; $new_response = $start($req, $res); self::$_busy = false; // Just want to make sure that processed response from middlewares // are instance of \Calf\HTTP\Response if ($new_response instanceof \Lollipop\HTTP\Response) { $res = $new_response; } else { $res->set($new_response); } return $res; }
php
static private function _process(\Lollipop\HTTP\Request $req, \Lollipop\HTTP\Response $res) { if (is_null(self::$_kernel)) { $active = self::$_active_route; $top = function(\Lollipop\HTTP\Request $req, \Lollipop\HTTP\Response $res) use ($active) { return Route::resolve($active['callback'], $req, $res, $active['arguments']); }; self::$_kernel = $top; } // Create a new address for the top callable $start = self::$_kernel; // Start dequeue self::$_busy = true; $new_response = $start($req, $res); self::$_busy = false; // Just want to make sure that processed response from middlewares // are instance of \Calf\HTTP\Response if ($new_response instanceof \Lollipop\HTTP\Response) { $res = $new_response; } else { $res->set($new_response); } return $res; }
[ "static", "private", "function", "_process", "(", "\\", "Lollipop", "\\", "HTTP", "\\", "Request", "$", "req", ",", "\\", "Lollipop", "\\", "HTTP", "\\", "Response", "$", "res", ")", "{", "if", "(", "is_null", "(", "self", "::", "$", "_kernel", ")", ")", "{", "$", "active", "=", "self", "::", "$", "_active_route", ";", "$", "top", "=", "function", "(", "\\", "Lollipop", "\\", "HTTP", "\\", "Request", "$", "req", ",", "\\", "Lollipop", "\\", "HTTP", "\\", "Response", "$", "res", ")", "use", "(", "$", "active", ")", "{", "return", "Route", "::", "resolve", "(", "$", "active", "[", "'callback'", "]", ",", "$", "req", ",", "$", "res", ",", "$", "active", "[", "'arguments'", "]", ")", ";", "}", ";", "self", "::", "$", "_kernel", "=", "$", "top", ";", "}", "// Create a new address for the top callable", "$", "start", "=", "self", "::", "$", "_kernel", ";", "// Start dequeue", "self", "::", "$", "_busy", "=", "true", ";", "$", "new_response", "=", "$", "start", "(", "$", "req", ",", "$", "res", ")", ";", "self", "::", "$", "_busy", "=", "false", ";", "// Just want to make sure that processed response from middlewares", "// are instance of \\Calf\\HTTP\\Response", "if", "(", "$", "new_response", "instanceof", "\\", "Lollipop", "\\", "HTTP", "\\", "Response", ")", "{", "$", "res", "=", "$", "new_response", ";", "}", "else", "{", "$", "res", "->", "set", "(", "$", "new_response", ")", ";", "}", "return", "$", "res", ";", "}" ]
Process middleware stack @access private @param \Lollipop\HTTP\Request $req Request Object @param \Lollipop\HTTP\Response $res Response Object @return \Lollipop\HTTP\Response Response object
[ "Process", "middleware", "stack" ]
004d80b21f7246bb3e08c7b9f74a165b0d3ca0f5
https://github.com/jabernardo/lollipop-php/blob/004d80b21f7246bb3e08c7b9f74a165b0d3ca0f5/Library/HTTP/Router.php#L399-L425
25,574
jabernardo/lollipop-php
Library/HTTP/Router.php
Router._getDefaultPageNotFound
static private function _getDefaultPageNotFound() { return [ 'path' => '404', 'callback' => function(\Lollipop\HTTP\Request $req, \Lollipop\HTTP\Response $res, $args = []) { // Create a default 404 page $pagenotfound = '<!DOCTYPE html>' . '<!-- Lollipop for PHP by John Aldrich Bernardo -->' . '<html>' . '<head><title>404 Not Found</title></head>' . '<meta name="viewport" content="width=device-width, initial-scale=1">' . '<body>' . '<h1>404 Not Found</h1>' . '<p>The page that you have requested could not be found.</p>' . '</body>' . '</html>'; // Create a new 404 Page Not Found Response $response = new Response($pagenotfound); // Set header for 404 $response->header('HTTP/1.0 404 Not Found'); // Execute return $response; }, 'arguments' => [] ]; }
php
static private function _getDefaultPageNotFound() { return [ 'path' => '404', 'callback' => function(\Lollipop\HTTP\Request $req, \Lollipop\HTTP\Response $res, $args = []) { // Create a default 404 page $pagenotfound = '<!DOCTYPE html>' . '<!-- Lollipop for PHP by John Aldrich Bernardo -->' . '<html>' . '<head><title>404 Not Found</title></head>' . '<meta name="viewport" content="width=device-width, initial-scale=1">' . '<body>' . '<h1>404 Not Found</h1>' . '<p>The page that you have requested could not be found.</p>' . '</body>' . '</html>'; // Create a new 404 Page Not Found Response $response = new Response($pagenotfound); // Set header for 404 $response->header('HTTP/1.0 404 Not Found'); // Execute return $response; }, 'arguments' => [] ]; }
[ "static", "private", "function", "_getDefaultPageNotFound", "(", ")", "{", "return", "[", "'path'", "=>", "'404'", ",", "'callback'", "=>", "function", "(", "\\", "Lollipop", "\\", "HTTP", "\\", "Request", "$", "req", ",", "\\", "Lollipop", "\\", "HTTP", "\\", "Response", "$", "res", ",", "$", "args", "=", "[", "]", ")", "{", "// Create a default 404 page", "$", "pagenotfound", "=", "'<!DOCTYPE html>'", ".", "'<!-- Lollipop for PHP by John Aldrich Bernardo -->'", ".", "'<html>'", ".", "'<head><title>404 Not Found</title></head>'", ".", "'<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">'", ".", "'<body>'", ".", "'<h1>404 Not Found</h1>'", ".", "'<p>The page that you have requested could not be found.</p>'", ".", "'</body>'", ".", "'</html>'", ";", "// Create a new 404 Page Not Found Response", "$", "response", "=", "new", "Response", "(", "$", "pagenotfound", ")", ";", "// Set header for 404", "$", "response", "->", "header", "(", "'HTTP/1.0 404 Not Found'", ")", ";", "// Execute", "return", "$", "response", ";", "}", ",", "'arguments'", "=>", "[", "]", "]", ";", "}" ]
Check if any of routes doesn't match @access private @return \Lollipop\HTTP\Response
[ "Check", "if", "any", "of", "routes", "doesn", "t", "match" ]
004d80b21f7246bb3e08c7b9f74a165b0d3ca0f5
https://github.com/jabernardo/lollipop-php/blob/004d80b21f7246bb3e08c7b9f74a165b0d3ca0f5/Library/HTTP/Router.php#L475-L501
25,575
ARCANESOFT/SEO
src/Providers/RouteServiceProvider.php
RouteServiceProvider.mapAdminRoutes
protected function mapAdminRoutes() { $this->name('seo.') ->prefix($this->config()->get('arcanesoft.seo.route.prefix', 'seo')) ->group(function () { Routes\Admin\DashboardRoutes::register(); Routes\Admin\PagesRoutes::register(); Routes\Admin\FootersRoutes::register(); Routes\Admin\MetasRoutes::register(); Routes\Admin\RedirectsRoutes::register(); Routes\Admin\SpammersRoutes::register(); Routes\Admin\SettingsRoutes::register(); }); }
php
protected function mapAdminRoutes() { $this->name('seo.') ->prefix($this->config()->get('arcanesoft.seo.route.prefix', 'seo')) ->group(function () { Routes\Admin\DashboardRoutes::register(); Routes\Admin\PagesRoutes::register(); Routes\Admin\FootersRoutes::register(); Routes\Admin\MetasRoutes::register(); Routes\Admin\RedirectsRoutes::register(); Routes\Admin\SpammersRoutes::register(); Routes\Admin\SettingsRoutes::register(); }); }
[ "protected", "function", "mapAdminRoutes", "(", ")", "{", "$", "this", "->", "name", "(", "'seo.'", ")", "->", "prefix", "(", "$", "this", "->", "config", "(", ")", "->", "get", "(", "'arcanesoft.seo.route.prefix'", ",", "'seo'", ")", ")", "->", "group", "(", "function", "(", ")", "{", "Routes", "\\", "Admin", "\\", "DashboardRoutes", "::", "register", "(", ")", ";", "Routes", "\\", "Admin", "\\", "PagesRoutes", "::", "register", "(", ")", ";", "Routes", "\\", "Admin", "\\", "FootersRoutes", "::", "register", "(", ")", ";", "Routes", "\\", "Admin", "\\", "MetasRoutes", "::", "register", "(", ")", ";", "Routes", "\\", "Admin", "\\", "RedirectsRoutes", "::", "register", "(", ")", ";", "Routes", "\\", "Admin", "\\", "SpammersRoutes", "::", "register", "(", ")", ";", "Routes", "\\", "Admin", "\\", "SettingsRoutes", "::", "register", "(", ")", ";", "}", ")", ";", "}" ]
Map the admin routes.
[ "Map", "the", "admin", "routes", "." ]
ce6d6135d55e8b2fd43cf7923839b4791b7c7ad2
https://github.com/ARCANESOFT/SEO/blob/ce6d6135d55e8b2fd43cf7923839b4791b7c7ad2/src/Providers/RouteServiceProvider.php#L62-L75
25,576
cinnamonlab/framework
src/Framework/Input.php
Input.file
static function file( $key, $default = null, $validator = null) { if ( ! isset($_FILES[$key]) || $_FILES[$key]['error'] != UPLOAD_ERR_OK) return self::processError($default); $file = new InputFile($_FILES[$key]['tmp_name']); $file->setContentType($_FILES[$key]['type']); $file->setOriginalName($_FILES[$key]['name']); if ($validator instanceof Validator) { if ( $validator->execute( $file ) ) { return $file; } else { return self::processError($default); } } else if (is_callable($validator)) { try { if ($validator($file) ) { return $file; } else { return self::processError($default); } } catch (Exception $e) { throw FrameworkException::internalError("Validator error"); } } return $file; }
php
static function file( $key, $default = null, $validator = null) { if ( ! isset($_FILES[$key]) || $_FILES[$key]['error'] != UPLOAD_ERR_OK) return self::processError($default); $file = new InputFile($_FILES[$key]['tmp_name']); $file->setContentType($_FILES[$key]['type']); $file->setOriginalName($_FILES[$key]['name']); if ($validator instanceof Validator) { if ( $validator->execute( $file ) ) { return $file; } else { return self::processError($default); } } else if (is_callable($validator)) { try { if ($validator($file) ) { return $file; } else { return self::processError($default); } } catch (Exception $e) { throw FrameworkException::internalError("Validator error"); } } return $file; }
[ "static", "function", "file", "(", "$", "key", ",", "$", "default", "=", "null", ",", "$", "validator", "=", "null", ")", "{", "if", "(", "!", "isset", "(", "$", "_FILES", "[", "$", "key", "]", ")", "||", "$", "_FILES", "[", "$", "key", "]", "[", "'error'", "]", "!=", "UPLOAD_ERR_OK", ")", "return", "self", "::", "processError", "(", "$", "default", ")", ";", "$", "file", "=", "new", "InputFile", "(", "$", "_FILES", "[", "$", "key", "]", "[", "'tmp_name'", "]", ")", ";", "$", "file", "->", "setContentType", "(", "$", "_FILES", "[", "$", "key", "]", "[", "'type'", "]", ")", ";", "$", "file", "->", "setOriginalName", "(", "$", "_FILES", "[", "$", "key", "]", "[", "'name'", "]", ")", ";", "if", "(", "$", "validator", "instanceof", "Validator", ")", "{", "if", "(", "$", "validator", "->", "execute", "(", "$", "file", ")", ")", "{", "return", "$", "file", ";", "}", "else", "{", "return", "self", "::", "processError", "(", "$", "default", ")", ";", "}", "}", "else", "if", "(", "is_callable", "(", "$", "validator", ")", ")", "{", "try", "{", "if", "(", "$", "validator", "(", "$", "file", ")", ")", "{", "return", "$", "file", ";", "}", "else", "{", "return", "self", "::", "processError", "(", "$", "default", ")", ";", "}", "}", "catch", "(", "Exception", "$", "e", ")", "{", "throw", "FrameworkException", "::", "internalError", "(", "\"Validator error\"", ")", ";", "}", "}", "return", "$", "file", ";", "}" ]
Get Uploaded File @param $key @param null $default @param null $validator @return InputFile
[ "Get", "Uploaded", "File" ]
958ba3e60d3f927adc40a543ec6d4f08d38cfd2c
https://github.com/cinnamonlab/framework/blob/958ba3e60d3f927adc40a543ec6d4f08d38cfd2c/src/Framework/Input.php#L76-L105
25,577
cinnamonlab/framework
src/Framework/Input.php
Input.set
static function set( $key, $value ) { $me = self::getInstance(); $me->parameters[$key] = $value; }
php
static function set( $key, $value ) { $me = self::getInstance(); $me->parameters[$key] = $value; }
[ "static", "function", "set", "(", "$", "key", ",", "$", "value", ")", "{", "$", "me", "=", "self", "::", "getInstance", "(", ")", ";", "$", "me", "->", "parameters", "[", "$", "key", "]", "=", "$", "value", ";", "}" ]
Set Value Manually @param $key @param $value
[ "Set", "Value", "Manually" ]
958ba3e60d3f927adc40a543ec6d4f08d38cfd2c
https://github.com/cinnamonlab/framework/blob/958ba3e60d3f927adc40a543ec6d4f08d38cfd2c/src/Framework/Input.php#L112-L115
25,578
MichaelJ2324/PHP-REST-Client
src/Auth/Abstracts/AbstractAuthController.php
AbstractAuthController.configureEndpoint
protected function configureEndpoint(EndpointInterface $Endpoint, $action) { switch ($action) { case self::ACTION_AUTH: $Endpoint = $this->configureAuthenticationEndpoint($Endpoint); break; case self::ACTION_LOGOUT: $Endpoint = $this->configureLogoutEndpoint($Endpoint); break; } return $Endpoint; }
php
protected function configureEndpoint(EndpointInterface $Endpoint, $action) { switch ($action) { case self::ACTION_AUTH: $Endpoint = $this->configureAuthenticationEndpoint($Endpoint); break; case self::ACTION_LOGOUT: $Endpoint = $this->configureLogoutEndpoint($Endpoint); break; } return $Endpoint; }
[ "protected", "function", "configureEndpoint", "(", "EndpointInterface", "$", "Endpoint", ",", "$", "action", ")", "{", "switch", "(", "$", "action", ")", "{", "case", "self", "::", "ACTION_AUTH", ":", "$", "Endpoint", "=", "$", "this", "->", "configureAuthenticationEndpoint", "(", "$", "Endpoint", ")", ";", "break", ";", "case", "self", "::", "ACTION_LOGOUT", ":", "$", "Endpoint", "=", "$", "this", "->", "configureLogoutEndpoint", "(", "$", "Endpoint", ")", ";", "break", ";", "}", "return", "$", "Endpoint", ";", "}" ]
Configure an actions Endpoint Object @param EndpointInterface $Endpoint @param string $action @return EndpointInterface
[ "Configure", "an", "actions", "Endpoint", "Object" ]
b8a2caaf6456eccaa845ba5c5098608aa9645c92
https://github.com/MichaelJ2324/PHP-REST-Client/blob/b8a2caaf6456eccaa845ba5c5098608aa9645c92/src/Auth/Abstracts/AbstractAuthController.php#L249-L260
25,579
eliasis-framework/complement
src/Complement.php
Complement.run
public static function run() { if (! session_id()) { session_start(); } $complementType = self::getType('strtoupper'); $path = App::$complementType(); if ($paths = File::getFilesFromDir($path)) { foreach ($paths as $path) { if (! $path->isDot() && $path->isDir()) { $_path = Url::addBackSlash($path->getPath()); $slug = $path->getBasename(); $file = $_path . $slug . '/' . $slug . '.json'; if (! File::exists($file)) { continue; } self::load($file); } } } self::requestHandler(self::getType('strtolower', false)); }
php
public static function run() { if (! session_id()) { session_start(); } $complementType = self::getType('strtoupper'); $path = App::$complementType(); if ($paths = File::getFilesFromDir($path)) { foreach ($paths as $path) { if (! $path->isDot() && $path->isDir()) { $_path = Url::addBackSlash($path->getPath()); $slug = $path->getBasename(); $file = $_path . $slug . '/' . $slug . '.json'; if (! File::exists($file)) { continue; } self::load($file); } } } self::requestHandler(self::getType('strtolower', false)); }
[ "public", "static", "function", "run", "(", ")", "{", "if", "(", "!", "session_id", "(", ")", ")", "{", "session_start", "(", ")", ";", "}", "$", "complementType", "=", "self", "::", "getType", "(", "'strtoupper'", ")", ";", "$", "path", "=", "App", "::", "$", "complementType", "(", ")", ";", "if", "(", "$", "paths", "=", "File", "::", "getFilesFromDir", "(", "$", "path", ")", ")", "{", "foreach", "(", "$", "paths", "as", "$", "path", ")", "{", "if", "(", "!", "$", "path", "->", "isDot", "(", ")", "&&", "$", "path", "->", "isDir", "(", ")", ")", "{", "$", "_path", "=", "Url", "::", "addBackSlash", "(", "$", "path", "->", "getPath", "(", ")", ")", ";", "$", "slug", "=", "$", "path", "->", "getBasename", "(", ")", ";", "$", "file", "=", "$", "_path", ".", "$", "slug", ".", "'/'", ".", "$", "slug", ".", "'.json'", ";", "if", "(", "!", "File", "::", "exists", "(", "$", "file", ")", ")", "{", "continue", ";", "}", "self", "::", "load", "(", "$", "file", ")", ";", "}", "}", "}", "self", "::", "requestHandler", "(", "self", "::", "getType", "(", "'strtolower'", ",", "false", ")", ")", ";", "}" ]
Load all complements found in the directory. @uses \Eliasis\Complement\ComplementRequest::requestHandler() @uses \Eliasis\Complement\ComplementHandler::getType()
[ "Load", "all", "complements", "found", "in", "the", "directory", "." ]
d50e92cf01600ff4573bf1761c312069044748c3
https://github.com/eliasis-framework/complement/blob/d50e92cf01600ff4573bf1761c312069044748c3/src/Complement.php#L111-L136
25,580
eliasis-framework/complement
src/Complement.php
Complement.load
public static function load($file) { $complement = Json::fileToArray($file); $complement['config-file'] = $file; self::$id = isset($complement['id']) ? $complement['id'] : 'Default'; $that = self::getInstance(); return $that->setComplement($complement); }
php
public static function load($file) { $complement = Json::fileToArray($file); $complement['config-file'] = $file; self::$id = isset($complement['id']) ? $complement['id'] : 'Default'; $that = self::getInstance(); return $that->setComplement($complement); }
[ "public", "static", "function", "load", "(", "$", "file", ")", "{", "$", "complement", "=", "Json", "::", "fileToArray", "(", "$", "file", ")", ";", "$", "complement", "[", "'config-file'", "]", "=", "$", "file", ";", "self", "::", "$", "id", "=", "isset", "(", "$", "complement", "[", "'id'", "]", ")", "?", "$", "complement", "[", "'id'", "]", ":", "'Default'", ";", "$", "that", "=", "self", "::", "getInstance", "(", ")", ";", "return", "$", "that", "->", "setComplement", "(", "$", "complement", ")", ";", "}" ]
Load complement configuration from json file and set settings. @param string $file → path or url to the complement configuration file @uses \Josantonius\Json\Json::fileToArray() @uses \Eliasis\Complement\ComplementHandler->setComplement() @return bool true
[ "Load", "complement", "configuration", "from", "json", "file", "and", "set", "settings", "." ]
d50e92cf01600ff4573bf1761c312069044748c3
https://github.com/eliasis-framework/complement/blob/d50e92cf01600ff4573bf1761c312069044748c3/src/Complement.php#L148-L156
25,581
eliasis-framework/complement
src/Complement.php
Complement.setCurrentID
public static function setCurrentID($id) { $type = self::getType(); $appID = App::getCurrentID(); if (array_key_exists($id, self::$instances[$appID][$type])) { self::$id = $id; return true; } return false; }
php
public static function setCurrentID($id) { $type = self::getType(); $appID = App::getCurrentID(); if (array_key_exists($id, self::$instances[$appID][$type])) { self::$id = $id; return true; } return false; }
[ "public", "static", "function", "setCurrentID", "(", "$", "id", ")", "{", "$", "type", "=", "self", "::", "getType", "(", ")", ";", "$", "appID", "=", "App", "::", "getCurrentID", "(", ")", ";", "if", "(", "array_key_exists", "(", "$", "id", ",", "self", "::", "$", "instances", "[", "$", "appID", "]", "[", "$", "type", "]", ")", ")", "{", "self", "::", "$", "id", "=", "$", "id", ";", "return", "true", ";", "}", "return", "false", ";", "}" ]
Define the current complement ID. @since 1.1.0 @param string $id → complement ID @return bool
[ "Define", "the", "current", "complement", "ID", "." ]
d50e92cf01600ff4573bf1761c312069044748c3
https://github.com/eliasis-framework/complement/blob/d50e92cf01600ff4573bf1761c312069044748c3/src/Complement.php#L250-L261
25,582
eliasis-framework/complement
src/Complement.php
Complement.script
public static function script($pathUrl = null, $vue = true, $vueResource = true) { $that = self::getInstance(); $file = $vue ? 'vue+' : ''; $file .= $vueResource ? 'vue-resource+' : ''; return $that->setFile($file . 'eliasis-complement.min', 'script', $pathUrl); }
php
public static function script($pathUrl = null, $vue = true, $vueResource = true) { $that = self::getInstance(); $file = $vue ? 'vue+' : ''; $file .= $vueResource ? 'vue-resource+' : ''; return $that->setFile($file . 'eliasis-complement.min', 'script', $pathUrl); }
[ "public", "static", "function", "script", "(", "$", "pathUrl", "=", "null", ",", "$", "vue", "=", "true", ",", "$", "vueResource", "=", "true", ")", "{", "$", "that", "=", "self", "::", "getInstance", "(", ")", ";", "$", "file", "=", "$", "vue", "?", "'vue+'", ":", "''", ";", "$", "file", ".=", "$", "vueResource", "?", "'vue-resource+'", ":", "''", ";", "return", "$", "that", "->", "setFile", "(", "$", "file", ".", "'eliasis-complement.min'", ",", "'script'", ",", "$", "pathUrl", ")", ";", "}" ]
Set and get script url. @param string $pathUrl → url where JS files will be created & loaded @param bool $vue → include Vue.js in the script @param bool $vueResource → include vue-resource in the script @uses \Eliasis\Complement\ComplementView::setFile() @return string → script url
[ "Set", "and", "get", "script", "url", "." ]
d50e92cf01600ff4573bf1761c312069044748c3
https://github.com/eliasis-framework/complement/blob/d50e92cf01600ff4573bf1761c312069044748c3/src/Complement.php#L274-L282
25,583
eliasis-framework/complement
src/Complement.php
Complement.exists
public static function exists($complementID) { $type = self::getType(); return array_key_exists( $complementID, self::$instances[App::getCurrentID()][$type] ); }
php
public static function exists($complementID) { $type = self::getType(); return array_key_exists( $complementID, self::$instances[App::getCurrentID()][$type] ); }
[ "public", "static", "function", "exists", "(", "$", "complementID", ")", "{", "$", "type", "=", "self", "::", "getType", "(", ")", ";", "return", "array_key_exists", "(", "$", "complementID", ",", "self", "::", "$", "instances", "[", "App", "::", "getCurrentID", "(", ")", "]", "[", "$", "type", "]", ")", ";", "}" ]
Check if complement exists. @param string $complementID → complement id @uses \Eliasis\Framework\App::getCurrentID() @uses \Eliasis\Complement\ComplementHandler::getType() @return bool
[ "Check", "if", "complement", "exists", "." ]
d50e92cf01600ff4573bf1761c312069044748c3
https://github.com/eliasis-framework/complement/blob/d50e92cf01600ff4573bf1761c312069044748c3/src/Complement.php#L310-L318
25,584
eliasis-framework/complement
src/Complement.php
Complement.getLibraryVersion
public static function getLibraryVersion() { $path = self::getLibraryPath(); $composer = Json::fileToArray($path . 'composer.json'); return isset($composer['version']) ? $composer['version'] : '1.1.1'; }
php
public static function getLibraryVersion() { $path = self::getLibraryPath(); $composer = Json::fileToArray($path . 'composer.json'); return isset($composer['version']) ? $composer['version'] : '1.1.1'; }
[ "public", "static", "function", "getLibraryVersion", "(", ")", "{", "$", "path", "=", "self", "::", "getLibraryPath", "(", ")", ";", "$", "composer", "=", "Json", "::", "fileToArray", "(", "$", "path", ".", "'composer.json'", ")", ";", "return", "isset", "(", "$", "composer", "[", "'version'", "]", ")", "?", "$", "composer", "[", "'version'", "]", ":", "'1.1.1'", ";", "}" ]
Get library version. @uses \Josantonius\Json\Json::fileToArray() @return string
[ "Get", "library", "version", "." ]
d50e92cf01600ff4573bf1761c312069044748c3
https://github.com/eliasis-framework/complement/blob/d50e92cf01600ff4573bf1761c312069044748c3/src/Complement.php#L337-L343
25,585
eliasis-framework/complement
src/Complement.php
Complement.getInstance
protected static function getInstance() { $type = self::getType(); $appID = App::getCurrentID(); $complementID = self::getCurrentID(); $complement = get_called_class(); if (! isset(self::$instances[$appID][$type][$complementID])) { self::$instances[$appID][$type][$complementID] = new $complement(); } return self::$instances[$appID][$type][$complementID]; }
php
protected static function getInstance() { $type = self::getType(); $appID = App::getCurrentID(); $complementID = self::getCurrentID(); $complement = get_called_class(); if (! isset(self::$instances[$appID][$type][$complementID])) { self::$instances[$appID][$type][$complementID] = new $complement(); } return self::$instances[$appID][$type][$complementID]; }
[ "protected", "static", "function", "getInstance", "(", ")", "{", "$", "type", "=", "self", "::", "getType", "(", ")", ";", "$", "appID", "=", "App", "::", "getCurrentID", "(", ")", ";", "$", "complementID", "=", "self", "::", "getCurrentID", "(", ")", ";", "$", "complement", "=", "get_called_class", "(", ")", ";", "if", "(", "!", "isset", "(", "self", "::", "$", "instances", "[", "$", "appID", "]", "[", "$", "type", "]", "[", "$", "complementID", "]", ")", ")", "{", "self", "::", "$", "instances", "[", "$", "appID", "]", "[", "$", "type", "]", "[", "$", "complementID", "]", "=", "new", "$", "complement", "(", ")", ";", "}", "return", "self", "::", "$", "instances", "[", "$", "appID", "]", "[", "$", "type", "]", "[", "$", "complementID", "]", ";", "}" ]
Get complement instance. @uses \Eliasis\Framework\App::getCurrentID() @uses \Eliasis\Complement\ComplementHandler::getType() @return object → complement instance
[ "Get", "complement", "instance", "." ]
d50e92cf01600ff4573bf1761c312069044748c3
https://github.com/eliasis-framework/complement/blob/d50e92cf01600ff4573bf1761c312069044748c3/src/Complement.php#L380-L391
25,586
cubicmushroom/valueobjects
src/Geography/Address.php
Address.fromNative
public static function fromNative() { $args = \func_get_args(); if (\count($args) != 8) { throw new \BadMethodCallException('You must provide exactly 8 arguments: 1) addressee name, 2) street name, 3) street number, 4) district, 5) city, 6) region, 7) postal code, 8) country code.'); } $name = new StringLiteral($args[0]); $street = new Street(new StringLiteral($args[1]), new StringLiteral($args[2])); $district = new StringLiteral($args[3]); $city = new StringLiteral($args[4]); $region = new StringLiteral($args[5]); $postalCode = new StringLiteral($args[6]); $country = Country::fromNative($args[7]); return new self($name, $street, $district, $city, $region, $postalCode, $country); }
php
public static function fromNative() { $args = \func_get_args(); if (\count($args) != 8) { throw new \BadMethodCallException('You must provide exactly 8 arguments: 1) addressee name, 2) street name, 3) street number, 4) district, 5) city, 6) region, 7) postal code, 8) country code.'); } $name = new StringLiteral($args[0]); $street = new Street(new StringLiteral($args[1]), new StringLiteral($args[2])); $district = new StringLiteral($args[3]); $city = new StringLiteral($args[4]); $region = new StringLiteral($args[5]); $postalCode = new StringLiteral($args[6]); $country = Country::fromNative($args[7]); return new self($name, $street, $district, $city, $region, $postalCode, $country); }
[ "public", "static", "function", "fromNative", "(", ")", "{", "$", "args", "=", "\\", "func_get_args", "(", ")", ";", "if", "(", "\\", "count", "(", "$", "args", ")", "!=", "8", ")", "{", "throw", "new", "\\", "BadMethodCallException", "(", "'You must provide exactly 8 arguments: 1) addressee name, 2) street name, 3) street number, 4) district, 5) city, 6) region, 7) postal code, 8) country code.'", ")", ";", "}", "$", "name", "=", "new", "StringLiteral", "(", "$", "args", "[", "0", "]", ")", ";", "$", "street", "=", "new", "Street", "(", "new", "StringLiteral", "(", "$", "args", "[", "1", "]", ")", ",", "new", "StringLiteral", "(", "$", "args", "[", "2", "]", ")", ")", ";", "$", "district", "=", "new", "StringLiteral", "(", "$", "args", "[", "3", "]", ")", ";", "$", "city", "=", "new", "StringLiteral", "(", "$", "args", "[", "4", "]", ")", ";", "$", "region", "=", "new", "StringLiteral", "(", "$", "args", "[", "5", "]", ")", ";", "$", "postalCode", "=", "new", "StringLiteral", "(", "$", "args", "[", "6", "]", ")", ";", "$", "country", "=", "Country", "::", "fromNative", "(", "$", "args", "[", "7", "]", ")", ";", "return", "new", "self", "(", "$", "name", ",", "$", "street", ",", "$", "district", ",", "$", "city", ",", "$", "region", ",", "$", "postalCode", ",", "$", "country", ")", ";", "}" ]
Returns a new Address from native PHP arguments @param string $name @param string $street_name @param string $street_number @param string $district @param string $city @param string $region @param string $postal_code @param string $country_code @return self @throws \BadMethodCallException
[ "Returns", "a", "new", "Address", "from", "native", "PHP", "arguments" ]
4554239ab75d65eeb9773219aa5b07e9fbfabb92
https://github.com/cubicmushroom/valueobjects/blob/4554239ab75d65eeb9773219aa5b07e9fbfabb92/src/Geography/Address.php#L61-L78
25,587
cubicmushroom/valueobjects
src/Geography/Address.php
Address.sameValueAs
public function sameValueAs(ValueObjectInterface $address) { if (false === Util::classEquals($this, $address)) { return false; } return $this->getName()->sameValueAs($address->getName()) && $this->getStreet()->sameValueAs($address->getStreet()) && $this->getDistrict()->sameValueAs($address->getDistrict()) && $this->getCity()->sameValueAs($address->getCity()) && $this->getRegion()->sameValueAs($address->getRegion()) && $this->getPostalCode()->sameValueAs($address->getPostalCode()) && $this->getCountry()->sameValueAs($address->getCountry()) ; }
php
public function sameValueAs(ValueObjectInterface $address) { if (false === Util::classEquals($this, $address)) { return false; } return $this->getName()->sameValueAs($address->getName()) && $this->getStreet()->sameValueAs($address->getStreet()) && $this->getDistrict()->sameValueAs($address->getDistrict()) && $this->getCity()->sameValueAs($address->getCity()) && $this->getRegion()->sameValueAs($address->getRegion()) && $this->getPostalCode()->sameValueAs($address->getPostalCode()) && $this->getCountry()->sameValueAs($address->getCountry()) ; }
[ "public", "function", "sameValueAs", "(", "ValueObjectInterface", "$", "address", ")", "{", "if", "(", "false", "===", "Util", "::", "classEquals", "(", "$", "this", ",", "$", "address", ")", ")", "{", "return", "false", ";", "}", "return", "$", "this", "->", "getName", "(", ")", "->", "sameValueAs", "(", "$", "address", "->", "getName", "(", ")", ")", "&&", "$", "this", "->", "getStreet", "(", ")", "->", "sameValueAs", "(", "$", "address", "->", "getStreet", "(", ")", ")", "&&", "$", "this", "->", "getDistrict", "(", ")", "->", "sameValueAs", "(", "$", "address", "->", "getDistrict", "(", ")", ")", "&&", "$", "this", "->", "getCity", "(", ")", "->", "sameValueAs", "(", "$", "address", "->", "getCity", "(", ")", ")", "&&", "$", "this", "->", "getRegion", "(", ")", "->", "sameValueAs", "(", "$", "address", "->", "getRegion", "(", ")", ")", "&&", "$", "this", "->", "getPostalCode", "(", ")", "->", "sameValueAs", "(", "$", "address", "->", "getPostalCode", "(", ")", ")", "&&", "$", "this", "->", "getCountry", "(", ")", "->", "sameValueAs", "(", "$", "address", "->", "getCountry", "(", ")", ")", ";", "}" ]
Tells whether two Address are equal @param ValueObjectInterface $address @return bool
[ "Tells", "whether", "two", "Address", "are", "equal" ]
4554239ab75d65eeb9773219aa5b07e9fbfabb92
https://github.com/cubicmushroom/valueobjects/blob/4554239ab75d65eeb9773219aa5b07e9fbfabb92/src/Geography/Address.php#L108-L122
25,588
agniukaitis/CInformer
src/cinformer/CInformer.php
CInformer.setMessage
public function setMessage($data) { // initialize a flash session variable if(!isset($_SESSION['flash'])) { $_SESSION['flash'] = array(); } // check for valid message template. Set to default if not valid if(!in_array($data['type'], $this->valid)) { $data['type'] = $this->valid[0]; } $_SESSION['flash']['type'] = $data['type']; $_SESSION['flash']['message'] = $data['message']; return true; }
php
public function setMessage($data) { // initialize a flash session variable if(!isset($_SESSION['flash'])) { $_SESSION['flash'] = array(); } // check for valid message template. Set to default if not valid if(!in_array($data['type'], $this->valid)) { $data['type'] = $this->valid[0]; } $_SESSION['flash']['type'] = $data['type']; $_SESSION['flash']['message'] = $data['message']; return true; }
[ "public", "function", "setMessage", "(", "$", "data", ")", "{", "// initialize a flash session variable", "if", "(", "!", "isset", "(", "$", "_SESSION", "[", "'flash'", "]", ")", ")", "{", "$", "_SESSION", "[", "'flash'", "]", "=", "array", "(", ")", ";", "}", "// check for valid message template. Set to default if not valid", "if", "(", "!", "in_array", "(", "$", "data", "[", "'type'", "]", ",", "$", "this", "->", "valid", ")", ")", "{", "$", "data", "[", "'type'", "]", "=", "$", "this", "->", "valid", "[", "0", "]", ";", "}", "$", "_SESSION", "[", "'flash'", "]", "[", "'type'", "]", "=", "$", "data", "[", "'type'", "]", ";", "$", "_SESSION", "[", "'flash'", "]", "[", "'message'", "]", "=", "$", "data", "[", "'message'", "]", ";", "return", "true", ";", "}" ]
Set the message into session variable @return boolean
[ "Set", "the", "message", "into", "session", "variable" ]
bfaed9d9f624174efe3ac0a6654d49d2fdba628b
https://github.com/agniukaitis/CInformer/blob/bfaed9d9f624174efe3ac0a6654d49d2fdba628b/src/cinformer/CInformer.php#L31-L47
25,589
sabinus52/OlixDatatablesBootstrapBundle
Twig/DatatableTwigExtension.php
DatatableTwigExtension.datatableRenderHtml
public function datatableRenderHtml(Twig_Environment $twig, AbstractDatatableView $datatable) { //return $twig->render('OlixDatatablesBootstrapBundle::datatable_html.html.twig', $this->getOptions($datatable)); return $twig->render('SgDatatablesBundle:Datatable:datatable_html.html.twig', $this->getOptions($datatable)); }
php
public function datatableRenderHtml(Twig_Environment $twig, AbstractDatatableView $datatable) { //return $twig->render('OlixDatatablesBootstrapBundle::datatable_html.html.twig', $this->getOptions($datatable)); return $twig->render('SgDatatablesBundle:Datatable:datatable_html.html.twig', $this->getOptions($datatable)); }
[ "public", "function", "datatableRenderHtml", "(", "Twig_Environment", "$", "twig", ",", "AbstractDatatableView", "$", "datatable", ")", "{", "//return $twig->render('OlixDatatablesBootstrapBundle::datatable_html.html.twig', $this->getOptions($datatable));", "return", "$", "twig", "->", "render", "(", "'SgDatatablesBundle:Datatable:datatable_html.html.twig'", ",", "$", "this", "->", "getOptions", "(", "$", "datatable", ")", ")", ";", "}" ]
Renders the html template. @param Twig_Environment $twig @param AbstractDatatableView $datatable @return mixed|string @throws Exception
[ "Renders", "the", "html", "template", "." ]
9b5d6dfb72b7aeecef43545378f50e7a6adc1b12
https://github.com/sabinus52/OlixDatatablesBootstrapBundle/blob/9b5d6dfb72b7aeecef43545378f50e7a6adc1b12/Twig/DatatableTwigExtension.php#L136-L140
25,590
sabinus52/OlixDatatablesBootstrapBundle
Twig/DatatableTwigExtension.php
DatatableTwigExtension.datatableRenderJs
public function datatableRenderJs(Twig_Environment $twig, AbstractDatatableView $datatable) { return $twig->render('SgDatatablesBundle:Datatable:datatable_js.html.twig', $this->getOptions($datatable)); }
php
public function datatableRenderJs(Twig_Environment $twig, AbstractDatatableView $datatable) { return $twig->render('SgDatatablesBundle:Datatable:datatable_js.html.twig', $this->getOptions($datatable)); }
[ "public", "function", "datatableRenderJs", "(", "Twig_Environment", "$", "twig", ",", "AbstractDatatableView", "$", "datatable", ")", "{", "return", "$", "twig", "->", "render", "(", "'SgDatatablesBundle:Datatable:datatable_js.html.twig'", ",", "$", "this", "->", "getOptions", "(", "$", "datatable", ")", ")", ";", "}" ]
Renders the js template. @param Twig_Environment $twig @param AbstractDatatableView $datatable @return mixed|string @throws Exception
[ "Renders", "the", "js", "template", "." ]
9b5d6dfb72b7aeecef43545378f50e7a6adc1b12
https://github.com/sabinus52/OlixDatatablesBootstrapBundle/blob/9b5d6dfb72b7aeecef43545378f50e7a6adc1b12/Twig/DatatableTwigExtension.php#L151-L154
25,591
sabinus52/OlixDatatablesBootstrapBundle
Twig/DatatableTwigExtension.php
DatatableTwigExtension.datatableFilterRender
public function datatableFilterRender(Twig_Environment $twig, AbstractDatatableView $datatable, AbstractColumn $column, $loopIndex) { if ($filterProperty = $column->getFilter()->getProperty()) { $filterColumnId = $datatable->getColumnIdByColumnName($filterProperty); } else { $filterColumnId = $loopIndex; } return $twig->render($column->getFilter()->getTemplate(), array( 'column' => $column, 'filterColumnId' => $filterColumnId, 'selectorId' => $loopIndex, 'tableId' => $datatable->getName() ) ); }
php
public function datatableFilterRender(Twig_Environment $twig, AbstractDatatableView $datatable, AbstractColumn $column, $loopIndex) { if ($filterProperty = $column->getFilter()->getProperty()) { $filterColumnId = $datatable->getColumnIdByColumnName($filterProperty); } else { $filterColumnId = $loopIndex; } return $twig->render($column->getFilter()->getTemplate(), array( 'column' => $column, 'filterColumnId' => $filterColumnId, 'selectorId' => $loopIndex, 'tableId' => $datatable->getName() ) ); }
[ "public", "function", "datatableFilterRender", "(", "Twig_Environment", "$", "twig", ",", "AbstractDatatableView", "$", "datatable", ",", "AbstractColumn", "$", "column", ",", "$", "loopIndex", ")", "{", "if", "(", "$", "filterProperty", "=", "$", "column", "->", "getFilter", "(", ")", "->", "getProperty", "(", ")", ")", "{", "$", "filterColumnId", "=", "$", "datatable", "->", "getColumnIdByColumnName", "(", "$", "filterProperty", ")", ";", "}", "else", "{", "$", "filterColumnId", "=", "$", "loopIndex", ";", "}", "return", "$", "twig", "->", "render", "(", "$", "column", "->", "getFilter", "(", ")", "->", "getTemplate", "(", ")", ",", "array", "(", "'column'", "=>", "$", "column", ",", "'filterColumnId'", "=>", "$", "filterColumnId", ",", "'selectorId'", "=>", "$", "loopIndex", ",", "'tableId'", "=>", "$", "datatable", "->", "getName", "(", ")", ")", ")", ";", "}" ]
Renders the custom datatable filter. @param Twig_Environment $twig @param AbstractDatatableView $datatable @param AbstractColumn $column @param integer $loopIndex @return mixed|string|void
[ "Renders", "the", "custom", "datatable", "filter", "." ]
9b5d6dfb72b7aeecef43545378f50e7a6adc1b12
https://github.com/sabinus52/OlixDatatablesBootstrapBundle/blob/9b5d6dfb72b7aeecef43545378f50e7a6adc1b12/Twig/DatatableTwigExtension.php#L166-L181
25,592
sabinus52/OlixDatatablesBootstrapBundle
Twig/DatatableTwigExtension.php
DatatableTwigExtension.datatableIcon
public function datatableIcon(Twig_Environment $twig, $icon, $label = '') { if ($icon) return $twig->render('SgDatatablesBundle:Action:icon.html.twig', array('icon' => $icon, 'label' => $label)); else return $label; }
php
public function datatableIcon(Twig_Environment $twig, $icon, $label = '') { if ($icon) return $twig->render('SgDatatablesBundle:Action:icon.html.twig', array('icon' => $icon, 'label' => $label)); else return $label; }
[ "public", "function", "datatableIcon", "(", "Twig_Environment", "$", "twig", ",", "$", "icon", ",", "$", "label", "=", "''", ")", "{", "if", "(", "$", "icon", ")", "return", "$", "twig", "->", "render", "(", "'SgDatatablesBundle:Action:icon.html.twig'", ",", "array", "(", "'icon'", "=>", "$", "icon", ",", "'label'", "=>", "$", "label", ")", ")", ";", "else", "return", "$", "label", ";", "}" ]
Renders icon && label. @param Twig_Environment $twig @param string $icon @param string $label @return string
[ "Renders", "icon", "&&", "label", "." ]
9b5d6dfb72b7aeecef43545378f50e7a6adc1b12
https://github.com/sabinus52/OlixDatatablesBootstrapBundle/blob/9b5d6dfb72b7aeecef43545378f50e7a6adc1b12/Twig/DatatableTwigExtension.php#L192-L198
25,593
vatson/isolated-callback
src/Vatson/Callback/IsolatedCallback.php
IsolatedCallback.registerChildShutdown
protected function registerChildShutdown() { $ipc = $this->ipc; register_shutdown_function(function () use ($ipc) { $error = error_get_last(); if ($error && isset($error['type']) && in_array($error['type'], array(E_ERROR, E_PARSE, E_CORE_ERROR, E_COMPILE_ERROR))) { $ipc->put(new ExceptionDataHolder( new \ErrorException($error['message'], 0, $error['type'], $error['file'], $error['line']) )); } }); register_shutdown_function(function () { posix_kill(getmypid(), SIGKILL); }); }
php
protected function registerChildShutdown() { $ipc = $this->ipc; register_shutdown_function(function () use ($ipc) { $error = error_get_last(); if ($error && isset($error['type']) && in_array($error['type'], array(E_ERROR, E_PARSE, E_CORE_ERROR, E_COMPILE_ERROR))) { $ipc->put(new ExceptionDataHolder( new \ErrorException($error['message'], 0, $error['type'], $error['file'], $error['line']) )); } }); register_shutdown_function(function () { posix_kill(getmypid(), SIGKILL); }); }
[ "protected", "function", "registerChildShutdown", "(", ")", "{", "$", "ipc", "=", "$", "this", "->", "ipc", ";", "register_shutdown_function", "(", "function", "(", ")", "use", "(", "$", "ipc", ")", "{", "$", "error", "=", "error_get_last", "(", ")", ";", "if", "(", "$", "error", "&&", "isset", "(", "$", "error", "[", "'type'", "]", ")", "&&", "in_array", "(", "$", "error", "[", "'type'", "]", ",", "array", "(", "E_ERROR", ",", "E_PARSE", ",", "E_CORE_ERROR", ",", "E_COMPILE_ERROR", ")", ")", ")", "{", "$", "ipc", "->", "put", "(", "new", "ExceptionDataHolder", "(", "new", "\\", "ErrorException", "(", "$", "error", "[", "'message'", "]", ",", "0", ",", "$", "error", "[", "'type'", "]", ",", "$", "error", "[", "'file'", "]", ",", "$", "error", "[", "'line'", "]", ")", ")", ")", ";", "}", "}", ")", ";", "register_shutdown_function", "(", "function", "(", ")", "{", "posix_kill", "(", "getmypid", "(", ")", ",", "SIGKILL", ")", ";", "}", ")", ";", "}" ]
Avoids the closing of resources in child process
[ "Avoids", "the", "closing", "of", "resources", "in", "child", "process" ]
c048f4cc830c246c0aa8c45da91af9e8c5a86ca4
https://github.com/vatson/isolated-callback/blob/c048f4cc830c246c0aa8c45da91af9e8c5a86ca4/src/Vatson/Callback/IsolatedCallback.php#L70-L86
25,594
FuzeWorks/Core
src/FuzeWorks/Events.php
Events.addListener
public static function addListener($callback, $eventName, $priority = EventPriority::NORMAL) { // Perform multiple checks if (EventPriority::getPriority($priority) == false) { throw new EventException('Can not add listener: Unknown priority '.$priority, 1); } if (!is_callable($callback)) { throw new EventException("Can not add listener: Callback is not callable", 1); } if (empty($eventName)) { throw new EventException("Can not add listener: No eventname provided", 1); } if (!isset(self::$listeners[$eventName])) { self::$listeners[$eventName] = array(); } if (!isset(self::$listeners[$eventName][$priority])) { self::$listeners[$eventName][$priority] = array(); } if (func_num_args() > 3) { $args = array_slice(func_get_args(), 3); } else { $args = array(); } self::$listeners[$eventName][$priority][] = array($callback, $args); }
php
public static function addListener($callback, $eventName, $priority = EventPriority::NORMAL) { // Perform multiple checks if (EventPriority::getPriority($priority) == false) { throw new EventException('Can not add listener: Unknown priority '.$priority, 1); } if (!is_callable($callback)) { throw new EventException("Can not add listener: Callback is not callable", 1); } if (empty($eventName)) { throw new EventException("Can not add listener: No eventname provided", 1); } if (!isset(self::$listeners[$eventName])) { self::$listeners[$eventName] = array(); } if (!isset(self::$listeners[$eventName][$priority])) { self::$listeners[$eventName][$priority] = array(); } if (func_num_args() > 3) { $args = array_slice(func_get_args(), 3); } else { $args = array(); } self::$listeners[$eventName][$priority][] = array($callback, $args); }
[ "public", "static", "function", "addListener", "(", "$", "callback", ",", "$", "eventName", ",", "$", "priority", "=", "EventPriority", "::", "NORMAL", ")", "{", "// Perform multiple checks", "if", "(", "EventPriority", "::", "getPriority", "(", "$", "priority", ")", "==", "false", ")", "{", "throw", "new", "EventException", "(", "'Can not add listener: Unknown priority '", ".", "$", "priority", ",", "1", ")", ";", "}", "if", "(", "!", "is_callable", "(", "$", "callback", ")", ")", "{", "throw", "new", "EventException", "(", "\"Can not add listener: Callback is not callable\"", ",", "1", ")", ";", "}", "if", "(", "empty", "(", "$", "eventName", ")", ")", "{", "throw", "new", "EventException", "(", "\"Can not add listener: No eventname provided\"", ",", "1", ")", ";", "}", "if", "(", "!", "isset", "(", "self", "::", "$", "listeners", "[", "$", "eventName", "]", ")", ")", "{", "self", "::", "$", "listeners", "[", "$", "eventName", "]", "=", "array", "(", ")", ";", "}", "if", "(", "!", "isset", "(", "self", "::", "$", "listeners", "[", "$", "eventName", "]", "[", "$", "priority", "]", ")", ")", "{", "self", "::", "$", "listeners", "[", "$", "eventName", "]", "[", "$", "priority", "]", "=", "array", "(", ")", ";", "}", "if", "(", "func_num_args", "(", ")", ">", "3", ")", "{", "$", "args", "=", "array_slice", "(", "func_get_args", "(", ")", ",", "3", ")", ";", "}", "else", "{", "$", "args", "=", "array", "(", ")", ";", "}", "self", "::", "$", "listeners", "[", "$", "eventName", "]", "[", "$", "priority", "]", "[", "]", "=", "array", "(", "$", "callback", ",", "$", "args", ")", ";", "}" ]
Adds a function as listener. @param mixed $callback The callback when the events get fired, see {@link http://php.net/manual/en/language.types.callable.php PHP.net} @param string $eventName The name of the event @param int $priority The priority, even though integers are valid, please use EventPriority (for example EventPriority::Lowest) @param mixed $parameters,... Parameters for the listener @see EventPriority @throws EventException
[ "Adds", "a", "function", "as", "listener", "." ]
051c64fdaa3a648174cbd54557d05ad553dd826b
https://github.com/FuzeWorks/Core/blob/051c64fdaa3a648174cbd54557d05ad553dd826b/src/FuzeWorks/Events.php#L85-L119
25,595
FuzeWorks/Core
src/FuzeWorks/Events.php
Events.removeListener
public static function removeListener($callback, $eventName, $priority = EventPriority::NORMAL) { if (EventPriority::getPriority($priority) == false) { throw new EventException('Unknown priority '.$priority); } if (!isset(self::$listeners[$eventName]) || !isset(self::$listeners[$eventName][$priority])) { return; } foreach (self::$listeners[$eventName][$priority] as $i => $_callback) { if ($_callback[0] == $callback) { unset(self::$listeners[$eventName][$priority][$i]); return; } } }
php
public static function removeListener($callback, $eventName, $priority = EventPriority::NORMAL) { if (EventPriority::getPriority($priority) == false) { throw new EventException('Unknown priority '.$priority); } if (!isset(self::$listeners[$eventName]) || !isset(self::$listeners[$eventName][$priority])) { return; } foreach (self::$listeners[$eventName][$priority] as $i => $_callback) { if ($_callback[0] == $callback) { unset(self::$listeners[$eventName][$priority][$i]); return; } } }
[ "public", "static", "function", "removeListener", "(", "$", "callback", ",", "$", "eventName", ",", "$", "priority", "=", "EventPriority", "::", "NORMAL", ")", "{", "if", "(", "EventPriority", "::", "getPriority", "(", "$", "priority", ")", "==", "false", ")", "{", "throw", "new", "EventException", "(", "'Unknown priority '", ".", "$", "priority", ")", ";", "}", "if", "(", "!", "isset", "(", "self", "::", "$", "listeners", "[", "$", "eventName", "]", ")", "||", "!", "isset", "(", "self", "::", "$", "listeners", "[", "$", "eventName", "]", "[", "$", "priority", "]", ")", ")", "{", "return", ";", "}", "foreach", "(", "self", "::", "$", "listeners", "[", "$", "eventName", "]", "[", "$", "priority", "]", "as", "$", "i", "=>", "$", "_callback", ")", "{", "if", "(", "$", "_callback", "[", "0", "]", "==", "$", "callback", ")", "{", "unset", "(", "self", "::", "$", "listeners", "[", "$", "eventName", "]", "[", "$", "priority", "]", "[", "$", "i", "]", ")", ";", "return", ";", "}", "}", "}" ]
Removes a function as listener. @param mixed callback The callback when the events get fired, see {@link http://php.net/manual/en/language.types.callable.php PHP.net} @param string $eventName The name of the event @param int $priority The priority, even though integers are valid, please use EventPriority (for example EventPriority::Lowest) @see EventPriority @throws EventException
[ "Removes", "a", "function", "as", "listener", "." ]
051c64fdaa3a648174cbd54557d05ad553dd826b
https://github.com/FuzeWorks/Core/blob/051c64fdaa3a648174cbd54557d05ad553dd826b/src/FuzeWorks/Events.php#L132-L149
25,596
netlogix/Netlogix.Crud
Classes/Netlogix/Crud/Domain/Service/DataTransferObjectFactory.php
DataTransferObjectFactory.getDataTransferObjectName
public function getDataTransferObjectName($object) { $objectName = TypeHandling::getTypeForValue($object); if (!array_key_exists($objectName, $this->classMappingConfiguration)) { foreach (array_reverse($this->classNameToDtoClassNameReplaceFragments, TRUE) as $dtoClassNameFragment => $classNameFragment) { $dtoClassName = str_replace($classNameFragment, $dtoClassNameFragment, $objectName); if (class_exists($dtoClassName)) { $this->classMappingConfiguration[$objectName] = $dtoClassName; break; } } } if (!isset($this->classMappingConfiguration[$objectName])) { throw new InvalidTargetException(sprintf('There is no DTO class name for "%s" objects.', $objectName), 1407499486); } return $this->classMappingConfiguration[$objectName]; }
php
public function getDataTransferObjectName($object) { $objectName = TypeHandling::getTypeForValue($object); if (!array_key_exists($objectName, $this->classMappingConfiguration)) { foreach (array_reverse($this->classNameToDtoClassNameReplaceFragments, TRUE) as $dtoClassNameFragment => $classNameFragment) { $dtoClassName = str_replace($classNameFragment, $dtoClassNameFragment, $objectName); if (class_exists($dtoClassName)) { $this->classMappingConfiguration[$objectName] = $dtoClassName; break; } } } if (!isset($this->classMappingConfiguration[$objectName])) { throw new InvalidTargetException(sprintf('There is no DTO class name for "%s" objects.', $objectName), 1407499486); } return $this->classMappingConfiguration[$objectName]; }
[ "public", "function", "getDataTransferObjectName", "(", "$", "object", ")", "{", "$", "objectName", "=", "TypeHandling", "::", "getTypeForValue", "(", "$", "object", ")", ";", "if", "(", "!", "array_key_exists", "(", "$", "objectName", ",", "$", "this", "->", "classMappingConfiguration", ")", ")", "{", "foreach", "(", "array_reverse", "(", "$", "this", "->", "classNameToDtoClassNameReplaceFragments", ",", "TRUE", ")", "as", "$", "dtoClassNameFragment", "=>", "$", "classNameFragment", ")", "{", "$", "dtoClassName", "=", "str_replace", "(", "$", "classNameFragment", ",", "$", "dtoClassNameFragment", ",", "$", "objectName", ")", ";", "if", "(", "class_exists", "(", "$", "dtoClassName", ")", ")", "{", "$", "this", "->", "classMappingConfiguration", "[", "$", "objectName", "]", "=", "$", "dtoClassName", ";", "break", ";", "}", "}", "}", "if", "(", "!", "isset", "(", "$", "this", "->", "classMappingConfiguration", "[", "$", "objectName", "]", ")", ")", "{", "throw", "new", "InvalidTargetException", "(", "sprintf", "(", "'There is no DTO class name for \"%s\" objects.'", ",", "$", "objectName", ")", ",", "1407499486", ")", ";", "}", "return", "$", "this", "->", "classMappingConfiguration", "[", "$", "objectName", "]", ";", "}" ]
Returns the class name of the given DataTransferObject. @param $object @return string @throws InvalidTargetException
[ "Returns", "the", "class", "name", "of", "the", "given", "DataTransferObject", "." ]
61438827ba6b0a7a63cd2f08a294967ed5928144
https://github.com/netlogix/Netlogix.Crud/blob/61438827ba6b0a7a63cd2f08a294967ed5928144/Classes/Netlogix/Crud/Domain/Service/DataTransferObjectFactory.php#L82-L100
25,597
netlogix/Netlogix.Crud
Classes/Netlogix/Crud/Domain/Service/DataTransferObjectFactory.php
DataTransferObjectFactory.getDataTransferObject
public function getDataTransferObject($object) { if ($object === NULL) { return NULL; } $identifier = $this->persistenceManager->getIdentifierByObject($object); $dto = $this->propertyMapper->convert($identifier, $this->getDataTransferObjectName($object)); return $dto; }
php
public function getDataTransferObject($object) { if ($object === NULL) { return NULL; } $identifier = $this->persistenceManager->getIdentifierByObject($object); $dto = $this->propertyMapper->convert($identifier, $this->getDataTransferObjectName($object)); return $dto; }
[ "public", "function", "getDataTransferObject", "(", "$", "object", ")", "{", "if", "(", "$", "object", "===", "NULL", ")", "{", "return", "NULL", ";", "}", "$", "identifier", "=", "$", "this", "->", "persistenceManager", "->", "getIdentifierByObject", "(", "$", "object", ")", ";", "$", "dto", "=", "$", "this", "->", "propertyMapper", "->", "convert", "(", "$", "identifier", ",", "$", "this", "->", "getDataTransferObjectName", "(", "$", "object", ")", ")", ";", "return", "$", "dto", ";", "}" ]
Returns a DataTransferObject for the given object name. @param mixed $object @return \Netlogix\Crud\Domain\Model\DataTransfer\AbstractDataTransferObject
[ "Returns", "a", "DataTransferObject", "for", "the", "given", "object", "name", "." ]
61438827ba6b0a7a63cd2f08a294967ed5928144
https://github.com/netlogix/Netlogix.Crud/blob/61438827ba6b0a7a63cd2f08a294967ed5928144/Classes/Netlogix/Crud/Domain/Service/DataTransferObjectFactory.php#L108-L115
25,598
netlogix/Netlogix.Crud
Classes/Netlogix/Crud/Domain/Service/DataTransferObjectFactory.php
DataTransferObjectFactory.pushClassNameToDtoClassNameReplaceFragments
public function pushClassNameToDtoClassNameReplaceFragments(array $classNameToDtoClassNameReplaceFragments, $mergeWithExistingFragments = TRUE) { array_push($this->classNameToDtoClassNameReplaceFragmentsStack, $this->classNameToDtoClassNameReplaceFragments); array_push($this->classMappingConfigurationStack, $this->classMappingConfiguration); $this->classNameToDtoClassNameReplaceFragments = \Netlogix\Crud\Utility\ArrayUtility::arrayMergeRecursiveOverrule( $mergeWithExistingFragments ? $this->classNameToDtoClassNameReplaceFragments : array(), $classNameToDtoClassNameReplaceFragments ); }
php
public function pushClassNameToDtoClassNameReplaceFragments(array $classNameToDtoClassNameReplaceFragments, $mergeWithExistingFragments = TRUE) { array_push($this->classNameToDtoClassNameReplaceFragmentsStack, $this->classNameToDtoClassNameReplaceFragments); array_push($this->classMappingConfigurationStack, $this->classMappingConfiguration); $this->classNameToDtoClassNameReplaceFragments = \Netlogix\Crud\Utility\ArrayUtility::arrayMergeRecursiveOverrule( $mergeWithExistingFragments ? $this->classNameToDtoClassNameReplaceFragments : array(), $classNameToDtoClassNameReplaceFragments ); }
[ "public", "function", "pushClassNameToDtoClassNameReplaceFragments", "(", "array", "$", "classNameToDtoClassNameReplaceFragments", ",", "$", "mergeWithExistingFragments", "=", "TRUE", ")", "{", "array_push", "(", "$", "this", "->", "classNameToDtoClassNameReplaceFragmentsStack", ",", "$", "this", "->", "classNameToDtoClassNameReplaceFragments", ")", ";", "array_push", "(", "$", "this", "->", "classMappingConfigurationStack", ",", "$", "this", "->", "classMappingConfiguration", ")", ";", "$", "this", "->", "classNameToDtoClassNameReplaceFragments", "=", "\\", "Netlogix", "\\", "Crud", "\\", "Utility", "\\", "ArrayUtility", "::", "arrayMergeRecursiveOverrule", "(", "$", "mergeWithExistingFragments", "?", "$", "this", "->", "classNameToDtoClassNameReplaceFragments", ":", "array", "(", ")", ",", "$", "classNameToDtoClassNameReplaceFragments", ")", ";", "}" ]
Register new class name fragments @param array $classNameToDtoClassNameReplaceFragments @param bool $mergeWithExistingFragments
[ "Register", "new", "class", "name", "fragments" ]
61438827ba6b0a7a63cd2f08a294967ed5928144
https://github.com/netlogix/Netlogix.Crud/blob/61438827ba6b0a7a63cd2f08a294967ed5928144/Classes/Netlogix/Crud/Domain/Service/DataTransferObjectFactory.php#L135-L142
25,599
netlogix/Netlogix.Crud
Classes/Netlogix/Crud/Domain/Service/DataTransferObjectFactory.php
DataTransferObjectFactory.popClassNameToDtoClassNameReplaceFragments
public function popClassNameToDtoClassNameReplaceFragments() { $this->classMappingConfiguration = array_pop($this->classMappingConfigurationStack); $this->classNameToDtoClassNameReplaceFragments = array_pop($this->classNameToDtoClassNameReplaceFragmentsStack); }
php
public function popClassNameToDtoClassNameReplaceFragments() { $this->classMappingConfiguration = array_pop($this->classMappingConfigurationStack); $this->classNameToDtoClassNameReplaceFragments = array_pop($this->classNameToDtoClassNameReplaceFragmentsStack); }
[ "public", "function", "popClassNameToDtoClassNameReplaceFragments", "(", ")", "{", "$", "this", "->", "classMappingConfiguration", "=", "array_pop", "(", "$", "this", "->", "classMappingConfigurationStack", ")", ";", "$", "this", "->", "classNameToDtoClassNameReplaceFragments", "=", "array_pop", "(", "$", "this", "->", "classNameToDtoClassNameReplaceFragmentsStack", ")", ";", "}" ]
Restore old class name fragment settings
[ "Restore", "old", "class", "name", "fragment", "settings" ]
61438827ba6b0a7a63cd2f08a294967ed5928144
https://github.com/netlogix/Netlogix.Crud/blob/61438827ba6b0a7a63cd2f08a294967ed5928144/Classes/Netlogix/Crud/Domain/Service/DataTransferObjectFactory.php#L147-L150