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
partition
stringclasses
1 value
indigophp-archive/supervisor-configuration
src/Configuration/Parser/Base.php
Base.parseSection
public function parseSection($name, array $section) { $name = explode(':', $name, 2); $class = $this->findSection($name[0]); if (isset($name[1])) { return new $class($name[1], $section); } return new $class($section); }
php
public function parseSection($name, array $section) { $name = explode(':', $name, 2); $class = $this->findSection($name[0]); if (isset($name[1])) { return new $class($name[1], $section); } return new $class($section); }
[ "public", "function", "parseSection", "(", "$", "name", ",", "array", "$", "section", ")", "{", "$", "name", "=", "explode", "(", "':'", ",", "$", "name", ",", "2", ")", ";", "$", "class", "=", "$", "this", "->", "findSection", "(", "$", "name", ...
Parses an individual section @param string $name @param array $section Array representation of section @return Section
[ "Parses", "an", "individual", "section" ]
7c5fca2e305be004ad91f8e2b4859ece1d484813
https://github.com/indigophp-archive/supervisor-configuration/blob/7c5fca2e305be004ad91f8e2b4859ece1d484813/src/Configuration/Parser/Base.php#L101-L112
train
indigophp-archive/codeception-fuel-module
fuel/fuel/core/classes/config.php
Config.save
public static function save($file, $config) { if ( ! is_array($config)) { if ( ! isset(static::$items[$config])) { return false; } $config = static::$items[$config]; } $info = pathinfo($file); $type = 'php'; if (isset($info['extension'])) { $type = $info['extension']; // Keep extension when it's an absolute path, because the finder won't add it if ($file[0] !== '/' and $file[1] !== ':') { $file = substr($file, 0, -(strlen($type) + 1)); } } $class = '\\Config_'.ucfirst($type); if ( ! class_exists($class)) { throw new \FuelException(sprintf('Invalid config type "%s".', $type)); } $driver = new $class($file); return $driver->save($config); }
php
public static function save($file, $config) { if ( ! is_array($config)) { if ( ! isset(static::$items[$config])) { return false; } $config = static::$items[$config]; } $info = pathinfo($file); $type = 'php'; if (isset($info['extension'])) { $type = $info['extension']; // Keep extension when it's an absolute path, because the finder won't add it if ($file[0] !== '/' and $file[1] !== ':') { $file = substr($file, 0, -(strlen($type) + 1)); } } $class = '\\Config_'.ucfirst($type); if ( ! class_exists($class)) { throw new \FuelException(sprintf('Invalid config type "%s".', $type)); } $driver = new $class($file); return $driver->save($config); }
[ "public", "static", "function", "save", "(", "$", "file", ",", "$", "config", ")", "{", "if", "(", "!", "is_array", "(", "$", "config", ")", ")", "{", "if", "(", "!", "isset", "(", "static", "::", "$", "items", "[", "$", "config", "]", ")", ")"...
Save a config array to disc. @param string $file desired file name @param string|array $config master config array key or config array @return bool false when config is empty or invalid else \File::update result
[ "Save", "a", "config", "array", "to", "disc", "." ]
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/config.php#L140-L174
train
lucifurious/kisma
src/Kisma/Core/Utility/ErrorHandler.php
ErrorHandler.renderError
public static function renderError() { try { $_errorTemplate = \Kisma::get( 'app.error_template', '_error.twig' ); Render::twigView( $_errorTemplate, array( 'base_path' => \Kisma::get( 'app.base_path' ), 'app_root' => \Kisma::get( 'app.root' ), 'page_title' => 'Error', 'error' => static::$_error, 'page_header' => 'Something has gone awry...', 'page_header_small' => 'Not cool. :(', 'navbar' => array( 'brand' => 'Kisma v' . \Kisma::KismaVersion, 'items' => array( array( 'title' => 'Kisma on GitHub!', 'href' => 'http://github.com/kisma/kisma/', 'target' => '_blank', 'active' => 'active', ), ), ), ) ); return true; } catch ( \Exception $_ex ) { Log::error( 'Exception during rendering of error: ' . print_r( static::$_error, true ) ); } return false; }
php
public static function renderError() { try { $_errorTemplate = \Kisma::get( 'app.error_template', '_error.twig' ); Render::twigView( $_errorTemplate, array( 'base_path' => \Kisma::get( 'app.base_path' ), 'app_root' => \Kisma::get( 'app.root' ), 'page_title' => 'Error', 'error' => static::$_error, 'page_header' => 'Something has gone awry...', 'page_header_small' => 'Not cool. :(', 'navbar' => array( 'brand' => 'Kisma v' . \Kisma::KismaVersion, 'items' => array( array( 'title' => 'Kisma on GitHub!', 'href' => 'http://github.com/kisma/kisma/', 'target' => '_blank', 'active' => 'active', ), ), ), ) ); return true; } catch ( \Exception $_ex ) { Log::error( 'Exception during rendering of error: ' . print_r( static::$_error, true ) ); } return false; }
[ "public", "static", "function", "renderError", "(", ")", "{", "try", "{", "$", "_errorTemplate", "=", "\\", "Kisma", "::", "get", "(", "'app.error_template'", ",", "'_error.twig'", ")", ";", "Render", "::", "twigView", "(", "$", "_errorTemplate", ",", "array...
Renders an error @return bool
[ "Renders", "an", "error" ]
4cc9954249da4e535b52f154e728935f07e648ae
https://github.com/lucifurious/kisma/blob/4cc9954249da4e535b52f154e728935f07e648ae/src/Kisma/Core/Utility/ErrorHandler.php#L168-L205
train
lucifurious/kisma
src/Kisma/Core/Utility/ErrorHandler.php
ErrorHandler._cleanTrace
protected static function _cleanTrace( array &$trace, $skipLines = null, $basePath = null ) { $_trace = array(); $_basePath = $basePath ?: \Kisma::get( 'app.base_path' ); // Skip some lines if ( !empty( $skipLines ) && count( $trace ) > $skipLines ) { $trace = array_slice( $trace, $skipLines ); } foreach ( $trace as $_index => $_code ) { $_traceItem = array(); Scalar::sins( $trace[$_index], 'file', 'Unspecified' ); Scalar::sins( $trace[$_index], 'line', 0 ); Scalar::sins( $trace[$_index], 'function', 'Unspecified' ); $_traceItem['file_name'] = trim( str_replace( array( $_basePath, "\t", "\r", "\n", PHP_EOL, 'phar://', ), array( null, ' ', null, null, null, null, ), $trace[$_index]['file'] ) ); $_args = null; if ( isset( $_code['args'] ) && !empty( $_code['args'] ) ) { foreach ( $_code['args'] as $_arg ) { if ( is_object( $_arg ) ) { $_args .= get_class( $_arg ) . ', '; } else if ( is_array( $_arg ) ) { $_args .= '[array], '; } else if ( is_bool( $_arg ) ) { if ( $_arg ) { $_args .= 'true, '; } else { $_args .= 'false, '; } } else if ( is_numeric( $_arg ) ) { $_args .= $_arg . ', '; } else if ( is_scalar( $_arg ) ) { $_args .= '"' . $_arg . '", '; } else { $_args .= '"' . gettype( $_arg ) . '", '; } } } $_traceItem['line'] = $trace[$_index]['line']; if ( isset( $_code['type'] ) ) { $_traceItem['function'] = ( isset( $_code['class'] ) ? $_code['class'] : null ) . $_code['type'] . $_code['function']; } else { $_traceItem['function'] = $_code['function']; } $_traceItem['function'] .= '(' . ( $_args ? ' ' . trim( $_args, ', ' ) . ' ' : null ) . ')'; $_traceItem['index'] = $_index; $_trace[] = $_traceItem; } return $_trace; }
php
protected static function _cleanTrace( array &$trace, $skipLines = null, $basePath = null ) { $_trace = array(); $_basePath = $basePath ?: \Kisma::get( 'app.base_path' ); // Skip some lines if ( !empty( $skipLines ) && count( $trace ) > $skipLines ) { $trace = array_slice( $trace, $skipLines ); } foreach ( $trace as $_index => $_code ) { $_traceItem = array(); Scalar::sins( $trace[$_index], 'file', 'Unspecified' ); Scalar::sins( $trace[$_index], 'line', 0 ); Scalar::sins( $trace[$_index], 'function', 'Unspecified' ); $_traceItem['file_name'] = trim( str_replace( array( $_basePath, "\t", "\r", "\n", PHP_EOL, 'phar://', ), array( null, ' ', null, null, null, null, ), $trace[$_index]['file'] ) ); $_args = null; if ( isset( $_code['args'] ) && !empty( $_code['args'] ) ) { foreach ( $_code['args'] as $_arg ) { if ( is_object( $_arg ) ) { $_args .= get_class( $_arg ) . ', '; } else if ( is_array( $_arg ) ) { $_args .= '[array], '; } else if ( is_bool( $_arg ) ) { if ( $_arg ) { $_args .= 'true, '; } else { $_args .= 'false, '; } } else if ( is_numeric( $_arg ) ) { $_args .= $_arg . ', '; } else if ( is_scalar( $_arg ) ) { $_args .= '"' . $_arg . '", '; } else { $_args .= '"' . gettype( $_arg ) . '", '; } } } $_traceItem['line'] = $trace[$_index]['line']; if ( isset( $_code['type'] ) ) { $_traceItem['function'] = ( isset( $_code['class'] ) ? $_code['class'] : null ) . $_code['type'] . $_code['function']; } else { $_traceItem['function'] = $_code['function']; } $_traceItem['function'] .= '(' . ( $_args ? ' ' . trim( $_args, ', ' ) . ' ' : null ) . ')'; $_traceItem['index'] = $_index; $_trace[] = $_traceItem; } return $_trace; }
[ "protected", "static", "function", "_cleanTrace", "(", "array", "&", "$", "trace", ",", "$", "skipLines", "=", "null", ",", "$", "basePath", "=", "null", ")", "{", "$", "_trace", "=", "array", "(", ")", ";", "$", "_basePath", "=", "$", "basePath", "?...
Cleans up a trace array @param array $trace @param int $skipLines @param null $basePath @return null|string
[ "Cleans", "up", "a", "trace", "array" ]
4cc9954249da4e535b52f154e728935f07e648ae
https://github.com/lucifurious/kisma/blob/4cc9954249da4e535b52f154e728935f07e648ae/src/Kisma/Core/Utility/ErrorHandler.php#L216-L314
train
phossa2/libs
src/Phossa2/Db/Driver/StatementAbstract.php
StatementAbstract.checkPreparation
protected function checkPreparation() { // must be prepared if (null === $this->prepared) { throw new RuntimeException( Message::get(Message::DB_STMT_NOTPREPARED), Message::DB_STMT_NOTPREPARED ); } // close any previous resultset $this->closeResult(); }
php
protected function checkPreparation() { // must be prepared if (null === $this->prepared) { throw new RuntimeException( Message::get(Message::DB_STMT_NOTPREPARED), Message::DB_STMT_NOTPREPARED ); } // close any previous resultset $this->closeResult(); }
[ "protected", "function", "checkPreparation", "(", ")", "{", "// must be prepared", "if", "(", "null", "===", "$", "this", "->", "prepared", ")", "{", "throw", "new", "RuntimeException", "(", "Message", "::", "get", "(", "Message", "::", "DB_STMT_NOTPREPARED", ...
Throw exception if not prepared @throws RuntimeException @access protected
[ "Throw", "exception", "if", "not", "prepared" ]
921e485c8cc29067f279da2cdd06f47a9bddd115
https://github.com/phossa2/libs/blob/921e485c8cc29067f279da2cdd06f47a9bddd115/src/Phossa2/Db/Driver/StatementAbstract.php#L158-L170
train
kairosProject/ApiLoader
KairosProject/ApiLoader/Loader/AbstractApiLoader.php
AbstractApiLoader.loadItemOrThrowException
private function loadItemOrThrowException( QueryBuildingEventInterface $event, string $eventName, EventDispatcherInterface $dispatcher ) { $queryResult = $this->executeItemQuery($event, $eventName, $dispatcher); if (empty($queryResult) && $this->noItemException) { $this->logger->notice( 'Item not found from loader', [ 'loader class' => static::class, 'from event' => $eventName, 'dispatched event' => $this->itemEventName ] ); throw new \RuntimeException('Item not found from loader', 404); } return $queryResult; }
php
private function loadItemOrThrowException( QueryBuildingEventInterface $event, string $eventName, EventDispatcherInterface $dispatcher ) { $queryResult = $this->executeItemQuery($event, $eventName, $dispatcher); if (empty($queryResult) && $this->noItemException) { $this->logger->notice( 'Item not found from loader', [ 'loader class' => static::class, 'from event' => $eventName, 'dispatched event' => $this->itemEventName ] ); throw new \RuntimeException('Item not found from loader', 404); } return $queryResult; }
[ "private", "function", "loadItemOrThrowException", "(", "QueryBuildingEventInterface", "$", "event", ",", "string", "$", "eventName", ",", "EventDispatcherInterface", "$", "dispatcher", ")", "{", "$", "queryResult", "=", "$", "this", "->", "executeItemQuery", "(", "...
Load item or throw exception Load an item by executing the executeQueryItem. In case of item cannot be resolved, this method will throw a RuntimeException. The exception throwing can be disabled by the $noItemException constructor argument. @param ProcessEventInterface $event The original event. @param string $eventName The original event name. @param EventDispatcherInterface $dispatcher The event dispatcher. @throws \RuntimeException If the item cannot be loaded @return mixed @SuppressWarnings(PHPMD.UnusedPrivateMethod)
[ "Load", "item", "or", "throw", "exception" ]
d07c75ccc139d8b55b782e5e7719f802a61f044a
https://github.com/kairosProject/ApiLoader/blob/d07c75ccc139d8b55b782e5e7719f802a61f044a/KairosProject/ApiLoader/Loader/AbstractApiLoader.php#L307-L328
train
nirix/radium
src/Helpers/Pagination.php
Pagination.createUri
public function createUri($page) { $queryString = $this->query; $queryString[] = "page={$page}"; $queryString = implode('&', $queryString); return Request::pathInfo() . "?{$queryString}"; }
php
public function createUri($page) { $queryString = $this->query; $queryString[] = "page={$page}"; $queryString = implode('&', $queryString); return Request::pathInfo() . "?{$queryString}"; }
[ "public", "function", "createUri", "(", "$", "page", ")", "{", "$", "queryString", "=", "$", "this", "->", "query", ";", "$", "queryString", "[", "]", "=", "\"page={$page}\"", ";", "$", "queryString", "=", "implode", "(", "'&'", ",", "$", "queryString", ...
Creates the URI for the specified page. @param integer $page @return string
[ "Creates", "the", "URI", "for", "the", "specified", "page", "." ]
cc6907bfee296b64a7630b0b188e233d7cdb86fd
https://github.com/nirix/radium/blob/cc6907bfee296b64a7630b0b188e233d7cdb86fd/src/Helpers/Pagination.php#L174-L181
train
nirix/radium
src/Helpers/Pagination.php
Pagination.createPageLinks
protected function createPageLinks() { $pageLinks = array(); if ($this->totalPages > 10) { $startRange = $this->page - floor($this->range/2); $endRange = $this->page + floor($this->range/2); //Start range if ($startRange <= 0) { $startRange = 1; $endRange += abs($startRange) + 1; } // End range if ($endRange > $this->totalPages) { $startRange -= $endRange - $this->totalPages; $endRange = $this->totalPages; } // Range $range = range($startRange, $endRange); // Add first page $this->pageLinks[] = array( 'page' => 1, 'uri' => $this->createUri(1) ); foreach ($range as $page) { // Skip for first and last page if ($page == 1 or $page == $this->totalPages) { continue; } $this->pageLinks[] = array( 'page' => $page, 'uri' => $this->createUri($page) ); } // Add last page $this->pageLinks[] = array( 'page' => $this->totalPages, 'uri' => $this->createUri($this->totalPages) ); } else { for ($i = 1; $i <= $this->totalPages; $i++) { $this->pageLinks[] = array( 'page' => $i, 'uri' => $this->createUri($i) ); } } }
php
protected function createPageLinks() { $pageLinks = array(); if ($this->totalPages > 10) { $startRange = $this->page - floor($this->range/2); $endRange = $this->page + floor($this->range/2); //Start range if ($startRange <= 0) { $startRange = 1; $endRange += abs($startRange) + 1; } // End range if ($endRange > $this->totalPages) { $startRange -= $endRange - $this->totalPages; $endRange = $this->totalPages; } // Range $range = range($startRange, $endRange); // Add first page $this->pageLinks[] = array( 'page' => 1, 'uri' => $this->createUri(1) ); foreach ($range as $page) { // Skip for first and last page if ($page == 1 or $page == $this->totalPages) { continue; } $this->pageLinks[] = array( 'page' => $page, 'uri' => $this->createUri($page) ); } // Add last page $this->pageLinks[] = array( 'page' => $this->totalPages, 'uri' => $this->createUri($this->totalPages) ); } else { for ($i = 1; $i <= $this->totalPages; $i++) { $this->pageLinks[] = array( 'page' => $i, 'uri' => $this->createUri($i) ); } } }
[ "protected", "function", "createPageLinks", "(", ")", "{", "$", "pageLinks", "=", "array", "(", ")", ";", "if", "(", "$", "this", "->", "totalPages", ">", "10", ")", "{", "$", "startRange", "=", "$", "this", "->", "page", "-", "floor", "(", "$", "t...
Creates the page links.
[ "Creates", "the", "page", "links", "." ]
cc6907bfee296b64a7630b0b188e233d7cdb86fd
https://github.com/nirix/radium/blob/cc6907bfee296b64a7630b0b188e233d7cdb86fd/src/Helpers/Pagination.php#L186-L240
train
lucifurious/kisma
src/Kisma/Core/Utility/Xml.php
Xml.fromObject
public static function fromObject( $object, $rootName = null, $nodeName = null, $addHeader = true ) { if ( !is_object( $object ) ) { throw new \InvalidArgumentException( 'The value of "$object" is not an object.' ); } return static::fromArray( get_object_vars( $object ), $rootName, $nodeName, $addHeader ); }
php
public static function fromObject( $object, $rootName = null, $nodeName = null, $addHeader = true ) { if ( !is_object( $object ) ) { throw new \InvalidArgumentException( 'The value of "$object" is not an object.' ); } return static::fromArray( get_object_vars( $object ), $rootName, $nodeName, $addHeader ); }
[ "public", "static", "function", "fromObject", "(", "$", "object", ",", "$", "rootName", "=", "null", ",", "$", "nodeName", "=", "null", ",", "$", "addHeader", "=", "true", ")", "{", "if", "(", "!", "is_object", "(", "$", "object", ")", ")", "{", "t...
Converts an object to an XML string @param mixed $object @param string $rootName @param string $nodeName @param bool $addHeader If true, the <?xml?> header is prepended to the result @throws \InvalidArgumentException @return null|string
[ "Converts", "an", "object", "to", "an", "XML", "string" ]
4cc9954249da4e535b52f154e728935f07e648ae
https://github.com/lucifurious/kisma/blob/4cc9954249da4e535b52f154e728935f07e648ae/src/Kisma/Core/Utility/Xml.php#L42-L50
train
lucifurious/kisma
src/Kisma/Core/Utility/Xml.php
Xml.fromArray
public static function fromArray( $data, $rootName = null, $nodeName = null, $addHeader = true ) { $_xml = true === $addHeader ? '<?xml version="1.0" encoding="UTF-8" ?>' : null; if ( null !== $rootName ) { $_xml .= Markup::openTag( $rootName ); } $_string = null; if ( $data instanceof \Traversable ) { foreach ( $data as $_key => $_value ) { if ( is_numeric( $_key ) ) { $_key = $nodeName ?: 'node'; } $_string .= Markup::tag( $_key, array(), static::fromArray( $_value, $nodeName ) ); } } else { $_string = htmlspecialchars( $data, ENT_QUOTES ); } // Add the converted XML $_xml .= $_string; if ( null !== $rootName ) { $_xml .= Markup::closeTag( $rootName ); } return $_xml; }
php
public static function fromArray( $data, $rootName = null, $nodeName = null, $addHeader = true ) { $_xml = true === $addHeader ? '<?xml version="1.0" encoding="UTF-8" ?>' : null; if ( null !== $rootName ) { $_xml .= Markup::openTag( $rootName ); } $_string = null; if ( $data instanceof \Traversable ) { foreach ( $data as $_key => $_value ) { if ( is_numeric( $_key ) ) { $_key = $nodeName ?: 'node'; } $_string .= Markup::tag( $_key, array(), static::fromArray( $_value, $nodeName ) ); } } else { $_string = htmlspecialchars( $data, ENT_QUOTES ); } // Add the converted XML $_xml .= $_string; if ( null !== $rootName ) { $_xml .= Markup::closeTag( $rootName ); } return $_xml; }
[ "public", "static", "function", "fromArray", "(", "$", "data", ",", "$", "rootName", "=", "null", ",", "$", "nodeName", "=", "null", ",", "$", "addHeader", "=", "true", ")", "{", "$", "_xml", "=", "true", "===", "$", "addHeader", "?", "'<?xml version=\...
Converts an array to an XML string @param mixed $data @param string $rootName @param string $nodeName @param bool $addHeader @return null|string
[ "Converts", "an", "array", "to", "an", "XML", "string" ]
4cc9954249da4e535b52f154e728935f07e648ae
https://github.com/lucifurious/kisma/blob/4cc9954249da4e535b52f154e728935f07e648ae/src/Kisma/Core/Utility/Xml.php#L62-L99
train
PentagonalProject/SlimService
src/Session.php
Session.&
public static function &createWithName($name = null, AuraSession $session = null) : Session { $session = ! is_null($session) ? new static : new static($session); if (is_null($name)) { return $session; } $session->setSegmentName($name); return $session; }
php
public static function &createWithName($name = null, AuraSession $session = null) : Session { $session = ! is_null($session) ? new static : new static($session); if (is_null($name)) { return $session; } $session->setSegmentName($name); return $session; }
[ "public", "static", "function", "&", "createWithName", "(", "$", "name", "=", "null", ",", "AuraSession", "$", "session", "=", "null", ")", ":", "Session", "{", "$", "session", "=", "!", "is_null", "(", "$", "session", ")", "?", "new", "static", ":", ...
Create Instance Session @param string|null $name @param AuraSession|null $session @return Session
[ "Create", "Instance", "Session" ]
65df2ad530e28b6d72aad5394a0872760aad44cb
https://github.com/PentagonalProject/SlimService/blob/65df2ad530e28b6d72aad5394a0872760aad44cb/src/Session.php#L112-L121
train
PentagonalProject/SlimService
src/Session.php
Session.startOrResume
public function startOrResume() : bool { if (!$this->session->isStarted()) { return $this->session->start(); } return $this->session->resume(); }
php
public function startOrResume() : bool { if (!$this->session->isStarted()) { return $this->session->start(); } return $this->session->resume(); }
[ "public", "function", "startOrResume", "(", ")", ":", "bool", "{", "if", "(", "!", "$", "this", "->", "session", "->", "isStarted", "(", ")", ")", "{", "return", "$", "this", "->", "session", "->", "start", "(", ")", ";", "}", "return", "$", "this"...
Start Or Resume Session @return bool
[ "Start", "Or", "Resume", "Session" ]
65df2ad530e28b6d72aad5394a0872760aad44cb
https://github.com/PentagonalProject/SlimService/blob/65df2ad530e28b6d72aad5394a0872760aad44cb/src/Session.php#L138-L145
train
PentagonalProject/SlimService
src/Session.php
Session.validateToken
public function validateToken($value) : bool { if (!is_string($value)) { return false; } return $this->getCSRFToken()->isValid($value); }
php
public function validateToken($value) : bool { if (!is_string($value)) { return false; } return $this->getCSRFToken()->isValid($value); }
[ "public", "function", "validateToken", "(", "$", "value", ")", ":", "bool", "{", "if", "(", "!", "is_string", "(", "$", "value", ")", ")", "{", "return", "false", ";", "}", "return", "$", "this", "->", "getCSRFToken", "(", ")", "->", "isValid", "(", ...
validate token set @param string $value @return bool
[ "validate", "token", "set" ]
65df2ad530e28b6d72aad5394a0872760aad44cb
https://github.com/PentagonalProject/SlimService/blob/65df2ad530e28b6d72aad5394a0872760aad44cb/src/Session.php#L194-L201
train
PentagonalProject/SlimService
src/Session.php
Session.exist
public function exist($keyName) : bool { # double check return $this->get($keyName, true) !== true && $this->get($keyName, false) !== false; }
php
public function exist($keyName) : bool { # double check return $this->get($keyName, true) !== true && $this->get($keyName, false) !== false; }
[ "public", "function", "exist", "(", "$", "keyName", ")", ":", "bool", "{", "# double check", "return", "$", "this", "->", "get", "(", "$", "keyName", ",", "true", ")", "!==", "true", "&&", "$", "this", "->", "get", "(", "$", "keyName", ",", "false", ...
Check whether Session is exists or not on segment @param string $keyName @return bool
[ "Check", "whether", "Session", "is", "exists", "or", "not", "on", "segment" ]
65df2ad530e28b6d72aad5394a0872760aad44cb
https://github.com/PentagonalProject/SlimService/blob/65df2ad530e28b6d72aad5394a0872760aad44cb/src/Session.php#L227-L233
train
railsphp/framework
src/Rails/ActionDispatch/Http/Parameters.php
Parameters.required
public function required($keys, array $params = [], array $parents = []) { if (!$params) { $params = $this->all(); } if (is_array($keys)) { foreach ($keys as $key => $value) { if (is_int($key)) { $key = $value; } if (!isset($params[$key])) { if ($parents) { $str = ''; foreach ($parents as $parent) { $str .= '[ ' . $parent . ' => '; } $str .= $key . str_repeat(' ]', count($parents)); } else { $str = $Key; } throw new ParameterMissingException(sprintf( "Missing parameter %s", $str )); } if (is_array($value)) { $params = $params[$key]; $parents[] = $key; $this->required($value, $params, $parents); } } } else { if (!isset($params[$keys])) { throw new ParameterMissingException(sprintf( "Missing parameter %s", $keys )); } } }
php
public function required($keys, array $params = [], array $parents = []) { if (!$params) { $params = $this->all(); } if (is_array($keys)) { foreach ($keys as $key => $value) { if (is_int($key)) { $key = $value; } if (!isset($params[$key])) { if ($parents) { $str = ''; foreach ($parents as $parent) { $str .= '[ ' . $parent . ' => '; } $str .= $key . str_repeat(' ]', count($parents)); } else { $str = $Key; } throw new ParameterMissingException(sprintf( "Missing parameter %s", $str )); } if (is_array($value)) { $params = $params[$key]; $parents[] = $key; $this->required($value, $params, $parents); } } } else { if (!isset($params[$keys])) { throw new ParameterMissingException(sprintf( "Missing parameter %s", $keys )); } } }
[ "public", "function", "required", "(", "$", "keys", ",", "array", "$", "params", "=", "[", "]", ",", "array", "$", "parents", "=", "[", "]", ")", "{", "if", "(", "!", "$", "params", ")", "{", "$", "params", "=", "$", "this", "->", "all", "(", ...
Checks for required parameters. If one of them is null, ParameterMissingException is thrown. ``` // Check for a value. $parameters->required('user'); // Check for an array and some keys $parameters->required(['user' => ['name', 'address']]); ``` @throws ParameterMissingException
[ "Checks", "for", "required", "parameters", ".", "If", "one", "of", "them", "is", "null", "ParameterMissingException", "is", "thrown", "." ]
2ac9d3e493035dcc68f3c3812423327127327cd5
https://github.com/railsphp/framework/blob/2ac9d3e493035dcc68f3c3812423327127327cd5/src/Rails/ActionDispatch/Http/Parameters.php#L200-L242
train
themichaelhall/bluemvc-core
src/Collections/RequestCookieCollection.php
RequestCookieCollection.set
public function set(string $name, RequestCookieInterface $requestCookie): void { $this->requestCookies[$name] = $requestCookie; }
php
public function set(string $name, RequestCookieInterface $requestCookie): void { $this->requestCookies[$name] = $requestCookie; }
[ "public", "function", "set", "(", "string", "$", "name", ",", "RequestCookieInterface", "$", "requestCookie", ")", ":", "void", "{", "$", "this", "->", "requestCookies", "[", "$", "name", "]", "=", "$", "requestCookie", ";", "}" ]
Sets a request cookie by name. @since 1.0.0 @param string $name The name. @param RequestCookieInterface $requestCookie The request cookie.
[ "Sets", "a", "request", "cookie", "by", "name", "." ]
cbc8ccf8ed4f15ec6105837b29c2bd3db3f93680
https://github.com/themichaelhall/bluemvc-core/blob/cbc8ccf8ed4f15ec6105837b29c2bd3db3f93680/src/Collections/RequestCookieCollection.php#L113-L116
train
chilimatic/transformer-component
src/TransformerFactory.php
TransformerFactory.make
public function make($name, $options) { if (!$name || !is_string($name)) { return null; } if (isset($this->objTemplates[$name])) { return clone $this->objTemplates[$name]; } if (!$this->namespaceTransformer) { $this->namespaceTransformer = $this->objTemplates[self::NAMESPACE_TRANSFORMER] = new PrependNamespace(); } $className = $this->namespaceTransformer->transform($name, ['namespace' => __NAMESPACE__]); if (!class_exists($className, true)) { return null; } $this->objTemplates[$name] = new $className(); return clone $this->objTemplates[$name]; }
php
public function make($name, $options) { if (!$name || !is_string($name)) { return null; } if (isset($this->objTemplates[$name])) { return clone $this->objTemplates[$name]; } if (!$this->namespaceTransformer) { $this->namespaceTransformer = $this->objTemplates[self::NAMESPACE_TRANSFORMER] = new PrependNamespace(); } $className = $this->namespaceTransformer->transform($name, ['namespace' => __NAMESPACE__]); if (!class_exists($className, true)) { return null; } $this->objTemplates[$name] = new $className(); return clone $this->objTemplates[$name]; }
[ "public", "function", "make", "(", "$", "name", ",", "$", "options", ")", "{", "if", "(", "!", "$", "name", "||", "!", "is_string", "(", "$", "name", ")", ")", "{", "return", "null", ";", "}", "if", "(", "isset", "(", "$", "this", "->", "objTem...
the name is expected to prepend the subnamespace "string" or "time" or something similar -> otherwise a config based mapping would be required @param string $name @param array $options @return IFlyWeightTransformer|null
[ "the", "name", "is", "expected", "to", "prepend", "the", "subnamespace", "string", "or", "time", "or", "something", "similar", "-", ">", "otherwise", "a", "config", "based", "mapping", "would", "be", "required" ]
1d20cda19531bb3d3476666793906680ee523363
https://github.com/chilimatic/transformer-component/blob/1d20cda19531bb3d3476666793906680ee523363/src/TransformerFactory.php#L32-L55
train
phossa2/libs
src/Phossa2/Db/Traits/ConnectTrait.php
ConnectTrait.setDefaultAttributes
protected function setDefaultAttributes() { if (!empty($this->attributes)) { foreach ($this->attributes as $attr => $val) { $this->realSetAttribute($attr, $val); } } }
php
protected function setDefaultAttributes() { if (!empty($this->attributes)) { foreach ($this->attributes as $attr => $val) { $this->realSetAttribute($attr, $val); } } }
[ "protected", "function", "setDefaultAttributes", "(", ")", "{", "if", "(", "!", "empty", "(", "$", "this", "->", "attributes", ")", ")", "{", "foreach", "(", "$", "this", "->", "attributes", "as", "$", "attr", "=>", "$", "val", ")", "{", "$", "this",...
Set default attributes @access protected
[ "Set", "default", "attributes" ]
921e485c8cc29067f279da2cdd06f47a9bddd115
https://github.com/phossa2/libs/blob/921e485c8cc29067f279da2cdd06f47a9bddd115/src/Phossa2/Db/Traits/ConnectTrait.php#L154-L161
train
johnniewalker/xandria
src/DAccess/AbstractMapperCollection.php
AbstractMapperCollection.doAdd
protected function doAdd($object) { $this->notifyAccess(); $this->objectsArray[$this->total] = $object; $this->total++; }
php
protected function doAdd($object) { $this->notifyAccess(); $this->objectsArray[$this->total] = $object; $this->total++; }
[ "protected", "function", "doAdd", "(", "$", "object", ")", "{", "$", "this", "->", "notifyAccess", "(", ")", ";", "$", "this", "->", "objectsArray", "[", "$", "this", "->", "total", "]", "=", "$", "object", ";", "$", "this", "->", "total", "++", ";...
leave the type checking of the arg to the concrete subclasses - to avoid being forced to create an DomainEntityAbstract if i don't want to
[ "leave", "the", "type", "checking", "of", "the", "arg", "to", "the", "concrete", "subclasses", "-", "to", "avoid", "being", "forced", "to", "create", "an", "DomainEntityAbstract", "if", "i", "don", "t", "want", "to" ]
c846b5aa2b55015f1d110024fe71a4e53829e660
https://github.com/johnniewalker/xandria/blob/c846b5aa2b55015f1d110024fe71a4e53829e660/src/DAccess/AbstractMapperCollection.php#L77-L82
train
gossi/trixionary
src/model/Base/Reference.php
Reference.countVideos
public function countVideos(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) { $partial = $this->collVideosPartial && !$this->isNew(); if (null === $this->collVideos || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collVideos) { return 0; } if ($partial && !$criteria) { return count($this->getVideos()); } $query = ChildVideoQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } return $query ->filterByReference($this) ->count($con); } return count($this->collVideos); }
php
public function countVideos(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) { $partial = $this->collVideosPartial && !$this->isNew(); if (null === $this->collVideos || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collVideos) { return 0; } if ($partial && !$criteria) { return count($this->getVideos()); } $query = ChildVideoQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } return $query ->filterByReference($this) ->count($con); } return count($this->collVideos); }
[ "public", "function", "countVideos", "(", "Criteria", "$", "criteria", "=", "null", ",", "$", "distinct", "=", "false", ",", "ConnectionInterface", "$", "con", "=", "null", ")", "{", "$", "partial", "=", "$", "this", "->", "collVideosPartial", "&&", "!", ...
Returns the number of related Video objects. @param Criteria $criteria @param boolean $distinct @param ConnectionInterface $con @return int Count of related Video objects. @throws PropelException
[ "Returns", "the", "number", "of", "related", "Video", "objects", "." ]
221a6c5322473d7d7f8e322958a3ee46d87da150
https://github.com/gossi/trixionary/blob/221a6c5322473d7d7f8e322958a3ee46d87da150/src/model/Base/Reference.php#L2419-L2442
train
gossi/trixionary
src/model/Base/Reference.php
Reference.getSkillReferences
public function getSkillReferences(Criteria $criteria = null, ConnectionInterface $con = null) { $partial = $this->collSkillReferencesPartial && !$this->isNew(); if (null === $this->collSkillReferences || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collSkillReferences) { // return empty collection $this->initSkillReferences(); } else { $collSkillReferences = ChildSkillReferenceQuery::create(null, $criteria) ->filterByReference($this) ->find($con); if (null !== $criteria) { if (false !== $this->collSkillReferencesPartial && count($collSkillReferences)) { $this->initSkillReferences(false); foreach ($collSkillReferences as $obj) { if (false == $this->collSkillReferences->contains($obj)) { $this->collSkillReferences->append($obj); } } $this->collSkillReferencesPartial = true; } return $collSkillReferences; } if ($partial && $this->collSkillReferences) { foreach ($this->collSkillReferences as $obj) { if ($obj->isNew()) { $collSkillReferences[] = $obj; } } } $this->collSkillReferences = $collSkillReferences; $this->collSkillReferencesPartial = false; } } return $this->collSkillReferences; }
php
public function getSkillReferences(Criteria $criteria = null, ConnectionInterface $con = null) { $partial = $this->collSkillReferencesPartial && !$this->isNew(); if (null === $this->collSkillReferences || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collSkillReferences) { // return empty collection $this->initSkillReferences(); } else { $collSkillReferences = ChildSkillReferenceQuery::create(null, $criteria) ->filterByReference($this) ->find($con); if (null !== $criteria) { if (false !== $this->collSkillReferencesPartial && count($collSkillReferences)) { $this->initSkillReferences(false); foreach ($collSkillReferences as $obj) { if (false == $this->collSkillReferences->contains($obj)) { $this->collSkillReferences->append($obj); } } $this->collSkillReferencesPartial = true; } return $collSkillReferences; } if ($partial && $this->collSkillReferences) { foreach ($this->collSkillReferences as $obj) { if ($obj->isNew()) { $collSkillReferences[] = $obj; } } } $this->collSkillReferences = $collSkillReferences; $this->collSkillReferencesPartial = false; } } return $this->collSkillReferences; }
[ "public", "function", "getSkillReferences", "(", "Criteria", "$", "criteria", "=", "null", ",", "ConnectionInterface", "$", "con", "=", "null", ")", "{", "$", "partial", "=", "$", "this", "->", "collSkillReferencesPartial", "&&", "!", "$", "this", "->", "isN...
Gets an array of ChildSkillReference objects which contain a foreign key that references this object. If the $criteria is not null, it is used to always fetch the results from the database. Otherwise the results are fetched from the database the first time, then cached. Next time the same method is called without $criteria, the cached collection is returned. If this ChildReference is new, it will return an empty collection or the current collection; the criteria is ignored on a new object. @param Criteria $criteria optional Criteria object to narrow the query @param ConnectionInterface $con optional connection object @return ObjectCollection|ChildSkillReference[] List of ChildSkillReference objects @throws PropelException
[ "Gets", "an", "array", "of", "ChildSkillReference", "objects", "which", "contain", "a", "foreign", "key", "that", "references", "this", "object", "." ]
221a6c5322473d7d7f8e322958a3ee46d87da150
https://github.com/gossi/trixionary/blob/221a6c5322473d7d7f8e322958a3ee46d87da150/src/model/Base/Reference.php#L2576-L2618
train
gossi/trixionary
src/model/Base/Reference.php
Reference.getSkillReferencesJoinSkill
public function getSkillReferencesJoinSkill(Criteria $criteria = null, ConnectionInterface $con = null, $joinBehavior = Criteria::LEFT_JOIN) { $query = ChildSkillReferenceQuery::create(null, $criteria); $query->joinWith('Skill', $joinBehavior); return $this->getSkillReferences($query, $con); }
php
public function getSkillReferencesJoinSkill(Criteria $criteria = null, ConnectionInterface $con = null, $joinBehavior = Criteria::LEFT_JOIN) { $query = ChildSkillReferenceQuery::create(null, $criteria); $query->joinWith('Skill', $joinBehavior); return $this->getSkillReferences($query, $con); }
[ "public", "function", "getSkillReferencesJoinSkill", "(", "Criteria", "$", "criteria", "=", "null", ",", "ConnectionInterface", "$", "con", "=", "null", ",", "$", "joinBehavior", "=", "Criteria", "::", "LEFT_JOIN", ")", "{", "$", "query", "=", "ChildSkillReferen...
If this collection has already been initialized with an identical criteria, it returns the collection. Otherwise if this Reference is new, it will return an empty collection; or if this Reference has previously been saved, it will retrieve related SkillReferences from storage. This method is protected by default in order to keep the public api reasonable. You can provide public methods for those you actually need in Reference. @param Criteria $criteria optional Criteria object to narrow the query @param ConnectionInterface $con optional connection object @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) @return ObjectCollection|ChildSkillReference[] List of ChildSkillReference objects
[ "If", "this", "collection", "has", "already", "been", "initialized", "with", "an", "identical", "criteria", "it", "returns", "the", "collection", ".", "Otherwise", "if", "this", "Reference", "is", "new", "it", "will", "return", "an", "empty", "collection", ";"...
221a6c5322473d7d7f8e322958a3ee46d87da150
https://github.com/gossi/trixionary/blob/221a6c5322473d7d7f8e322958a3ee46d87da150/src/model/Base/Reference.php#L2757-L2763
train
gossi/trixionary
src/model/Base/Reference.php
Reference.getSkills
public function getSkills(Criteria $criteria = null, ConnectionInterface $con = null) { $partial = $this->collSkillsPartial && !$this->isNew(); if (null === $this->collSkills || null !== $criteria || $partial) { if ($this->isNew()) { // return empty collection if (null === $this->collSkills) { $this->initSkills(); } } else { $query = ChildSkillQuery::create(null, $criteria) ->filterByReference($this); $collSkills = $query->find($con); if (null !== $criteria) { return $collSkills; } if ($partial && $this->collSkills) { //make sure that already added objects gets added to the list of the database. foreach ($this->collSkills as $obj) { if (!$collSkills->contains($obj)) { $collSkills[] = $obj; } } } $this->collSkills = $collSkills; $this->collSkillsPartial = false; } } return $this->collSkills; }
php
public function getSkills(Criteria $criteria = null, ConnectionInterface $con = null) { $partial = $this->collSkillsPartial && !$this->isNew(); if (null === $this->collSkills || null !== $criteria || $partial) { if ($this->isNew()) { // return empty collection if (null === $this->collSkills) { $this->initSkills(); } } else { $query = ChildSkillQuery::create(null, $criteria) ->filterByReference($this); $collSkills = $query->find($con); if (null !== $criteria) { return $collSkills; } if ($partial && $this->collSkills) { //make sure that already added objects gets added to the list of the database. foreach ($this->collSkills as $obj) { if (!$collSkills->contains($obj)) { $collSkills[] = $obj; } } } $this->collSkills = $collSkills; $this->collSkillsPartial = false; } } return $this->collSkills; }
[ "public", "function", "getSkills", "(", "Criteria", "$", "criteria", "=", "null", ",", "ConnectionInterface", "$", "con", "=", "null", ")", "{", "$", "partial", "=", "$", "this", "->", "collSkillsPartial", "&&", "!", "$", "this", "->", "isNew", "(", ")",...
Gets a collection of ChildSkill objects related by a many-to-many relationship to the current object by way of the kk_trixionary_skill_reference cross-reference table. If the $criteria is not null, it is used to always fetch the results from the database. Otherwise the results are fetched from the database the first time, then cached. Next time the same method is called without $criteria, the cached collection is returned. If this ChildReference is new, it will return an empty collection or the current collection; the criteria is ignored on a new object. @param Criteria $criteria Optional query object to filter the query @param ConnectionInterface $con Optional connection object @return ObjectCollection|ChildSkill[] List of ChildSkill objects
[ "Gets", "a", "collection", "of", "ChildSkill", "objects", "related", "by", "a", "many", "-", "to", "-", "many", "relationship", "to", "the", "current", "object", "by", "way", "of", "the", "kk_trixionary_skill_reference", "cross", "-", "reference", "table", "."...
221a6c5322473d7d7f8e322958a3ee46d87da150
https://github.com/gossi/trixionary/blob/221a6c5322473d7d7f8e322958a3ee46d87da150/src/model/Base/Reference.php#L2821-L2854
train
gossi/trixionary
src/model/Base/Reference.php
Reference.removeSkill
public function removeSkill(ChildSkill $skill) { if ($this->getSkills()->contains($skill)) { $skillReference = new ChildSkillReference(); $skillReference->setSkill($skill); if ($skill->isReferencesLoaded()) { //remove the back reference if available $skill->getReferences()->removeObject($this); } $skillReference->setReference($this); $this->removeSkillReference(clone $skillReference); $skillReference->clear(); $this->collSkills->remove($this->collSkills->search($skill)); if (null === $this->skillsScheduledForDeletion) { $this->skillsScheduledForDeletion = clone $this->collSkills; $this->skillsScheduledForDeletion->clear(); } $this->skillsScheduledForDeletion->push($skill); } return $this; }
php
public function removeSkill(ChildSkill $skill) { if ($this->getSkills()->contains($skill)) { $skillReference = new ChildSkillReference(); $skillReference->setSkill($skill); if ($skill->isReferencesLoaded()) { //remove the back reference if available $skill->getReferences()->removeObject($this); } $skillReference->setReference($this); $this->removeSkillReference(clone $skillReference); $skillReference->clear(); $this->collSkills->remove($this->collSkills->search($skill)); if (null === $this->skillsScheduledForDeletion) { $this->skillsScheduledForDeletion = clone $this->collSkills; $this->skillsScheduledForDeletion->clear(); } $this->skillsScheduledForDeletion->push($skill); } return $this; }
[ "public", "function", "removeSkill", "(", "ChildSkill", "$", "skill", ")", "{", "if", "(", "$", "this", "->", "getSkills", "(", ")", "->", "contains", "(", "$", "skill", ")", ")", "{", "$", "skillReference", "=", "new", "ChildSkillReference", "(", ")", ...
Remove skill of this object through the kk_trixionary_skill_reference cross reference table. @param ChildSkill $skill @return ChildReference The current object (for fluent API support)
[ "Remove", "skill", "of", "this", "object", "through", "the", "kk_trixionary_skill_reference", "cross", "reference", "table", "." ]
221a6c5322473d7d7f8e322958a3ee46d87da150
https://github.com/gossi/trixionary/blob/221a6c5322473d7d7f8e322958a3ee46d87da150/src/model/Base/Reference.php#L2979-L3005
train
bmdevel/php-index
classes/Index.php
Index.search
public function search($key) { $binarySearch = new BinarySearch($this); $result = $binarySearch->search($key); if (\is_null($result) || $result->getKey() != $key) { return null; } return $result; }
php
public function search($key) { $binarySearch = new BinarySearch($this); $result = $binarySearch->search($key); if (\is_null($result) || $result->getKey() != $key) { return null; } return $result; }
[ "public", "function", "search", "(", "$", "key", ")", "{", "$", "binarySearch", "=", "new", "BinarySearch", "(", "$", "this", ")", ";", "$", "result", "=", "$", "binarySearch", "->", "search", "(", "$", "key", ")", ";", "if", "(", "\\", "is_null", ...
Searches for the container with that key Returns null if the key wasn't found. @param string $key Key in the index @return Result @throws ReadDataIndexException
[ "Searches", "for", "the", "container", "with", "that", "key" ]
6a6b476f1706b9524bfb34f6ce0963b1aea91259
https://github.com/bmdevel/php-index/blob/6a6b476f1706b9524bfb34f6ce0963b1aea91259/classes/Index.php#L74-L83
train
bmdevel/php-index
classes/Index.php
Index.searchRange
public function searchRange(Range $range) { $iterator = $this->getIterator(); // find start $start = null; $binarySearch = new BinarySearch($this); $startHint = $binarySearch->search($range->getMin()); if ($startHint == null) { return new RangeIterator($iterator, Range::getEmptyRange()); } $iterator->setOffset($startHint->getOffset(), Parser::HINT_RESULT_BOUNDARY); if (! $range->contains($startHint->getKey()) && $startHint->getKey() <= $range->getMin()) { // shift $startHint higher foreach ($iterator as $result) { if ($range->contains($result->getKey())) { $start = $result; break; } } } else { // shift $startHint lower if ($range->contains($startHint->getKey())) { $start = $startHint; } $iterator->setDirection(KeyReader::DIRECTION_BACKWARD); foreach ($iterator as $result) { // Skip everything which is too big if (! $range->contains($result->getKey() && $result->getKey() >= $range->getMax())) { continue; } // shift the start left until no more key is included if ($range->contains($result->getKey())) { $start = $result; } else { break; } } } if (is_null($start)) { return new RangeIterator($iterator, Range::getEmptyRange()); } $iterator = $this->getIterator(); $iterator->setOffset($start->getOffset(), Parser::HINT_RESULT_BOUNDARY); return new RangeIterator($iterator, $range); }
php
public function searchRange(Range $range) { $iterator = $this->getIterator(); // find start $start = null; $binarySearch = new BinarySearch($this); $startHint = $binarySearch->search($range->getMin()); if ($startHint == null) { return new RangeIterator($iterator, Range::getEmptyRange()); } $iterator->setOffset($startHint->getOffset(), Parser::HINT_RESULT_BOUNDARY); if (! $range->contains($startHint->getKey()) && $startHint->getKey() <= $range->getMin()) { // shift $startHint higher foreach ($iterator as $result) { if ($range->contains($result->getKey())) { $start = $result; break; } } } else { // shift $startHint lower if ($range->contains($startHint->getKey())) { $start = $startHint; } $iterator->setDirection(KeyReader::DIRECTION_BACKWARD); foreach ($iterator as $result) { // Skip everything which is too big if (! $range->contains($result->getKey() && $result->getKey() >= $range->getMax())) { continue; } // shift the start left until no more key is included if ($range->contains($result->getKey())) { $start = $result; } else { break; } } } if (is_null($start)) { return new RangeIterator($iterator, Range::getEmptyRange()); } $iterator = $this->getIterator(); $iterator->setOffset($start->getOffset(), Parser::HINT_RESULT_BOUNDARY); return new RangeIterator($iterator, $range); }
[ "public", "function", "searchRange", "(", "Range", "$", "range", ")", "{", "$", "iterator", "=", "$", "this", "->", "getIterator", "(", ")", ";", "// find start", "$", "start", "=", "null", ";", "$", "binarySearch", "=", "new", "BinarySearch", "(", "$", ...
Searches a range @param Range $range @return RangeIterator
[ "Searches", "a", "range" ]
6a6b476f1706b9524bfb34f6ce0963b1aea91259
https://github.com/bmdevel/php-index/blob/6a6b476f1706b9524bfb34f6ce0963b1aea91259/classes/Index.php#L92-L151
train
phproberto/joomla-common
src/Object/Object.php
Object.get
public function get($property, $default = null) { if (!$this->has($property)) { return $default; } return null !== $this->data[$property] ? $this->data[$property] : $default; }
php
public function get($property, $default = null) { if (!$this->has($property)) { return $default; } return null !== $this->data[$property] ? $this->data[$property] : $default; }
[ "public", "function", "get", "(", "$", "property", ",", "$", "default", "=", "null", ")", "{", "if", "(", "!", "$", "this", "->", "has", "(", "$", "property", ")", ")", "{", "return", "$", "default", ";", "}", "return", "null", "!==", "$", "this"...
Get property of the object @param string $property Name of the property to retrieve @param mixed $default Default value if property does not exist @return mixed
[ "Get", "property", "of", "the", "object" ]
bbb37df453bfcb545c3a2c6f14340f0a27e448b2
https://github.com/phproberto/joomla-common/blob/bbb37df453bfcb545c3a2c6f14340f0a27e448b2/src/Object/Object.php#L84-L92
train
eghojansu/nutrition
src/SQL/Mapper.php
Mapper.copyfrom
public function copyfrom($var,$func=NULL) { if (is_string($var)) { $var = Base::instance()->get($var); } if ($func) { $var = call_user_func($func, $var); } foreach ($var as $key=>$val) { if ( array_key_exists($key, $this->fields) || array_key_exists($key, $this->extras) ) { $this->set($key,$val); } } }
php
public function copyfrom($var,$func=NULL) { if (is_string($var)) { $var = Base::instance()->get($var); } if ($func) { $var = call_user_func($func, $var); } foreach ($var as $key=>$val) { if ( array_key_exists($key, $this->fields) || array_key_exists($key, $this->extras) ) { $this->set($key,$val); } } }
[ "public", "function", "copyfrom", "(", "$", "var", ",", "$", "func", "=", "NULL", ")", "{", "if", "(", "is_string", "(", "$", "var", ")", ")", "{", "$", "var", "=", "Base", "::", "instance", "(", ")", "->", "get", "(", "$", "var", ")", ";", "...
Override parent method to accept custom property assigment @param mixed $var @param callable $func @return void
[ "Override", "parent", "method", "to", "accept", "custom", "property", "assigment" ]
3941c62aeb6dafda55349a38dd4107d521f8964a
https://github.com/eghojansu/nutrition/blob/3941c62aeb6dafda55349a38dd4107d521f8964a/src/SQL/Mapper.php#L188-L204
train
chigix/chiji-frontend
src/Annotation/RequireAnnotation.php
RequireAnnotation.parse
public function parse($param_str) { $file = new File(trim($param_str), $this->getScope()->getFile()->getAbsoluteFile()->getParent()); if (!$file->exists()) { throw new ResourceNotFoundException($param_str, $this->getScope(), $this->getOccursPos(), "The Requirement File Not Exists"); } if (is_null($require_resource = $this->getParentProject()->getResourceByFile($file))) { throw new \Chigi\Chiji\Exception\ProjectMemberNotFoundException("ERROR: UNREGISTERED Resource File: " + $file->getAbsolutePath()); } if ($this->getScope() instanceof RequiresMapInterface) { $this->getScope()->getRequires()->addResource($require_resource); } }
php
public function parse($param_str) { $file = new File(trim($param_str), $this->getScope()->getFile()->getAbsoluteFile()->getParent()); if (!$file->exists()) { throw new ResourceNotFoundException($param_str, $this->getScope(), $this->getOccursPos(), "The Requirement File Not Exists"); } if (is_null($require_resource = $this->getParentProject()->getResourceByFile($file))) { throw new \Chigi\Chiji\Exception\ProjectMemberNotFoundException("ERROR: UNREGISTERED Resource File: " + $file->getAbsolutePath()); } if ($this->getScope() instanceof RequiresMapInterface) { $this->getScope()->getRequires()->addResource($require_resource); } }
[ "public", "function", "parse", "(", "$", "param_str", ")", "{", "$", "file", "=", "new", "File", "(", "trim", "(", "$", "param_str", ")", ",", "$", "this", "->", "getScope", "(", ")", "->", "getFile", "(", ")", "->", "getAbsoluteFile", "(", ")", "-...
Parse the path param in the require annotation to an Resource File Object. @param string $param_str The String as params following the command name @throws ResourceNotFoundException
[ "Parse", "the", "path", "param", "in", "the", "require", "annotation", "to", "an", "Resource", "File", "Object", "." ]
5407f98c21ee99f8bbef43c97a231c0f81ed3e74
https://github.com/chigix/chiji-frontend/blob/5407f98c21ee99f8bbef43c97a231c0f81ed3e74/src/Annotation/RequireAnnotation.php#L38-L49
train
bishopb/vanilla
applications/dashboard/models/tiny_diff.php
Tiny_diff.compare
public function compare($old, $new, $mode = 'normal') { // Mixed if ( $mode === 'mixed') { // Insert characters $ins_begin = '<ins>+ '; $ins_end = '</ins>' . PHP_EOL; // Delete characters $del_begin = '<del>- '; $del_end = '</del>' . PHP_EOL; } // HTML mode elseif ( $mode === 'html' ) { // Insert characters $ins_begin = '<ins>'; $ins_end = '</ins>' . PHP_EOL; // Delete characters $del_begin = '<del>'; $del_end = '</del>' . PHP_EOL; } // Normal mode else { // Insert characters $ins_begin = '+ '; $ins_end = PHP_EOL; // Delete characters $del_begin = '- '; $del_end = PHP_EOL; } // Turn the strings into an array so it's a bit easier to parse them $diff = $this->diff(explode(PHP_EOL, $old), explode(PHP_EOL, $new)); $result = ''; if ($mode == 'raw') return $diff; foreach($diff as $line) { if(is_array($line)) { $result .= !empty($line['del']) ? $del_begin . implode(PHP_EOL, $line['del']) . $del_end : ''; $result .= !empty($line['ins']) ? $ins_begin . implode(PHP_EOL, $line['ins']) . $ins_end : ''; } else { $result .= $line . PHP_EOL; } } // Return the result return $result; }
php
public function compare($old, $new, $mode = 'normal') { // Mixed if ( $mode === 'mixed') { // Insert characters $ins_begin = '<ins>+ '; $ins_end = '</ins>' . PHP_EOL; // Delete characters $del_begin = '<del>- '; $del_end = '</del>' . PHP_EOL; } // HTML mode elseif ( $mode === 'html' ) { // Insert characters $ins_begin = '<ins>'; $ins_end = '</ins>' . PHP_EOL; // Delete characters $del_begin = '<del>'; $del_end = '</del>' . PHP_EOL; } // Normal mode else { // Insert characters $ins_begin = '+ '; $ins_end = PHP_EOL; // Delete characters $del_begin = '- '; $del_end = PHP_EOL; } // Turn the strings into an array so it's a bit easier to parse them $diff = $this->diff(explode(PHP_EOL, $old), explode(PHP_EOL, $new)); $result = ''; if ($mode == 'raw') return $diff; foreach($diff as $line) { if(is_array($line)) { $result .= !empty($line['del']) ? $del_begin . implode(PHP_EOL, $line['del']) . $del_end : ''; $result .= !empty($line['ins']) ? $ins_begin . implode(PHP_EOL, $line['ins']) . $ins_end : ''; } else { $result .= $line . PHP_EOL; } } // Return the result return $result; }
[ "public", "function", "compare", "(", "$", "old", ",", "$", "new", ",", "$", "mode", "=", "'normal'", ")", "{", "// Mixed", "if", "(", "$", "mode", "===", "'mixed'", ")", "{", "// Insert characters", "$", "ins_begin", "=", "'<ins>+ '", ";", "$", "ins_e...
Compare two strings and return the difference @access public @param string $old The first block of data @param string $new The second block of data @param string $mode The mode to use. Possible values are normal, html and mixed @return string
[ "Compare", "two", "strings", "and", "return", "the", "difference" ]
8494eb4a4ad61603479015a8054d23ff488364e8
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/applications/dashboard/models/tiny_diff.php#L44-L102
train
bishopb/vanilla
applications/dashboard/models/tiny_diff.php
Tiny_diff.diff
private function diff($old, $new) { $maxlen = 0; // Go through each old line. foreach($old as $old_line => $old_value) { // Get the new lines that match the old line $new_lines = array_keys($new, $old_value); // Go through each new line number foreach($new_lines as $new_line) { $matrix[$old_line][$new_line] = isset($matrix[$old_line - 1][$new_line - 1]) ? $matrix[$old_line - 1][$new_line - 1] + 1 : 1; if($matrix[$old_line][$new_line] > $maxlen) { $maxlen = $matrix[$old_line][$new_line]; $old_max = $old_line + 1 - $maxlen; $new_max = $new_line + 1 - $maxlen; } } } if($maxlen == 0) { return array(array('del'=>$old, 'ins'=>$new)); } return array_merge( self::diff(array_slice($old, 0, $old_max), array_slice($new, 0, $new_max)), array_slice($new, $new_max, $maxlen), self::diff(array_slice($old, $old_max + $maxlen), array_slice($new, $new_max + $maxlen)) ); }
php
private function diff($old, $new) { $maxlen = 0; // Go through each old line. foreach($old as $old_line => $old_value) { // Get the new lines that match the old line $new_lines = array_keys($new, $old_value); // Go through each new line number foreach($new_lines as $new_line) { $matrix[$old_line][$new_line] = isset($matrix[$old_line - 1][$new_line - 1]) ? $matrix[$old_line - 1][$new_line - 1] + 1 : 1; if($matrix[$old_line][$new_line] > $maxlen) { $maxlen = $matrix[$old_line][$new_line]; $old_max = $old_line + 1 - $maxlen; $new_max = $new_line + 1 - $maxlen; } } } if($maxlen == 0) { return array(array('del'=>$old, 'ins'=>$new)); } return array_merge( self::diff(array_slice($old, 0, $old_max), array_slice($new, 0, $new_max)), array_slice($new, $new_max, $maxlen), self::diff(array_slice($old, $old_max + $maxlen), array_slice($new, $new_max + $maxlen)) ); }
[ "private", "function", "diff", "(", "$", "old", ",", "$", "new", ")", "{", "$", "maxlen", "=", "0", ";", "// Go through each old line.", "foreach", "(", "$", "old", "as", "$", "old_line", "=>", "$", "old_value", ")", "{", "// Get the new lines that match the...
Diff function. Contributed by Dan Horrigan who again took it from Paul Butler. @author Paul Butler @link http://github.com/paulgb/simplediff/blob/master/simplediff.php @access private @param string $old The old block of data @param string $new The new block of data
[ "Diff", "function", ".", "Contributed", "by", "Dan", "Horrigan", "who", "again", "took", "it", "from", "Paul", "Butler", "." ]
8494eb4a4ad61603479015a8054d23ff488364e8
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/applications/dashboard/models/tiny_diff.php#L115-L145
train
GodsDev/backyard
GodsDev/Backyard/BackyardGeo.php
BackyardGeo.getRoughDistance
public function getRoughDistance($clientLng, $clientLat, $poiLng, $poiLat) { $result = abs($clientLng - $poiLng) + abs($clientLat - $poiLat); $this->BackyardError->log(5, "client({$clientLng}, {$clientLat}) poi({$poiLng}, {$poiLat}) roughDistance = {$result}"); return $result; }
php
public function getRoughDistance($clientLng, $clientLat, $poiLng, $poiLat) { $result = abs($clientLng - $poiLng) + abs($clientLat - $poiLat); $this->BackyardError->log(5, "client({$clientLng}, {$clientLat}) poi({$poiLng}, {$poiLat}) roughDistance = {$result}"); return $result; }
[ "public", "function", "getRoughDistance", "(", "$", "clientLng", ",", "$", "clientLat", ",", "$", "poiLng", ",", "$", "poiLat", ")", "{", "$", "result", "=", "abs", "(", "$", "clientLng", "-", "$", "poiLng", ")", "+", "abs", "(", "$", "clientLat", "-...
1 ~ 100km @param float $clientLng @param float $clientLat @param float $poiLng @param float $poiLat @return float
[ "1", "~", "100km" ]
992da766a50fca04e9c6e963cbe98d37e3d47f8f
https://github.com/GodsDev/backyard/blob/992da766a50fca04e9c6e963cbe98d37e3d47f8f/GodsDev/Backyard/BackyardGeo.php#L100-L105
train
hegotecnologia/support
src/Domain/ServiceProvider.php
ServiceProvider.register
public function register() { // Register Sub Providers $this->registerSubProviders(collect($this->subProviders)); // Register bindings. $this->registerBindings(collect($this->bindings)); // Register migrations. $this->registerMigrations(collect($this->migrations)); // Register seeders. $this->registerSeeders(collect($this->seeders)); // Register model factories. $this->registerFactories(collect($this->factories)); }
php
public function register() { // Register Sub Providers $this->registerSubProviders(collect($this->subProviders)); // Register bindings. $this->registerBindings(collect($this->bindings)); // Register migrations. $this->registerMigrations(collect($this->migrations)); // Register seeders. $this->registerSeeders(collect($this->seeders)); // Register model factories. $this->registerFactories(collect($this->factories)); }
[ "public", "function", "register", "(", ")", "{", "// Register Sub Providers", "$", "this", "->", "registerSubProviders", "(", "collect", "(", "$", "this", "->", "subProviders", ")", ")", ";", "// Register bindings.", "$", "this", "->", "registerBindings", "(", "...
Register the current Domain.
[ "Register", "the", "current", "Domain", "." ]
3862bdf82dd7d3a6f0cec1afd2a04531bd75e0cc
https://github.com/hegotecnologia/support/blob/3862bdf82dd7d3a6f0cec1afd2a04531bd75e0cc/src/Domain/ServiceProvider.php#L60-L72
train
hegotecnologia/support
src/Domain/ServiceProvider.php
ServiceProvider.registerSubProviders
protected function registerSubProviders(Collection $subProviders) { $subProviders->each(function ($provider) { $this->app->register($provider); }); }
php
protected function registerSubProviders(Collection $subProviders) { $subProviders->each(function ($provider) { $this->app->register($provider); }); }
[ "protected", "function", "registerSubProviders", "(", "Collection", "$", "subProviders", ")", "{", "$", "subProviders", "->", "each", "(", "function", "(", "$", "provider", ")", "{", "$", "this", "->", "app", "->", "register", "(", "$", "provider", ")", ";...
Register domain sub providers. @param Collection $subProviders
[ "Register", "domain", "sub", "providers", "." ]
3862bdf82dd7d3a6f0cec1afd2a04531bd75e0cc
https://github.com/hegotecnologia/support/blob/3862bdf82dd7d3a6f0cec1afd2a04531bd75e0cc/src/Domain/ServiceProvider.php#L79-L84
train
hegotecnologia/support
src/Domain/ServiceProvider.php
ServiceProvider.registerBindings
protected function registerBindings(Collection $bindings) { $bindings->each(function ($concretion, $abstraction) { $this->app->bind($abstraction, $concretion); }); }
php
protected function registerBindings(Collection $bindings) { $bindings->each(function ($concretion, $abstraction) { $this->app->bind($abstraction, $concretion); }); }
[ "protected", "function", "registerBindings", "(", "Collection", "$", "bindings", ")", "{", "$", "bindings", "->", "each", "(", "function", "(", "$", "concretion", ",", "$", "abstraction", ")", "{", "$", "this", "->", "app", "->", "bind", "(", "$", "abstr...
Register the defined domain bindings. @param Collection $bindings
[ "Register", "the", "defined", "domain", "bindings", "." ]
3862bdf82dd7d3a6f0cec1afd2a04531bd75e0cc
https://github.com/hegotecnologia/support/blob/3862bdf82dd7d3a6f0cec1afd2a04531bd75e0cc/src/Domain/ServiceProvider.php#L91-L96
train
martinhej/robocloud
src/robocloud/Kinesis/RobocloudKinesisClient.php
RobocloudKinesisClient.getKinesisClient
public function getKinesisClient($type) { if (!empty($this->clients[$type])) { return $this->clients[$type]; } $config = [ 'version' => $this->config['api_version'], 'region' => $this->config['region'], ]; $config['credentials'] = [ 'key' => $this->config[$type]['key'], 'secret' => $this->config[$type]['secret'], ]; $sdk = new Sdk(); $this->clients[$type] = $sdk->createKinesis($config); return $this->clients[$type]; }
php
public function getKinesisClient($type) { if (!empty($this->clients[$type])) { return $this->clients[$type]; } $config = [ 'version' => $this->config['api_version'], 'region' => $this->config['region'], ]; $config['credentials'] = [ 'key' => $this->config[$type]['key'], 'secret' => $this->config[$type]['secret'], ]; $sdk = new Sdk(); $this->clients[$type] = $sdk->createKinesis($config); return $this->clients[$type]; }
[ "public", "function", "getKinesisClient", "(", "$", "type", ")", "{", "if", "(", "!", "empty", "(", "$", "this", "->", "clients", "[", "$", "type", "]", ")", ")", "{", "return", "$", "this", "->", "clients", "[", "$", "type", "]", ";", "}", "$", ...
Gets the Kinesis client. @param string $type The client type [producer, consumer]. @return \Aws\Kinesis\KinesisClient
[ "Gets", "the", "Kinesis", "client", "." ]
108dfbc2b6e9aca2a87795c3e7518cbf1cf5d229
https://github.com/martinhej/robocloud/blob/108dfbc2b6e9aca2a87795c3e7518cbf1cf5d229/src/robocloud/Kinesis/RobocloudKinesisClient.php#L38-L59
train
dsi-agpt/minibus
src/Minibus/Controller/IndexController.php
IndexController.preDispatch
public function preDispatch(MvcEvent $e) { if ($this->zfcUserAuthentication ()->hasIdentity ()) { $userName = $this->zfcUserAuthentication ()->getIdentity ()->getUsername (); } else { $userName = 'anonymous'; } $this->layout ()->setVariable ( 'dataTypes', $this->getDataTypesHandler ()->getDataTypes () ); $this->layout ()->setVariable ( 'userName', $userName ); $this->layout ()->setVariable ( 'action', $this->params ( 'action' ) ); $this->layout ()->setVariable ( 'authService', $this->getFileAuthService () ); $this->layout ()->setVariable ( 'jqueryUiTheme', $this->getJqueryUiTheme () ); $controller = $this->params ( 'controller' ); $controller = explode ( '\\', $controller ); $controller = array_pop ( $controller ); $controller = strtolower ( $controller ); $this->layout ()->setVariable ( 'controller', $controller ); }
php
public function preDispatch(MvcEvent $e) { if ($this->zfcUserAuthentication ()->hasIdentity ()) { $userName = $this->zfcUserAuthentication ()->getIdentity ()->getUsername (); } else { $userName = 'anonymous'; } $this->layout ()->setVariable ( 'dataTypes', $this->getDataTypesHandler ()->getDataTypes () ); $this->layout ()->setVariable ( 'userName', $userName ); $this->layout ()->setVariable ( 'action', $this->params ( 'action' ) ); $this->layout ()->setVariable ( 'authService', $this->getFileAuthService () ); $this->layout ()->setVariable ( 'jqueryUiTheme', $this->getJqueryUiTheme () ); $controller = $this->params ( 'controller' ); $controller = explode ( '\\', $controller ); $controller = array_pop ( $controller ); $controller = strtolower ( $controller ); $this->layout ()->setVariable ( 'controller', $controller ); }
[ "public", "function", "preDispatch", "(", "MvcEvent", "$", "e", ")", "{", "if", "(", "$", "this", "->", "zfcUserAuthentication", "(", ")", "->", "hasIdentity", "(", ")", ")", "{", "$", "userName", "=", "$", "this", "->", "zfcUserAuthentication", "(", ")"...
Avant l'action @param MvcEvent $e
[ "Avant", "l", "action" ]
8262e3d398b8ca30b02ad5665834b46b7a85f1a6
https://github.com/dsi-agpt/minibus/blob/8262e3d398b8ca30b02ad5665834b46b7a85f1a6/src/Minibus/Controller/IndexController.php#L40-L56
train
monomelodies/ornament
src/Collection.php
Collection.isDirty
public function isDirty() { if (count($this) != $this->_original) { return true; } if (count($this->_deleted)) { return true; } foreach ($this as $model) { if (is_object($model) && ($model->isDirty() || $model->isNew()) ) { return true; } } return false; }
php
public function isDirty() { if (count($this) != $this->_original) { return true; } if (count($this->_deleted)) { return true; } foreach ($this as $model) { if (is_object($model) && ($model->isDirty() || $model->isNew()) ) { return true; } } return false; }
[ "public", "function", "isDirty", "(", ")", "{", "if", "(", "count", "(", "$", "this", ")", "!=", "$", "this", "->", "_original", ")", "{", "return", "true", ";", "}", "if", "(", "count", "(", "$", "this", "->", "_deleted", ")", ")", "{", "return"...
Check if the collection is "dirty", i.e. its contents have changed since the last save. @return boolean true if dirty, otherwise false.
[ "Check", "if", "the", "collection", "is", "dirty", "i", ".", "e", ".", "its", "contents", "have", "changed", "since", "the", "last", "save", "." ]
d7d070ad11f5731be141cf55c2756accaaf51402
https://github.com/monomelodies/ornament/blob/d7d070ad11f5731be141cf55c2756accaaf51402/src/Collection.php#L60-L76
train
monomelodies/ornament
src/Collection.php
Collection.markClean
public function markClean() { foreach ($this as $model) { if (is_object($model)) { $model->markClean(); } } $this->_original = count($this); }
php
public function markClean() { foreach ($this as $model) { if (is_object($model)) { $model->markClean(); } } $this->_original = count($this); }
[ "public", "function", "markClean", "(", ")", "{", "foreach", "(", "$", "this", "as", "$", "model", ")", "{", "if", "(", "is_object", "(", "$", "model", ")", ")", "{", "$", "model", "->", "markClean", "(", ")", ";", "}", "}", "$", "this", "->", ...
Mark the collection as "clean", i.e. in pristine state. @return void
[ "Mark", "the", "collection", "as", "clean", "i", ".", "e", ".", "in", "pristine", "state", "." ]
d7d070ad11f5731be141cf55c2756accaaf51402
https://github.com/monomelodies/ornament/blob/d7d070ad11f5731be141cf55c2756accaaf51402/src/Collection.php#L83-L91
train
monomelodies/ornament
src/Collection.php
Collection.jsonSerialize
public function jsonSerialize() { $out = []; foreach ($this as $model) { if (!is_object($model)) { continue; } if ($model instanceof JsonSerializable) { $out[] = $model->jsonSerialize(); } else { $out[] = (object)(array)$model; } } return $out; }
php
public function jsonSerialize() { $out = []; foreach ($this as $model) { if (!is_object($model)) { continue; } if ($model instanceof JsonSerializable) { $out[] = $model->jsonSerialize(); } else { $out[] = (object)(array)$model; } } return $out; }
[ "public", "function", "jsonSerialize", "(", ")", "{", "$", "out", "=", "[", "]", ";", "foreach", "(", "$", "this", "as", "$", "model", ")", "{", "if", "(", "!", "is_object", "(", "$", "model", ")", ")", "{", "continue", ";", "}", "if", "(", "$"...
Export the Collection as a regular PHP array for Json serialization. @return array The Collection represented as an array.
[ "Export", "the", "Collection", "as", "a", "regular", "PHP", "array", "for", "Json", "serialization", "." ]
d7d070ad11f5731be141cf55c2756accaaf51402
https://github.com/monomelodies/ornament/blob/d7d070ad11f5731be141cf55c2756accaaf51402/src/Collection.php#L98-L112
train
G4MR/Configs
src/Item.php
Item.get
public function get($key, $default = null) { if(!is_string($key) || empty($key)) { return $default; } //split string into array $item_pieces = explode('.', $key); //let igorw check if array item exists return igorw\get_in($this->data, $item_pieces, $default); }
php
public function get($key, $default = null) { if(!is_string($key) || empty($key)) { return $default; } //split string into array $item_pieces = explode('.', $key); //let igorw check if array item exists return igorw\get_in($this->data, $item_pieces, $default); }
[ "public", "function", "get", "(", "$", "key", ",", "$", "default", "=", "null", ")", "{", "if", "(", "!", "is_string", "(", "$", "key", ")", "||", "empty", "(", "$", "key", ")", ")", "{", "return", "$", "default", ";", "}", "//split string into arr...
Gets item from array if it exists else return default value @param string $item dot notation config_file.array.item @param mixed $default value if it doesn't exist @return mixed
[ "Gets", "item", "from", "array", "if", "it", "exists", "else", "return", "default", "value" ]
3e5d13f822cb5c9e2f5a1f946d9107f534570b6a
https://github.com/G4MR/Configs/blob/3e5d13f822cb5c9e2f5a1f946d9107f534570b6a/src/Item.php#L30-L41
train
vinala/kernel
src/Database/Seeder.php
Seeder.execute
protected static function execute($seeder) { $data = self::fill($seeder); // $table = new DBTable($seeder->table); return $table->insert($data); }
php
protected static function execute($seeder) { $data = self::fill($seeder); // $table = new DBTable($seeder->table); return $table->insert($data); }
[ "protected", "static", "function", "execute", "(", "$", "seeder", ")", "{", "$", "data", "=", "self", "::", "fill", "(", "$", "seeder", ")", ";", "//", "$", "table", "=", "new", "DBTable", "(", "$", "seeder", "->", "table", ")", ";", "return", "$",...
Execute thh seeder.
[ "Execute", "thh", "seeder", "." ]
346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a
https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Database/Seeder.php#L54-L61
train
vinala/kernel
src/Database/Seeder.php
Seeder.fill
public static function fill($seeder) { $data = []; // if ($seeder->count <= 0) { foreach ($seeder->data() as $value) { // Collection::push($data, $value); array_push($data, $value); } } else { for ($i = 0; $i < $seeder->count; $i++) { // Collection::push($data, $seeder->data()); array_push($data, $seeder->data()); } } // return $data; }
php
public static function fill($seeder) { $data = []; // if ($seeder->count <= 0) { foreach ($seeder->data() as $value) { // Collection::push($data, $value); array_push($data, $value); } } else { for ($i = 0; $i < $seeder->count; $i++) { // Collection::push($data, $seeder->data()); array_push($data, $seeder->data()); } } // return $data; }
[ "public", "static", "function", "fill", "(", "$", "seeder", ")", "{", "$", "data", "=", "[", "]", ";", "//", "if", "(", "$", "seeder", "->", "count", "<=", "0", ")", "{", "foreach", "(", "$", "seeder", "->", "data", "(", ")", "as", "$", "value"...
Fill data.
[ "Fill", "data", "." ]
346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a
https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Database/Seeder.php#L66-L83
train
agencms/auth
src/Controllers/PasswordController.php
PasswordController.request
public function request(Request $request) { $user = User::whereEmail($request->email)->firstOrFail(); $user->sendResetPasswordNotification($this->broker()->createToken($user), $request); return response()->json('Password request successful', 200); }
php
public function request(Request $request) { $user = User::whereEmail($request->email)->firstOrFail(); $user->sendResetPasswordNotification($this->broker()->createToken($user), $request); return response()->json('Password request successful', 200); }
[ "public", "function", "request", "(", "Request", "$", "request", ")", "{", "$", "user", "=", "User", "::", "whereEmail", "(", "$", "request", "->", "email", ")", "->", "firstOrFail", "(", ")", ";", "$", "user", "->", "sendResetPasswordNotification", "(", ...
Send an email to the registered email address with a reset password link @param Request $request @return \Illuminate\Http\RedirectResponse|\Illuminate\Http\JsonResponse
[ "Send", "an", "email", "to", "the", "registered", "email", "address", "with", "a", "reset", "password", "link" ]
a255988180c461c1ccbc62e2ab3660d379e6e072
https://github.com/agencms/auth/blob/a255988180c461c1ccbc62e2ab3660d379e6e072/src/Controllers/PasswordController.php#L21-L27
train
veridu/idos-sdk-php
src/idOS/Endpoint/Profile/Scores.php
Scores.createNew
public function createNew( string $attribute, string $name, float $value ) : array { return $this->sendPost( sprintf('/profiles/%s/scores', $this->userName), [], [ 'attribute' => $attribute, 'name' => $name, 'value' => $value ] ); }
php
public function createNew( string $attribute, string $name, float $value ) : array { return $this->sendPost( sprintf('/profiles/%s/scores', $this->userName), [], [ 'attribute' => $attribute, 'name' => $name, 'value' => $value ] ); }
[ "public", "function", "createNew", "(", "string", "$", "attribute", ",", "string", "$", "name", ",", "float", "$", "value", ")", ":", "array", "{", "return", "$", "this", "->", "sendPost", "(", "sprintf", "(", "'/profiles/%s/scores'", ",", "$", "this", "...
Creates a new score for the given source. @param string $attribute @param string $name @param float $value @return array Response
[ "Creates", "a", "new", "score", "for", "the", "given", "source", "." ]
e56757bed10404756f2f0485a4b7f55794192008
https://github.com/veridu/idos-sdk-php/blob/e56757bed10404756f2f0485a4b7f55794192008/src/idOS/Endpoint/Profile/Scores.php#L20-L34
train
veridu/idos-sdk-php
src/idOS/Endpoint/Profile/Scores.php
Scores.upsertOne
public function upsertOne( string $attribute, string $name, float $value ) : array { return $this->sendPut( sprintf('/profiles/%s/scores', $this->userName), [], [ 'attribute' => $attribute, 'name' => $name, 'value' => $value ] ); }
php
public function upsertOne( string $attribute, string $name, float $value ) : array { return $this->sendPut( sprintf('/profiles/%s/scores', $this->userName), [], [ 'attribute' => $attribute, 'name' => $name, 'value' => $value ] ); }
[ "public", "function", "upsertOne", "(", "string", "$", "attribute", ",", "string", "$", "name", ",", "float", "$", "value", ")", ":", "array", "{", "return", "$", "this", "->", "sendPut", "(", "sprintf", "(", "'/profiles/%s/scores'", ",", "$", "this", "-...
Tries to update a score and if it doesnt exists, creates a new score. @param string $attribute @param string $name @param float $value @return array Response
[ "Tries", "to", "update", "a", "score", "and", "if", "it", "doesnt", "exists", "creates", "a", "new", "score", "." ]
e56757bed10404756f2f0485a4b7f55794192008
https://github.com/veridu/idos-sdk-php/blob/e56757bed10404756f2f0485a4b7f55794192008/src/idOS/Endpoint/Profile/Scores.php#L45-L59
train
veridu/idos-sdk-php
src/idOS/Endpoint/Profile/Scores.php
Scores.updateOne
public function updateOne(string $attribute, string $name, float $value) : array { return $this->sendPatch( sprintf('/profiles/%s/scores/%s', $this->userName, $name), [], [ 'attribute' => $attribute, 'value' => $value ] ); }
php
public function updateOne(string $attribute, string $name, float $value) : array { return $this->sendPatch( sprintf('/profiles/%s/scores/%s', $this->userName, $name), [], [ 'attribute' => $attribute, 'value' => $value ] ); }
[ "public", "function", "updateOne", "(", "string", "$", "attribute", ",", "string", "$", "name", ",", "float", "$", "value", ")", ":", "array", "{", "return", "$", "this", "->", "sendPatch", "(", "sprintf", "(", "'/profiles/%s/scores/%s'", ",", "$", "this",...
Updates a score in the given profile. @param string $attribute @param string $name @param float $value @return array Response
[ "Updates", "a", "score", "in", "the", "given", "profile", "." ]
e56757bed10404756f2f0485a4b7f55794192008
https://github.com/veridu/idos-sdk-php/blob/e56757bed10404756f2f0485a4b7f55794192008/src/idOS/Endpoint/Profile/Scores.php#L97-L106
train
DaoAndCo/cakephp-cachecleaner
src/Shell/ClearShell.php
ClearShell.all
public function all() { foreach ( $this->tasks as $task => $option ) { $task = $this->taskClassname($task); $this->$task->all(); } }
php
public function all() { foreach ( $this->tasks as $task => $option ) { $task = $this->taskClassname($task); $this->$task->all(); } }
[ "public", "function", "all", "(", ")", "{", "foreach", "(", "$", "this", "->", "tasks", "as", "$", "task", "=>", "$", "option", ")", "{", "$", "task", "=", "$", "this", "->", "taskClassname", "(", "$", "task", ")", ";", "$", "this", "->", "$", ...
Execute all tasks
[ "Execute", "all", "tasks" ]
b4a05a003c3e0e55671eb315f900511cfcd295d6
https://github.com/DaoAndCo/cakephp-cachecleaner/blob/b4a05a003c3e0e55671eb315f900511cfcd295d6/src/Shell/ClearShell.php#L67-L73
train
whackashoe/bstall
src/Whackashoe/Bstall/Bstall.php
Bstall.make
public function make($name="default", $width=100, $height=100, $bgcolor=0xFFFFFF) { $bstall = new Bstall; $this->width = $width; $this->height = $height; $this->bgcolor = $bgcolor; $this->load($name); return View::make('bstall::canvas', [ 'name' => $name, 'width' => $this->width, 'height' => $this->height, 'canvas' => json_encode($this->canvas, true) ]); }
php
public function make($name="default", $width=100, $height=100, $bgcolor=0xFFFFFF) { $bstall = new Bstall; $this->width = $width; $this->height = $height; $this->bgcolor = $bgcolor; $this->load($name); return View::make('bstall::canvas', [ 'name' => $name, 'width' => $this->width, 'height' => $this->height, 'canvas' => json_encode($this->canvas, true) ]); }
[ "public", "function", "make", "(", "$", "name", "=", "\"default\"", ",", "$", "width", "=", "100", ",", "$", "height", "=", "100", ",", "$", "bgcolor", "=", "0xFFFFFF", ")", "{", "$", "bstall", "=", "new", "Bstall", ";", "$", "this", "->", "width",...
Print stall's canvas @param string $name @param int $width @param int $height @param int $bgcolor @return Illuminate\View\View
[ "Print", "stall", "s", "canvas" ]
f8b04d0fb5cb6b7b55396fe8749a1cf9c8b846fe
https://github.com/whackashoe/bstall/blob/f8b04d0fb5cb6b7b55396fe8749a1cf9c8b846fe/src/Whackashoe/Bstall/Bstall.php#L41-L55
train
whackashoe/bstall
src/Whackashoe/Bstall/Bstall.php
Bstall.load
public function load($name) { $stall = $this->redis->get("bstall_{$name}"); if(is_null($stall)) { $this->clean(); $this->save($name); } else { $canvas = unserialize($stall); $this->canvas = $canvas; } }
php
public function load($name) { $stall = $this->redis->get("bstall_{$name}"); if(is_null($stall)) { $this->clean(); $this->save($name); } else { $canvas = unserialize($stall); $this->canvas = $canvas; } }
[ "public", "function", "load", "(", "$", "name", ")", "{", "$", "stall", "=", "$", "this", "->", "redis", "->", "get", "(", "\"bstall_{$name}\"", ")", ";", "if", "(", "is_null", "(", "$", "stall", ")", ")", "{", "$", "this", "->", "clean", "(", ")...
Load or initialize a stall @param string $name @return void
[ "Load", "or", "initialize", "a", "stall" ]
f8b04d0fb5cb6b7b55396fe8749a1cf9c8b846fe
https://github.com/whackashoe/bstall/blob/f8b04d0fb5cb6b7b55396fe8749a1cf9c8b846fe/src/Whackashoe/Bstall/Bstall.php#L64-L75
train
whackashoe/bstall
src/Whackashoe/Bstall/Bstall.php
Bstall.clean
public function clean() { $this->canvas = []; for($y=0; $y < $this->height; $y++) { array_push($this->canvas, []); for($x=0; $x < $this->width; $x++) { $this->canvas[$y][$x] = $this->bgcolor; } } }
php
public function clean() { $this->canvas = []; for($y=0; $y < $this->height; $y++) { array_push($this->canvas, []); for($x=0; $x < $this->width; $x++) { $this->canvas[$y][$x] = $this->bgcolor; } } }
[ "public", "function", "clean", "(", ")", "{", "$", "this", "->", "canvas", "=", "[", "]", ";", "for", "(", "$", "y", "=", "0", ";", "$", "y", "<", "$", "this", "->", "height", ";", "$", "y", "++", ")", "{", "array_push", "(", "$", "this", "...
Cleans the stall, replacing each pixel with the set background color @param string $name @return void
[ "Cleans", "the", "stall", "replacing", "each", "pixel", "with", "the", "set", "background", "color" ]
f8b04d0fb5cb6b7b55396fe8749a1cf9c8b846fe
https://github.com/whackashoe/bstall/blob/f8b04d0fb5cb6b7b55396fe8749a1cf9c8b846fe/src/Whackashoe/Bstall/Bstall.php#L96-L107
train
whackashoe/bstall
src/Whackashoe/Bstall/Bstall.php
Bstall.write
public function write($x, $y, $color) { if(isset($this->canvas[$y][$x])) { $this->canvas[$y][$x] = $color; } }
php
public function write($x, $y, $color) { if(isset($this->canvas[$y][$x])) { $this->canvas[$y][$x] = $color; } }
[ "public", "function", "write", "(", "$", "x", ",", "$", "y", ",", "$", "color", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "canvas", "[", "$", "y", "]", "[", "$", "x", "]", ")", ")", "{", "$", "this", "->", "canvas", "[", "$", ...
Scribble onto the stall @param int $x @param int $y @param int $color @return void
[ "Scribble", "onto", "the", "stall" ]
f8b04d0fb5cb6b7b55396fe8749a1cf9c8b846fe
https://github.com/whackashoe/bstall/blob/f8b04d0fb5cb6b7b55396fe8749a1cf9c8b846fe/src/Whackashoe/Bstall/Bstall.php#L118-L123
train
jsiefer/class-mocker
src/next.php
next.parent
public static function parent() { if (!self::$activeTraitMethod) { throw new \BadMethodCallException("next:parent() call is only allowed in trait calls"); } $arguments = func_get_args(); return call_user_func(self::$activeTraitMethod, $arguments); }
php
public static function parent() { if (!self::$activeTraitMethod) { throw new \BadMethodCallException("next:parent() call is only allowed in trait calls"); } $arguments = func_get_args(); return call_user_func(self::$activeTraitMethod, $arguments); }
[ "public", "static", "function", "parent", "(", ")", "{", "if", "(", "!", "self", "::", "$", "activeTraitMethod", ")", "{", "throw", "new", "\\", "BadMethodCallException", "(", "\"next:parent() call is only allowed in trait calls\"", ")", ";", "}", "$", "arguments"...
Allows call to parent trait method if it got overwritten @return mixed @see \JSiefer\ClassMocker\Mock\BaseMock::__callTraitMethods()
[ "Allows", "call", "to", "parent", "trait", "method", "if", "it", "got", "overwritten" ]
a355fc9bece8e6f27fbfd09b1631234f7d73a791
https://github.com/jsiefer/class-mocker/blob/a355fc9bece8e6f27fbfd09b1631234f7d73a791/src/next.php#L70-L78
train
academic/VipaImportBundle
Importer/PKP/ArticleStatisticImporter.php
ArticleStatisticImporter.importArticleStatistics
public function importArticleStatistics() { $pendingImports = $this->em->getRepository('ImportBundle:PendingStatisticImport')->findAll(); $this->consoleOutput->writeln("Importing article statistics..."); foreach ($pendingImports as $import) { $this->importArticleStatistic($import->getOldId(), $import->getArticle()->getId()); $this->em->remove($import); $this->em->flush($import); } }
php
public function importArticleStatistics() { $pendingImports = $this->em->getRepository('ImportBundle:PendingStatisticImport')->findAll(); $this->consoleOutput->writeln("Importing article statistics..."); foreach ($pendingImports as $import) { $this->importArticleStatistic($import->getOldId(), $import->getArticle()->getId()); $this->em->remove($import); $this->em->flush($import); } }
[ "public", "function", "importArticleStatistics", "(", ")", "{", "$", "pendingImports", "=", "$", "this", "->", "em", "->", "getRepository", "(", "'ImportBundle:PendingStatisticImport'", ")", "->", "findAll", "(", ")", ";", "$", "this", "->", "consoleOutput", "->...
Imports article statistics whose import are pending.
[ "Imports", "article", "statistics", "whose", "import", "are", "pending", "." ]
cee7d9e51613706a4fd6e2eade44041ce1af9ad3
https://github.com/academic/VipaImportBundle/blob/cee7d9e51613706a4fd6e2eade44041ce1af9ad3/Importer/PKP/ArticleStatisticImporter.php#L15-L25
train
academic/VipaImportBundle
Importer/PKP/ArticleStatisticImporter.php
ArticleStatisticImporter.importArticleStatistic
public function importArticleStatistic($oldId, $newId) { $article = $this->em->getRepository('VipaJournalBundle:Article')->find($newId); if (!$article) { $this->consoleOutput->writeln("Couldn't find #" . $newId . " on the new database."); return; } $this->consoleOutput->writeln("Reading view statistics for #" . $oldId . "..."); $viewStatsSql = "SELECT DATE(view_time) AS date, COUNT(*) as view FROM " . "article_view_stats WHERE article_id = :id GROUP BY DATE(view_time)"; $viewStatsStatement = $this->dbalConnection->prepare($viewStatsSql); $viewStatsStatement->bindValue('id', $oldId); $viewStatsStatement->execute(); $this->consoleOutput->writeln("Reading download statistics for #" . $oldId . "..."); $downloadStatsSql = "SELECT DATE(download_time) AS date, COUNT(*) as download FROM " . "article_download_stats WHERE article_id = :id GROUP BY DATE(download_time)"; $downloadStatsStatement = $this->dbalConnection->prepare($downloadStatsSql); $downloadStatsStatement->bindValue('id', $oldId); $downloadStatsStatement->execute(); $pkpViewStats = $viewStatsStatement->fetchAll(); $pkpDownloadStats = $downloadStatsStatement->fetchAll(); foreach ($pkpViewStats as $stat) { $articleFileStatistic = new ArticleStatistic(); $articleFileStatistic->setArticle($article); $articleFileStatistic->setDate(DateTime::createFromFormat('Y-m-d', $stat['date'])); $articleFileStatistic->setView($stat['view']); $this->em->persist($articleFileStatistic); } if (!$article->getArticleFiles()->isEmpty()) { foreach ($pkpDownloadStats as $stat) { $articleFileStatistic = new ArticleFileStatistic(); $articleFileStatistic->setArticleFile($article->getArticleFiles()->first()); $articleFileStatistic->setDate(DateTime::createFromFormat('Y-m-d', $stat['date'])); $articleFileStatistic->setDownload($stat['download']); $this->em->persist($articleFileStatistic); } } $this->em->flush(); }
php
public function importArticleStatistic($oldId, $newId) { $article = $this->em->getRepository('VipaJournalBundle:Article')->find($newId); if (!$article) { $this->consoleOutput->writeln("Couldn't find #" . $newId . " on the new database."); return; } $this->consoleOutput->writeln("Reading view statistics for #" . $oldId . "..."); $viewStatsSql = "SELECT DATE(view_time) AS date, COUNT(*) as view FROM " . "article_view_stats WHERE article_id = :id GROUP BY DATE(view_time)"; $viewStatsStatement = $this->dbalConnection->prepare($viewStatsSql); $viewStatsStatement->bindValue('id', $oldId); $viewStatsStatement->execute(); $this->consoleOutput->writeln("Reading download statistics for #" . $oldId . "..."); $downloadStatsSql = "SELECT DATE(download_time) AS date, COUNT(*) as download FROM " . "article_download_stats WHERE article_id = :id GROUP BY DATE(download_time)"; $downloadStatsStatement = $this->dbalConnection->prepare($downloadStatsSql); $downloadStatsStatement->bindValue('id', $oldId); $downloadStatsStatement->execute(); $pkpViewStats = $viewStatsStatement->fetchAll(); $pkpDownloadStats = $downloadStatsStatement->fetchAll(); foreach ($pkpViewStats as $stat) { $articleFileStatistic = new ArticleStatistic(); $articleFileStatistic->setArticle($article); $articleFileStatistic->setDate(DateTime::createFromFormat('Y-m-d', $stat['date'])); $articleFileStatistic->setView($stat['view']); $this->em->persist($articleFileStatistic); } if (!$article->getArticleFiles()->isEmpty()) { foreach ($pkpDownloadStats as $stat) { $articleFileStatistic = new ArticleFileStatistic(); $articleFileStatistic->setArticleFile($article->getArticleFiles()->first()); $articleFileStatistic->setDate(DateTime::createFromFormat('Y-m-d', $stat['date'])); $articleFileStatistic->setDownload($stat['download']); $this->em->persist($articleFileStatistic); } } $this->em->flush(); }
[ "public", "function", "importArticleStatistic", "(", "$", "oldId", ",", "$", "newId", ")", "{", "$", "article", "=", "$", "this", "->", "em", "->", "getRepository", "(", "'VipaJournalBundle:Article'", ")", "->", "find", "(", "$", "newId", ")", ";", "if", ...
Imports the given article's statistics @param int $oldId Old ID of the article @param int $newId New ID of the article @throws \Doctrine\DBAL\DBALException
[ "Imports", "the", "given", "article", "s", "statistics" ]
cee7d9e51613706a4fd6e2eade44041ce1af9ad3
https://github.com/academic/VipaImportBundle/blob/cee7d9e51613706a4fd6e2eade44041ce1af9ad3/Importer/PKP/ArticleStatisticImporter.php#L33-L77
train
n0m4dz/laracasa
Zend/Gdata.php
Zend_Gdata.getFeed
public function getFeed($location, $className = 'Zend_Gdata_Feed') { if (is_string($location)) { $uri = $location; } elseif ($location instanceof Zend_Gdata_Query) { $uri = $location->getQueryUrl(); } else { require_once 'Zend/Gdata/App/InvalidArgumentException.php'; throw new Zend_Gdata_App_InvalidArgumentException( 'You must specify the location as either a string URI ' . 'or a child of Zend_Gdata_Query'); } return parent::getFeed($uri, $className); }
php
public function getFeed($location, $className = 'Zend_Gdata_Feed') { if (is_string($location)) { $uri = $location; } elseif ($location instanceof Zend_Gdata_Query) { $uri = $location->getQueryUrl(); } else { require_once 'Zend/Gdata/App/InvalidArgumentException.php'; throw new Zend_Gdata_App_InvalidArgumentException( 'You must specify the location as either a string URI ' . 'or a child of Zend_Gdata_Query'); } return parent::getFeed($uri, $className); }
[ "public", "function", "getFeed", "(", "$", "location", ",", "$", "className", "=", "'Zend_Gdata_Feed'", ")", "{", "if", "(", "is_string", "(", "$", "location", ")", ")", "{", "$", "uri", "=", "$", "location", ";", "}", "elseif", "(", "$", "location", ...
Retrieve feed as string or object @param mixed $location The location as string or Zend_Gdata_Query @param string $className The class type to use for returning the feed @throws Zend_Gdata_App_InvalidArgumentException @return string|Zend_Gdata_App_Feed Returns string only if the object mapping has been disabled explicitly by passing false to the useObjectMapping() function.
[ "Retrieve", "feed", "as", "string", "or", "object" ]
6141f0c16c7d4453275e3b74be5041f336085c91
https://github.com/n0m4dz/laracasa/blob/6141f0c16c7d4453275e3b74be5041f336085c91/Zend/Gdata.php#L150-L163
train
n0m4dz/laracasa
Zend/Gdata.php
Zend_Gdata.performHttpRequest
public function performHttpRequest($method, $url, $headers = array(), $body = null, $contentType = null, $remainingRedirects = null) { if ($this->_httpClient instanceof Zend_Gdata_HttpClient) { $filterResult = $this->_httpClient->filterHttpRequest($method, $url, $headers, $body, $contentType); $method = $filterResult['method']; $url = $filterResult['url']; $body = $filterResult['body']; $headers = $filterResult['headers']; $contentType = $filterResult['contentType']; return $this->_httpClient->filterHttpResponse(parent::performHttpRequest($method, $url, $headers, $body, $contentType, $remainingRedirects)); } else { return parent::performHttpRequest($method, $url, $headers, $body, $contentType, $remainingRedirects); } }
php
public function performHttpRequest($method, $url, $headers = array(), $body = null, $contentType = null, $remainingRedirects = null) { if ($this->_httpClient instanceof Zend_Gdata_HttpClient) { $filterResult = $this->_httpClient->filterHttpRequest($method, $url, $headers, $body, $contentType); $method = $filterResult['method']; $url = $filterResult['url']; $body = $filterResult['body']; $headers = $filterResult['headers']; $contentType = $filterResult['contentType']; return $this->_httpClient->filterHttpResponse(parent::performHttpRequest($method, $url, $headers, $body, $contentType, $remainingRedirects)); } else { return parent::performHttpRequest($method, $url, $headers, $body, $contentType, $remainingRedirects); } }
[ "public", "function", "performHttpRequest", "(", "$", "method", ",", "$", "url", ",", "$", "headers", "=", "array", "(", ")", ",", "$", "body", "=", "null", ",", "$", "contentType", "=", "null", ",", "$", "remainingRedirects", "=", "null", ")", "{", ...
Performs a HTTP request using the specified method. Overrides the definition in the parent (Zend_Gdata_App) and uses the Zend_Gdata_HttpClient functionality to filter the HTTP requests and responses. @param string $method The HTTP method for the request - 'GET', 'POST', 'PUT', 'DELETE' @param string $url The URL to which this request is being performed, or null if found in $data @param array $headers An associative array of HTTP headers for this request @param string $body The body of the HTTP request @param string $contentType The value for the content type of the request body @param int $remainingRedirects Number of redirects to follow if requests results in one @return Zend_Http_Response The response object
[ "Performs", "a", "HTTP", "request", "using", "the", "specified", "method", "." ]
6141f0c16c7d4453275e3b74be5041f336085c91
https://github.com/n0m4dz/laracasa/blob/6141f0c16c7d4453275e3b74be5041f336085c91/Zend/Gdata.php#L210-L223
train
n0m4dz/laracasa
Zend/Gdata.php
Zend_Gdata.isAuthenticated
public function isAuthenticated() { $client = parent::getHttpClient(); if ($client->getClientLoginToken() || $client->getAuthSubToken() ) { return true; } return false; }
php
public function isAuthenticated() { $client = parent::getHttpClient(); if ($client->getClientLoginToken() || $client->getAuthSubToken() ) { return true; } return false; }
[ "public", "function", "isAuthenticated", "(", ")", "{", "$", "client", "=", "parent", "::", "getHttpClient", "(", ")", ";", "if", "(", "$", "client", "->", "getClientLoginToken", "(", ")", "||", "$", "client", "->", "getAuthSubToken", "(", ")", ")", "{",...
Determines whether service object is authenticated. @return boolean True if service object is authenticated, false otherwise.
[ "Determines", "whether", "service", "object", "is", "authenticated", "." ]
6141f0c16c7d4453275e3b74be5041f336085c91
https://github.com/n0m4dz/laracasa/blob/6141f0c16c7d4453275e3b74be5041f336085c91/Zend/Gdata.php#L230-L240
train
wasabi-cms/cms
src/View/Helper/CmsPageHelper.php
CmsPageHelper.renderTree
public function renderTree($pages, $closedPages, $langId, $level = null) { if (empty($pages)) { $newPageLink = $this->Html->link( __d('wasabi_cms', 'Please add your first Page'), [ 'plugin' => 'Wasabi/Cms', 'controller' => 'Pages', 'action' => 'add' ], [ 'title' => __d('wasabi_cms', 'Add your first Page') ] ); return '<li class="center">' . __d('wasabi_cms', 'There are no pages yet. {0}.', $newPageLink) . '</li>'; } $output = ''; $depth = ($level !== null) ? $level : 1; foreach ($pages as $page) { $closed = false; $classes = ['page']; if (in_array($page->id, $closedPages)) { $closed = true; $classes[] = 'closed'; } $pageRow = $this->_View->element('Wasabi/Cms.../Pages/__page-row', [ 'page' => $page, 'closed' => $closed, 'langId' => $langId ]); if (!empty($page->children)) { $pageRow .= '<ul' . ($closed ? ' style="display: none;"' : '') . '>' . $this->renderTree($page->children, $closedPages, $langId, $depth + 1) . '</ul>'; } else { $classes[] = 'no-children'; } $output .= '<li class="' . join(' ', $classes) . '" data-cms-page-id="' . $page->id . '">' . $pageRow . '</li>'; } return $output; }
php
public function renderTree($pages, $closedPages, $langId, $level = null) { if (empty($pages)) { $newPageLink = $this->Html->link( __d('wasabi_cms', 'Please add your first Page'), [ 'plugin' => 'Wasabi/Cms', 'controller' => 'Pages', 'action' => 'add' ], [ 'title' => __d('wasabi_cms', 'Add your first Page') ] ); return '<li class="center">' . __d('wasabi_cms', 'There are no pages yet. {0}.', $newPageLink) . '</li>'; } $output = ''; $depth = ($level !== null) ? $level : 1; foreach ($pages as $page) { $closed = false; $classes = ['page']; if (in_array($page->id, $closedPages)) { $closed = true; $classes[] = 'closed'; } $pageRow = $this->_View->element('Wasabi/Cms.../Pages/__page-row', [ 'page' => $page, 'closed' => $closed, 'langId' => $langId ]); if (!empty($page->children)) { $pageRow .= '<ul' . ($closed ? ' style="display: none;"' : '') . '>' . $this->renderTree($page->children, $closedPages, $langId, $depth + 1) . '</ul>'; } else { $classes[] = 'no-children'; } $output .= '<li class="' . join(' ', $classes) . '" data-cms-page-id="' . $page->id . '">' . $pageRow . '</li>'; } return $output; }
[ "public", "function", "renderTree", "(", "$", "pages", ",", "$", "closedPages", ",", "$", "langId", ",", "$", "level", "=", "null", ")", "{", "if", "(", "empty", "(", "$", "pages", ")", ")", "{", "$", "newPageLink", "=", "$", "this", "->", "Html", ...
Renders a complete tree of pages without the toplevel ul element. @param array $pages @param array $closedPages @param integer $langId @param integer|null $level @return string
[ "Renders", "a", "complete", "tree", "of", "pages", "without", "the", "toplevel", "ul", "element", "." ]
2787b6422ea1d719cf49951b3253fd0ac31d22ca
https://github.com/wasabi-cms/cms/blob/2787b6422ea1d719cf49951b3253fd0ac31d22ca/src/View/Helper/CmsPageHelper.php#L34-L77
train
tux-rampage/rampage-php
library/rampage/core/xml/SimpleXmlElement.php
SimpleXmlElement._toBoolean
protected function _toBoolean($value) { $value = strtolower((string)$value); $result = ($value != 'false') && ($value != 'off') && !empty($value); return $result; }
php
protected function _toBoolean($value) { $value = strtolower((string)$value); $result = ($value != 'false') && ($value != 'off') && !empty($value); return $result; }
[ "protected", "function", "_toBoolean", "(", "$", "value", ")", "{", "$", "value", "=", "strtolower", "(", "(", "string", ")", "$", "value", ")", ";", "$", "result", "=", "(", "$", "value", "!=", "'false'", ")", "&&", "(", "$", "value", "!=", "'off'...
Get boolean value @param string $value @return bool
[ "Get", "boolean", "value" ]
1c679b04a6d477e2f8fdb86135e1d9f0c128b1cf
https://github.com/tux-rampage/rampage-php/blob/1c679b04a6d477e2f8fdb86135e1d9f0c128b1cf/library/rampage/core/xml/SimpleXmlElement.php#L66-L74
train
tux-rampage/rampage-php
library/rampage/core/xml/SimpleXmlElement.php
SimpleXmlElement.quoteXpathValue
public static function quoteXpathValue($string) { if (strpos($string, "'") === false) { return "'$string'"; } if (strpos($string, '"') === false) { return '"' . $string . '"'; } // String contains ' and " -> need to use concat ... $parts = explode("'", $string); $quoted = implode('\', "\'", \'', $parts); return "concat('$quoted')"; }
php
public static function quoteXpathValue($string) { if (strpos($string, "'") === false) { return "'$string'"; } if (strpos($string, '"') === false) { return '"' . $string . '"'; } // String contains ' and " -> need to use concat ... $parts = explode("'", $string); $quoted = implode('\', "\'", \'', $parts); return "concat('$quoted')"; }
[ "public", "static", "function", "quoteXpathValue", "(", "$", "string", ")", "{", "if", "(", "strpos", "(", "$", "string", ",", "\"'\"", ")", "===", "false", ")", "{", "return", "\"'$string'\"", ";", "}", "if", "(", "strpos", "(", "$", "string", ",", ...
Quote the given value for an xpath expression This will also automatically enclose the string @param string $string @return string
[ "Quote", "the", "given", "value", "for", "an", "xpath", "expression" ]
1c679b04a6d477e2f8fdb86135e1d9f0c128b1cf
https://github.com/tux-rampage/rampage-php/blob/1c679b04a6d477e2f8fdb86135e1d9f0c128b1cf/library/rampage/core/xml/SimpleXmlElement.php#L152-L167
train
tux-rampage/rampage-php
library/rampage/core/xml/SimpleXmlElement.php
SimpleXmlElement.getPath
public function getPath() { $stack = array($this->getName()); $current = $this; while ($parent = $current->getParent()) { array_unshift($stack, $parent->getName()); $current = $parent; } return implode('/', $stack); }
php
public function getPath() { $stack = array($this->getName()); $current = $this; while ($parent = $current->getParent()) { array_unshift($stack, $parent->getName()); $current = $parent; } return implode('/', $stack); }
[ "public", "function", "getPath", "(", ")", "{", "$", "stack", "=", "array", "(", "$", "this", "->", "getName", "(", ")", ")", ";", "$", "current", "=", "$", "this", ";", "while", "(", "$", "parent", "=", "$", "current", "->", "getParent", "(", ")...
returns the path name @return string
[ "returns", "the", "path", "name" ]
1c679b04a6d477e2f8fdb86135e1d9f0c128b1cf
https://github.com/tux-rampage/rampage-php/blob/1c679b04a6d477e2f8fdb86135e1d9f0c128b1cf/library/rampage/core/xml/SimpleXmlElement.php#L241-L252
train
tux-rampage/rampage-php
library/rampage/core/xml/SimpleXmlElement.php
SimpleXmlElement.toValue
public function toValue($type = null, $valueAttribute = null) { $value = ($valueAttribute)? (string)$this[$valueAttribute] : (string)$this; $type = ($type)?: (string)$this['type']; switch ($type) { case 'int': $value = (int)$value; break; case 'float': $value = (float)$value; break; case 'bool': $value = $this->_toBoolean($value); break; case 'double': $value = (double)$value; break; case 'null': $value = null; break; case 'array': $value = $this->toArray(true); break; } return $value; }
php
public function toValue($type = null, $valueAttribute = null) { $value = ($valueAttribute)? (string)$this[$valueAttribute] : (string)$this; $type = ($type)?: (string)$this['type']; switch ($type) { case 'int': $value = (int)$value; break; case 'float': $value = (float)$value; break; case 'bool': $value = $this->_toBoolean($value); break; case 'double': $value = (double)$value; break; case 'null': $value = null; break; case 'array': $value = $this->toArray(true); break; } return $value; }
[ "public", "function", "toValue", "(", "$", "type", "=", "null", ",", "$", "valueAttribute", "=", "null", ")", "{", "$", "value", "=", "(", "$", "valueAttribute", ")", "?", "(", "string", ")", "$", "this", "[", "$", "valueAttribute", "]", ":", "(", ...
To php value @param string $type @return mixed
[ "To", "php", "value" ]
1c679b04a6d477e2f8fdb86135e1d9f0c128b1cf
https://github.com/tux-rampage/rampage-php/blob/1c679b04a6d477e2f8fdb86135e1d9f0c128b1cf/library/rampage/core/xml/SimpleXmlElement.php#L271-L303
train
tux-rampage/rampage-php
library/rampage/core/xml/SimpleXmlElement.php
SimpleXmlElement.toArray
public function toArray($force = true) { if (!$force && !$this->hasChildren()) { return $this->toValue(); } $data = array(); foreach ($this->children() as $name => $child) { $data[$name] = $child->toArray(false); } return $data; }
php
public function toArray($force = true) { if (!$force && !$this->hasChildren()) { return $this->toValue(); } $data = array(); foreach ($this->children() as $name => $child) { $data[$name] = $child->toArray(false); } return $data; }
[ "public", "function", "toArray", "(", "$", "force", "=", "true", ")", "{", "if", "(", "!", "$", "force", "&&", "!", "$", "this", "->", "hasChildren", "(", ")", ")", "{", "return", "$", "this", "->", "toValue", "(", ")", ";", "}", "$", "data", "...
convert to array @return string
[ "convert", "to", "array" ]
1c679b04a6d477e2f8fdb86135e1d9f0c128b1cf
https://github.com/tux-rampage/rampage-php/blob/1c679b04a6d477e2f8fdb86135e1d9f0c128b1cf/library/rampage/core/xml/SimpleXmlElement.php#L310-L322
train
tux-rampage/rampage-php
library/rampage/core/xml/SimpleXmlElement.php
SimpleXmlElement.toPhpValue
public function toPhpValue($type = null, $serviceLocator = null) { if (!$type) { $type = $this->getName(); } switch ($type) { case 'array': $value = array(); if (!isset($this->item)) { return $value; } foreach ($this->item as $item) { if (!($type = (string)$item['type'])) { $type = 'string'; } // Instance must be defined in subtag if (($type == 'instance') && !$item->{$type}) { $current = null; } else { $current = ($item->{$type})? $item->{$type}->toPhpValue($type, $serviceLocator) : $item->toPhpValue($type, $serviceLocator); } if (!isset($item['key']) && !isset($item['index'])) { $value[] = $current; continue; } $key = (isset($item['key']))? (string)$item['key'] : intval((string)$item['index']); $value[$key] = $current; } break; case 'null': $value = null; break; case 'instance': $class = (string)$this['class']; $value = null; if (($serviceLocator instanceof ServiceLocatorInterface) && ($serviceLocator->has($class))) { $value = $serviceLocator->get($class); break; } if ($serviceLocator instanceof DependencyInjectionInterface) { $options = array(); if (isset($this->options)) { $options = $this->options->toPhpValue('array', $serviceLocator); } $value = $serviceLocator->newInstance($class, $options); break; } break; default: $value = $this->toValue($type); break; } return $value; }
php
public function toPhpValue($type = null, $serviceLocator = null) { if (!$type) { $type = $this->getName(); } switch ($type) { case 'array': $value = array(); if (!isset($this->item)) { return $value; } foreach ($this->item as $item) { if (!($type = (string)$item['type'])) { $type = 'string'; } // Instance must be defined in subtag if (($type == 'instance') && !$item->{$type}) { $current = null; } else { $current = ($item->{$type})? $item->{$type}->toPhpValue($type, $serviceLocator) : $item->toPhpValue($type, $serviceLocator); } if (!isset($item['key']) && !isset($item['index'])) { $value[] = $current; continue; } $key = (isset($item['key']))? (string)$item['key'] : intval((string)$item['index']); $value[$key] = $current; } break; case 'null': $value = null; break; case 'instance': $class = (string)$this['class']; $value = null; if (($serviceLocator instanceof ServiceLocatorInterface) && ($serviceLocator->has($class))) { $value = $serviceLocator->get($class); break; } if ($serviceLocator instanceof DependencyInjectionInterface) { $options = array(); if (isset($this->options)) { $options = $this->options->toPhpValue('array', $serviceLocator); } $value = $serviceLocator->newInstance($class, $options); break; } break; default: $value = $this->toValue($type); break; } return $value; }
[ "public", "function", "toPhpValue", "(", "$", "type", "=", "null", ",", "$", "serviceLocator", "=", "null", ")", "{", "if", "(", "!", "$", "type", ")", "{", "$", "type", "=", "$", "this", "->", "getName", "(", ")", ";", "}", "switch", "(", "$", ...
Convert to php value @param string $type @return mixed
[ "Convert", "to", "php", "value" ]
1c679b04a6d477e2f8fdb86135e1d9f0c128b1cf
https://github.com/tux-rampage/rampage-php/blob/1c679b04a6d477e2f8fdb86135e1d9f0c128b1cf/library/rampage/core/xml/SimpleXmlElement.php#L330-L397
train
tux-rampage/rampage-php
library/rampage/core/xml/SimpleXmlElement.php
SimpleXmlElement._getMergeRule
protected function _getMergeRule($element, &$affected = null, $rule = null) { if ($rule instanceof MergeRuleInterface) { $result = $rule($this, $element, $affected); if ($result !== false) { return $result; } } $name = $element->getName(); if (isset($this->{$name})) { $affected = $this->{$name}; return self::MERGE_REPLACE; } return self::MERGE_APPEND; }
php
protected function _getMergeRule($element, &$affected = null, $rule = null) { if ($rule instanceof MergeRuleInterface) { $result = $rule($this, $element, $affected); if ($result !== false) { return $result; } } $name = $element->getName(); if (isset($this->{$name})) { $affected = $this->{$name}; return self::MERGE_REPLACE; } return self::MERGE_APPEND; }
[ "protected", "function", "_getMergeRule", "(", "$", "element", ",", "&", "$", "affected", "=", "null", ",", "$", "rule", "=", "null", ")", "{", "if", "(", "$", "rule", "instanceof", "MergeRuleInterface", ")", "{", "$", "result", "=", "$", "rule", "(", ...
find merge rule @param \rampage\core\xml\SimpleXmlElement $element @param \rampage\core\xml\SimpleXmlElement $affected @return int
[ "find", "merge", "rule" ]
1c679b04a6d477e2f8fdb86135e1d9f0c128b1cf
https://github.com/tux-rampage/rampage-php/blob/1c679b04a6d477e2f8fdb86135e1d9f0c128b1cf/library/rampage/core/xml/SimpleXmlElement.php#L406-L423
train
tux-rampage/rampage-php
library/rampage/core/xml/SimpleXmlElement.php
SimpleXmlElement.mergeAttributes
public function mergeAttributes(SimpleXmlElement $node, $replace = true) { foreach ($node->attributes() as $name => $value) { if (isset($this[$name])) { if ($replace) { $this[$name] = (string)$value; } continue; } $this->addAttribute($name, (string)$value); } return $this; }
php
public function mergeAttributes(SimpleXmlElement $node, $replace = true) { foreach ($node->attributes() as $name => $value) { if (isset($this[$name])) { if ($replace) { $this[$name] = (string)$value; } continue; } $this->addAttribute($name, (string)$value); } return $this; }
[ "public", "function", "mergeAttributes", "(", "SimpleXmlElement", "$", "node", ",", "$", "replace", "=", "true", ")", "{", "foreach", "(", "$", "node", "->", "attributes", "(", ")", "as", "$", "name", "=>", "$", "value", ")", "{", "if", "(", "isset", ...
Merge attributes from the given node to this one @param \rampage\core\xml\SimpleXmlElement $node @param bool $replace
[ "Merge", "attributes", "from", "the", "given", "node", "to", "this", "one" ]
1c679b04a6d477e2f8fdb86135e1d9f0c128b1cf
https://github.com/tux-rampage/rampage-php/blob/1c679b04a6d477e2f8fdb86135e1d9f0c128b1cf/library/rampage/core/xml/SimpleXmlElement.php#L431-L446
train
tux-rampage/rampage-php
library/rampage/core/xml/SimpleXmlElement.php
SimpleXmlElement.merge
public function merge(SimpleXmlElement $element, $replace = true, $rule = null) { foreach ($element->children() as $name => $child) { $affected = null; $currentpath = $child->getPath(); $action = $this->_getMergeRule($child, $affected, $rule); if ($action == self::MERGE_APPEND) { $affected = $this->addChild($name, (string)$child); } if (!$affected instanceof SimpleXmlElement) { continue; } $affected->mergeAttributes($child, $replace); if ($child->hasChildren()) { $affected->merge($child, $replace, $rule); continue; } else if ($replace) { $affected[0] = (string)$child; } } return $this; }
php
public function merge(SimpleXmlElement $element, $replace = true, $rule = null) { foreach ($element->children() as $name => $child) { $affected = null; $currentpath = $child->getPath(); $action = $this->_getMergeRule($child, $affected, $rule); if ($action == self::MERGE_APPEND) { $affected = $this->addChild($name, (string)$child); } if (!$affected instanceof SimpleXmlElement) { continue; } $affected->mergeAttributes($child, $replace); if ($child->hasChildren()) { $affected->merge($child, $replace, $rule); continue; } else if ($replace) { $affected[0] = (string)$child; } } return $this; }
[ "public", "function", "merge", "(", "SimpleXmlElement", "$", "element", ",", "$", "replace", "=", "true", ",", "$", "rule", "=", "null", ")", "{", "foreach", "(", "$", "element", "->", "children", "(", ")", "as", "$", "name", "=>", "$", "child", ")",...
merge another xml element into this one @param SimpleXmlElement $element @return string
[ "merge", "another", "xml", "element", "into", "this", "one" ]
1c679b04a6d477e2f8fdb86135e1d9f0c128b1cf
https://github.com/tux-rampage/rampage-php/blob/1c679b04a6d477e2f8fdb86135e1d9f0c128b1cf/library/rampage/core/xml/SimpleXmlElement.php#L454-L480
train
gios-asu/nectary
src/routers/router.php
Router.route_exists
private function route_exists() : bool { if ( property_exists( $this, 'routes' ) ) { return array_key_exists( $this->__method_name, $this->routes ); } return false; }
php
private function route_exists() : bool { if ( property_exists( $this, 'routes' ) ) { return array_key_exists( $this->__method_name, $this->routes ); } return false; }
[ "private", "function", "route_exists", "(", ")", ":", "bool", "{", "if", "(", "property_exists", "(", "$", "this", ",", "'routes'", ")", ")", "{", "return", "array_key_exists", "(", "$", "this", "->", "__method_name", ",", "$", "this", "->", "routes", ")...
Check if the route has been defined @return bool
[ "Check", "if", "the", "route", "has", "been", "defined" ]
f972c737a9036a3090652950a1309a62c07d86c0
https://github.com/gios-asu/nectary/blob/f972c737a9036a3090652950a1309a62c07d86c0/src/routers/router.php#L82-L87
train
gios-asu/nectary
src/routers/router.php
Router.route_request
private function route_request() { $named_arguments = $this->get_named_arguments(); list( $to_class, $to_method, $on_error ) = $this->get_route_parts(); return $this->do_route( $to_class, $to_method, $named_arguments, $on_error ); }
php
private function route_request() { $named_arguments = $this->get_named_arguments(); list( $to_class, $to_method, $on_error ) = $this->get_route_parts(); return $this->do_route( $to_class, $to_method, $named_arguments, $on_error ); }
[ "private", "function", "route_request", "(", ")", "{", "$", "named_arguments", "=", "$", "this", "->", "get_named_arguments", "(", ")", ";", "list", "(", "$", "to_class", ",", "$", "to_method", ",", "$", "on_error", ")", "=", "$", "this", "->", "get_rout...
Build and do the route @throws \ReflectionException
[ "Build", "and", "do", "the", "route" ]
f972c737a9036a3090652950a1309a62c07d86c0
https://github.com/gios-asu/nectary/blob/f972c737a9036a3090652950a1309a62c07d86c0/src/routers/router.php#L94-L100
train
gios-asu/nectary
src/routers/router.php
Router.get_named_arguments
private function get_named_arguments() : array { // name the parameters $named_arguments = []; if ( array_key_exists( 'expects', $this->routes[ $this->__method_name ] ) ) { $expects = $this->routes[ $this->__method_name ]['expects']; foreach ( $expects as $index => $parameter_name ) { if ( array_key_exists( $index, $this->__arguments ) ) { $named_arguments[ $parameter_name ] = $this->__arguments[ $index ]; } } } return $named_arguments; }
php
private function get_named_arguments() : array { // name the parameters $named_arguments = []; if ( array_key_exists( 'expects', $this->routes[ $this->__method_name ] ) ) { $expects = $this->routes[ $this->__method_name ]['expects']; foreach ( $expects as $index => $parameter_name ) { if ( array_key_exists( $index, $this->__arguments ) ) { $named_arguments[ $parameter_name ] = $this->__arguments[ $index ]; } } } return $named_arguments; }
[ "private", "function", "get_named_arguments", "(", ")", ":", "array", "{", "// name the parameters", "$", "named_arguments", "=", "[", "]", ";", "if", "(", "array_key_exists", "(", "'expects'", ",", "$", "this", "->", "routes", "[", "$", "this", "->", "__met...
Map the arguments passed into the method to the expected arguments defined by the route @return array
[ "Map", "the", "arguments", "passed", "into", "the", "method", "to", "the", "expected", "arguments", "defined", "by", "the", "route" ]
f972c737a9036a3090652950a1309a62c07d86c0
https://github.com/gios-asu/nectary/blob/f972c737a9036a3090652950a1309a62c07d86c0/src/routers/router.php#L108-L123
train
gios-asu/nectary
src/routers/router.php
Router.get_route_parts
private function get_route_parts() : array { $to = $this->routes[ $this->__method_name ]['to']; if ( \is_array( $to ) ) { $to_parts = $to; } else { $to_parts = explode( '@', $to ); } $to_class = $to_parts[0]; $to_method = $to_parts[1]; $on_error = null; if ( array_key_exists( 'on_error', $this->routes[ $this->__method_name ] ) ) { $on_error = $this->routes[ $this->__method_name ]['on_error']; } return [ $to_class, $to_method, $on_error ]; }
php
private function get_route_parts() : array { $to = $this->routes[ $this->__method_name ]['to']; if ( \is_array( $to ) ) { $to_parts = $to; } else { $to_parts = explode( '@', $to ); } $to_class = $to_parts[0]; $to_method = $to_parts[1]; $on_error = null; if ( array_key_exists( 'on_error', $this->routes[ $this->__method_name ] ) ) { $on_error = $this->routes[ $this->__method_name ]['on_error']; } return [ $to_class, $to_method, $on_error ]; }
[ "private", "function", "get_route_parts", "(", ")", ":", "array", "{", "$", "to", "=", "$", "this", "->", "routes", "[", "$", "this", "->", "__method_name", "]", "[", "'to'", "]", ";", "if", "(", "\\", "is_array", "(", "$", "to", ")", ")", "{", "...
Get the individual parts of the route, including the class and method to route to @return array
[ "Get", "the", "individual", "parts", "of", "the", "route", "including", "the", "class", "and", "method", "to", "route", "to" ]
f972c737a9036a3090652950a1309a62c07d86c0
https://github.com/gios-asu/nectary/blob/f972c737a9036a3090652950a1309a62c07d86c0/src/routers/router.php#L131-L148
train
gios-asu/nectary
src/routers/router.php
Router.do_route
private function do_route( $class_name, $method_name, $named_arguments, $on_error ) { if ( \is_object( $class_name ) ) { return $this->call( array( $class_name, $method_name, ), $named_arguments ); } $injector_factory = new Dependency_Injection_Factory( $class_name, $method_name, $named_arguments ); list( $obj, $dependencies, $validators ) = $injector_factory->build(); // Check all validators foreach ( $validators as $validator ) { $message = $validator->validate( $on_error ); if ( $message ) { return $message; } } return $this->call( array( $obj, $method_name, ), $dependencies ); }
php
private function do_route( $class_name, $method_name, $named_arguments, $on_error ) { if ( \is_object( $class_name ) ) { return $this->call( array( $class_name, $method_name, ), $named_arguments ); } $injector_factory = new Dependency_Injection_Factory( $class_name, $method_name, $named_arguments ); list( $obj, $dependencies, $validators ) = $injector_factory->build(); // Check all validators foreach ( $validators as $validator ) { $message = $validator->validate( $on_error ); if ( $message ) { return $message; } } return $this->call( array( $obj, $method_name, ), $dependencies ); }
[ "private", "function", "do_route", "(", "$", "class_name", ",", "$", "method_name", ",", "$", "named_arguments", ",", "$", "on_error", ")", "{", "if", "(", "\\", "is_object", "(", "$", "class_name", ")", ")", "{", "return", "$", "this", "->", "call", "...
Resolve dependencies for dependency injection and call the given route @param string $class_name The class to route to @param string $method_name The method name to call in the give class @param array $named_arguments Associative array of suggested arguments @param callback $on_error Callback if a validator fails @return mixed @throws \ReflectionException
[ "Resolve", "dependencies", "for", "dependency", "injection", "and", "call", "the", "given", "route" ]
f972c737a9036a3090652950a1309a62c07d86c0
https://github.com/gios-asu/nectary/blob/f972c737a9036a3090652950a1309a62c07d86c0/src/routers/router.php#L161-L200
train
tonjoo/tiga-framework
src/Response/ResponseFactory.php
ResponseFactory.template
public static function template($template, $parameter = array(), $status = 200, $headers = array()) { View::setTemplate($template, $parameter); return new Response('', $status, $headers); }
php
public static function template($template, $parameter = array(), $status = 200, $headers = array()) { View::setTemplate($template, $parameter); return new Response('', $status, $headers); }
[ "public", "static", "function", "template", "(", "$", "template", ",", "$", "parameter", "=", "array", "(", ")", ",", "$", "status", "=", "200", ",", "$", "headers", "=", "array", "(", ")", ")", "{", "View", "::", "setTemplate", "(", "$", "template",...
Generate response from template. @param string $template @param array $parameter @param int $status @param array $headers @return Response
[ "Generate", "response", "from", "template", "." ]
3c2eebd3bc616106fa1bba3e43f1791aff75eec5
https://github.com/tonjoo/tiga-framework/blob/3c2eebd3bc616106fa1bba3e43f1791aff75eec5/src/Response/ResponseFactory.php#L37-L42
train
tonjoo/tiga-framework
src/Response/ResponseFactory.php
ResponseFactory.json
public static function json($data, $status = 200, $headers = array()) { $jsonHeader = array('Content-Type' => 'application/json'); $content = json_encode($data); return new Response($content, $status, $jsonHeader); }
php
public static function json($data, $status = 200, $headers = array()) { $jsonHeader = array('Content-Type' => 'application/json'); $content = json_encode($data); return new Response($content, $status, $jsonHeader); }
[ "public", "static", "function", "json", "(", "$", "data", ",", "$", "status", "=", "200", ",", "$", "headers", "=", "array", "(", ")", ")", "{", "$", "jsonHeader", "=", "array", "(", "'Content-Type'", "=>", "'application/json'", ")", ";", "$", "content...
Return JSON response. @param array $data @param int $status @param array $headers @return Response
[ "Return", "JSON", "response", "." ]
3c2eebd3bc616106fa1bba3e43f1791aff75eec5
https://github.com/tonjoo/tiga-framework/blob/3c2eebd3bc616106fa1bba3e43f1791aff75eec5/src/Response/ResponseFactory.php#L53-L60
train
tonjoo/tiga-framework
src/Response/ResponseFactory.php
ResponseFactory.redirect
public static function redirect($url, $status = 302, $headers = array()) { $redirect = new RedirectResponse($url, $status, $headers); $redirect->sendHeaders(); die(); }
php
public static function redirect($url, $status = 302, $headers = array()) { $redirect = new RedirectResponse($url, $status, $headers); $redirect->sendHeaders(); die(); }
[ "public", "static", "function", "redirect", "(", "$", "url", ",", "$", "status", "=", "302", ",", "$", "headers", "=", "array", "(", ")", ")", "{", "$", "redirect", "=", "new", "RedirectResponse", "(", "$", "url", ",", "$", "status", ",", "$", "hea...
Redirect Response. @param string $url @param int $status @param array $headers
[ "Redirect", "Response", "." ]
3c2eebd3bc616106fa1bba3e43f1791aff75eec5
https://github.com/tonjoo/tiga-framework/blob/3c2eebd3bc616106fa1bba3e43f1791aff75eec5/src/Response/ResponseFactory.php#L69-L74
train
tonjoo/tiga-framework
src/Response/ResponseFactory.php
ResponseFactory.download
public static function download($file, $status = 200, $headers = array()) { require_once ABSPATH.'wp-admin/includes/file.php'; WP_Filesystem(); global $wp_filesystem; $fileData = $wp_filesystem->get_contents($file); $downloadHeader['Content-Description'] = 'File Transfer'; $downloadHeader['Content-Type'] = 'application/octet-stream'; $downloadHeader['Content-Disposition'] = 'attachment; filename='.basename($file); $downloadHeader['Content-Transfer-Encoding'] = 'binary'; $downloadHeader['Expires'] = '0'; $downloadHeader['Cache-Control'] = 'must-revalidate'; $downloadHeader['Pragma'] = 'public'; $downloadHeader['Content-Length'] = filesize($file); $response = new Response($fileData, 200, $downloadHeader); $response->send(); }
php
public static function download($file, $status = 200, $headers = array()) { require_once ABSPATH.'wp-admin/includes/file.php'; WP_Filesystem(); global $wp_filesystem; $fileData = $wp_filesystem->get_contents($file); $downloadHeader['Content-Description'] = 'File Transfer'; $downloadHeader['Content-Type'] = 'application/octet-stream'; $downloadHeader['Content-Disposition'] = 'attachment; filename='.basename($file); $downloadHeader['Content-Transfer-Encoding'] = 'binary'; $downloadHeader['Expires'] = '0'; $downloadHeader['Cache-Control'] = 'must-revalidate'; $downloadHeader['Pragma'] = 'public'; $downloadHeader['Content-Length'] = filesize($file); $response = new Response($fileData, 200, $downloadHeader); $response->send(); }
[ "public", "static", "function", "download", "(", "$", "file", ",", "$", "status", "=", "200", ",", "$", "headers", "=", "array", "(", ")", ")", "{", "require_once", "ABSPATH", ".", "'wp-admin/includes/file.php'", ";", "WP_Filesystem", "(", ")", ";", "globa...
Generate download file. @param string $file @param int $status @param array $headers
[ "Generate", "download", "file", "." ]
3c2eebd3bc616106fa1bba3e43f1791aff75eec5
https://github.com/tonjoo/tiga-framework/blob/3c2eebd3bc616106fa1bba3e43f1791aff75eec5/src/Response/ResponseFactory.php#L83-L104
train
HouseOfAgile/dacorp-extra-bundle
Listener/LanguageListener.php
LanguageListener.setLocaleForUnauthenticatedUser
public function setLocaleForUnauthenticatedUser(GetResponseEvent $event) { if (HttpKernelInterface::MASTER_REQUEST !== $event->getRequestType()) { return; } $request = $event->getRequest(); if ('unset' == $request->getLocale()) { if ($locale = $request->getSession()->get('_locale')) { $request->setLocale($locale); } else { $request->setLocale($request->getPreferredLanguage()); } } }
php
public function setLocaleForUnauthenticatedUser(GetResponseEvent $event) { if (HttpKernelInterface::MASTER_REQUEST !== $event->getRequestType()) { return; } $request = $event->getRequest(); if ('unset' == $request->getLocale()) { if ($locale = $request->getSession()->get('_locale')) { $request->setLocale($locale); } else { $request->setLocale($request->getPreferredLanguage()); } } }
[ "public", "function", "setLocaleForUnauthenticatedUser", "(", "GetResponseEvent", "$", "event", ")", "{", "if", "(", "HttpKernelInterface", "::", "MASTER_REQUEST", "!==", "$", "event", "->", "getRequestType", "(", ")", ")", "{", "return", ";", "}", "$", "request...
kernel.request event. If a guest user doesn't have an opened session, locale is equal to "undefined" as configured by default in parameters.ini. If so, set as a locale the user's preferred language. @param \Symfony\Component\HttpKernel\Event\GetResponseEvent $event
[ "kernel", ".", "request", "event", ".", "If", "a", "guest", "user", "doesn", "t", "have", "an", "opened", "session", "locale", "is", "equal", "to", "undefined", "as", "configured", "by", "default", "in", "parameters", ".", "ini", ".", "If", "so", "set", ...
99fe024791e7833058908a2e5544bde948031524
https://github.com/HouseOfAgile/dacorp-extra-bundle/blob/99fe024791e7833058908a2e5544bde948031524/Listener/LanguageListener.php#L36-L49
train
HouseOfAgile/dacorp-extra-bundle
Listener/LanguageListener.php
LanguageListener.setLocaleForAuthenticatedUser
public function setLocaleForAuthenticatedUser(InteractiveLoginEvent $event) { $user = $event->getAuthenticationToken()->getUser(); if ($lang = $user->getLocale()) { $this->session->set('_locale', $lang); } else { $request = $event->getRequest(); if ('unset' == $request->getLocale()) { $this->session->set('_locale', 'en'); } } }
php
public function setLocaleForAuthenticatedUser(InteractiveLoginEvent $event) { $user = $event->getAuthenticationToken()->getUser(); if ($lang = $user->getLocale()) { $this->session->set('_locale', $lang); } else { $request = $event->getRequest(); if ('unset' == $request->getLocale()) { $this->session->set('_locale', 'en'); } } }
[ "public", "function", "setLocaleForAuthenticatedUser", "(", "InteractiveLoginEvent", "$", "event", ")", "{", "$", "user", "=", "$", "event", "->", "getAuthenticationToken", "(", ")", "->", "getUser", "(", ")", ";", "if", "(", "$", "lang", "=", "$", "user", ...
security.interactive_login event. If a user chose a language in preferences, it would be set, if not, a locale that was set by setLocaleForUnauthenticatedUser remains. @param \Symfony\Component\Security\Http\Event\InteractiveLoginEvent $event
[ "security", ".", "interactive_login", "event", ".", "If", "a", "user", "chose", "a", "language", "in", "preferences", "it", "would", "be", "set", "if", "not", "a", "locale", "that", "was", "set", "by", "setLocaleForUnauthenticatedUser", "remains", "." ]
99fe024791e7833058908a2e5544bde948031524
https://github.com/HouseOfAgile/dacorp-extra-bundle/blob/99fe024791e7833058908a2e5544bde948031524/Listener/LanguageListener.php#L57-L68
train
judus/minimal-minimal
src/Facades/App.php
App.makeInstance
protected static function makeInstance( $class, array $options = null ): Implementation { $options || $options = ['provider' => self::app()]; return IOC::make($class, [$options, true]); }
php
protected static function makeInstance( $class, array $options = null ): Implementation { $options || $options = ['provider' => self::app()]; return IOC::make($class, [$options, true]); }
[ "protected", "static", "function", "makeInstance", "(", "$", "class", ",", "array", "$", "options", "=", "null", ")", ":", "Implementation", "{", "$", "options", "||", "$", "options", "=", "[", "'provider'", "=>", "self", "::", "app", "(", ")", "]", ";...
Make the instance this facade refers to @param $class @param array|null $options @return Implementation
[ "Make", "the", "instance", "this", "facade", "refers", "to" ]
36db55c537175cead2ab412f166bf2574d0f9597
https://github.com/judus/minimal-minimal/blob/36db55c537175cead2ab412f166bf2574d0f9597/src/Facades/App.php#L38-L45
train
judus/minimal-minimal
src/Facades/App.php
App.getInstance
public static function getInstance( $class = null, array $options = [] ) { /** @var Implementation $instance */ if (is_null(self::$instance)) { if (is_null($class)) { self::$instance = self::makeInstance( Implementation::class, $options )->getApp($options); self::$instance->load(); } else { ! is_object($class) || self::$instance = $class; } } return self::$instance; }
php
public static function getInstance( $class = null, array $options = [] ) { /** @var Implementation $instance */ if (is_null(self::$instance)) { if (is_null($class)) { self::$instance = self::makeInstance( Implementation::class, $options )->getApp($options); self::$instance->load(); } else { ! is_object($class) || self::$instance = $class; } } return self::$instance; }
[ "public", "static", "function", "getInstance", "(", "$", "class", "=", "null", ",", "array", "$", "options", "=", "[", "]", ")", "{", "/** @var Implementation $instance */", "if", "(", "is_null", "(", "self", "::", "$", "instance", ")", ")", "{", "if", "...
Get the instance this facade refers to @param null $class @param array $options @return Implementation
[ "Get", "the", "instance", "this", "facade", "refers", "to" ]
36db55c537175cead2ab412f166bf2574d0f9597
https://github.com/judus/minimal-minimal/blob/36db55c537175cead2ab412f166bf2574d0f9597/src/Facades/App.php#L88-L105
train
mfrost503/Snaggle
src/Client/Signatures/Signature.php
Signature.setHttpMethod
public function setHttpMethod($method) { $allowedMethods = array( 'POST', 'PUT', 'GET', 'DELETE', 'PATCH' ); if (!in_array(strtoupper($method), $allowedMethods)) { throw new \InvalidArgumentException('Provided method not allowed'); } $this->httpMethod = strtoupper($method); return $this; }
php
public function setHttpMethod($method) { $allowedMethods = array( 'POST', 'PUT', 'GET', 'DELETE', 'PATCH' ); if (!in_array(strtoupper($method), $allowedMethods)) { throw new \InvalidArgumentException('Provided method not allowed'); } $this->httpMethod = strtoupper($method); return $this; }
[ "public", "function", "setHttpMethod", "(", "$", "method", ")", "{", "$", "allowedMethods", "=", "array", "(", "'POST'", ",", "'PUT'", ",", "'GET'", ",", "'DELETE'", ",", "'PATCH'", ")", ";", "if", "(", "!", "in_array", "(", "strtoupper", "(", "$", "me...
Method to set the HTTP verb for the request @param string $method
[ "Method", "to", "set", "the", "HTTP", "verb", "for", "the", "request" ]
20990fe94b12b2013bca22689cde3b231eac4380
https://github.com/mfrost503/Snaggle/blob/20990fe94b12b2013bca22689cde3b231eac4380/src/Client/Signatures/Signature.php#L122-L136
train
mfrost503/Snaggle
src/Client/Signatures/Signature.php
Signature.getNonce
public function getNonce() { if ($this->nonce !== '') { return $this->nonce; } $this->nonce = md5(uniqid(rand(), true)); return $this->nonce; }
php
public function getNonce() { if ($this->nonce !== '') { return $this->nonce; } $this->nonce = md5(uniqid(rand(), true)); return $this->nonce; }
[ "public", "function", "getNonce", "(", ")", "{", "if", "(", "$", "this", "->", "nonce", "!==", "''", ")", "{", "return", "$", "this", "->", "nonce", ";", "}", "$", "this", "->", "nonce", "=", "md5", "(", "uniqid", "(", "rand", "(", ")", ",", "t...
Method to retrieve the nonce @return string
[ "Method", "to", "retrieve", "the", "nonce" ]
20990fe94b12b2013bca22689cde3b231eac4380
https://github.com/mfrost503/Snaggle/blob/20990fe94b12b2013bca22689cde3b231eac4380/src/Client/Signatures/Signature.php#L176-L183
train
mfrost503/Snaggle
src/Client/Signatures/Signature.php
Signature.setTimestamp
public function setTimestamp($timestamp = 0) { $this->timestamp = $timestamp; if ($timestamp === 0) { $this->timestamp = $this->generateTimestamp(); } return $this; }
php
public function setTimestamp($timestamp = 0) { $this->timestamp = $timestamp; if ($timestamp === 0) { $this->timestamp = $this->generateTimestamp(); } return $this; }
[ "public", "function", "setTimestamp", "(", "$", "timestamp", "=", "0", ")", "{", "$", "this", "->", "timestamp", "=", "$", "timestamp", ";", "if", "(", "$", "timestamp", "===", "0", ")", "{", "$", "this", "->", "timestamp", "=", "$", "this", "->", ...
Method to set the timestamp parameter for the signature @param int $timestamp
[ "Method", "to", "set", "the", "timestamp", "parameter", "for", "the", "signature" ]
20990fe94b12b2013bca22689cde3b231eac4380
https://github.com/mfrost503/Snaggle/blob/20990fe94b12b2013bca22689cde3b231eac4380/src/Client/Signatures/Signature.php#L242-L249
train
tomphp/TjoAnnotationRouter
src/TjoAnnotationRouter/Service/AnnotationManagerFactory.php
AnnotationManagerFactory.createService
public function createService(ServiceLocatorInterface $serviceLocator) { $annotationManager = new AnnotationManager(); $parser = new DoctrineAnnotationParser(); foreach ($this->defaultAnnotations as $annotationName) { $class = 'TjoAnnotationRouter\\Annotation\\' . $annotationName; $parser->registerAnnotation($class); } $annotationManager->attach($parser); return $annotationManager; }
php
public function createService(ServiceLocatorInterface $serviceLocator) { $annotationManager = new AnnotationManager(); $parser = new DoctrineAnnotationParser(); foreach ($this->defaultAnnotations as $annotationName) { $class = 'TjoAnnotationRouter\\Annotation\\' . $annotationName; $parser->registerAnnotation($class); } $annotationManager->attach($parser); return $annotationManager; }
[ "public", "function", "createService", "(", "ServiceLocatorInterface", "$", "serviceLocator", ")", "{", "$", "annotationManager", "=", "new", "AnnotationManager", "(", ")", ";", "$", "parser", "=", "new", "DoctrineAnnotationParser", "(", ")", ";", "foreach", "(", ...
Returns a configured instance of Zend\Code\Annotation\AnnotationManager @return AnnotationManager
[ "Returns", "a", "configured", "instance", "of", "Zend", "\\", "Code", "\\", "Annotation", "\\", "AnnotationManager" ]
ee323691e948d82449287eae5c1ecce80cc90971
https://github.com/tomphp/TjoAnnotationRouter/blob/ee323691e948d82449287eae5c1ecce80cc90971/src/TjoAnnotationRouter/Service/AnnotationManagerFactory.php#L38-L52
train
lazyguru/toggl
src/TimeEntry.php
TimeEntry.setTask
public function setTask($task) { $taskCode = filter_var($task, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); if (strpos($taskCode, '-') !== false) { $taskCode = str_replace('-', '', $taskCode); } $taskCode = $this->project . $taskCode; $this->task = $taskCode; }
php
public function setTask($task) { $taskCode = filter_var($task, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); if (strpos($taskCode, '-') !== false) { $taskCode = str_replace('-', '', $taskCode); } $taskCode = $this->project . $taskCode; $this->task = $taskCode; }
[ "public", "function", "setTask", "(", "$", "task", ")", "{", "$", "taskCode", "=", "filter_var", "(", "$", "task", ",", "FILTER_SANITIZE_NUMBER_FLOAT", ",", "FILTER_FLAG_ALLOW_FRACTION", ")", ";", "if", "(", "strpos", "(", "$", "taskCode", ",", "'-'", ")", ...
Sets the internal task ID for this task. Task is determineed by concatenating project and task code @param string $task
[ "Sets", "the", "internal", "task", "ID", "for", "this", "task", ".", "Task", "is", "determineed", "by", "concatenating", "project", "and", "task", "code" ]
5ce8b5f937b38dc5afd40b362db26e93239d7135
https://github.com/lazyguru/toggl/blob/5ce8b5f937b38dc5afd40b362db26e93239d7135/src/TimeEntry.php#L52-L60
train
lazyguru/toggl
src/TimeEntry.php
TimeEntry.processTags
public function processTags($tags = null) { if (empty($tags)) { $tags = $this->tags; } foreach ($tags as $tag) { $this->tags[] = $tag; if (preg_match('/[A-Z]+\-[\d]+/', $tag)) { $this->setTicket($tag); continue; } if ($tag == 'Jira') { $this->setLogged(true); } } $this->tags = array_unique($this->tags); }
php
public function processTags($tags = null) { if (empty($tags)) { $tags = $this->tags; } foreach ($tags as $tag) { $this->tags[] = $tag; if (preg_match('/[A-Z]+\-[\d]+/', $tag)) { $this->setTicket($tag); continue; } if ($tag == 'Jira') { $this->setLogged(true); } } $this->tags = array_unique($this->tags); }
[ "public", "function", "processTags", "(", "$", "tags", "=", "null", ")", "{", "if", "(", "empty", "(", "$", "tags", ")", ")", "{", "$", "tags", "=", "$", "this", "->", "tags", ";", "}", "foreach", "(", "$", "tags", "as", "$", "tag", ")", "{", ...
Processes an array of tags to find the ticket number as well as other internally used tags @param array $tags An array of tags to process
[ "Processes", "an", "array", "of", "tags", "to", "find", "the", "ticket", "number", "as", "well", "as", "other", "internally", "used", "tags" ]
5ce8b5f937b38dc5afd40b362db26e93239d7135
https://github.com/lazyguru/toggl/blob/5ce8b5f937b38dc5afd40b362db26e93239d7135/src/TimeEntry.php#L269-L285
train
ipunkt/rancherize-backup-storagebox
plugin/Backup/Methods/Storagebox/StorageboxMethod.php
StorageboxMethod.startRestoreService
private function startRestoreService( StorageboxData $data, $backupKey, Database $database, OutputInterface $output) { $stackName = $data->getBackup()->getStackName(); $restoreService = new Service(); $restoreService->setImage('ipunktbs/xtrabackup:1.1.1'); $restoreService->setName('restore-'.$backupKey); $restoreService->setCommand('restore '.$backupKey); $restoreService->setRestart(Service::RESTART_START_ONCE); $mysqlVolume = $this->makeVolume($data); $backupVolume = $this->makeBackupVolume($database); $restoreService->addVolume( $mysqlVolume ); $restoreService->addVolume( $backupVolume ); /** * @var SchedulerParser $schedulerParser */ //$schedulerParser = container(SchedulerParser::class); $schedulerParser = container('scheduler-parser'); $config = new ArrayConfiguration([ 'scheduler' => [ 'should-have-tags' => [ 'primary-restore' ] ] ]); $schedulerParser->parse($restoreService, $config); $restoreInfrastructure = new Infrastructure(); $restoreInfrastructure->addService($restoreService); $this->infrastructureWriter->setPath( $this->getWorkDirectory() ) ->setSkipClear(false) ->write($restoreInfrastructure, new FileWriter()); $output->writeln("Starting ".$restoreService->getName()."."); $this->rancherService->start( $this->getWorkDirectory(), $stackName); $output->writeln("Waiting for ".$restoreService->getName()." to finish."); $this->rancherService->wait($stackName, $restoreService->getName(), new HealthStateMatcher('started-once') ); $output->writeln($restoreService->getName()." finished."); return $restoreService; }
php
private function startRestoreService( StorageboxData $data, $backupKey, Database $database, OutputInterface $output) { $stackName = $data->getBackup()->getStackName(); $restoreService = new Service(); $restoreService->setImage('ipunktbs/xtrabackup:1.1.1'); $restoreService->setName('restore-'.$backupKey); $restoreService->setCommand('restore '.$backupKey); $restoreService->setRestart(Service::RESTART_START_ONCE); $mysqlVolume = $this->makeVolume($data); $backupVolume = $this->makeBackupVolume($database); $restoreService->addVolume( $mysqlVolume ); $restoreService->addVolume( $backupVolume ); /** * @var SchedulerParser $schedulerParser */ //$schedulerParser = container(SchedulerParser::class); $schedulerParser = container('scheduler-parser'); $config = new ArrayConfiguration([ 'scheduler' => [ 'should-have-tags' => [ 'primary-restore' ] ] ]); $schedulerParser->parse($restoreService, $config); $restoreInfrastructure = new Infrastructure(); $restoreInfrastructure->addService($restoreService); $this->infrastructureWriter->setPath( $this->getWorkDirectory() ) ->setSkipClear(false) ->write($restoreInfrastructure, new FileWriter()); $output->writeln("Starting ".$restoreService->getName()."."); $this->rancherService->start( $this->getWorkDirectory(), $stackName); $output->writeln("Waiting for ".$restoreService->getName()." to finish."); $this->rancherService->wait($stackName, $restoreService->getName(), new HealthStateMatcher('started-once') ); $output->writeln($restoreService->getName()." finished."); return $restoreService; }
[ "private", "function", "startRestoreService", "(", "StorageboxData", "$", "data", ",", "$", "backupKey", ",", "Database", "$", "database", ",", "OutputInterface", "$", "output", ")", "{", "$", "stackName", "=", "$", "data", "->", "getBackup", "(", ")", "->",...
Start the restore service @param StorageboxData $data @param string $backupKey @param Database $database @param OutputInterface $output @return Service
[ "Start", "the", "restore", "service" ]
2c018a2a811aea864c33bddb3ed5f53cd7b696f8
https://github.com/ipunkt/rancherize-backup-storagebox/blob/2c018a2a811aea864c33bddb3ed5f53cd7b696f8/plugin/Backup/Methods/Storagebox/StorageboxMethod.php#L286-L326
train
ipunkt/rancherize-backup-storagebox
plugin/Backup/Methods/Storagebox/StorageboxMethod.php
StorageboxMethod.startNewService
private function startNewService(Service $restoreService,StorageboxData $data, $backupKey, OutputInterface $output) { $stackName = $data->getBackup()->getStackName(); $restoreServiceName = $restoreService->getName(); $dockerCompose = [ 'version' => '2', 'services' => array_merge( [$data->getBackup()->getServiceName() => $data->getService()], $data->getSidekicks() ) ]; $rancherCompose = $data->getRancherData(); // TODO: Allow to set as option. If not set: ask user $regex = '~$~'; $replacement = '-'.$backupKey; foreach($this->modifiers as $modifier) { if($modifier instanceof RequiresReplacementRegex) $modifier->setReplacementRegex($regex, $replacement); $modifier->modify($dockerCompose, $rancherCompose, $data); } // Start on the same server as the restore service $compose = &$dockerCompose; foreach([ 'services', $data->getNewServiceName(), 'labels', ] as $key) { if( !array_key_exists($key, $compose) ) $compose[$key] = []; $compose = &$compose[$key]; } $dockerCompose['services'][$data->getNewServiceName()]['labels']['io.rancher.scheduler.affinity:container_label_soft'] = "io.rancher.stack_service.name=${stackName}/${restoreServiceName}"; $dockerFileContent = Yaml::dump($dockerCompose, 100, 2); $this->buildService->createDockerCompose($dockerFileContent); $rancherFileContent = Yaml::dump($rancherCompose, 100, 2); $this->buildService->createRancherCompose($rancherFileContent); $stackName = $data->getBackup()->getStackName(); $newServiceName = $data->getNewServiceName(); $output->writeln("Starting $newServiceName."); $this->rancherService->start( $this->getWorkDirectory(), $stackName); $output->writeln("Waiting for $newServiceName to start."); $this->rancherService->wait($stackName, $newServiceName, new SingleStateMatcher('active') ); $output->writeln("$newServiceName Started."); }
php
private function startNewService(Service $restoreService,StorageboxData $data, $backupKey, OutputInterface $output) { $stackName = $data->getBackup()->getStackName(); $restoreServiceName = $restoreService->getName(); $dockerCompose = [ 'version' => '2', 'services' => array_merge( [$data->getBackup()->getServiceName() => $data->getService()], $data->getSidekicks() ) ]; $rancherCompose = $data->getRancherData(); // TODO: Allow to set as option. If not set: ask user $regex = '~$~'; $replacement = '-'.$backupKey; foreach($this->modifiers as $modifier) { if($modifier instanceof RequiresReplacementRegex) $modifier->setReplacementRegex($regex, $replacement); $modifier->modify($dockerCompose, $rancherCompose, $data); } // Start on the same server as the restore service $compose = &$dockerCompose; foreach([ 'services', $data->getNewServiceName(), 'labels', ] as $key) { if( !array_key_exists($key, $compose) ) $compose[$key] = []; $compose = &$compose[$key]; } $dockerCompose['services'][$data->getNewServiceName()]['labels']['io.rancher.scheduler.affinity:container_label_soft'] = "io.rancher.stack_service.name=${stackName}/${restoreServiceName}"; $dockerFileContent = Yaml::dump($dockerCompose, 100, 2); $this->buildService->createDockerCompose($dockerFileContent); $rancherFileContent = Yaml::dump($rancherCompose, 100, 2); $this->buildService->createRancherCompose($rancherFileContent); $stackName = $data->getBackup()->getStackName(); $newServiceName = $data->getNewServiceName(); $output->writeln("Starting $newServiceName."); $this->rancherService->start( $this->getWorkDirectory(), $stackName); $output->writeln("Waiting for $newServiceName to start."); $this->rancherService->wait($stackName, $newServiceName, new SingleStateMatcher('active') ); $output->writeln("$newServiceName Started."); }
[ "private", "function", "startNewService", "(", "Service", "$", "restoreService", ",", "StorageboxData", "$", "data", ",", "$", "backupKey", ",", "OutputInterface", "$", "output", ")", "{", "$", "stackName", "=", "$", "data", "->", "getBackup", "(", ")", "->"...
Start the new service @param Service $restoreService @param StorageboxData $data @param $backupKey @param OutputInterface $output
[ "Start", "the", "new", "service" ]
2c018a2a811aea864c33bddb3ed5f53cd7b696f8
https://github.com/ipunkt/rancherize-backup-storagebox/blob/2c018a2a811aea864c33bddb3ed5f53cd7b696f8/plugin/Backup/Methods/Storagebox/StorageboxMethod.php#L335-L385
train
asbsoft/yii2module-content_2_170309
models/ContentBase.php
ContentBase.prepareI18nModels
public function prepareI18nModels() { $mI18n = $this->getJoined()->all(); $modelsI18n = []; foreach ($mI18n as $modelI18n) { $modelI18n->correctSelectedText(); $modelsI18n[$modelI18n->lang_code] = $modelI18n; } foreach ($this->languages as $langCode => $lang) { if (empty($modelsI18n[$langCode])) { $newI18n = $this->module->model(static::I18N_JOIN_MODEL); $modelsI18n[$langCode] = $newI18n->loadDefaultValues(); $modelsI18n[$langCode]->lang_code = $langCode; } } return $modelsI18n; }
php
public function prepareI18nModels() { $mI18n = $this->getJoined()->all(); $modelsI18n = []; foreach ($mI18n as $modelI18n) { $modelI18n->correctSelectedText(); $modelsI18n[$modelI18n->lang_code] = $modelI18n; } foreach ($this->languages as $langCode => $lang) { if (empty($modelsI18n[$langCode])) { $newI18n = $this->module->model(static::I18N_JOIN_MODEL); $modelsI18n[$langCode] = $newI18n->loadDefaultValues(); $modelsI18n[$langCode]->lang_code = $langCode; } } return $modelsI18n; }
[ "public", "function", "prepareI18nModels", "(", ")", "{", "$", "mI18n", "=", "$", "this", "->", "getJoined", "(", ")", "->", "all", "(", ")", ";", "$", "modelsI18n", "=", "[", "]", ";", "foreach", "(", "$", "mI18n", "as", "$", "modelI18n", ")", "{"...
Prepare i18n-models array, create new if need. No error if new language add or not found joined record - will create new i18n-model with default values. @return array in format langCode => i18n-model's object
[ "Prepare", "i18n", "-", "models", "array", "create", "new", "if", "need", ".", "No", "error", "if", "new", "language", "add", "or", "not", "found", "joined", "record", "-", "will", "create", "new", "i18n", "-", "model", "with", "default", "values", "." ]
9e7ee40fd48ef9656a9f95379f20bf6a4004187b
https://github.com/asbsoft/yii2module-content_2_170309/blob/9e7ee40fd48ef9656a9f95379f20bf6a4004187b/models/ContentBase.php#L217-L233
train
wasabi-cms/core
src/Model/Entity/Setting.php
Setting.errors
public function errors($field = null, $errors = null, $overwrite = false) { if (isset($this->_properties['scope'])) { $this->_errors = []; } return parent::errors($field, $errors, $overwrite); }
php
public function errors($field = null, $errors = null, $overwrite = false) { if (isset($this->_properties['scope'])) { $this->_errors = []; } return parent::errors($field, $errors, $overwrite); }
[ "public", "function", "errors", "(", "$", "field", "=", "null", ",", "$", "errors", "=", "null", ",", "$", "overwrite", "=", "false", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "_properties", "[", "'scope'", "]", ")", ")", "{", "$", "t...
Skip error checking for the actual save operation since the entity is checked for errors manually within the KeyValueBehavior. @param string|array|null $field The field to get errors for, or the array of errors to set. @param string|array|null $errors The errors to be set for $field @param bool $overwrite Whether or not to overwrite pre-existing errors for $field @return array|\Cake\Datasource\EntityInterface
[ "Skip", "error", "checking", "for", "the", "actual", "save", "operation", "since", "the", "entity", "is", "checked", "for", "errors", "manually", "within", "the", "KeyValueBehavior", "." ]
0eadbb64d2fc201bacc63c93814adeca70e08f90
https://github.com/wasabi-cms/core/blob/0eadbb64d2fc201bacc63c93814adeca70e08f90/src/Model/Entity/Setting.php#L35-L42
train
theluckyteam/php-jira
src/jira/Repository/RepositoryDispatcher.php
RepositoryDispatcher.addRepository
public function addRepository(RepositoryInterface $repository) { if ($repository instanceof IssueRepository) { $type = 'issue'; } else { throw new \Exception('Unknown repository type.'); } $this->repositories[$type] = $repository; }
php
public function addRepository(RepositoryInterface $repository) { if ($repository instanceof IssueRepository) { $type = 'issue'; } else { throw new \Exception('Unknown repository type.'); } $this->repositories[$type] = $repository; }
[ "public", "function", "addRepository", "(", "RepositoryInterface", "$", "repository", ")", "{", "if", "(", "$", "repository", "instanceof", "IssueRepository", ")", "{", "$", "type", "=", "'issue'", ";", "}", "else", "{", "throw", "new", "\\", "Exception", "(...
Register the repository in the manager @param RepositoryInterface $repository @throws \Exception
[ "Register", "the", "repository", "in", "the", "manager" ]
5a50ab4fc57dd77239f1b7e9c87738318c258c38
https://github.com/theluckyteam/php-jira/blob/5a50ab4fc57dd77239f1b7e9c87738318c258c38/src/jira/Repository/RepositoryDispatcher.php#L130-L139
train
eureka-framework/Eurekon
Help.php
Help.addArgument
public function addArgument($shortName = '', $fullName = '', $description = '', $hasValue = false, $isMandatory = false) { $argument = new \stdClass(); $argument->shortName = $shortName; $argument->fullName = $fullName; $argument->description = $description; $argument->hasValue = (bool) $hasValue; $argument->isMandatory = (bool) $isMandatory; $this->arguments[] = $argument; }
php
public function addArgument($shortName = '', $fullName = '', $description = '', $hasValue = false, $isMandatory = false) { $argument = new \stdClass(); $argument->shortName = $shortName; $argument->fullName = $fullName; $argument->description = $description; $argument->hasValue = (bool) $hasValue; $argument->isMandatory = (bool) $isMandatory; $this->arguments[] = $argument; }
[ "public", "function", "addArgument", "(", "$", "shortName", "=", "''", ",", "$", "fullName", "=", "''", ",", "$", "description", "=", "''", ",", "$", "hasValue", "=", "false", ",", "$", "isMandatory", "=", "false", ")", "{", "$", "argument", "=", "ne...
Add argument in list for script help @param string $shortName Short name for argument @param string $fullName Full name for argument @param string $description Argument's description @param boolean $hasValue If argument must have value @param boolean $isMandatory Set true to force mandatory mention. @return void
[ "Add", "argument", "in", "list", "for", "script", "help" ]
86f958f9458ea369894286d8cdc4fe4ded33489a
https://github.com/eureka-framework/Eurekon/blob/86f958f9458ea369894286d8cdc4fe4ded33489a/Help.php#L142-L152
train
EarthlingInteractive/PHPCMIPREST
lib/EarthIT/CMIPREST/ResultAssembler/NOJResultAssembler.php
EarthIT_CMIPREST_ResultAssembler_NOJResultAssembler._q45
protected function _q45( EarthIT_Schema_ResourceClass $rc, array $items ) { $restObjects = array(); $keyByIds = $this->shouldKeyRestItemsById($rc); foreach( $items as $item ) { $restItem = $this->internalObjectToRest($rc, $item); if( $keyByIds ) { $restObjects[EarthIT_Storage_Util::itemId($item,$rc)] = $restItem; } else { $restObjects[] = $restItem; } } return $this->jsonTyped($restObjects, $keyByIds ? EarthIT_JSON::JT_OBJECT : EarthIT_JSON::JT_LIST); }
php
protected function _q45( EarthIT_Schema_ResourceClass $rc, array $items ) { $restObjects = array(); $keyByIds = $this->shouldKeyRestItemsById($rc); foreach( $items as $item ) { $restItem = $this->internalObjectToRest($rc, $item); if( $keyByIds ) { $restObjects[EarthIT_Storage_Util::itemId($item,$rc)] = $restItem; } else { $restObjects[] = $restItem; } } return $this->jsonTyped($restObjects, $keyByIds ? EarthIT_JSON::JT_OBJECT : EarthIT_JSON::JT_LIST); }
[ "protected", "function", "_q45", "(", "EarthIT_Schema_ResourceClass", "$", "rc", ",", "array", "$", "items", ")", "{", "$", "restObjects", "=", "array", "(", ")", ";", "$", "keyByIds", "=", "$", "this", "->", "shouldKeyRestItemsById", "(", "$", "rc", ")", ...
Convert the given rows from DB to REST format according to the specified resource class.
[ "Convert", "the", "given", "rows", "from", "DB", "to", "REST", "format", "according", "to", "the", "specified", "resource", "class", "." ]
db0398ea4fc07fa62f2de9ba43f2f3137170d9f0
https://github.com/EarthlingInteractive/PHPCMIPREST/blob/db0398ea4fc07fa62f2de9ba43f2f3137170d9f0/lib/EarthIT/CMIPREST/ResultAssembler/NOJResultAssembler.php#L67-L79
train
teamelf/core
src/Http/ViewController.php
ViewController.addAssets
protected function addAssets() { $this->assets = ViewService::getAssetManager(); $this->assets ->addCss(__DIR__ . '/../../assets/common/dist/common.css') ->addJs(__DIR__ . '/../../assets/common/dist/common.js') ->entry('teamelf/common/main'); }
php
protected function addAssets() { $this->assets = ViewService::getAssetManager(); $this->assets ->addCss(__DIR__ . '/../../assets/common/dist/common.css') ->addJs(__DIR__ . '/../../assets/common/dist/common.js') ->entry('teamelf/common/main'); }
[ "protected", "function", "addAssets", "(", ")", "{", "$", "this", "->", "assets", "=", "ViewService", "::", "getAssetManager", "(", ")", ";", "$", "this", "->", "assets", "->", "addCss", "(", "__DIR__", ".", "'/../../assets/common/dist/common.css'", ")", "->",...
add common assets
[ "add", "common", "assets" ]
653fc6e27f42239c2a8998a5fea325480e9dd39e
https://github.com/teamelf/core/blob/653fc6e27f42239c2a8998a5fea325480e9dd39e/src/Http/ViewController.php#L54-L61
train
zepi/turbo-base
Zepi/DataSource/Doctrine/src/Manager/EntityManager.php
EntityManager.buildDataRequestQuery
public function buildDataRequestQuery(DataRequest $dataRequest, QueryBuilder $queryBuilder, $entity, $tableCode) { $queryBuilder->select($tableCode) ->from($entity, $tableCode); $hasWhere = false; $i = 1; foreach ($dataRequest->getFilters() as $filter) { $whereQuery = $tableCode . '.' . $filter->getFieldName() . ' ' . $filter->getMode() . ' :p' . $i; if ($hasWhere) { $queryBuilder->andWhere($whereQuery); } else { $queryBuilder->where($whereQuery); $hasWhere = true; } $queryBuilder->setParameter('p' . $i, $this->prepareValue($filter->getNeededValue(), $filter->getMode())); $i++; } // Sorting if ($dataRequest->hasSorting()) { $mode = 'ASC'; if (in_array($dataRequest->getSortByDirection(), array('ASC', 'DESC'))) { $mode = $dataRequest->getSortByDirection(); } $queryBuilder->orderBy($tableCode . '.' . $dataRequest->getSortBy(), $mode); } // Offset if ($dataRequest->hasRange()) { $queryBuilder->setFirstResult($dataRequest->getOffset()); $queryBuilder->setMaxResults($dataRequest->getNumberOfEntries()); } }
php
public function buildDataRequestQuery(DataRequest $dataRequest, QueryBuilder $queryBuilder, $entity, $tableCode) { $queryBuilder->select($tableCode) ->from($entity, $tableCode); $hasWhere = false; $i = 1; foreach ($dataRequest->getFilters() as $filter) { $whereQuery = $tableCode . '.' . $filter->getFieldName() . ' ' . $filter->getMode() . ' :p' . $i; if ($hasWhere) { $queryBuilder->andWhere($whereQuery); } else { $queryBuilder->where($whereQuery); $hasWhere = true; } $queryBuilder->setParameter('p' . $i, $this->prepareValue($filter->getNeededValue(), $filter->getMode())); $i++; } // Sorting if ($dataRequest->hasSorting()) { $mode = 'ASC'; if (in_array($dataRequest->getSortByDirection(), array('ASC', 'DESC'))) { $mode = $dataRequest->getSortByDirection(); } $queryBuilder->orderBy($tableCode . '.' . $dataRequest->getSortBy(), $mode); } // Offset if ($dataRequest->hasRange()) { $queryBuilder->setFirstResult($dataRequest->getOffset()); $queryBuilder->setMaxResults($dataRequest->getNumberOfEntries()); } }
[ "public", "function", "buildDataRequestQuery", "(", "DataRequest", "$", "dataRequest", ",", "QueryBuilder", "$", "queryBuilder", ",", "$", "entity", ",", "$", "tableCode", ")", "{", "$", "queryBuilder", "->", "select", "(", "$", "tableCode", ")", "->", "from",...
Builds the query for the given data request object @access public @param \Zepi\DataSource\Core\Entity\DataRequest $dataRequest @param \Doctrine\ORM\QueryBuilder $queryBuilder @param string $entity @param string $tableCode
[ "Builds", "the", "query", "for", "the", "given", "data", "request", "object" ]
9a36d8c7649317f55f91b2adf386bd1f04ec02a3
https://github.com/zepi/turbo-base/blob/9a36d8c7649317f55f91b2adf386bd1f04ec02a3/Zepi/DataSource/Doctrine/src/Manager/EntityManager.php#L74-L109
train
oscarotero/server
src/Server.php
Server.run
public static function run($cwd = null, array $index = ['html', 'php'], $front = '/index.php') { if ($cwd === null) { $cwd = getcwd(); } $file = self::getFilePath($cwd, $index); //The file does not exists if ($file === false) { return false; } //The file is the front controller if (!empty($front) && ($file === $cwd.$front)) { return false; } //The file can be served by the php server if ($cwd === getcwd()) { return true; } $ext = strtolower(pathinfo($file, PATHINFO_EXTENSION)); //The file is a php script that must be included if ($ext === 'php') { return $file; } //Output the file content if (isset(self::$mimes[$ext])) { $mime = self::$mimes[$ext]; } else { $info = new finfo(FILEINFO_MIME); $mime = $info->file($file); } header('Content-Type: '.$mime); readfile($file); exit; }
php
public static function run($cwd = null, array $index = ['html', 'php'], $front = '/index.php') { if ($cwd === null) { $cwd = getcwd(); } $file = self::getFilePath($cwd, $index); //The file does not exists if ($file === false) { return false; } //The file is the front controller if (!empty($front) && ($file === $cwd.$front)) { return false; } //The file can be served by the php server if ($cwd === getcwd()) { return true; } $ext = strtolower(pathinfo($file, PATHINFO_EXTENSION)); //The file is a php script that must be included if ($ext === 'php') { return $file; } //Output the file content if (isset(self::$mimes[$ext])) { $mime = self::$mimes[$ext]; } else { $info = new finfo(FILEINFO_MIME); $mime = $info->file($file); } header('Content-Type: '.$mime); readfile($file); exit; }
[ "public", "static", "function", "run", "(", "$", "cwd", "=", "null", ",", "array", "$", "index", "=", "[", "'html'", ",", "'php'", "]", ",", "$", "front", "=", "'/index.php'", ")", "{", "if", "(", "$", "cwd", "===", "null", ")", "{", "$", "cwd", ...
Runs the server @param string|null $cwd @param array $index @param string $front @return bool|string
[ "Runs", "the", "server" ]
cee9636e0d6fda094dae819f8151fd6b6563f0dc
https://github.com/oscarotero/server/blob/cee9636e0d6fda094dae819f8151fd6b6563f0dc/src/Server.php#L24-L65
train
oscarotero/server
src/Server.php
Server.getRequestPath
public static function getRequestPath() { if (empty($_SERVER['REQUEST_URI'])) { return false; } $path = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH); return empty($path) ? $path : urldecode($path); }
php
public static function getRequestPath() { if (empty($_SERVER['REQUEST_URI'])) { return false; } $path = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH); return empty($path) ? $path : urldecode($path); }
[ "public", "static", "function", "getRequestPath", "(", ")", "{", "if", "(", "empty", "(", "$", "_SERVER", "[", "'REQUEST_URI'", "]", ")", ")", "{", "return", "false", ";", "}", "$", "path", "=", "parse_url", "(", "$", "_SERVER", "[", "'REQUEST_URI'", "...
Returns the path of the request uri @return string|false
[ "Returns", "the", "path", "of", "the", "request", "uri" ]
cee9636e0d6fda094dae819f8151fd6b6563f0dc
https://github.com/oscarotero/server/blob/cee9636e0d6fda094dae819f8151fd6b6563f0dc/src/Server.php#L72-L81
train
oscarotero/server
src/Server.php
Server.getFilePath
public static function getFilePath($cwd, array $index) { $path = self::getRequestPath(); if ($path === false) { return false; } $file = $cwd.$path; if (is_file($file)) { return $file; } if (empty($index)) { return false; } foreach ($index as $ext) { $f = rtrim($file, '/').'/index.'.$ext; if (is_file($f)) { return $f; } } return false; }
php
public static function getFilePath($cwd, array $index) { $path = self::getRequestPath(); if ($path === false) { return false; } $file = $cwd.$path; if (is_file($file)) { return $file; } if (empty($index)) { return false; } foreach ($index as $ext) { $f = rtrim($file, '/').'/index.'.$ext; if (is_file($f)) { return $f; } } return false; }
[ "public", "static", "function", "getFilePath", "(", "$", "cwd", ",", "array", "$", "index", ")", "{", "$", "path", "=", "self", "::", "getRequestPath", "(", ")", ";", "if", "(", "$", "path", "===", "false", ")", "{", "return", "false", ";", "}", "$...
Check whether the requested path exists @param string $cwd @param array $index @return string|false
[ "Check", "whether", "the", "requested", "path", "exists" ]
cee9636e0d6fda094dae819f8151fd6b6563f0dc
https://github.com/oscarotero/server/blob/cee9636e0d6fda094dae819f8151fd6b6563f0dc/src/Server.php#L91-L118
train
PowerOnSystem/WebFramework
src/Routing/Dispatcher.php
Dispatcher.handle
public function handle( \AltoRouter $router, \PowerOn\Network\Request $request ) { $match = $router->match($request->path); if ( $match ) { $target = explode('#', $match['target']); $this->controller = $target[0]; $this->action = key_exists(1, $target) ? $target[1] : 'index'; } else { $url = $request->urlToArray(); $controller = array_shift($url); $action = array_shift($url); $this->controller = $controller ? $controller : 'index'; $this->action = $action ? $action : 'index'; } $handler = $this->loadController(); if ( !$handler || !method_exists($handler, $this->action) ) { throw new NotFoundException('El sitio al que intenta ingresar no existe.'); } return $handler; }
php
public function handle( \AltoRouter $router, \PowerOn\Network\Request $request ) { $match = $router->match($request->path); if ( $match ) { $target = explode('#', $match['target']); $this->controller = $target[0]; $this->action = key_exists(1, $target) ? $target[1] : 'index'; } else { $url = $request->urlToArray(); $controller = array_shift($url); $action = array_shift($url); $this->controller = $controller ? $controller : 'index'; $this->action = $action ? $action : 'index'; } $handler = $this->loadController(); if ( !$handler || !method_exists($handler, $this->action) ) { throw new NotFoundException('El sitio al que intenta ingresar no existe.'); } return $handler; }
[ "public", "function", "handle", "(", "\\", "AltoRouter", "$", "router", ",", "\\", "PowerOn", "\\", "Network", "\\", "Request", "$", "request", ")", "{", "$", "match", "=", "$", "router", "->", "match", "(", "$", "request", "->", "path", ")", ";", "i...
Obtiene el controlador a utilizar @return \PowerOn\Controller\Controller Devuelve el controlador
[ "Obtiene", "el", "controlador", "a", "utilizar" ]
3b885a390adc42d6ad93d7900d33d97c66a6c2a9
https://github.com/PowerOnSystem/WebFramework/blob/3b885a390adc42d6ad93d7900d33d97c66a6c2a9/src/Routing/Dispatcher.php#L48-L69
train