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
miaoxing/plugin
src/BasePlugin.php
BasePlugin.display
protected function display($data = []) { // eg onScript $function = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 2)[1]['function']; $event = lcfirst(substr($function, 2)); $id = $this->getId(); // eg @plugin/plugin/script.php $name = '@' . $id . '/' . $id . '/' . $event . $this->view->getExtension(); $this->view->display($name, $data); }
php
protected function display($data = []) { // eg onScript $function = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 2)[1]['function']; $event = lcfirst(substr($function, 2)); $id = $this->getId(); // eg @plugin/plugin/script.php $name = '@' . $id . '/' . $id . '/' . $event . $this->view->getExtension(); $this->view->display($name, $data); }
[ "protected", "function", "display", "(", "$", "data", "=", "[", "]", ")", "{", "// eg onScript", "$", "function", "=", "debug_backtrace", "(", "DEBUG_BACKTRACE_IGNORE_ARGS", ",", "2", ")", "[", "1", "]", "[", "'function'", "]", ";", "$", "event", "=", "l...
Output a rendered template by current event template @param array $data
[ "Output", "a", "rendered", "template", "by", "current", "event", "template" ]
f287a1e6c97abba6f06906255b8c26e8ab0afe61
https://github.com/miaoxing/plugin/blob/f287a1e6c97abba6f06906255b8c26e8ab0afe61/src/BasePlugin.php#L137-L148
train
miaoxing/plugin
src/BasePlugin.php
BasePlugin.getBasePath
public function getBasePath() { if (!$this->basePath) { $class = new \ReflectionClass($this); $this->basePath = substr(dirname($class->getFileName()), strlen(getcwd()) + 1); // TODO 改为默认 if (substr($class->getName(), 0, 8) == 'Miaoxing') { $this->basePath = dirname($this->basePath); } } return $this->basePath; }
php
public function getBasePath() { if (!$this->basePath) { $class = new \ReflectionClass($this); $this->basePath = substr(dirname($class->getFileName()), strlen(getcwd()) + 1); // TODO 改为默认 if (substr($class->getName(), 0, 8) == 'Miaoxing') { $this->basePath = dirname($this->basePath); } } return $this->basePath; }
[ "public", "function", "getBasePath", "(", ")", "{", "if", "(", "!", "$", "this", "->", "basePath", ")", "{", "$", "class", "=", "new", "\\", "ReflectionClass", "(", "$", "this", ")", ";", "$", "this", "->", "basePath", "=", "substr", "(", "dirname", ...
Returns the web path for this plugin @return string
[ "Returns", "the", "web", "path", "for", "this", "plugin" ]
f287a1e6c97abba6f06906255b8c26e8ab0afe61
https://github.com/miaoxing/plugin/blob/f287a1e6c97abba6f06906255b8c26e8ab0afe61/src/BasePlugin.php#L155-L168
train
stubbles/stubbles-peer
src/main/php/IpAddress.php
IpAddress.isInCidrRange
public function isInCidrRange(string $cidrIpShort, $cidrMask): bool { if (is_string($cidrMask) && !ctype_digit($cidrMask)) { throw new \InvalidArgumentException( 'cidrMask must be of type int or a string losslessly' . ' convertible to int.' ); } list($lower, $upper) = $this->calculateIpRange( $this->completeCidrIp($cidrIpShort), (int) $cidrMask ); return $this->asLong() >= $lower && $this->asLong() <= $upper; }
php
public function isInCidrRange(string $cidrIpShort, $cidrMask): bool { if (is_string($cidrMask) && !ctype_digit($cidrMask)) { throw new \InvalidArgumentException( 'cidrMask must be of type int or a string losslessly' . ' convertible to int.' ); } list($lower, $upper) = $this->calculateIpRange( $this->completeCidrIp($cidrIpShort), (int) $cidrMask ); return $this->asLong() >= $lower && $this->asLong() <= $upper; }
[ "public", "function", "isInCidrRange", "(", "string", "$", "cidrIpShort", ",", "$", "cidrMask", ")", ":", "bool", "{", "if", "(", "is_string", "(", "$", "cidrMask", ")", "&&", "!", "ctype_digit", "(", "$", "cidrMask", ")", ")", "{", "throw", "new", "\\...
checks if IP address is in given CIDR range A cidr range is commonly notated as 10.16/13. From this, $cidrIpShort would be 10.16 and $cidrMask would be 13 or 47. Please note that this method currently supports IPv4 only. @param string $cidrIpShort @param int|string $cidrMask @return bool @throws \InvalidArgumentException when $cidrMask is not a valid integer @see http://en.wikipedia.org/wiki/Classless_Inter-Domain_Routing#CIDR_notation
[ "checks", "if", "IP", "address", "is", "in", "given", "CIDR", "range" ]
dc8b0a517dc4c84b615cc3c88f0d64a2b742f9cc
https://github.com/stubbles/stubbles-peer/blob/dc8b0a517dc4c84b615cc3c88f0d64a2b742f9cc/src/main/php/IpAddress.php#L185-L199
train
stubbles/stubbles-peer
src/main/php/IpAddress.php
IpAddress.calculateIpRange
private function calculateIpRange(int $cidrIpLong, int $cidrMask): array { $netWork = $cidrIpLong & $this->netMask($cidrMask); $lower = $netWork + 1; // ignore network ID (eg: 192.168.1.0) $upper = ($netWork | $this->inverseNetMask($cidrMask)) - 1 ; // ignore broadcast IP (eg: 192.168.1.255) return array($lower, $upper); }
php
private function calculateIpRange(int $cidrIpLong, int $cidrMask): array { $netWork = $cidrIpLong & $this->netMask($cidrMask); $lower = $netWork + 1; // ignore network ID (eg: 192.168.1.0) $upper = ($netWork | $this->inverseNetMask($cidrMask)) - 1 ; // ignore broadcast IP (eg: 192.168.1.255) return array($lower, $upper); }
[ "private", "function", "calculateIpRange", "(", "int", "$", "cidrIpLong", ",", "int", "$", "cidrMask", ")", ":", "array", "{", "$", "netWork", "=", "$", "cidrIpLong", "&", "$", "this", "->", "netMask", "(", "$", "cidrMask", ")", ";", "$", "lower", "=",...
returns lower and upper ip for IP range as long @param int $cidrIpLong @param int $cidrMask @return int[]
[ "returns", "lower", "and", "upper", "ip", "for", "IP", "range", "as", "long" ]
dc8b0a517dc4c84b615cc3c88f0d64a2b742f9cc
https://github.com/stubbles/stubbles-peer/blob/dc8b0a517dc4c84b615cc3c88f0d64a2b742f9cc/src/main/php/IpAddress.php#L208-L214
train
stubbles/stubbles-peer
src/main/php/IpAddress.php
IpAddress.openSocket
public function openSocket(int $port, int $timeout = 5, callable $openWith = null): Stream { $socket = new Socket($this->ip, $port, null); if (null !== $openWith) { $socket->openWith($openWith); } return $socket->connect()->setTimeout($timeout); }
php
public function openSocket(int $port, int $timeout = 5, callable $openWith = null): Stream { $socket = new Socket($this->ip, $port, null); if (null !== $openWith) { $socket->openWith($openWith); } return $socket->connect()->setTimeout($timeout); }
[ "public", "function", "openSocket", "(", "int", "$", "port", ",", "int", "$", "timeout", "=", "5", ",", "callable", "$", "openWith", "=", "null", ")", ":", "Stream", "{", "$", "socket", "=", "new", "Socket", "(", "$", "this", "->", "ip", ",", "$", ...
opens socket to this ip address @param int $port port to connect to @param int $timeout optional connection timeout @param callable $openWith optional open port with this function @return \stubbles\peer\Stream
[ "opens", "socket", "to", "this", "ip", "address" ]
dc8b0a517dc4c84b615cc3c88f0d64a2b742f9cc
https://github.com/stubbles/stubbles-peer/blob/dc8b0a517dc4c84b615cc3c88f0d64a2b742f9cc/src/main/php/IpAddress.php#L289-L297
train
pryley/castor-framework
src/Services/Normalizer.php
Normalizer.form
public function form( array $args = [], $implode = false ) { $attributes = $this->parseAttributes( self::FORM_ATTRIBUTES, $args ); return $this->maybeImplode( $attributes, $implode ); }
php
public function form( array $args = [], $implode = false ) { $attributes = $this->parseAttributes( self::FORM_ATTRIBUTES, $args ); return $this->maybeImplode( $attributes, $implode ); }
[ "public", "function", "form", "(", "array", "$", "args", "=", "[", "]", ",", "$", "implode", "=", "false", ")", "{", "$", "attributes", "=", "$", "this", "->", "parseAttributes", "(", "self", "::", "FORM_ATTRIBUTES", ",", "$", "args", ")", ";", "retu...
Normalize form attributes @return array|string
[ "Normalize", "form", "attributes" ]
cbc137d02625cd05f4cc96414d6f70e451cb821f
https://github.com/pryley/castor-framework/blob/cbc137d02625cd05f4cc96414d6f70e451cb821f/src/Services/Normalizer.php#L67-L72
train
pryley/castor-framework
src/Services/Normalizer.php
Normalizer.input
public function input( array $args = [], $implode = false ) { $this->filterInputType(); $attributes = $this->parseAttributes( self::INPUT_ATTRIBUTES, $args ); return $this->maybeImplode( $attributes, $implode ); }
php
public function input( array $args = [], $implode = false ) { $this->filterInputType(); $attributes = $this->parseAttributes( self::INPUT_ATTRIBUTES, $args ); return $this->maybeImplode( $attributes, $implode ); }
[ "public", "function", "input", "(", "array", "$", "args", "=", "[", "]", ",", "$", "implode", "=", "false", ")", "{", "$", "this", "->", "filterInputType", "(", ")", ";", "$", "attributes", "=", "$", "this", "->", "parseAttributes", "(", "self", "::"...
Normalize input attributes @return array|string
[ "Normalize", "input", "attributes" ]
cbc137d02625cd05f4cc96414d6f70e451cb821f
https://github.com/pryley/castor-framework/blob/cbc137d02625cd05f4cc96414d6f70e451cb821f/src/Services/Normalizer.php#L79-L86
train
pryley/castor-framework
src/Services/Normalizer.php
Normalizer.maybeImplode
public function maybeImplode( array $attributes, $implode = true ) { if( !$implode || $implode !== 'implode' ) { return $attributes; } $results = []; foreach( $attributes as $key => $value ) { // if data attributes, use single quotes in case of json encoded values $quotes = false !== stripos( $key, 'data-' ) ? "'" : '"'; if( is_array( $value )) { $value = json_encode( $value ); $quotes = "'"; } $results[] = is_string( $key ) ? sprintf( '%1$s=%3$s%2$s%3$s', $key, $value, $quotes ) : $value; } return implode( ' ', $results ); }
php
public function maybeImplode( array $attributes, $implode = true ) { if( !$implode || $implode !== 'implode' ) { return $attributes; } $results = []; foreach( $attributes as $key => $value ) { // if data attributes, use single quotes in case of json encoded values $quotes = false !== stripos( $key, 'data-' ) ? "'" : '"'; if( is_array( $value )) { $value = json_encode( $value ); $quotes = "'"; } $results[] = is_string( $key ) ? sprintf( '%1$s=%3$s%2$s%3$s', $key, $value, $quotes ) : $value; } return implode( ' ', $results ); }
[ "public", "function", "maybeImplode", "(", "array", "$", "attributes", ",", "$", "implode", "=", "true", ")", "{", "if", "(", "!", "$", "implode", "||", "$", "implode", "!==", "'implode'", ")", "{", "return", "$", "attributes", ";", "}", "$", "results"...
Possibly implode attributes into a string @param bool|string $implode @return array|string
[ "Possibly", "implode", "attributes", "into", "a", "string" ]
cbc137d02625cd05f4cc96414d6f70e451cb821f
https://github.com/pryley/castor-framework/blob/cbc137d02625cd05f4cc96414d6f70e451cb821f/src/Services/Normalizer.php#L95-L113
train
pryley/castor-framework
src/Services/Normalizer.php
Normalizer.select
public function select( array $args = [], $implode = false ) { $attributes = $this->parseAttributes( self::SELECT_ATTRIBUTES, $args ); return $this->maybeImplode( $attributes, $implode ); }
php
public function select( array $args = [], $implode = false ) { $attributes = $this->parseAttributes( self::SELECT_ATTRIBUTES, $args ); return $this->maybeImplode( $attributes, $implode ); }
[ "public", "function", "select", "(", "array", "$", "args", "=", "[", "]", ",", "$", "implode", "=", "false", ")", "{", "$", "attributes", "=", "$", "this", "->", "parseAttributes", "(", "self", "::", "SELECT_ATTRIBUTES", ",", "$", "args", ")", ";", "...
Normalize select attributes @return array|string
[ "Normalize", "select", "attributes" ]
cbc137d02625cd05f4cc96414d6f70e451cb821f
https://github.com/pryley/castor-framework/blob/cbc137d02625cd05f4cc96414d6f70e451cb821f/src/Services/Normalizer.php#L120-L125
train
pryley/castor-framework
src/Services/Normalizer.php
Normalizer.textarea
public function textarea( array $args = [], $implode = false ) { $attributes = $this->parseAttributes( self::TEXTAREA_ATTRIBUTES, $args ); return $this->maybeImplode( $attributes, $implode ); }
php
public function textarea( array $args = [], $implode = false ) { $attributes = $this->parseAttributes( self::TEXTAREA_ATTRIBUTES, $args ); return $this->maybeImplode( $attributes, $implode ); }
[ "public", "function", "textarea", "(", "array", "$", "args", "=", "[", "]", ",", "$", "implode", "=", "false", ")", "{", "$", "attributes", "=", "$", "this", "->", "parseAttributes", "(", "self", "::", "TEXTAREA_ATTRIBUTES", ",", "$", "args", ")", ";",...
Normalize textarea attributes @return array|string
[ "Normalize", "textarea", "attributes" ]
cbc137d02625cd05f4cc96414d6f70e451cb821f
https://github.com/pryley/castor-framework/blob/cbc137d02625cd05f4cc96414d6f70e451cb821f/src/Services/Normalizer.php#L132-L137
train
pryley/castor-framework
src/Services/Normalizer.php
Normalizer.filterAttributes
protected function filterAttributes( array $attributeKeys ) { $filtered = array_intersect_key( $this->args, array_flip( $attributeKeys )); // normalize truthy boolean attributes foreach( $filtered as $key => $value ) { if( !in_array( $key, self::BOOLEAN_ATTRIBUTES ))continue; if( $value !== false ) { $filtered[ $key ] = ''; continue; } unset( $filtered[ $key ] ); } $filteredKeys = array_filter( array_keys( $filtered ), function( $key ) use ( $filtered ) { return !( empty( $filtered[ $key ] ) && !is_numeric( $filtered[ $key ] ) && !in_array( $key, self::BOOLEAN_ATTRIBUTES ) ); }); return array_intersect_key( $filtered, array_flip( $filteredKeys )); }
php
protected function filterAttributes( array $attributeKeys ) { $filtered = array_intersect_key( $this->args, array_flip( $attributeKeys )); // normalize truthy boolean attributes foreach( $filtered as $key => $value ) { if( !in_array( $key, self::BOOLEAN_ATTRIBUTES ))continue; if( $value !== false ) { $filtered[ $key ] = ''; continue; } unset( $filtered[ $key ] ); } $filteredKeys = array_filter( array_keys( $filtered ), function( $key ) use ( $filtered ) { return !( empty( $filtered[ $key ] ) && !is_numeric( $filtered[ $key ] ) && !in_array( $key, self::BOOLEAN_ATTRIBUTES ) ); }); return array_intersect_key( $filtered, array_flip( $filteredKeys )); }
[ "protected", "function", "filterAttributes", "(", "array", "$", "attributeKeys", ")", "{", "$", "filtered", "=", "array_intersect_key", "(", "$", "this", "->", "args", ",", "array_flip", "(", "$", "attributeKeys", ")", ")", ";", "// normalize truthy boolean attrib...
Filter attributes by the provided attrribute keys and remove any non-boolean keys with empty values @return array
[ "Filter", "attributes", "by", "the", "provided", "attrribute", "keys", "and", "remove", "any", "non", "-", "boolean", "keys", "with", "empty", "values" ]
cbc137d02625cd05f4cc96414d6f70e451cb821f
https://github.com/pryley/castor-framework/blob/cbc137d02625cd05f4cc96414d6f70e451cb821f/src/Services/Normalizer.php#L145-L170
train
SlabPHP/cache-manager
src/Driver.php
Driver.requireProvider
private function requireProvider($message = '') { if (empty($this->cacheProvider)) { if (!empty($this->log)) $this->log->notice("Cache provider is not available. " . $message); return false; } return true; }
php
private function requireProvider($message = '') { if (empty($this->cacheProvider)) { if (!empty($this->log)) $this->log->notice("Cache provider is not available. " . $message); return false; } return true; }
[ "private", "function", "requireProvider", "(", "$", "message", "=", "''", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "cacheProvider", ")", ")", "{", "if", "(", "!", "empty", "(", "$", "this", "->", "log", ")", ")", "$", "this", "->", "...
Require a provider @param string $message @return boolean
[ "Require", "a", "provider" ]
7bbf9fe6519071fe14d382e98925cd3e10010a3a
https://github.com/SlabPHP/cache-manager/blob/7bbf9fe6519071fe14d382e98925cd3e10010a3a/src/Driver.php#L55-L64
train
SlabPHP/cache-manager
src/Driver.php
Driver.execute
public function execute(Request $request) { if (!$this->requireProvider("Executing cache request")) return null; $cacheKey = $request->getCacheKey(); if (empty($cacheKey)) { if (!empty($this->log)) $this->log->error("Invalid or missing cache key."); return null; } $cacheRefresh = $request->getForceRefresh(); if (!$cacheRefresh) { $cacheData = $this->cacheProvider->get($cacheKey); if (!empty($cacheData)) { if (!empty($this->log)) $this->log->debug("Cache hit on key " . $cacheKey); return $cacheData; } } if (!empty($this->log)) $this->log->debug("CACHE", "Cache miss on key " . $cacheKey); $value = $request->executeCallback(); if (!empty($value)) { $this->cacheProvider->set($cacheKey, $value, $request->getCacheTTL()); } return $value; }
php
public function execute(Request $request) { if (!$this->requireProvider("Executing cache request")) return null; $cacheKey = $request->getCacheKey(); if (empty($cacheKey)) { if (!empty($this->log)) $this->log->error("Invalid or missing cache key."); return null; } $cacheRefresh = $request->getForceRefresh(); if (!$cacheRefresh) { $cacheData = $this->cacheProvider->get($cacheKey); if (!empty($cacheData)) { if (!empty($this->log)) $this->log->debug("Cache hit on key " . $cacheKey); return $cacheData; } } if (!empty($this->log)) $this->log->debug("CACHE", "Cache miss on key " . $cacheKey); $value = $request->executeCallback(); if (!empty($value)) { $this->cacheProvider->set($cacheKey, $value, $request->getCacheTTL()); } return $value; }
[ "public", "function", "execute", "(", "Request", "$", "request", ")", "{", "if", "(", "!", "$", "this", "->", "requireProvider", "(", "\"Executing cache request\"", ")", ")", "return", "null", ";", "$", "cacheKey", "=", "$", "request", "->", "getCacheKey", ...
Do a cache request @param Request $request @return mixed
[ "Do", "a", "cache", "request" ]
7bbf9fe6519071fe14d382e98925cd3e10010a3a
https://github.com/SlabPHP/cache-manager/blob/7bbf9fe6519071fe14d382e98925cd3e10010a3a/src/Driver.php#L132-L164
train
zarathustra323/modlr-data
src/Zarathustra/ModlrData/Metadata/FieldMetadata.php
FieldMetadata.validateKey
protected function validateKey($key) { $reserved = ['type', 'id']; if (in_array(strtolower($key), $reserved)) { throw MetadataException::reservedFieldKey($key, $reserved); } }
php
protected function validateKey($key) { $reserved = ['type', 'id']; if (in_array(strtolower($key), $reserved)) { throw MetadataException::reservedFieldKey($key, $reserved); } }
[ "protected", "function", "validateKey", "(", "$", "key", ")", "{", "$", "reserved", "=", "[", "'type'", ",", "'id'", "]", ";", "if", "(", "in_array", "(", "strtolower", "(", "$", "key", ")", ",", "$", "reserved", ")", ")", "{", "throw", "MetadataExce...
Validates that the field key is not reserved. @param string $key @throws MetadataException
[ "Validates", "that", "the", "field", "key", "is", "not", "reserved", "." ]
7c2c767216055f75abf8cf22e2200f11998ed24e
https://github.com/zarathustra323/modlr-data/blob/7c2c767216055f75abf8cf22e2200f11998ed24e/src/Zarathustra/ModlrData/Metadata/FieldMetadata.php#L49-L55
train
bit55/midcore
src/Middleware/RouteActionHandler.php
RouteActionHandler.executeHandler
public function executeHandler($request, $handler) { // execute actions as middleware if (!is_array($handler) || is_callable($handler)) { $handler = [$handler, \Bit55\Midcore\Middleware\NotFoundHandler::class]; } $dispatcher = new Dispatcher($handler, $this->container); return $dispatcher->dispatch($request); }
php
public function executeHandler($request, $handler) { // execute actions as middleware if (!is_array($handler) || is_callable($handler)) { $handler = [$handler, \Bit55\Midcore\Middleware\NotFoundHandler::class]; } $dispatcher = new Dispatcher($handler, $this->container); return $dispatcher->dispatch($request); }
[ "public", "function", "executeHandler", "(", "$", "request", ",", "$", "handler", ")", "{", "// execute actions as middleware", "if", "(", "!", "is_array", "(", "$", "handler", ")", "||", "is_callable", "(", "$", "handler", ")", ")", "{", "$", "handler", "...
Executing application action. @param string|callable|array $handler
[ "Executing", "application", "action", "." ]
53f96a82e709918b4691372f0554a6e6f6ba2ae3
https://github.com/bit55/midcore/blob/53f96a82e709918b4691372f0554a6e6f6ba2ae3/src/Middleware/RouteActionHandler.php#L44-L53
train
agentmedia/phine-core
src/Core/Modules/Backend/LayoutList.php
LayoutList.RemovalObject
protected function RemovalObject() { $id = Request::PostData('delete'); return $id ? Layout::Schema()->ByID($id) : null; }
php
protected function RemovalObject() { $id = Request::PostData('delete'); return $id ? Layout::Schema()->ByID($id) : null; }
[ "protected", "function", "RemovalObject", "(", ")", "{", "$", "id", "=", "Request", "::", "PostData", "(", "'delete'", ")", ";", "return", "$", "id", "?", "Layout", "::", "Schema", "(", ")", "->", "ByID", "(", "$", "id", ")", ":", "null", ";", "}" ...
Gets the layout that is requested to be removed @return Layout The removal layout
[ "Gets", "the", "layout", "that", "is", "requested", "to", "be", "removed" ]
38c1be8d03ebffae950d00a96da3c612aff67832
https://github.com/agentmedia/phine-core/blob/38c1be8d03ebffae950d00a96da3c612aff67832/src/Core/Modules/Backend/LayoutList.php#L68-L72
train
agentmedia/phine-core
src/Core/Modules/Backend/LayoutList.php
LayoutList.CanDelete
protected function CanDelete(Layout $layout) { return self::Guard()->Allow(BackendAction::Delete(), $layout) && self::Guard()->Allow(BackendAction::UseIt(), new LayoutForm()); }
php
protected function CanDelete(Layout $layout) { return self::Guard()->Allow(BackendAction::Delete(), $layout) && self::Guard()->Allow(BackendAction::UseIt(), new LayoutForm()); }
[ "protected", "function", "CanDelete", "(", "Layout", "$", "layout", ")", "{", "return", "self", "::", "Guard", "(", ")", "->", "Allow", "(", "BackendAction", "::", "Delete", "(", ")", ",", "$", "layout", ")", "&&", "self", "::", "Guard", "(", ")", "-...
True if layout can be deleted @param Layout $layout The layout @return boo
[ "True", "if", "layout", "can", "be", "deleted" ]
38c1be8d03ebffae950d00a96da3c612aff67832
https://github.com/agentmedia/phine-core/blob/38c1be8d03ebffae950d00a96da3c612aff67832/src/Core/Modules/Backend/LayoutList.php#L120-L124
train
zapheus/zapheus
src/Routing/Resolver.php
Resolver.resolve
public function resolve(RouteInterface $route) { if (is_string($handler = $route->handler())) { $handler = explode('@', $handler); } $parameters = (array) $route->parameters(); list($handler, $reflection) = $this->reflection($handler); $parameters = $this->arguments($reflection, $parameters); return call_user_func_array($handler, $parameters); }
php
public function resolve(RouteInterface $route) { if (is_string($handler = $route->handler())) { $handler = explode('@', $handler); } $parameters = (array) $route->parameters(); list($handler, $reflection) = $this->reflection($handler); $parameters = $this->arguments($reflection, $parameters); return call_user_func_array($handler, $parameters); }
[ "public", "function", "resolve", "(", "RouteInterface", "$", "route", ")", "{", "if", "(", "is_string", "(", "$", "handler", "=", "$", "route", "->", "handler", "(", ")", ")", ")", "{", "$", "handler", "=", "explode", "(", "'@'", ",", "$", "handler",...
Resolves the specified route instance. @param \Zapheus\Routing\RouteInterface $route @return mixed
[ "Resolves", "the", "specified", "route", "instance", "." ]
96618b5cee7d20b6700d0475e4334ae4b5163a6b
https://github.com/zapheus/zapheus/blob/96618b5cee7d20b6700d0475e4334ae4b5163a6b/src/Routing/Resolver.php#L36-L50
train
zapheus/zapheus
src/Routing/Resolver.php
Resolver.instance
protected function instance($class) { $reflection = new \ReflectionClass($class); $arguments = array(); $constructor = $reflection->getConstructor(); if ($this->container->has($class)) { return $this->container->get($class); } if ($constructor !== null) { $arguments = $this->arguments($constructor); } return $reflection->newInstanceArgs($arguments); }
php
protected function instance($class) { $reflection = new \ReflectionClass($class); $arguments = array(); $constructor = $reflection->getConstructor(); if ($this->container->has($class)) { return $this->container->get($class); } if ($constructor !== null) { $arguments = $this->arguments($constructor); } return $reflection->newInstanceArgs($arguments); }
[ "protected", "function", "instance", "(", "$", "class", ")", "{", "$", "reflection", "=", "new", "\\", "ReflectionClass", "(", "$", "class", ")", ";", "$", "arguments", "=", "array", "(", ")", ";", "$", "constructor", "=", "$", "reflection", "->", "get...
Returns the instance of the identifier from the container. @param string $class @return mixed
[ "Returns", "the", "instance", "of", "the", "identifier", "from", "the", "container", "." ]
96618b5cee7d20b6700d0475e4334ae4b5163a6b
https://github.com/zapheus/zapheus/blob/96618b5cee7d20b6700d0475e4334ae4b5163a6b/src/Routing/Resolver.php#L99-L118
train
zapheus/zapheus
src/Routing/Resolver.php
Resolver.reflection
protected function reflection($handler) { if (! is_array($handler)) { $instance = new \ReflectionFunction($handler); return array($handler, $instance); } list($class, $method) = (array) $handler; $instance = new \ReflectionMethod($class, $method); $handler = array($this->instance($class), $method); return array((array) $handler, $instance); }
php
protected function reflection($handler) { if (! is_array($handler)) { $instance = new \ReflectionFunction($handler); return array($handler, $instance); } list($class, $method) = (array) $handler; $instance = new \ReflectionMethod($class, $method); $handler = array($this->instance($class), $method); return array((array) $handler, $instance); }
[ "protected", "function", "reflection", "(", "$", "handler", ")", "{", "if", "(", "!", "is_array", "(", "$", "handler", ")", ")", "{", "$", "instance", "=", "new", "\\", "ReflectionFunction", "(", "$", "handler", ")", ";", "return", "array", "(", "$", ...
Returns a ReflectionFunctionAbstract instance. @param array|callable $handler @return \ReflectionFunctionAbstract
[ "Returns", "a", "ReflectionFunctionAbstract", "instance", "." ]
96618b5cee7d20b6700d0475e4334ae4b5163a6b
https://github.com/zapheus/zapheus/blob/96618b5cee7d20b6700d0475e4334ae4b5163a6b/src/Routing/Resolver.php#L126-L142
train
Ydle/HubBundle
Controller/LogsController.php
LogsController.indexAction
public function indexAction(Request $request) { $query = $this->get('ydle.logger')->createViewLogQuery(); $paginator = $this->get('knp_paginator'); $pagination = $paginator->paginate( $query, $this->get('request')->query->get('page', 1)/*page number*/, 25/*limit per page*/ ); $logs = new Logs(); $form = $this->createForm("logsfilter_form", $logs); return $this->render('YdleHubBundle:Logs:index.html.twig', array( 'pagination' => $pagination, 'form' => $form->createView() )); }
php
public function indexAction(Request $request) { $query = $this->get('ydle.logger')->createViewLogQuery(); $paginator = $this->get('knp_paginator'); $pagination = $paginator->paginate( $query, $this->get('request')->query->get('page', 1)/*page number*/, 25/*limit per page*/ ); $logs = new Logs(); $form = $this->createForm("logsfilter_form", $logs); return $this->render('YdleHubBundle:Logs:index.html.twig', array( 'pagination' => $pagination, 'form' => $form->createView() )); }
[ "public", "function", "indexAction", "(", "Request", "$", "request", ")", "{", "$", "query", "=", "$", "this", "->", "get", "(", "'ydle.logger'", ")", "->", "createViewLogQuery", "(", ")", ";", "$", "paginator", "=", "$", "this", "->", "get", "(", "'kn...
Homepage for logs @param \Symfony\Component\HttpFoundation\Request $request @return type
[ "Homepage", "for", "logs" ]
7fa423241246bcfd115f2ed3ad3997b4b63adb01
https://github.com/Ydle/HubBundle/blob/7fa423241246bcfd115f2ed3ad3997b4b63adb01/Controller/LogsController.php#L34-L52
train
cloudtek/dynamodm
lib/Cloudtek/DynamoDM/Schema/Index/Index.php
Index.getDefinition
public function getDefinition() { $definition['KeySchema'] = $this->getDefinitionKeySchema(); if ($this->isPrimary()) { $definition['AttributeDefinitions'] = $this->getDefinitionAttributes(); } else { $definition['IndexName'] = $this->getName(); $definition['Projection'] = $this->getDefinitionProjection(); } if (!$this->isSecondaryLocal()) { $definition['ProvisionedThroughput'] = $this->getDefinitionProvisionedThroughput(); } return $this->isPrimary() ? $definition : [$this->getDefinitionIndexType() => $definition]; }
php
public function getDefinition() { $definition['KeySchema'] = $this->getDefinitionKeySchema(); if ($this->isPrimary()) { $definition['AttributeDefinitions'] = $this->getDefinitionAttributes(); } else { $definition['IndexName'] = $this->getName(); $definition['Projection'] = $this->getDefinitionProjection(); } if (!$this->isSecondaryLocal()) { $definition['ProvisionedThroughput'] = $this->getDefinitionProvisionedThroughput(); } return $this->isPrimary() ? $definition : [$this->getDefinitionIndexType() => $definition]; }
[ "public", "function", "getDefinition", "(", ")", "{", "$", "definition", "[", "'KeySchema'", "]", "=", "$", "this", "->", "getDefinitionKeySchema", "(", ")", ";", "if", "(", "$", "this", "->", "isPrimary", "(", ")", ")", "{", "$", "definition", "[", "'...
Return the index definition, formatted for AWS SDK. @return array
[ "Return", "the", "index", "definition", "formatted", "for", "AWS", "SDK", "." ]
119d355e2c5cbaef1f867970349b4432f5704fcd
https://github.com/cloudtek/dynamodm/blob/119d355e2c5cbaef1f867970349b4432f5704fcd/lib/Cloudtek/DynamoDM/Schema/Index/Index.php#L114-L131
train
jenskooij/cloudcontrol
src/storage/factories/BrickFactory.php
BrickFactory.createBrickFromPostValues
public static function createBrickFromPostValues($postValues) { if (isset($postValues['title'])) { $brickObject = new \stdClass(); $brickObject->title = $postValues['title']; $brickObject->slug = StringUtil::slugify($postValues['title']); $brickObject->fields = array(); if (isset($postValues['fieldTitles'], $postValues['fieldTypes'], $postValues['fieldRequired'], $postValues['fieldMultiple'])) { foreach ($postValues['fieldTitles'] as $key => $value) { $fieldObject = self::createFieldObject($postValues, $value, $key); $brickObject->fields[] = $fieldObject; } } return $brickObject; } else { throw new \Exception('Trying to create document type with invalid data.'); } }
php
public static function createBrickFromPostValues($postValues) { if (isset($postValues['title'])) { $brickObject = new \stdClass(); $brickObject->title = $postValues['title']; $brickObject->slug = StringUtil::slugify($postValues['title']); $brickObject->fields = array(); if (isset($postValues['fieldTitles'], $postValues['fieldTypes'], $postValues['fieldRequired'], $postValues['fieldMultiple'])) { foreach ($postValues['fieldTitles'] as $key => $value) { $fieldObject = self::createFieldObject($postValues, $value, $key); $brickObject->fields[] = $fieldObject; } } return $brickObject; } else { throw new \Exception('Trying to create document type with invalid data.'); } }
[ "public", "static", "function", "createBrickFromPostValues", "(", "$", "postValues", ")", "{", "if", "(", "isset", "(", "$", "postValues", "[", "'title'", "]", ")", ")", "{", "$", "brickObject", "=", "new", "\\", "stdClass", "(", ")", ";", "$", "brickObj...
Create a brick from post values @param $postValues @return \stdClass @throws \Exception
[ "Create", "a", "brick", "from", "post", "values" ]
76e5d9ac8f9c50d06d39a995d13cc03742536548
https://github.com/jenskooij/cloudcontrol/blob/76e5d9ac8f9c50d06d39a995d13cc03742536548/src/storage/factories/BrickFactory.php#L23-L42
train
jamset/process-load-manager
src/Pm.php
Pm.manage
public function manage() { if (!($this->processManagerDto instanceof ProcessManagerDto)) { throw new ProcessManagerException("ProcessManagerDto wasn't set."); } $this->executionDto = new ExecutionDto(); $this->reactControlDto = $this->processManagerDto; $this->initStartMethods(); $this->context = new Context($this->loop); $this->dtoContainer = new DtoContainer(); $this->tasks = $this->processManagerDto->getTasksNumber(); $this->commandsManager = new CommandsManager(); $this->logger->info("PM start work." . $this->loggerPostfix); $this->initWorkersPublisher(); $this->declareLmRequester(); $this->initLoadManager(); $this->initLoadManagingControl(); $this->loop->run(); return null; }
php
public function manage() { if (!($this->processManagerDto instanceof ProcessManagerDto)) { throw new ProcessManagerException("ProcessManagerDto wasn't set."); } $this->executionDto = new ExecutionDto(); $this->reactControlDto = $this->processManagerDto; $this->initStartMethods(); $this->context = new Context($this->loop); $this->dtoContainer = new DtoContainer(); $this->tasks = $this->processManagerDto->getTasksNumber(); $this->commandsManager = new CommandsManager(); $this->logger->info("PM start work." . $this->loggerPostfix); $this->initWorkersPublisher(); $this->declareLmRequester(); $this->initLoadManager(); $this->initLoadManagingControl(); $this->loop->run(); return null; }
[ "public", "function", "manage", "(", ")", "{", "if", "(", "!", "(", "$", "this", "->", "processManagerDto", "instanceof", "ProcessManagerDto", ")", ")", "{", "throw", "new", "ProcessManagerException", "(", "\"ProcessManagerDto wasn't set.\"", ")", ";", "}", "$",...
Manage processes creation and termination during to load manager info and tasks number @param ProcessManagerDto $processManagerDto
[ "Manage", "processes", "creation", "and", "termination", "during", "to", "load", "manager", "info", "and", "tasks", "number" ]
cffed6ff73bf66617565707ec4f2c9251a497cc6
https://github.com/jamset/process-load-manager/blob/cffed6ff73bf66617565707ec4f2c9251a497cc6/src/Pm.php#L189-L214
train
pMatviienko/zf2-common
SbxCommon/src/SbxCommon/Form/View/Helper/Bootstrap/Captcha/Image.php
Image.render
public function render(ElementInterface $element) { $captcha = $element->getCaptcha(); if ($captcha === null || !$captcha instanceof CaptchaAdapter) { throw new Exception\DomainException(sprintf( '%s requires that the element has a "captcha" attribute of type Zend\Captcha\Image; none found', __METHOD__ )); } $captcha->generate(); $imgAttributes = array( 'width' => $captcha->getWidth(), 'height' => $captcha->getHeight(), 'alt' => $captcha->getImgAlt(), 'src' => $captcha->getImgUrl() . $captcha->getId() . $captcha->getSuffix(), ); if ($element->hasAttribute('id')) { $imgAttributes['id'] = $element->getAttribute('id') . '-image'; } $closingBracket = $this->getInlineClosingBracket(); $img = sprintf( '<img %s%s', $this->createAttributesString($imgAttributes), $closingBracket ); $position = $this->getCaptchaPosition(); $separator = $this->getSeparator(); $captchaInput = $this->renderCaptchaInputs($element); $pattern = '<div style="float:left;" class="form-captcha-image">%s%s</div><div class="form-captcha-input" style="margin-left:' . $imgAttributes['width'] . 'px">%s</div>'; if ($position == self::CAPTCHA_PREPEND) { return sprintf($pattern, $captchaInput, $separator, $img); } return sprintf($pattern, $img, $separator, $captchaInput); }
php
public function render(ElementInterface $element) { $captcha = $element->getCaptcha(); if ($captcha === null || !$captcha instanceof CaptchaAdapter) { throw new Exception\DomainException(sprintf( '%s requires that the element has a "captcha" attribute of type Zend\Captcha\Image; none found', __METHOD__ )); } $captcha->generate(); $imgAttributes = array( 'width' => $captcha->getWidth(), 'height' => $captcha->getHeight(), 'alt' => $captcha->getImgAlt(), 'src' => $captcha->getImgUrl() . $captcha->getId() . $captcha->getSuffix(), ); if ($element->hasAttribute('id')) { $imgAttributes['id'] = $element->getAttribute('id') . '-image'; } $closingBracket = $this->getInlineClosingBracket(); $img = sprintf( '<img %s%s', $this->createAttributesString($imgAttributes), $closingBracket ); $position = $this->getCaptchaPosition(); $separator = $this->getSeparator(); $captchaInput = $this->renderCaptchaInputs($element); $pattern = '<div style="float:left;" class="form-captcha-image">%s%s</div><div class="form-captcha-input" style="margin-left:' . $imgAttributes['width'] . 'px">%s</div>'; if ($position == self::CAPTCHA_PREPEND) { return sprintf($pattern, $captchaInput, $separator, $img); } return sprintf($pattern, $img, $separator, $captchaInput); }
[ "public", "function", "render", "(", "ElementInterface", "$", "element", ")", "{", "$", "captcha", "=", "$", "element", "->", "getCaptcha", "(", ")", ";", "if", "(", "$", "captcha", "===", "null", "||", "!", "$", "captcha", "instanceof", "CaptchaAdapter", ...
Render the captcha @param ElementInterface $element @throws Exception\DomainException @return string
[ "Render", "the", "captcha" ]
e59aa9b1eece72437cf0fd7c8466c0daeffcc481
https://github.com/pMatviienko/zf2-common/blob/e59aa9b1eece72437cf0fd7c8466c0daeffcc481/SbxCommon/src/SbxCommon/Form/View/Helper/Bootstrap/Captcha/Image.php#L18-L58
train
koolkode/view-express
src/ExpressViewFactory.php
ExpressViewFactory.createView
public function createView(ExpressViewRenderer $renderer, $resource) { $resource = (string)$resource; if(!is_file($resource)) { throw new \RuntimeException(sprintf('Express view not found: "%s"', $resource)); } $key = $this->createKey($resource); $typeName = $this->createTypeName($resource); if(class_exists($typeName, false)) { return $typeName; } $file = $this->cachePath . '/' . $key . '.php'; if(!is_file($file) || filemtime($file) < filemtime($resource)) { $time = microtime(true); try { $code = $this->parseView($renderer, file_get_contents($resource), $resource)->generateCode($key); } catch(\Exception $e) { throw new \RuntimeException(sprintf('Unable to parse express view "%s"', $resource), 0, $e); } Filesystem::writeFile($file, $code); $diff = sprintf('%.2f', microtime(true) - $time); if($this->logger) { $this->logger->info('Compiled express view {view}, time spent {time} seconds', ['view' => $resource, 'time' => $diff]); } } require_once $file; if(!class_exists($typeName, false)) { throw new \RuntimeException(sprintf('Unable to load compiled express view "%s"', $resource)); } return $typeName; }
php
public function createView(ExpressViewRenderer $renderer, $resource) { $resource = (string)$resource; if(!is_file($resource)) { throw new \RuntimeException(sprintf('Express view not found: "%s"', $resource)); } $key = $this->createKey($resource); $typeName = $this->createTypeName($resource); if(class_exists($typeName, false)) { return $typeName; } $file = $this->cachePath . '/' . $key . '.php'; if(!is_file($file) || filemtime($file) < filemtime($resource)) { $time = microtime(true); try { $code = $this->parseView($renderer, file_get_contents($resource), $resource)->generateCode($key); } catch(\Exception $e) { throw new \RuntimeException(sprintf('Unable to parse express view "%s"', $resource), 0, $e); } Filesystem::writeFile($file, $code); $diff = sprintf('%.2f', microtime(true) - $time); if($this->logger) { $this->logger->info('Compiled express view {view}, time spent {time} seconds', ['view' => $resource, 'time' => $diff]); } } require_once $file; if(!class_exists($typeName, false)) { throw new \RuntimeException(sprintf('Unable to load compiled express view "%s"', $resource)); } return $typeName; }
[ "public", "function", "createView", "(", "ExpressViewRenderer", "$", "renderer", ",", "$", "resource", ")", "{", "$", "resource", "=", "(", "string", ")", "$", "resource", ";", "if", "(", "!", "is_file", "(", "$", "resource", ")", ")", "{", "throw", "n...
Create an express view from the given XML view, will utilize the cache directory to dump and load a template compiled into plain PHP code. @param ExpressViewRenderer $renderer @param string $resource The resource to be compiled into a view. @return string The fully-qualified name of the compiled view. @throws \RuntimeException When the given resource could not be found.
[ "Create", "an", "express", "view", "from", "the", "given", "XML", "view", "will", "utilize", "the", "cache", "directory", "to", "dump", "and", "load", "a", "template", "compiled", "into", "plain", "PHP", "code", "." ]
a8ebe6f373b6bfe8b8818d6264535e8fe063a596
https://github.com/koolkode/view-express/blob/a8ebe6f373b6bfe8b8818d6264535e8fe063a596/src/ExpressViewFactory.php#L77-L127
train
koolkode/view-express
src/ExpressViewFactory.php
ExpressViewFactory.parseView
protected function parseView(ExpressViewRenderer $renderer, $data, $resource = '') { try { // This ugly pre-processing is neccessary due to DOM XML forgetting about self-closing elements. $reader = new XmlStreamReader(); $reader->XML($data); $buffer = '<?xml version="1.0"?>' . "\n"; while($reader->read()) { switch($reader->nodeType) { case XmlStreamReader::ELEMENT: $buffer .= '<' . $reader->name; $namespaces = []; while($reader->moveToNextAttribute()) { if($reader->namespaceURI == self::NS_XML) { switch($reader->localName) { case 'nsdec': case 'empty': continue 2; } } if($reader->namespaceURI == self::NS_XMLNS) { $namespaces[$reader->name] = $reader->value; } $buffer .= ' ' . $reader->name . '="' . htmlspecialchars($reader->value, ENT_COMPAT | ENT_XML1 | ENT_SUBSTITUTE, 'UTF-8') . '"'; } $reader->moveToElement(); if(!empty($namespaces)) { $encoded = base64_encode(json_encode($namespaces, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE)); $buffer .= ' xml:nsdec="' . htmlspecialchars($encoded, ENT_QUOTES | ENT_XML1 | ENT_SUBSTITUTE, 'UTF-8') . '"'; } if($reader->isEmptyElement) { $buffer .= ' xml:empty="" />'; } else { $buffer .= '>'; } break; case XmlStreamReader::END_ELEMENT: $buffer .= '</' . $reader->name . '>'; break; case XmlStreamReader::SIGNIFICANT_WHITESPACE: case XmlStreamReader::TEXT: case XmlStreamReader::WHITESPACE: $buffer .= htmlspecialchars($reader->value, ENT_QUOTES | ENT_XML1 | ENT_SUBSTITUTE, 'UTF-8'); break; } } // Parse XML buffer into a DOM document. $builder = new XmlDocumentBuilder(); $xml = $builder->buildFromSource($buffer); $compiler = new ExpressCompiler($renderer); $compiler->setResource($resource); $parser = new ExpressViewParser(); $view = $parser->parseSource($xml); $view->compile($compiler); return $compiler; } catch(\Exception $e) { $ex = $e; do { if($ex instanceof ExpressViewException) { if($ex->getErrorFile() === NULL) { $ex->setErrorFile($resource); } } } while($ex = $ex->getPrevious()); throw $e; } }
php
protected function parseView(ExpressViewRenderer $renderer, $data, $resource = '') { try { // This ugly pre-processing is neccessary due to DOM XML forgetting about self-closing elements. $reader = new XmlStreamReader(); $reader->XML($data); $buffer = '<?xml version="1.0"?>' . "\n"; while($reader->read()) { switch($reader->nodeType) { case XmlStreamReader::ELEMENT: $buffer .= '<' . $reader->name; $namespaces = []; while($reader->moveToNextAttribute()) { if($reader->namespaceURI == self::NS_XML) { switch($reader->localName) { case 'nsdec': case 'empty': continue 2; } } if($reader->namespaceURI == self::NS_XMLNS) { $namespaces[$reader->name] = $reader->value; } $buffer .= ' ' . $reader->name . '="' . htmlspecialchars($reader->value, ENT_COMPAT | ENT_XML1 | ENT_SUBSTITUTE, 'UTF-8') . '"'; } $reader->moveToElement(); if(!empty($namespaces)) { $encoded = base64_encode(json_encode($namespaces, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE)); $buffer .= ' xml:nsdec="' . htmlspecialchars($encoded, ENT_QUOTES | ENT_XML1 | ENT_SUBSTITUTE, 'UTF-8') . '"'; } if($reader->isEmptyElement) { $buffer .= ' xml:empty="" />'; } else { $buffer .= '>'; } break; case XmlStreamReader::END_ELEMENT: $buffer .= '</' . $reader->name . '>'; break; case XmlStreamReader::SIGNIFICANT_WHITESPACE: case XmlStreamReader::TEXT: case XmlStreamReader::WHITESPACE: $buffer .= htmlspecialchars($reader->value, ENT_QUOTES | ENT_XML1 | ENT_SUBSTITUTE, 'UTF-8'); break; } } // Parse XML buffer into a DOM document. $builder = new XmlDocumentBuilder(); $xml = $builder->buildFromSource($buffer); $compiler = new ExpressCompiler($renderer); $compiler->setResource($resource); $parser = new ExpressViewParser(); $view = $parser->parseSource($xml); $view->compile($compiler); return $compiler; } catch(\Exception $e) { $ex = $e; do { if($ex instanceof ExpressViewException) { if($ex->getErrorFile() === NULL) { $ex->setErrorFile($resource); } } } while($ex = $ex->getPrevious()); throw $e; } }
[ "protected", "function", "parseView", "(", "ExpressViewRenderer", "$", "renderer", ",", "$", "data", ",", "$", "resource", "=", "''", ")", "{", "try", "{", "// This ugly pre-processing is neccessary due to DOM XML forgetting about self-closing elements.", "$", "reader", "...
Compile the given XML source and return a compiler object. @param string $data @return ExpressCompiler
[ "Compile", "the", "given", "XML", "source", "and", "return", "a", "compiler", "object", "." ]
a8ebe6f373b6bfe8b8818d6264535e8fe063a596
https://github.com/koolkode/view-express/blob/a8ebe6f373b6bfe8b8818d6264535e8fe063a596/src/ExpressViewFactory.php#L135-L234
train
agentmedia/phine-core
src/Core/Modules/Backend/MembergroupList.php
MembergroupList.Init
protected function Init() { $sql = Access::SqlBuilder(); $tbl = Membergroup::Schema()->Table(); $order = $sql->OrderList($sql->OrderAsc($tbl->Field('Name'))); $this->groups = Membergroup::Schema()->Fetch(false, null, $order); return parent::Init(); }
php
protected function Init() { $sql = Access::SqlBuilder(); $tbl = Membergroup::Schema()->Table(); $order = $sql->OrderList($sql->OrderAsc($tbl->Field('Name'))); $this->groups = Membergroup::Schema()->Fetch(false, null, $order); return parent::Init(); }
[ "protected", "function", "Init", "(", ")", "{", "$", "sql", "=", "Access", "::", "SqlBuilder", "(", ")", ";", "$", "tbl", "=", "Membergroup", "::", "Schema", "(", ")", "->", "Table", "(", ")", ";", "$", "order", "=", "$", "sql", "->", "OrderList", ...
Initiaizes the set of groups
[ "Initiaizes", "the", "set", "of", "groups" ]
38c1be8d03ebffae950d00a96da3c612aff67832
https://github.com/agentmedia/phine-core/blob/38c1be8d03ebffae950d00a96da3c612aff67832/src/Core/Modules/Backend/MembergroupList.php#L31-L38
train
Finesse/QueryScribe
src/QueryBricks/ResolvesClosuresTrait.php
ResolvesClosuresTrait.resolveSubQueryClosure
protected function resolveSubQueryClosure(\Closure $callback): Query { if ($this->closureResolver === null) { return $this->makeCopyForSubQuery()->apply($callback); } else { return $this->closureResolver->resolveSubQueryClosure($callback); } }
php
protected function resolveSubQueryClosure(\Closure $callback): Query { if ($this->closureResolver === null) { return $this->makeCopyForSubQuery()->apply($callback); } else { return $this->closureResolver->resolveSubQueryClosure($callback); } }
[ "protected", "function", "resolveSubQueryClosure", "(", "\\", "Closure", "$", "callback", ")", ":", "Query", "{", "if", "(", "$", "this", "->", "closureResolver", "===", "null", ")", "{", "return", "$", "this", "->", "makeCopyForSubQuery", "(", ")", "->", ...
Retrieves the query object from a closure given instead of a subquery. @param \Closure $callback @return Query Retrieved query @throws InvalidReturnValueException
[ "Retrieves", "the", "query", "object", "from", "a", "closure", "given", "instead", "of", "a", "subquery", "." ]
4edba721e37693780d142229b3ecb0cd4004c7a5
https://github.com/Finesse/QueryScribe/blob/4edba721e37693780d142229b3ecb0cd4004c7a5/src/QueryBricks/ResolvesClosuresTrait.php#L40-L47
train
Finesse/QueryScribe
src/QueryBricks/ResolvesClosuresTrait.php
ResolvesClosuresTrait.resolveCriteriaGroupClosure
protected function resolveCriteriaGroupClosure(\Closure $callback): Query { if ($this->closureResolver === null) { return $this->makeCopyForCriteriaGroup()->apply($callback); } else { return $this->closureResolver->resolveCriteriaGroupClosure($callback); } }
php
protected function resolveCriteriaGroupClosure(\Closure $callback): Query { if ($this->closureResolver === null) { return $this->makeCopyForCriteriaGroup()->apply($callback); } else { return $this->closureResolver->resolveCriteriaGroupClosure($callback); } }
[ "protected", "function", "resolveCriteriaGroupClosure", "(", "\\", "Closure", "$", "callback", ")", ":", "Query", "{", "if", "(", "$", "this", "->", "closureResolver", "===", "null", ")", "{", "return", "$", "this", "->", "makeCopyForCriteriaGroup", "(", ")", ...
Retrieves the query object from a closure given instead of a criteria group query. @param \Closure $callback @return Query Retrieved query @throws InvalidReturnValueException
[ "Retrieves", "the", "query", "object", "from", "a", "closure", "given", "instead", "of", "a", "criteria", "group", "query", "." ]
4edba721e37693780d142229b3ecb0cd4004c7a5
https://github.com/Finesse/QueryScribe/blob/4edba721e37693780d142229b3ecb0cd4004c7a5/src/QueryBricks/ResolvesClosuresTrait.php#L56-L63
train
kaiohken1982/NeobazaarMailerModule
src/Mailer/Mail/ExpiredClassified.php
ExpiredClassified.configure
public function configure(array $data) { $this->checkData($data); $body = new MimeMessage(); $body->addPart($this->getPart($data)); $this->setBody($body); $this->addTo($data['to']); //$this->addReplyTo($data['from']); $this->setSubject(utf8_decode($this->subject)); return $this; }
php
public function configure(array $data) { $this->checkData($data); $body = new MimeMessage(); $body->addPart($this->getPart($data)); $this->setBody($body); $this->addTo($data['to']); //$this->addReplyTo($data['from']); $this->setSubject(utf8_decode($this->subject)); return $this; }
[ "public", "function", "configure", "(", "array", "$", "data", ")", "{", "$", "this", "->", "checkData", "(", "$", "data", ")", ";", "$", "body", "=", "new", "MimeMessage", "(", ")", ";", "$", "body", "->", "addPart", "(", "$", "this", "->", "getPar...
Configure amil message with passed data @throws \Exception @param array $data @return \Mailer\Mail\ClassifiedAnswer
[ "Configure", "amil", "message", "with", "passed", "data" ]
0afc66196a0a392ecb4f052f483f2b5ff606bd8f
https://github.com/kaiohken1982/NeobazaarMailerModule/blob/0afc66196a0a392ecb4f052f483f2b5ff606bd8f/src/Mailer/Mail/ExpiredClassified.php#L80-L92
train
theopera/framework
src/Component/Http/HttpClient.php
HttpClient.execute
public function execute(Request $request) : Response { $host = $request->getHost(); $socket = new ClientSocket($host, 80); $socket->connect(); $communicator = $socket->getCommunicator(); $communicator->write($request); $communicator->writeLine('');$communicator->writeLine(''); $headers = new Headers(); $body = ''; $headerLine = true; $statusLine = $communicator->read(1024, PHP_NORMAL_READ); while($line = $communicator->read(5000, PHP_NORMAL_READ)){ if ($headerLine && $line === PHP_EOL) { continue; } if ($headerLine && ($line === "\r" || $line === PHP_EOL)) { $headerLine = false; continue; } if ($headerLine) { $headers->add(Header::createFromString($line)); }else{ $body .= $line; } } return new Response($body, 200, $headers); }
php
public function execute(Request $request) : Response { $host = $request->getHost(); $socket = new ClientSocket($host, 80); $socket->connect(); $communicator = $socket->getCommunicator(); $communicator->write($request); $communicator->writeLine('');$communicator->writeLine(''); $headers = new Headers(); $body = ''; $headerLine = true; $statusLine = $communicator->read(1024, PHP_NORMAL_READ); while($line = $communicator->read(5000, PHP_NORMAL_READ)){ if ($headerLine && $line === PHP_EOL) { continue; } if ($headerLine && ($line === "\r" || $line === PHP_EOL)) { $headerLine = false; continue; } if ($headerLine) { $headers->add(Header::createFromString($line)); }else{ $body .= $line; } } return new Response($body, 200, $headers); }
[ "public", "function", "execute", "(", "Request", "$", "request", ")", ":", "Response", "{", "$", "host", "=", "$", "request", "->", "getHost", "(", ")", ";", "$", "socket", "=", "new", "ClientSocket", "(", "$", "host", ",", "80", ")", ";", "$", "so...
Executes a http request on success a Response object will be returned @param Request $request @return Response
[ "Executes", "a", "http", "request", "on", "success", "a", "Response", "object", "will", "be", "returned" ]
fa6165d3891a310faa580c81dee49a63c150c711
https://github.com/theopera/framework/blob/fa6165d3891a310faa580c81dee49a63c150c711/src/Component/Http/HttpClient.php#L38-L73
train
naucon/Utility
src/IteratorDecoratorLimit.php
IteratorDecoratorLimit.hasNext
public function hasNext() { if (parent::hasNext() && ($this->getItemPosition() < ($this->getItemOffset() + $this->getItemCount()) - 1) ) { return true; } return false; }
php
public function hasNext() { if (parent::hasNext() && ($this->getItemPosition() < ($this->getItemOffset() + $this->getItemCount()) - 1) ) { return true; } return false; }
[ "public", "function", "hasNext", "(", ")", "{", "if", "(", "parent", "::", "hasNext", "(", ")", "&&", "(", "$", "this", "->", "getItemPosition", "(", ")", "<", "(", "$", "this", "->", "getItemOffset", "(", ")", "+", "$", "this", "->", "getItemCount",...
return true if iterator has a next items @return bool has next item
[ "return", "true", "if", "iterator", "has", "a", "next", "items" ]
d225bb5d09d82400917f710c9d502949a66442c4
https://github.com/naucon/Utility/blob/d225bb5d09d82400917f710c9d502949a66442c4/src/IteratorDecoratorLimit.php#L101-L109
train
naucon/Utility
src/IteratorDecoratorLimit.php
IteratorDecoratorLimit.valid
public function valid() { if ($this->getItemPosition() >= $this->getItemOffset() && $this->getItemPosition() < ($this->getItemOffset() + $this->getItemCount()) ) { return parent::valid(); } return false; }
php
public function valid() { if ($this->getItemPosition() >= $this->getItemOffset() && $this->getItemPosition() < ($this->getItemOffset() + $this->getItemCount()) ) { return parent::valid(); } return false; }
[ "public", "function", "valid", "(", ")", "{", "if", "(", "$", "this", "->", "getItemPosition", "(", ")", ">=", "$", "this", "->", "getItemOffset", "(", ")", "&&", "$", "this", "->", "getItemPosition", "(", ")", "<", "(", "$", "this", "->", "getItemOf...
return true if current item is valid @return bool current item is valid
[ "return", "true", "if", "current", "item", "is", "valid" ]
d225bb5d09d82400917f710c9d502949a66442c4
https://github.com/naucon/Utility/blob/d225bb5d09d82400917f710c9d502949a66442c4/src/IteratorDecoratorLimit.php#L131-L139
train
naucon/Utility
src/IteratorDecoratorLimit.php
IteratorDecoratorLimit.count
public function count() { $countItems = $this->countItems() - $this->getItemOffset(); if ($countItems >= $this->getItemCount()) { $countItems = $this->getItemCount(); } return $countItems; }
php
public function count() { $countItems = $this->countItems() - $this->getItemOffset(); if ($countItems >= $this->getItemCount()) { $countItems = $this->getItemCount(); } return $countItems; }
[ "public", "function", "count", "(", ")", "{", "$", "countItems", "=", "$", "this", "->", "countItems", "(", ")", "-", "$", "this", "->", "getItemOffset", "(", ")", ";", "if", "(", "$", "countItems", ">=", "$", "this", "->", "getItemCount", "(", ")", ...
return the number of items in the subset @return int number of items
[ "return", "the", "number", "of", "items", "in", "the", "subset" ]
d225bb5d09d82400917f710c9d502949a66442c4
https://github.com/naucon/Utility/blob/d225bb5d09d82400917f710c9d502949a66442c4/src/IteratorDecoratorLimit.php#L180-L187
train
FuzeWorks/Core
src/FuzeWorks/Plugins.php
Plugins.loadHeaders
public function loadHeaders() { // Cycle through all pluginPaths $this->headers = array(); foreach ($this->pluginPaths as $pluginPath) { // If directory does not exist, skip it if (!file_exists($pluginPath) || !is_dir($pluginPath)) { continue; } // Fetch the contents of the path $pluginPathContents = array_diff(scandir($pluginPath), array('..', '.')); // Now go through each entry in the plugin folder foreach ($pluginPathContents as $pluginFolder) { if (!is_dir($pluginPath . DS . $pluginFolder)) { continue; } // If a header file exists, use it $file = $pluginPath . DS . $pluginFolder . DS . 'header.php'; $pluginName = ucfirst($pluginFolder); $className = '\FuzeWorks\Plugins\\'.$pluginName.'Header'; if (file_exists($file)) { // And load it if (in_array($pluginName, $this->cfg->disabled_plugins)) { $this->headers[$pluginName] = 'disabled'; } else { require_once($file); $header = new $className(); $this->headers[$pluginName] = $header; $this->headers[$pluginName]->init(); Factory::getInstance()->logger->log('Loaded Plugin Header: \'' . $pluginName . '\''); } } // If it doesn't exist, skip it continue; } } }
php
public function loadHeaders() { // Cycle through all pluginPaths $this->headers = array(); foreach ($this->pluginPaths as $pluginPath) { // If directory does not exist, skip it if (!file_exists($pluginPath) || !is_dir($pluginPath)) { continue; } // Fetch the contents of the path $pluginPathContents = array_diff(scandir($pluginPath), array('..', '.')); // Now go through each entry in the plugin folder foreach ($pluginPathContents as $pluginFolder) { if (!is_dir($pluginPath . DS . $pluginFolder)) { continue; } // If a header file exists, use it $file = $pluginPath . DS . $pluginFolder . DS . 'header.php'; $pluginName = ucfirst($pluginFolder); $className = '\FuzeWorks\Plugins\\'.$pluginName.'Header'; if (file_exists($file)) { // And load it if (in_array($pluginName, $this->cfg->disabled_plugins)) { $this->headers[$pluginName] = 'disabled'; } else { require_once($file); $header = new $className(); $this->headers[$pluginName] = $header; $this->headers[$pluginName]->init(); Factory::getInstance()->logger->log('Loaded Plugin Header: \'' . $pluginName . '\''); } } // If it doesn't exist, skip it continue; } } }
[ "public", "function", "loadHeaders", "(", ")", "{", "// Cycle through all pluginPaths", "$", "this", "->", "headers", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "pluginPaths", "as", "$", "pluginPath", ")", "{", "// If directory does not exis...
Load the header files of all plugins.
[ "Load", "the", "header", "files", "of", "all", "plugins", "." ]
051c64fdaa3a648174cbd54557d05ad553dd826b
https://github.com/FuzeWorks/Core/blob/051c64fdaa3a648174cbd54557d05ad553dd826b/src/FuzeWorks/Plugins.php#L103-L152
train
FuzeWorks/Core
src/FuzeWorks/Plugins.php
Plugins.removePluginPath
public function removePluginPath($directory) { if (($key = array_search($directory, $this->pluginPaths)) !== false) { unset($this->pluginPaths[$key]); } }
php
public function removePluginPath($directory) { if (($key = array_search($directory, $this->pluginPaths)) !== false) { unset($this->pluginPaths[$key]); } }
[ "public", "function", "removePluginPath", "(", "$", "directory", ")", "{", "if", "(", "(", "$", "key", "=", "array_search", "(", "$", "directory", ",", "$", "this", "->", "pluginPaths", ")", ")", "!==", "false", ")", "{", "unset", "(", "$", "this", "...
Remove a path where plugins can be found @param string $directory The directory @return void
[ "Remove", "a", "path", "where", "plugins", "can", "be", "found" ]
051c64fdaa3a648174cbd54557d05ad553dd826b
https://github.com/FuzeWorks/Core/blob/051c64fdaa3a648174cbd54557d05ad553dd826b/src/FuzeWorks/Plugins.php#L271-L277
train
pframework/p
source/P/AutoFactory.php
AutoFactory.create
static public function create(ServiceLocator $serviceLocator, $requestedClass, array $options = null) { if (class_exists($requestedClass)) { $reflection = new \ReflectionClass($requestedClass); $arguments = []; $constructor = $reflection->getConstructor(); if ($constructor) { $constructorParams = $reflection->getConstructor()->getParameters(); if (count($constructorParams) == 0) { return new $requestedClass; } else { foreach ($constructorParams as $param) { $class = $param->getClass(); $argument = null; if ($class) { $argument = $serviceLocator->get($class->getName()); // The Service Locator itself is not in the SL, so checking for it explicitly if ($class->getName() == ServiceLocator::class) { $argument = $serviceLocator; } } if ($argument == null && $serviceLocator->has($param->getName())) { $argument = $serviceLocator->get($param->getName()); } if (!$param->isOptional() && $argument == null) { throw new \RuntimeException('Missing required argument "' . $param->getName() . '" for class "' . $requestedClass); } if ($param->isOptional() && $argument == null) { $arguments[$param->getName()] = $param->getDefaultValue(); } else { $arguments[$param->getName()] = $argument; } } } } $instance = $reflection->newInstanceArgs($arguments); return $instance; } throw new \RuntimeException('Cannot find class ' . $requestedClass); }
php
static public function create(ServiceLocator $serviceLocator, $requestedClass, array $options = null) { if (class_exists($requestedClass)) { $reflection = new \ReflectionClass($requestedClass); $arguments = []; $constructor = $reflection->getConstructor(); if ($constructor) { $constructorParams = $reflection->getConstructor()->getParameters(); if (count($constructorParams) == 0) { return new $requestedClass; } else { foreach ($constructorParams as $param) { $class = $param->getClass(); $argument = null; if ($class) { $argument = $serviceLocator->get($class->getName()); // The Service Locator itself is not in the SL, so checking for it explicitly if ($class->getName() == ServiceLocator::class) { $argument = $serviceLocator; } } if ($argument == null && $serviceLocator->has($param->getName())) { $argument = $serviceLocator->get($param->getName()); } if (!$param->isOptional() && $argument == null) { throw new \RuntimeException('Missing required argument "' . $param->getName() . '" for class "' . $requestedClass); } if ($param->isOptional() && $argument == null) { $arguments[$param->getName()] = $param->getDefaultValue(); } else { $arguments[$param->getName()] = $argument; } } } } $instance = $reflection->newInstanceArgs($arguments); return $instance; } throw new \RuntimeException('Cannot find class ' . $requestedClass); }
[ "static", "public", "function", "create", "(", "ServiceLocator", "$", "serviceLocator", ",", "$", "requestedClass", ",", "array", "$", "options", "=", "null", ")", "{", "if", "(", "class_exists", "(", "$", "requestedClass", ")", ")", "{", "$", "reflection", ...
Attempts to create a new class based on constructor typehints and parameter names @param ServiceLocator $serviceLocator @param string $requestedClass @return object @throws \Exception
[ "Attempts", "to", "create", "a", "new", "class", "based", "on", "constructor", "typehints", "and", "parameter", "names" ]
925e3748b4b52fe1139f25ead9e10f30ebb85b79
https://github.com/pframework/p/blob/925e3748b4b52fe1139f25ead9e10f30ebb85b79/source/P/AutoFactory.php#L21-L70
train
bkstg/resource-bundle
Repository/ResourceRepository.php
ResourceRepository.findAllByGroupQuery
public function findAllByGroupQuery(GroupInterface $group, bool $active = true): Query { $qb = $this->createQueryBuilder('r'); return $qb ->join('r.groups', 'g') // Add conditions. ->andWhere($qb->expr()->eq('g', ':group')) ->andWhere($qb->expr()->eq('r.active', ':active')) // Add parameters. ->setParameter('group', $group) ->setParameter('active', $active) // Order by and get results. ->orderBy('r.pinned', 'DESC') ->addOrderBy('r.name', 'ASC') ->getQuery(); }
php
public function findAllByGroupQuery(GroupInterface $group, bool $active = true): Query { $qb = $this->createQueryBuilder('r'); return $qb ->join('r.groups', 'g') // Add conditions. ->andWhere($qb->expr()->eq('g', ':group')) ->andWhere($qb->expr()->eq('r.active', ':active')) // Add parameters. ->setParameter('group', $group) ->setParameter('active', $active) // Order by and get results. ->orderBy('r.pinned', 'DESC') ->addOrderBy('r.name', 'ASC') ->getQuery(); }
[ "public", "function", "findAllByGroupQuery", "(", "GroupInterface", "$", "group", ",", "bool", "$", "active", "=", "true", ")", ":", "Query", "{", "$", "qb", "=", "$", "this", "->", "createQueryBuilder", "(", "'r'", ")", ";", "return", "$", "qb", "->", ...
Get the query to find all resources by group. @param GroupInterface $group The group to search in. @param bool $active The active state to search. @return Query
[ "Get", "the", "query", "to", "find", "all", "resources", "by", "group", "." ]
9d094366799a4df117a1dd747af9bb6debe14325
https://github.com/bkstg/resource-bundle/blob/9d094366799a4df117a1dd747af9bb6debe14325/Repository/ResourceRepository.php#L28-L47
train
spoom-php/core
src/extension/Storage/File.php
File.file
protected function file( string $namespace ): FileInterface { $meta = $this->getNamespace( $namespace ); return $this->path->get( $namespace . '.' . $meta[ 'format' ] ); }
php
protected function file( string $namespace ): FileInterface { $meta = $this->getNamespace( $namespace ); return $this->path->get( $namespace . '.' . $meta[ 'format' ] ); }
[ "protected", "function", "file", "(", "string", "$", "namespace", ")", ":", "FileInterface", "{", "$", "meta", "=", "$", "this", "->", "getNamespace", "(", "$", "namespace", ")", ";", "return", "$", "this", "->", "path", "->", "get", "(", "$", "namespa...
Get storage file for the given namespace @param string $namespace @return FileInterface @throws \LogicException
[ "Get", "storage", "file", "for", "the", "given", "namespace" ]
ea7184213352fa2fad7636927a019e5798734e04
https://github.com/spoom-php/core/blob/ea7184213352fa2fad7636927a019e5798734e04/src/extension/Storage/File.php#L123-L127
train
pipaslot/forms
src/Forms/Controls/DatePicker.php
DatePicker.register
public static function register() { Container::extensionMethod('addDate', function ($container, $name, $label = NULL) { $picker = $container[$name] = new DatePicker($label); return $picker; }); }
php
public static function register() { Container::extensionMethod('addDate', function ($container, $name, $label = NULL) { $picker = $container[$name] = new DatePicker($label); return $picker; }); }
[ "public", "static", "function", "register", "(", ")", "{", "Container", "::", "extensionMethod", "(", "'addDate'", ",", "function", "(", "$", "container", ",", "$", "name", ",", "$", "label", "=", "NULL", ")", "{", "$", "picker", "=", "$", "container", ...
Registers this control @return DatePicker
[ "Registers", "this", "control" ]
9e1d48db512f843270fd4079ed3ff1b1729c951b
https://github.com/pipaslot/forms/blob/9e1d48db512f843270fd4079ed3ff1b1729c951b/src/Forms/Controls/DatePicker.php#L41-L47
train
ScaraMVC/Framework
src/Scara/Utils/Benchmark.php
Benchmark.check
public function check($name) { if (array_key_exists($name, static::$marks)) { return number_format((microtime(true) - static::$marks[$name]) * 1000, 2); } return 0.0; }
php
public function check($name) { if (array_key_exists($name, static::$marks)) { return number_format((microtime(true) - static::$marks[$name]) * 1000, 2); } return 0.0; }
[ "public", "function", "check", "(", "$", "name", ")", "{", "if", "(", "array_key_exists", "(", "$", "name", ",", "static", "::", "$", "marks", ")", ")", "{", "return", "number_format", "(", "(", "microtime", "(", "true", ")", "-", "static", "::", "$"...
Gets elapsed time in milliseconds for given benchmark. @param string $name @return float
[ "Gets", "elapsed", "time", "in", "milliseconds", "for", "given", "benchmark", "." ]
199b08b45fadf5dae14ac4732af03b36e15bbef2
https://github.com/ScaraMVC/Framework/blob/199b08b45fadf5dae14ac4732af03b36e15bbef2/src/Scara/Utils/Benchmark.php#L36-L43
train
JoeBengalen/Assert
src/Helper.php
Helper.valueToString
public static function valueToString($value) { if (null === $value) { return 'null'; } if (true === $value) { return 'true'; } if (false === $value) { return 'false'; } if (is_array($value)) { return 'array(' . count($value) . ')'; } if (is_object($value)) { return get_class($value); } if (is_resource($value)) { return 'resource'; } if (is_string($value)) { return '"' . $value . '"'; } return (string) $value; }
php
public static function valueToString($value) { if (null === $value) { return 'null'; } if (true === $value) { return 'true'; } if (false === $value) { return 'false'; } if (is_array($value)) { return 'array(' . count($value) . ')'; } if (is_object($value)) { return get_class($value); } if (is_resource($value)) { return 'resource'; } if (is_string($value)) { return '"' . $value . '"'; } return (string) $value; }
[ "public", "static", "function", "valueToString", "(", "$", "value", ")", "{", "if", "(", "null", "===", "$", "value", ")", "{", "return", "'null'", ";", "}", "if", "(", "true", "===", "$", "value", ")", "{", "return", "'true'", ";", "}", "if", "(",...
Transform a value into a user friendly string. @param mixed $value @return string
[ "Transform", "a", "value", "into", "a", "user", "friendly", "string", "." ]
022b3f698d6bb94bda10a3e5f2f9f2219796c233
https://github.com/JoeBengalen/Assert/blob/022b3f698d6bb94bda10a3e5f2f9f2219796c233/src/Helper.php#L43-L74
train
RichardTrujilloTorres/validators
src/Validators/Types/PrimitiveType.php
PrimitiveType.checkType
public function checkType($value) { if (isset($this->name) && null !== $this->name) { $fn = 'is_'.$this->name; return $fn($value); } throw new \Exception('Invalid name or name not defined for primitive type.'); }
php
public function checkType($value) { if (isset($this->name) && null !== $this->name) { $fn = 'is_'.$this->name; return $fn($value); } throw new \Exception('Invalid name or name not defined for primitive type.'); }
[ "public", "function", "checkType", "(", "$", "value", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "name", ")", "&&", "null", "!==", "$", "this", "->", "name", ")", "{", "$", "fn", "=", "'is_'", ".", "$", "this", "->", "name", ";", "re...
Is the value type the same of this object? @param mixed $value The value to check @return bool
[ "Is", "the", "value", "type", "the", "same", "of", "this", "object?" ]
e29ff479d816c3f8a931bfbefedd0642dc50ea91
https://github.com/RichardTrujilloTorres/validators/blob/e29ff479d816c3f8a931bfbefedd0642dc50ea91/src/Validators/Types/PrimitiveType.php#L40-L49
train
SysControllers/Admin
public/assets/global/plugins/kcfinder/lib/class_gd.php
gd.get_prop_width
public function get_prop_width($resized_height) { $width = intval(($this->width * $resized_height) / $this->height); if (!$width) $width = 1; return $width; }
php
public function get_prop_width($resized_height) { $width = intval(($this->width * $resized_height) / $this->height); if (!$width) $width = 1; return $width; }
[ "public", "function", "get_prop_width", "(", "$", "resized_height", ")", "{", "$", "width", "=", "intval", "(", "(", "$", "this", "->", "width", "*", "$", "resized_height", ")", "/", "$", "this", "->", "height", ")", ";", "if", "(", "!", "$", "width"...
Returns calculated proportional width from the given height @param integer $resized_height @return integer
[ "Returns", "calculated", "proportional", "width", "from", "the", "given", "height" ]
8f1df46aca422b87f2f522fbba610dcfa0c5f7f3
https://github.com/SysControllers/Admin/blob/8f1df46aca422b87f2f522fbba610dcfa0c5f7f3/public/assets/global/plugins/kcfinder/lib/class_gd.php#L153-L157
train
SysControllers/Admin
public/assets/global/plugins/kcfinder/lib/class_gd.php
gd.get_prop_height
public function get_prop_height($resized_width) { $height = intval(($this->height * $resized_width) / $this->width); if (!$height) $height = 1; return $height; }
php
public function get_prop_height($resized_width) { $height = intval(($this->height * $resized_width) / $this->width); if (!$height) $height = 1; return $height; }
[ "public", "function", "get_prop_height", "(", "$", "resized_width", ")", "{", "$", "height", "=", "intval", "(", "(", "$", "this", "->", "height", "*", "$", "resized_width", ")", "/", "$", "this", "->", "width", ")", ";", "if", "(", "!", "$", "height...
Returns calculated proportional height from the given width @param integer $resized_width @return integer
[ "Returns", "calculated", "proportional", "height", "from", "the", "given", "width" ]
8f1df46aca422b87f2f522fbba610dcfa0c5f7f3
https://github.com/SysControllers/Admin/blob/8f1df46aca422b87f2f522fbba610dcfa0c5f7f3/public/assets/global/plugins/kcfinder/lib/class_gd.php#L163-L167
train
SysControllers/Admin
public/assets/global/plugins/kcfinder/lib/class_gd.php
gd.resize
public function resize($width, $height) { if (!$width) $width = 1; if (!$height) $height = 1; return ( (false !== ($img = new gd(array($width, $height)))) && $img->imagecopyresampled($this) && (false !== ($this->image = $img->get_image())) && (false !== ($this->width = $img->get_width())) && (false !== ($this->height = $img->get_height())) ); }
php
public function resize($width, $height) { if (!$width) $width = 1; if (!$height) $height = 1; return ( (false !== ($img = new gd(array($width, $height)))) && $img->imagecopyresampled($this) && (false !== ($this->image = $img->get_image())) && (false !== ($this->width = $img->get_width())) && (false !== ($this->height = $img->get_height())) ); }
[ "public", "function", "resize", "(", "$", "width", ",", "$", "height", ")", "{", "if", "(", "!", "$", "width", ")", "$", "width", "=", "1", ";", "if", "(", "!", "$", "height", ")", "$", "height", "=", "1", ";", "return", "(", "(", "false", "!...
Resize image. Returns TRUE on success or FALSE on failure @param integer $width @param integer $height @return bool
[ "Resize", "image", ".", "Returns", "TRUE", "on", "success", "or", "FALSE", "on", "failure" ]
8f1df46aca422b87f2f522fbba610dcfa0c5f7f3
https://github.com/SysControllers/Admin/blob/8f1df46aca422b87f2f522fbba610dcfa0c5f7f3/public/assets/global/plugins/kcfinder/lib/class_gd.php#L196-L206
train
SysControllers/Admin
public/assets/global/plugins/kcfinder/lib/class_gd.php
gd.resize_fit
public function resize_fit($width, $height) { if ((!$width && !$height) || (($width == $this->width) && ($height == $this->height))) return true; if (!$width || (($height / $width) < ($this->height / $this->width))) $width = intval(($this->width * $height) / $this->height); elseif (!$height || (($width / $height) < ($this->width / $this->height))) $height = intval(($this->height * $width) / $this->width); if (!$width) $width = 1; if (!$height) $height = 1; return $this->resize($width, $height); }
php
public function resize_fit($width, $height) { if ((!$width && !$height) || (($width == $this->width) && ($height == $this->height))) return true; if (!$width || (($height / $width) < ($this->height / $this->width))) $width = intval(($this->width * $height) / $this->height); elseif (!$height || (($width / $height) < ($this->width / $this->height))) $height = intval(($this->height * $width) / $this->width); if (!$width) $width = 1; if (!$height) $height = 1; return $this->resize($width, $height); }
[ "public", "function", "resize_fit", "(", "$", "width", ",", "$", "height", ")", "{", "if", "(", "(", "!", "$", "width", "&&", "!", "$", "height", ")", "||", "(", "(", "$", "width", "==", "$", "this", "->", "width", ")", "&&", "(", "$", "height"...
Resize image to fit in given resolution. Returns TRUE on success or FALSE on failure @param integer $width @param integer $height @return bool
[ "Resize", "image", "to", "fit", "in", "given", "resolution", ".", "Returns", "TRUE", "on", "success", "or", "FALSE", "on", "failure" ]
8f1df46aca422b87f2f522fbba610dcfa0c5f7f3
https://github.com/SysControllers/Admin/blob/8f1df46aca422b87f2f522fbba610dcfa0c5f7f3/public/assets/global/plugins/kcfinder/lib/class_gd.php#L243-L253
train
AnonymPHP/Anonym-Cookie
src/Anonym/Components/UseCookieHeaders.php
UseCookieHeaders.useCookies
public function useCookies() { if (!headers_sent()) { if (count($this->getCookies())) { foreach ($this->getCookies() as $cookie) { header($cookie); } } return $this; } else { throw new HeadersAlreadySendedException( ' Başlıklarınız zaten gönderilmiş, cookie kullanılamaz. ' ); } }
php
public function useCookies() { if (!headers_sent()) { if (count($this->getCookies())) { foreach ($this->getCookies() as $cookie) { header($cookie); } } return $this; } else { throw new HeadersAlreadySendedException( ' Başlıklarınız zaten gönderilmiş, cookie kullanılamaz. ' ); } }
[ "public", "function", "useCookies", "(", ")", "{", "if", "(", "!", "headers_sent", "(", ")", ")", "{", "if", "(", "count", "(", "$", "this", "->", "getCookies", "(", ")", ")", ")", "{", "foreach", "(", "$", "this", "->", "getCookies", "(", ")", "...
Cookie leri header olarak atar @throws HeadersAlreadySendedException @return $this
[ "Cookie", "leri", "header", "olarak", "atar" ]
7e02403f76fab42355f02326c5589d3fca271e3b
https://github.com/AnonymPHP/Anonym-Cookie/blob/7e02403f76fab42355f02326c5589d3fca271e3b/src/Anonym/Components/UseCookieHeaders.php#L39-L58
train
managlea/EntityManager
src/EntityManager/DoctrineEntityManager.php
DoctrineEntityManager.createDetachedEntity
public static function createDetachedEntity(string $objectName, array $data) { $detachedEntity = new $objectName; self::updateEntityFromArray($detachedEntity, $data); return $detachedEntity; }
php
public static function createDetachedEntity(string $objectName, array $data) { $detachedEntity = new $objectName; self::updateEntityFromArray($detachedEntity, $data); return $detachedEntity; }
[ "public", "static", "function", "createDetachedEntity", "(", "string", "$", "objectName", ",", "array", "$", "data", ")", "{", "$", "detachedEntity", "=", "new", "$", "objectName", ";", "self", "::", "updateEntityFromArray", "(", "$", "detachedEntity", ",", "$...
Creates new entity based on object name sets object parameter from data @param string $objectName @param array $data @return mixed
[ "Creates", "new", "entity", "based", "on", "object", "name", "sets", "object", "parameter", "from", "data" ]
b5dc5d8786779ebafebaf5fa2c7d80d268417fef
https://github.com/managlea/EntityManager/blob/b5dc5d8786779ebafebaf5fa2c7d80d268417fef/src/EntityManager/DoctrineEntityManager.php#L118-L125
train
managlea/EntityManager
src/EntityManager/DoctrineEntityManager.php
DoctrineEntityManager.updateEntityFromArray
public static function updateEntityFromArray($entity, array $data) { foreach ($data as $field => $value) { $method = 'set' . self::formatStringToMethodName($field); if (method_exists($entity, $method)) { $entity->$method($value); } } return $entity; }
php
public static function updateEntityFromArray($entity, array $data) { foreach ($data as $field => $value) { $method = 'set' . self::formatStringToMethodName($field); if (method_exists($entity, $method)) { $entity->$method($value); } } return $entity; }
[ "public", "static", "function", "updateEntityFromArray", "(", "$", "entity", ",", "array", "$", "data", ")", "{", "foreach", "(", "$", "data", "as", "$", "field", "=>", "$", "value", ")", "{", "$", "method", "=", "'set'", ".", "self", "::", "formatStri...
Updates Entity from data calling setters based on data keys @param object $entity @param array $data @return mixed
[ "Updates", "Entity", "from", "data", "calling", "setters", "based", "on", "data", "keys" ]
b5dc5d8786779ebafebaf5fa2c7d80d268417fef
https://github.com/managlea/EntityManager/blob/b5dc5d8786779ebafebaf5fa2c7d80d268417fef/src/EntityManager/DoctrineEntityManager.php#L134-L144
train
managlea/EntityManager
src/EntityManager/DoctrineEntityManager.php
DoctrineEntityManager.formatStringToMethodName
public static function formatStringToMethodName(string $input) : string { $methodName = implode('', array_map('ucfirst', explode('_', strtolower($input)))); return $methodName; }
php
public static function formatStringToMethodName(string $input) : string { $methodName = implode('', array_map('ucfirst', explode('_', strtolower($input)))); return $methodName; }
[ "public", "static", "function", "formatStringToMethodName", "(", "string", "$", "input", ")", ":", "string", "{", "$", "methodName", "=", "implode", "(", "''", ",", "array_map", "(", "'ucfirst'", ",", "explode", "(", "'_'", ",", "strtolower", "(", "$", "in...
Generates camel-case method names from string @param string $input @return string
[ "Generates", "camel", "-", "case", "method", "names", "from", "string" ]
b5dc5d8786779ebafebaf5fa2c7d80d268417fef
https://github.com/managlea/EntityManager/blob/b5dc5d8786779ebafebaf5fa2c7d80d268417fef/src/EntityManager/DoctrineEntityManager.php#L151-L156
train
zhaoxianfang/tools
src/Symfony/Component/DependencyInjection/Dumper/XmlDumper.php
XmlDumper.dump
public function dump(array $options = array()) { $this->document = new \DOMDocument('1.0', 'utf-8'); $this->document->formatOutput = true; $container = $this->document->createElementNS('http://symfony.com/schema/dic/services', 'container'); $container->setAttribute('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance'); $container->setAttribute('xsi:schemaLocation', 'http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd'); $this->addParameters($container); $this->addServices($container); $this->document->appendChild($container); $xml = $this->document->saveXML(); $this->document = null; return $this->container->resolveEnvPlaceholders($xml); }
php
public function dump(array $options = array()) { $this->document = new \DOMDocument('1.0', 'utf-8'); $this->document->formatOutput = true; $container = $this->document->createElementNS('http://symfony.com/schema/dic/services', 'container'); $container->setAttribute('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance'); $container->setAttribute('xsi:schemaLocation', 'http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd'); $this->addParameters($container); $this->addServices($container); $this->document->appendChild($container); $xml = $this->document->saveXML(); $this->document = null; return $this->container->resolveEnvPlaceholders($xml); }
[ "public", "function", "dump", "(", "array", "$", "options", "=", "array", "(", ")", ")", "{", "$", "this", "->", "document", "=", "new", "\\", "DOMDocument", "(", "'1.0'", ",", "'utf-8'", ")", ";", "$", "this", "->", "document", "->", "formatOutput", ...
Dumps the service container as an XML string. @return string An xml string representing of the service container
[ "Dumps", "the", "service", "container", "as", "an", "XML", "string", "." ]
d8fc8a9ecd75b5ce4236f0a2e9fdc055108573e7
https://github.com/zhaoxianfang/tools/blob/d8fc8a9ecd75b5ce4236f0a2e9fdc055108573e7/src/Symfony/Component/DependencyInjection/Dumper/XmlDumper.php#L43-L60
train
zhaoxianfang/tools
src/Symfony/Component/DependencyInjection/Dumper/XmlDumper.php
XmlDumper.escape
private function escape(array $arguments) { $args = array(); foreach ($arguments as $k => $v) { if (is_array($v)) { $args[$k] = $this->escape($v); } elseif (is_string($v)) { $args[$k] = str_replace('%', '%%', $v); } else { $args[$k] = $v; } } return $args; }
php
private function escape(array $arguments) { $args = array(); foreach ($arguments as $k => $v) { if (is_array($v)) { $args[$k] = $this->escape($v); } elseif (is_string($v)) { $args[$k] = str_replace('%', '%%', $v); } else { $args[$k] = $v; } } return $args; }
[ "private", "function", "escape", "(", "array", "$", "arguments", ")", "{", "$", "args", "=", "array", "(", ")", ";", "foreach", "(", "$", "arguments", "as", "$", "k", "=>", "$", "v", ")", "{", "if", "(", "is_array", "(", "$", "v", ")", ")", "{"...
Escapes arguments. @return array
[ "Escapes", "arguments", "." ]
d8fc8a9ecd75b5ce4236f0a2e9fdc055108573e7
https://github.com/zhaoxianfang/tools/blob/d8fc8a9ecd75b5ce4236f0a2e9fdc055108573e7/src/Symfony/Component/DependencyInjection/Dumper/XmlDumper.php#L324-L338
train
zhaoxianfang/tools
src/Symfony/Component/DependencyInjection/Dumper/XmlDumper.php
XmlDumper.phpToXml
public static function phpToXml($value) { switch (true) { case null === $value: return 'null'; case true === $value: return 'true'; case false === $value: return 'false'; case $value instanceof Parameter: return '%'.$value.'%'; case is_object($value) || is_resource($value): throw new RuntimeException('Unable to dump a service container if a parameter is an object or a resource.'); default: return (string) $value; } }
php
public static function phpToXml($value) { switch (true) { case null === $value: return 'null'; case true === $value: return 'true'; case false === $value: return 'false'; case $value instanceof Parameter: return '%'.$value.'%'; case is_object($value) || is_resource($value): throw new RuntimeException('Unable to dump a service container if a parameter is an object or a resource.'); default: return (string) $value; } }
[ "public", "static", "function", "phpToXml", "(", "$", "value", ")", "{", "switch", "(", "true", ")", "{", "case", "null", "===", "$", "value", ":", "return", "'null'", ";", "case", "true", "===", "$", "value", ":", "return", "'true'", ";", "case", "f...
Converts php types to xml types. @param mixed $value Value to convert @return string @throws RuntimeException When trying to dump object or resource
[ "Converts", "php", "types", "to", "xml", "types", "." ]
d8fc8a9ecd75b5ce4236f0a2e9fdc055108573e7
https://github.com/zhaoxianfang/tools/blob/d8fc8a9ecd75b5ce4236f0a2e9fdc055108573e7/src/Symfony/Component/DependencyInjection/Dumper/XmlDumper.php#L349-L365
train
cloudtek/dynamodm
lib/Cloudtek/DynamoDM/ReferencePrimer.php
ReferencePrimer.primeReferences
public function primeReferences(ClassMetadata $class, $documents, $attributeName, $refresh, $readOnly, $primer = null) { $data = $this->parseDotSyntaxForPrimer($attributeName, $class, $documents); $mapping = $data['mapping']; $attributeName = $data['attributeName']; $class = $data['class']; $documents = $data['documents']; /* Inverse-side references would need to be populated before we can * collect references to be primed. This is not supported. */ if (!$mapping->reference || !$mapping->isOwningSide) { throw new \InvalidArgumentException(sprintf('Attribute "%s" is not the owning side of a reference relationship in class "%s"', $attributeName, $class->name)); } if ($primer !== null && !is_callable($primer)) { throw new \InvalidArgumentException('$primer is not callable'); } $primer = $primer ?: $this->defaultPrimer; /** @var PersistentCollectionInterface $document */ foreach ($documents as $document) { $value = $class->getAttributeValue($document, $attributeName); /* The attribute will need to be either a Proxy (reference-one) or * PersistentCollection (reference-many) in order to prime anything. */ if (!is_object($value)) { continue; } if ($mapping->isOne() && $value instanceof Proxy && !$value->__isInitialized()) { $identifier = $this->uow->getDocumentIdentifier($value); $className = $identifier->class->getName(); $this->groupedIds[$className][$identifier->getSerialized()] = $identifier; } elseif ($mapping->isMany() && $value instanceof PersistentCollectionInterface) { $this->addManyReferences($value); } } foreach ($this->groupedIds as $className => $ids) { $class = $this->dm->getClassMetadata($className); call_user_func($primer, $this->dm, $class, array_values($ids), $refresh, $readOnly); } }
php
public function primeReferences(ClassMetadata $class, $documents, $attributeName, $refresh, $readOnly, $primer = null) { $data = $this->parseDotSyntaxForPrimer($attributeName, $class, $documents); $mapping = $data['mapping']; $attributeName = $data['attributeName']; $class = $data['class']; $documents = $data['documents']; /* Inverse-side references would need to be populated before we can * collect references to be primed. This is not supported. */ if (!$mapping->reference || !$mapping->isOwningSide) { throw new \InvalidArgumentException(sprintf('Attribute "%s" is not the owning side of a reference relationship in class "%s"', $attributeName, $class->name)); } if ($primer !== null && !is_callable($primer)) { throw new \InvalidArgumentException('$primer is not callable'); } $primer = $primer ?: $this->defaultPrimer; /** @var PersistentCollectionInterface $document */ foreach ($documents as $document) { $value = $class->getAttributeValue($document, $attributeName); /* The attribute will need to be either a Proxy (reference-one) or * PersistentCollection (reference-many) in order to prime anything. */ if (!is_object($value)) { continue; } if ($mapping->isOne() && $value instanceof Proxy && !$value->__isInitialized()) { $identifier = $this->uow->getDocumentIdentifier($value); $className = $identifier->class->getName(); $this->groupedIds[$className][$identifier->getSerialized()] = $identifier; } elseif ($mapping->isMany() && $value instanceof PersistentCollectionInterface) { $this->addManyReferences($value); } } foreach ($this->groupedIds as $className => $ids) { $class = $this->dm->getClassMetadata($className); call_user_func($primer, $this->dm, $class, array_values($ids), $refresh, $readOnly); } }
[ "public", "function", "primeReferences", "(", "ClassMetadata", "$", "class", ",", "$", "documents", ",", "$", "attributeName", ",", "$", "refresh", ",", "$", "readOnly", ",", "$", "primer", "=", "null", ")", "{", "$", "data", "=", "$", "this", "->", "p...
Prime references within a mapped attribute of one or more documents. If a $primer callable is provided, it should have the same signature as the default primer defined in the constructor. If $primer is not callable, the default primer will be used. @param ClassMetadata $class Class metadata for the document @param array|\Traversable $documents Documents containing references to prime @param string $attributeName Attribute name containing references to prime @param bool $refresh @param bool $readOnly @param callable $primer Optional primer callable
[ "Prime", "references", "within", "a", "mapped", "attribute", "of", "one", "or", "more", "documents", "." ]
119d355e2c5cbaef1f867970349b4432f5704fcd
https://github.com/cloudtek/dynamodm/blob/119d355e2c5cbaef1f867970349b4432f5704fcd/lib/Cloudtek/DynamoDM/ReferencePrimer.php#L195-L242
train
Innmind/Math
src/Geometry/Angle.php
Angle.sum
public function sum(): Segment { return AlKashi::side( $this->firstSegment, $this->degree, $this->secondSegment ); }
php
public function sum(): Segment { return AlKashi::side( $this->firstSegment, $this->degree, $this->secondSegment ); }
[ "public", "function", "sum", "(", ")", ":", "Segment", "{", "return", "AlKashi", "::", "side", "(", "$", "this", "->", "firstSegment", ",", "$", "this", "->", "degree", ",", "$", "this", "->", "secondSegment", ")", ";", "}" ]
It sums the segments like we would sum vectors, except here we don't use vectors as it would need a plan to express a direction
[ "It", "sums", "the", "segments", "like", "we", "would", "sum", "vectors", "except", "here", "we", "don", "t", "use", "vectors", "as", "it", "would", "need", "a", "plan", "to", "express", "a", "direction" ]
ac9ad4dd1852c145e90f5edc0f38a873b125a50b
https://github.com/Innmind/Math/blob/ac9ad4dd1852c145e90f5edc0f38a873b125a50b/src/Geometry/Angle.php#L51-L58
train
Linkvalue-Interne/MajoraFrameworkExtraBundle
src/Majora/Framework/Loader/Bridge/Form/DataTransformerLoaderTrait.php
DataTransformerLoaderTrait.transform
public function transform($entity) { if (null === $entity) { return ''; } if (!is_subclass_of($entity, $this->entityClass)) { throw new \InvalidArgumentException(sprintf( 'Unsupported entity "%s" into "%s" loader.', get_class($entity), __CLASS__ )); } return $entity->getId(); }
php
public function transform($entity) { if (null === $entity) { return ''; } if (!is_subclass_of($entity, $this->entityClass)) { throw new \InvalidArgumentException(sprintf( 'Unsupported entity "%s" into "%s" loader.', get_class($entity), __CLASS__ )); } return $entity->getId(); }
[ "public", "function", "transform", "(", "$", "entity", ")", "{", "if", "(", "null", "===", "$", "entity", ")", "{", "return", "''", ";", "}", "if", "(", "!", "is_subclass_of", "(", "$", "entity", ",", "$", "this", "->", "entityClass", ")", ")", "{"...
Model -> View @see DataTransformerInterface::transform()
[ "Model", "-", ">", "View" ]
6f368380cfc39d27fafb0844e9a53b4d86d7c034
https://github.com/Linkvalue-Interne/MajoraFrameworkExtraBundle/blob/6f368380cfc39d27fafb0844e9a53b4d86d7c034/src/Majora/Framework/Loader/Bridge/Form/DataTransformerLoaderTrait.php#L22-L36
train
Linkvalue-Interne/MajoraFrameworkExtraBundle
src/Majora/Framework/Loader/Bridge/Form/DataTransformerLoaderTrait.php
DataTransformerLoaderTrait.reverseTransform
public function reverseTransform($id) { if (!$id) { return null; } if (!$entity = $this->retrieve($id)) { throw new TransformationFailedException(sprintf( '%s#%s cannot be found.', $this->entityClass, $id )); } return $entity; }
php
public function reverseTransform($id) { if (!$id) { return null; } if (!$entity = $this->retrieve($id)) { throw new TransformationFailedException(sprintf( '%s#%s cannot be found.', $this->entityClass, $id )); } return $entity; }
[ "public", "function", "reverseTransform", "(", "$", "id", ")", "{", "if", "(", "!", "$", "id", ")", "{", "return", "null", ";", "}", "if", "(", "!", "$", "entity", "=", "$", "this", "->", "retrieve", "(", "$", "id", ")", ")", "{", "throw", "new...
View -> Model @see DataTransformerInterface::reverseTransform()
[ "View", "-", ">", "Model" ]
6f368380cfc39d27fafb0844e9a53b4d86d7c034
https://github.com/Linkvalue-Interne/MajoraFrameworkExtraBundle/blob/6f368380cfc39d27fafb0844e9a53b4d86d7c034/src/Majora/Framework/Loader/Bridge/Form/DataTransformerLoaderTrait.php#L43-L57
train
praxigento/mobi_mod_downline
Cli/Tree/Clean.php
Clean.execute
protected function execute( \Symfony\Component\Console\Input\InputInterface $input, \Symfony\Component\Console\Output\OutputInterface $output ) { /* bind $output context to log-methods. */ $this->setOut($output); $this->logInfo("Command '" . $this->getName() . "' is started."); try { $req = new ARequest(); $this->servClean->exec($req); } catch (\Throwable $e) { $this->logError("Command '" . $this->getName() . "' failed. Reason: " . $e->getMessage()); } $this->logInfo("Command '" . $this->getName() . "' is completed."); }
php
protected function execute( \Symfony\Component\Console\Input\InputInterface $input, \Symfony\Component\Console\Output\OutputInterface $output ) { /* bind $output context to log-methods. */ $this->setOut($output); $this->logInfo("Command '" . $this->getName() . "' is started."); try { $req = new ARequest(); $this->servClean->exec($req); } catch (\Throwable $e) { $this->logError("Command '" . $this->getName() . "' failed. Reason: " . $e->getMessage()); } $this->logInfo("Command '" . $this->getName() . "' is completed."); }
[ "protected", "function", "execute", "(", "\\", "Symfony", "\\", "Component", "\\", "Console", "\\", "Input", "\\", "InputInterface", "$", "input", ",", "\\", "Symfony", "\\", "Component", "\\", "Console", "\\", "Output", "\\", "OutputInterface", "$", "output",...
Override 'execute' method to prevent "DDL statements are not allowed in transactions" error. @param \Symfony\Component\Console\Input\InputInterface $input @param \Symfony\Component\Console\Output\OutputInterface $output @return int|void|null
[ "Override", "execute", "method", "to", "prevent", "DDL", "statements", "are", "not", "allowed", "in", "transactions", "error", "." ]
0f3c276dfff1aa029f9fd205ccfc56f207a2e75b
https://github.com/praxigento/mobi_mod_downline/blob/0f3c276dfff1aa029f9fd205ccfc56f207a2e75b/Cli/Tree/Clean.php#L37-L52
train
ekyna/Table
Context/ActiveFilter.php
ActiveFilter.toArray
public function toArray() { return [ $this->id, $this->filterName, $this->operator, serialize($this->value), ]; }
php
public function toArray() { return [ $this->id, $this->filterName, $this->operator, serialize($this->value), ]; }
[ "public", "function", "toArray", "(", ")", "{", "return", "[", "$", "this", "->", "id", ",", "$", "this", "->", "filterName", ",", "$", "this", "->", "operator", ",", "serialize", "(", "$", "this", "->", "value", ")", ",", "]", ";", "}" ]
Returns the array representation of the active filter. @return array
[ "Returns", "the", "array", "representation", "of", "the", "active", "filter", "." ]
6f06e8fd8a3248d52f3a91f10508471344db311a
https://github.com/ekyna/Table/blob/6f06e8fd8a3248d52f3a91f10508471344db311a/Context/ActiveFilter.php#L113-L121
train
ekyna/Table
Context/ActiveFilter.php
ActiveFilter.createFromArray
static public function createFromArray(array $data) { if (4 != count($data)) { throw new InvalidArgumentException("Expected data as a 4 length array."); } $filter = new static($data[0], $data[1]); $filter->setOperator($data[2]); $filter->setValue(unserialize($data[3])); return $filter; }
php
static public function createFromArray(array $data) { if (4 != count($data)) { throw new InvalidArgumentException("Expected data as a 4 length array."); } $filter = new static($data[0], $data[1]); $filter->setOperator($data[2]); $filter->setValue(unserialize($data[3])); return $filter; }
[ "static", "public", "function", "createFromArray", "(", "array", "$", "data", ")", "{", "if", "(", "4", "!=", "count", "(", "$", "data", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "\"Expected data as a 4 length array.\"", ")", ";", "}", ...
Creates the active filter from the given data array. @param array $data @return ActiveFilter
[ "Creates", "the", "active", "filter", "from", "the", "given", "data", "array", "." ]
6f06e8fd8a3248d52f3a91f10508471344db311a
https://github.com/ekyna/Table/blob/6f06e8fd8a3248d52f3a91f10508471344db311a/Context/ActiveFilter.php#L130-L141
train
mtils/file-db
src/FileDB/Model/DummyRepository.php
DummyRepository.getFromPath
public function getFromPath($path, $depth=0, $withParents=false) { if(isset($this->fs[$path])){ return $this->fs[$path]; } }
php
public function getFromPath($path, $depth=0, $withParents=false) { if(isset($this->fs[$path])){ return $this->fs[$path]; } }
[ "public", "function", "getFromPath", "(", "$", "path", ",", "$", "depth", "=", "0", ",", "$", "withParents", "=", "false", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "fs", "[", "$", "path", "]", ")", ")", "{", "return", "$", "this", ...
Get a file object by the given path @param string $path @return \FileDB\Contracts\Model\File
[ "Get", "a", "file", "object", "by", "the", "given", "path" ]
270ebc26b0fa3d2c996ca8861507fa63d2db6814
https://github.com/mtils/file-db/blob/270ebc26b0fa3d2c996ca8861507fa63d2db6814/src/FileDB/Model/DummyRepository.php#L80-L87
train
mtils/file-db
src/FileDB/Model/DummyRepository.php
DummyRepository.getById
public function getById($id, $depth=0, $withParents=false) { foreach($this->fs as $file){ if($file->getId() == $id){ return $file; } } }
php
public function getById($id, $depth=0, $withParents=false) { foreach($this->fs as $file){ if($file->getId() == $id){ return $file; } } }
[ "public", "function", "getById", "(", "$", "id", ",", "$", "depth", "=", "0", ",", "$", "withParents", "=", "false", ")", "{", "foreach", "(", "$", "this", "->", "fs", "as", "$", "file", ")", "{", "if", "(", "$", "file", "->", "getId", "(", ")"...
Get a file by its unique id. In normal filesystems its unique id is the path. In Database driven filesystems its easier to work with primary keys etc. @param mixed $id @param int $depth @return \FileDB\Contracts\Model\File
[ "Get", "a", "file", "by", "its", "unique", "id", ".", "In", "normal", "filesystems", "its", "unique", "id", "is", "the", "path", ".", "In", "Database", "driven", "filesystems", "its", "easier", "to", "work", "with", "primary", "keys", "etc", "." ]
270ebc26b0fa3d2c996ca8861507fa63d2db6814
https://github.com/mtils/file-db/blob/270ebc26b0fa3d2c996ca8861507fa63d2db6814/src/FileDB/Model/DummyRepository.php#L98-L107
train
mtils/file-db
src/FileDB/Model/DummyRepository.php
DummyRepository.getByHash
public function getByHash($hash) { foreach($this->fs as $file){ if($file->getHash() == $hash){ return $file; } } }
php
public function getByHash($hash) { foreach($this->fs as $file){ if($file->getHash() == $hash){ return $file; } } }
[ "public", "function", "getByHash", "(", "$", "hash", ")", "{", "foreach", "(", "$", "this", "->", "fs", "as", "$", "file", ")", "{", "if", "(", "$", "file", "->", "getHash", "(", ")", "==", "$", "hash", ")", "{", "return", "$", "file", ";", "}"...
Get a file by its hash @param string $hash @return \FileDB\Contracts\Model\File
[ "Get", "a", "file", "by", "its", "hash" ]
270ebc26b0fa3d2c996ca8861507fa63d2db6814
https://github.com/mtils/file-db/blob/270ebc26b0fa3d2c996ca8861507fa63d2db6814/src/FileDB/Model/DummyRepository.php#L115-L124
train
mtils/file-db
src/FileDB/Model/DummyRepository.php
DummyRepository.delete
public function delete(FileInterface $file) { if(isset($this->fs[$file->getPath()])){ unset($this->fs[$file->getPath()]); } if($dir = $file->getDir()){ $dir->removeChild($file); } return $this; }
php
public function delete(FileInterface $file) { if(isset($this->fs[$file->getPath()])){ unset($this->fs[$file->getPath()]); } if($dir = $file->getDir()){ $dir->removeChild($file); } return $this; }
[ "public", "function", "delete", "(", "FileInterface", "$", "file", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "fs", "[", "$", "file", "->", "getPath", "(", ")", "]", ")", ")", "{", "unset", "(", "$", "this", "->", "fs", "[", "$", "fi...
Delete the file. If it is a directory recursively delete it @param \FileDB\Contracts\Model\File $file @return self
[ "Delete", "the", "file", ".", "If", "it", "is", "a", "directory", "recursively", "delete", "it" ]
270ebc26b0fa3d2c996ca8861507fa63d2db6814
https://github.com/mtils/file-db/blob/270ebc26b0fa3d2c996ca8861507fa63d2db6814/src/FileDB/Model/DummyRepository.php#L172-L183
train
praxigento/mobi_mod_downline
Plugin/Magento/Customer/Model/ResourceModel/CustomerRepository.php
CustomerRepository.beforeDeleteById
public function beforeDeleteById( \Magento\Customer\Api\CustomerRepositoryInterface $subject, $customerId ) { $this->deleteSnaps($customerId); $this->deleteChange($customerId); $result = [$customerId]; return $result; }
php
public function beforeDeleteById( \Magento\Customer\Api\CustomerRepositoryInterface $subject, $customerId ) { $this->deleteSnaps($customerId); $this->deleteChange($customerId); $result = [$customerId]; return $result; }
[ "public", "function", "beforeDeleteById", "(", "\\", "Magento", "\\", "Customer", "\\", "Api", "\\", "CustomerRepositoryInterface", "$", "subject", ",", "$", "customerId", ")", "{", "$", "this", "->", "deleteSnaps", "(", "$", "customerId", ")", ";", "$", "th...
Remove customer related data from Downline on customer delete from adminhtml. @param \Magento\Customer\Api\CustomerRepositoryInterface $subject @param $customerId @return array
[ "Remove", "customer", "related", "data", "from", "Downline", "on", "customer", "delete", "from", "adminhtml", "." ]
0f3c276dfff1aa029f9fd205ccfc56f207a2e75b
https://github.com/praxigento/mobi_mod_downline/blob/0f3c276dfff1aa029f9fd205ccfc56f207a2e75b/Plugin/Magento/Customer/Model/ResourceModel/CustomerRepository.php#L37-L45
train
net-tools/core
src/Helpers/NetworkingHelper.php
NetworkingHelper.sendXmlHttpResponseHeaders
static function sendXmlHttpResponseHeaders($contenttype = "application/json", $charset = 'utf-8') { if ( is_null($charset) ) $charset = mb_internal_encoding(); // charset header("Content-Type: $contenttype; charset=$charset"); // no cache header("Expires: Sat, 1 Jan 2005 00:00:00 GMT"); header("Last-Modified: ".gmdate( "D, d M Y H:i:s")." GMT"); header("Cache-Control: no-cache, must-revalidate"); header("Pragma: no-cache"); }
php
static function sendXmlHttpResponseHeaders($contenttype = "application/json", $charset = 'utf-8') { if ( is_null($charset) ) $charset = mb_internal_encoding(); // charset header("Content-Type: $contenttype; charset=$charset"); // no cache header("Expires: Sat, 1 Jan 2005 00:00:00 GMT"); header("Last-Modified: ".gmdate( "D, d M Y H:i:s")." GMT"); header("Cache-Control: no-cache, must-revalidate"); header("Pragma: no-cache"); }
[ "static", "function", "sendXmlHttpResponseHeaders", "(", "$", "contenttype", "=", "\"application/json\"", ",", "$", "charset", "=", "'utf-8'", ")", "{", "if", "(", "is_null", "(", "$", "charset", ")", ")", "$", "charset", "=", "mb_internal_encoding", "(", ")",...
Output http headers suitable for xmlhttp @param string $contenttype Content-type to output @param string $charset Charset of content
[ "Output", "http", "headers", "suitable", "for", "xmlhttp" ]
51446641cee22c0cf53d2b409c76cc8bd1a187e7
https://github.com/net-tools/core/blob/51446641cee22c0cf53d2b409c76cc8bd1a187e7/src/Helpers/NetworkingHelper.php#L28-L41
train
net-tools/core
src/Helpers/NetworkingHelper.php
NetworkingHelper.appendToUrl
static function appendToUrl($url, $append) { if ( $append ) { $regs = []; if ( preg_match('|^(.+?)(?:\?(.*?))?(#.*)?$|', $url, $regs) ) { $u = $regs[1]; // URL part $q = $regs[2]; // querystring $a = $regs[3]; // anchor #xxxx // append a new parameter if one or more already exist if ( $q ) $q = $q . "&" . $append; else $q = $append; // rebuild full url return $u . '?' . $q . $a; } else // impossible case return $url; } else return $url; }
php
static function appendToUrl($url, $append) { if ( $append ) { $regs = []; if ( preg_match('|^(.+?)(?:\?(.*?))?(#.*)?$|', $url, $regs) ) { $u = $regs[1]; // URL part $q = $regs[2]; // querystring $a = $regs[3]; // anchor #xxxx // append a new parameter if one or more already exist if ( $q ) $q = $q . "&" . $append; else $q = $append; // rebuild full url return $u . '?' . $q . $a; } else // impossible case return $url; } else return $url; }
[ "static", "function", "appendToUrl", "(", "$", "url", ",", "$", "append", ")", "{", "if", "(", "$", "append", ")", "{", "$", "regs", "=", "[", "]", ";", "if", "(", "preg_match", "(", "'|^(.+?)(?:\\?(.*?))?(#.*)?$|'", ",", "$", "url", ",", "$", "regs"...
Append a parameter to an url @param string $url Url string to process @param string $append Querystring to append to $url @return string Return a new url with appended string
[ "Append", "a", "parameter", "to", "an", "url" ]
51446641cee22c0cf53d2b409c76cc8bd1a187e7
https://github.com/net-tools/core/blob/51446641cee22c0cf53d2b409c76cc8bd1a187e7/src/Helpers/NetworkingHelper.php#L51-L77
train
wasinger/adaptimage
src/Output/OutputTypeOptionsJpeg.php
OutputTypeOptionsJpeg.getFilters
public function getFilters() { if ($this->progressive) { $fc = new FilterChain(); $fc->add(new Interlace(ImageInterface::INTERLACE_PLANE)); return $fc; } else { return null; } }
php
public function getFilters() { if ($this->progressive) { $fc = new FilterChain(); $fc->add(new Interlace(ImageInterface::INTERLACE_PLANE)); return $fc; } else { return null; } }
[ "public", "function", "getFilters", "(", ")", "{", "if", "(", "$", "this", "->", "progressive", ")", "{", "$", "fc", "=", "new", "FilterChain", "(", ")", ";", "$", "fc", "->", "add", "(", "new", "Interlace", "(", "ImageInterface", "::", "INTERLACE_PLAN...
Return a FilterChain with Filters for postprocessing the image @return FilterChain|null
[ "Return", "a", "FilterChain", "with", "Filters", "for", "postprocessing", "the", "image" ]
7b529b25081b399451c8bbd56d0cef7daaa83ec4
https://github.com/wasinger/adaptimage/blob/7b529b25081b399451c8bbd56d0cef7daaa83ec4/src/Output/OutputTypeOptionsJpeg.php#L48-L57
train
RedCirclePL/ConsoleProcessManagerBundle
Entity/Call.php
Call.getExecutionTimeProportion
public function getExecutionTimeProportion() { if ($this->getExecutionTime() && $this->getProcess()->getAvgExecutionTime()) { return round($this->getExecutionTime() / $this->getProcess()->getAvgExecutionTime(), 2); } elseif ($this->getExecutionTime()) { return $this->getExecutionTime(); } elseif ($this->getProcess()->getAvgExecutionTime()) { return 0; } else { return 1; } }
php
public function getExecutionTimeProportion() { if ($this->getExecutionTime() && $this->getProcess()->getAvgExecutionTime()) { return round($this->getExecutionTime() / $this->getProcess()->getAvgExecutionTime(), 2); } elseif ($this->getExecutionTime()) { return $this->getExecutionTime(); } elseif ($this->getProcess()->getAvgExecutionTime()) { return 0; } else { return 1; } }
[ "public", "function", "getExecutionTimeProportion", "(", ")", "{", "if", "(", "$", "this", "->", "getExecutionTime", "(", ")", "&&", "$", "this", "->", "getProcess", "(", ")", "->", "getAvgExecutionTime", "(", ")", ")", "{", "return", "round", "(", "$", ...
Returns proportion between execution time and avg execution time @return float
[ "Returns", "proportion", "between", "execution", "time", "and", "avg", "execution", "time" ]
76b17924d3b7faf81f81f5fdaa96555200dee66b
https://github.com/RedCirclePL/ConsoleProcessManagerBundle/blob/76b17924d3b7faf81f81f5fdaa96555200dee66b/Entity/Call.php#L221-L232
train
RedCirclePL/ConsoleProcessManagerBundle
Entity/Call.php
Call.countErrorsForProcess
public function countErrorsForProcess(LifecycleEventArgs $event) { $entityManager = $event->getEntityManager(); $repository = $entityManager->getRepository(get_class($this)); $repository->countByProcessIdAndStatus( $this->getProcess(), [self::STATUS_FAILED, self::STATUS_ABORTED], 72, true ); }
php
public function countErrorsForProcess(LifecycleEventArgs $event) { $entityManager = $event->getEntityManager(); $repository = $entityManager->getRepository(get_class($this)); $repository->countByProcessIdAndStatus( $this->getProcess(), [self::STATUS_FAILED, self::STATUS_ABORTED], 72, true ); }
[ "public", "function", "countErrorsForProcess", "(", "LifecycleEventArgs", "$", "event", ")", "{", "$", "entityManager", "=", "$", "event", "->", "getEntityManager", "(", ")", ";", "$", "repository", "=", "$", "entityManager", "->", "getRepository", "(", "get_cla...
Gets triggered only after update @ORM\PostUpdate @param LifecycleEventArgs $event
[ "Gets", "triggered", "only", "after", "update" ]
76b17924d3b7faf81f81f5fdaa96555200dee66b
https://github.com/RedCirclePL/ConsoleProcessManagerBundle/blob/76b17924d3b7faf81f81f5fdaa96555200dee66b/Entity/Call.php#L309-L320
train
Hnto/nuki
src/Providers/Core/Output/Base.php
Base.buildRenderer
private function buildRenderer($render = 'foil', array $renderingInfo = []) { switch($render) { case "raw": $renderer = new RawRenderer(); $renderInfo = []; break; case "json": $renderer = new JsonRenderer(); $renderInfo = []; break; case "foil": default: $renderer = new FoilRenderer(); $renderInfo['options'] = $renderingInfo['engines']['foil']['options']; $renderInfo['folders'] = $renderingInfo['engines']['foil']['folders']; break; } //Setup renderer $renderer->setup($renderInfo); return $renderer; }
php
private function buildRenderer($render = 'foil', array $renderingInfo = []) { switch($render) { case "raw": $renderer = new RawRenderer(); $renderInfo = []; break; case "json": $renderer = new JsonRenderer(); $renderInfo = []; break; case "foil": default: $renderer = new FoilRenderer(); $renderInfo['options'] = $renderingInfo['engines']['foil']['options']; $renderInfo['folders'] = $renderingInfo['engines']['foil']['folders']; break; } //Setup renderer $renderer->setup($renderInfo); return $renderer; }
[ "private", "function", "buildRenderer", "(", "$", "render", "=", "'foil'", ",", "array", "$", "renderingInfo", "=", "[", "]", ")", "{", "switch", "(", "$", "render", ")", "{", "case", "\"raw\"", ":", "$", "renderer", "=", "new", "RawRenderer", "(", ")"...
Build, setup and return renderer @param string $render @param array $renderingInfo @return \Nuki\Skeletons\Handlers\Renderer
[ "Build", "setup", "and", "return", "renderer" ]
c3fb16244e8d611c335a88e3b9c9ee7d81fafc0c
https://github.com/Hnto/nuki/blob/c3fb16244e8d611c335a88e3b9c9ee7d81fafc0c/src/Providers/Core/Output/Base.php#L84-L108
train
agentmedia/phine-core
src/Core/Logic/Tree/TreeBuilder.php
TreeBuilder.Insert
function Insert($item, $parent = null, $previous = null) { if ($previous) { $parent = $this->provider->ParentOf($previous); } $oldNext = $this->provider->NextOf($item); $oldPrev = $this->provider->PreviousOf($item); $oldFirst = $this->provider->FirstChildOf($parent); if (!($oldPrev && $previous && $this->provider->Equals($oldPrev, $previous))) { $this->CloseCutGap($oldPrev, $oldNext, $item); } $this->UpdateInsertItem($item, $parent, $previous); if (!$previous) { $this->AssureFirstChild($item, $oldFirst); } }
php
function Insert($item, $parent = null, $previous = null) { if ($previous) { $parent = $this->provider->ParentOf($previous); } $oldNext = $this->provider->NextOf($item); $oldPrev = $this->provider->PreviousOf($item); $oldFirst = $this->provider->FirstChildOf($parent); if (!($oldPrev && $previous && $this->provider->Equals($oldPrev, $previous))) { $this->CloseCutGap($oldPrev, $oldNext, $item); } $this->UpdateInsertItem($item, $parent, $previous); if (!$previous) { $this->AssureFirstChild($item, $oldFirst); } }
[ "function", "Insert", "(", "$", "item", ",", "$", "parent", "=", "null", ",", "$", "previous", "=", "null", ")", "{", "if", "(", "$", "previous", ")", "{", "$", "parent", "=", "$", "this", "->", "provider", "->", "ParentOf", "(", "$", "previous", ...
Inserts the item @param mixed $item @param mixed $parent @param mixed $previous
[ "Inserts", "the", "item" ]
38c1be8d03ebffae950d00a96da3c612aff67832
https://github.com/agentmedia/phine-core/blob/38c1be8d03ebffae950d00a96da3c612aff67832/src/Core/Logic/Tree/TreeBuilder.php#L28-L47
train
agentmedia/phine-core
src/Core/Logic/Tree/TreeBuilder.php
TreeBuilder.Remove
function Remove($item) { $prev = $this->provider->PreviousOf($item); $next = $this->provider->NextOf($item); if ($next) { $this->provider->SetPrevious($next, $prev); } $this->provider->Delete($item); if ($next) { $this->provider->Save($next); } }
php
function Remove($item) { $prev = $this->provider->PreviousOf($item); $next = $this->provider->NextOf($item); if ($next) { $this->provider->SetPrevious($next, $prev); } $this->provider->Delete($item); if ($next) { $this->provider->Save($next); } }
[ "function", "Remove", "(", "$", "item", ")", "{", "$", "prev", "=", "$", "this", "->", "provider", "->", "PreviousOf", "(", "$", "item", ")", ";", "$", "next", "=", "$", "this", "->", "provider", "->", "NextOf", "(", "$", "item", ")", ";", "if", ...
Removes the item @param mixed $item
[ "Removes", "the", "item" ]
38c1be8d03ebffae950d00a96da3c612aff67832
https://github.com/agentmedia/phine-core/blob/38c1be8d03ebffae950d00a96da3c612aff67832/src/Core/Logic/Tree/TreeBuilder.php#L91-L104
train
erenmustafaozdal/laravel-modules-base
src/Traits/ModelDataTrait.php
ModelDataTrait.getPhoto
public function getPhoto($attributes = [], $type='original', $onlyUrl = false, $modelSlug = null, $relation = null) { $this->setAttributes($modelSlug,'photo'); $photo = $this->getFile(); if( ! is_null($photo)) { $src = $this->getFileSrc($photo, $relation, $type); } else { $type = $type === 'original' ? 'biggest' : $type; $src = config("{$this->module}.{$this->modelSlug}.default_img_path") . "/{$type}.jpg"; } $attr = $this->getHTMLAttributes($attributes); return $onlyUrl ? asset($src) : '<img src="'.asset($src).'" '.$attr.'>'; }
php
public function getPhoto($attributes = [], $type='original', $onlyUrl = false, $modelSlug = null, $relation = null) { $this->setAttributes($modelSlug,'photo'); $photo = $this->getFile(); if( ! is_null($photo)) { $src = $this->getFileSrc($photo, $relation, $type); } else { $type = $type === 'original' ? 'biggest' : $type; $src = config("{$this->module}.{$this->modelSlug}.default_img_path") . "/{$type}.jpg"; } $attr = $this->getHTMLAttributes($attributes); return $onlyUrl ? asset($src) : '<img src="'.asset($src).'" '.$attr.'>'; }
[ "public", "function", "getPhoto", "(", "$", "attributes", "=", "[", "]", ",", "$", "type", "=", "'original'", ",", "$", "onlyUrl", "=", "false", ",", "$", "modelSlug", "=", "null", ",", "$", "relation", "=", "null", ")", "{", "$", "this", "->", "se...
get the html photo element @param array $attributes @param string $type original or thumbnails key @param boolean $onlyUrl @param string|null $modelSlug @param string|null $relation @return string
[ "get", "the", "html", "photo", "element" ]
c26600543817642926bcf16ada84009e00d784e0
https://github.com/erenmustafaozdal/laravel-modules-base/blob/c26600543817642926bcf16ada84009e00d784e0/src/Traits/ModelDataTrait.php#L94-L108
train
erenmustafaozdal/laravel-modules-base
src/Traits/ModelDataTrait.php
ModelDataTrait.getDocument
public function getDocument($attributes = [], $onlyUrl = false, $modelSlug = null, $relation = null) { $this->setAttributes($modelSlug,'file'); $file = $this->getFile(); if (is_null($file)) { return ''; } $src = $this->getFileDownloadSrc($file, $relation); $attr = $this->getHTMLAttributes($attributes); return $onlyUrl ? asset($src) : '<a href="'.asset($src).'" '.$attr.'> ' . $file . '</a>'; }
php
public function getDocument($attributes = [], $onlyUrl = false, $modelSlug = null, $relation = null) { $this->setAttributes($modelSlug,'file'); $file = $this->getFile(); if (is_null($file)) { return ''; } $src = $this->getFileDownloadSrc($file, $relation); $attr = $this->getHTMLAttributes($attributes); return $onlyUrl ? asset($src) : '<a href="'.asset($src).'" '.$attr.'> ' . $file . '</a>'; }
[ "public", "function", "getDocument", "(", "$", "attributes", "=", "[", "]", ",", "$", "onlyUrl", "=", "false", ",", "$", "modelSlug", "=", "null", ",", "$", "relation", "=", "null", ")", "{", "$", "this", "->", "setAttributes", "(", "$", "modelSlug", ...
get the html document element @param array $attributes @param boolean $onlyUrl @param string|null $modelSlug @param string|null $relation @return string
[ "get", "the", "html", "document", "element" ]
c26600543817642926bcf16ada84009e00d784e0
https://github.com/erenmustafaozdal/laravel-modules-base/blob/c26600543817642926bcf16ada84009e00d784e0/src/Traits/ModelDataTrait.php#L119-L130
train
erenmustafaozdal/laravel-modules-base
src/Traits/ModelDataTrait.php
ModelDataTrait.setAttributes
private function setAttributes($modelSlug, $type) { $this->module = getModule(get_class($this)); $this->modelSlug = is_null($modelSlug) ? getModelSlug($this) : $modelSlug; $this->options = config("{$this->module}.{$this->modelSlug}.uploads.{$type}"); $this->column = $this->options['column']; }
php
private function setAttributes($modelSlug, $type) { $this->module = getModule(get_class($this)); $this->modelSlug = is_null($modelSlug) ? getModelSlug($this) : $modelSlug; $this->options = config("{$this->module}.{$this->modelSlug}.uploads.{$type}"); $this->column = $this->options['column']; }
[ "private", "function", "setAttributes", "(", "$", "modelSlug", ",", "$", "type", ")", "{", "$", "this", "->", "module", "=", "getModule", "(", "get_class", "(", "$", "this", ")", ")", ";", "$", "this", "->", "modelSlug", "=", "is_null", "(", "$", "mo...
set the model specific attribute @param string $modelSlug @param string $type
[ "set", "the", "model", "specific", "attribute" ]
c26600543817642926bcf16ada84009e00d784e0
https://github.com/erenmustafaozdal/laravel-modules-base/blob/c26600543817642926bcf16ada84009e00d784e0/src/Traits/ModelDataTrait.php#L138-L144
train
erenmustafaozdal/laravel-modules-base
src/Traits/ModelDataTrait.php
ModelDataTrait.getFileSrc
private function getFileSrc($file, $relation, $type = null) { $id = is_null($relation) ? $this->id : $this->$relation; $src = $this->options['path']."/{$id}/"; if (is_null($type)) { return $src . $file; } $src .= $type === 'original' ? "original/{$file}" : "thumbnails/{$type}_{$file}"; return $src; }
php
private function getFileSrc($file, $relation, $type = null) { $id = is_null($relation) ? $this->id : $this->$relation; $src = $this->options['path']."/{$id}/"; if (is_null($type)) { return $src . $file; } $src .= $type === 'original' ? "original/{$file}" : "thumbnails/{$type}_{$file}"; return $src; }
[ "private", "function", "getFileSrc", "(", "$", "file", ",", "$", "relation", ",", "$", "type", "=", "null", ")", "{", "$", "id", "=", "is_null", "(", "$", "relation", ")", "?", "$", "this", "->", "id", ":", "$", "this", "->", "$", "relation", ";"...
get the file src @param string $file @param string|null $relation @param string|null $type @return string
[ "get", "the", "file", "src" ]
c26600543817642926bcf16ada84009e00d784e0
https://github.com/erenmustafaozdal/laravel-modules-base/blob/c26600543817642926bcf16ada84009e00d784e0/src/Traits/ModelDataTrait.php#L165-L174
train
erenmustafaozdal/laravel-modules-base
src/Traits/ModelDataTrait.php
ModelDataTrait.getFileDownloadSrc
private function getFileDownloadSrc($file, $relation) { $id = is_null($relation) ? $this->id : $this->$relation; return route('download.document',['id' => $id]); }
php
private function getFileDownloadSrc($file, $relation) { $id = is_null($relation) ? $this->id : $this->$relation; return route('download.document',['id' => $id]); }
[ "private", "function", "getFileDownloadSrc", "(", "$", "file", ",", "$", "relation", ")", "{", "$", "id", "=", "is_null", "(", "$", "relation", ")", "?", "$", "this", "->", "id", ":", "$", "this", "->", "$", "relation", ";", "return", "route", "(", ...
get the file download src @param string $file @param string|null $relation @return string
[ "get", "the", "file", "download", "src" ]
c26600543817642926bcf16ada84009e00d784e0
https://github.com/erenmustafaozdal/laravel-modules-base/blob/c26600543817642926bcf16ada84009e00d784e0/src/Traits/ModelDataTrait.php#L183-L187
train
erenmustafaozdal/laravel-modules-base
src/Traits/ModelDataTrait.php
ModelDataTrait.getHTMLAttributes
private function getHTMLAttributes($attributes) { $attr = ''; foreach($attributes as $key => $value) { $attr .= $key.'="'.$value.'" '; } return $attr; }
php
private function getHTMLAttributes($attributes) { $attr = ''; foreach($attributes as $key => $value) { $attr .= $key.'="'.$value.'" '; } return $attr; }
[ "private", "function", "getHTMLAttributes", "(", "$", "attributes", ")", "{", "$", "attr", "=", "''", ";", "foreach", "(", "$", "attributes", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "attr", ".=", "$", "key", ".", "'=\"'", ".", "$", "va...
get html attribute for file @param array $attributes @return string
[ "get", "html", "attribute", "for", "file" ]
c26600543817642926bcf16ada84009e00d784e0
https://github.com/erenmustafaozdal/laravel-modules-base/blob/c26600543817642926bcf16ada84009e00d784e0/src/Traits/ModelDataTrait.php#L195-L202
train
erenmustafaozdal/laravel-modules-base
src/Traits/ModelDataTrait.php
ModelDataTrait.scopeExtrasWithValues
public function scopeExtrasWithValues($query, $model) { $modelSlug = $model ? getModelSlug($model) : false; return $query->with([ 'extras' => function($query) use($model,$modelSlug) { if ( ! $model ) return $query; return $query->with([ "{$modelSlug}s" => function($query) use($model,$modelSlug) { return $query->wherePivot("{$modelSlug}_id",$model->id); } ]); } ]); }
php
public function scopeExtrasWithValues($query, $model) { $modelSlug = $model ? getModelSlug($model) : false; return $query->with([ 'extras' => function($query) use($model,$modelSlug) { if ( ! $model ) return $query; return $query->with([ "{$modelSlug}s" => function($query) use($model,$modelSlug) { return $query->wherePivot("{$modelSlug}_id",$model->id); } ]); } ]); }
[ "public", "function", "scopeExtrasWithValues", "(", "$", "query", ",", "$", "model", ")", "{", "$", "modelSlug", "=", "$", "model", "?", "getModelSlug", "(", "$", "model", ")", ":", "false", ";", "return", "$", "query", "->", "with", "(", "[", "'extras...
get extra column datas with model values @param \Illuminate\Database\Eloquent\Builder $query @param $model @return \Illuminate\Database\Eloquent\Builder
[ "get", "extra", "column", "datas", "with", "model", "values" ]
c26600543817642926bcf16ada84009e00d784e0
https://github.com/erenmustafaozdal/laravel-modules-base/blob/c26600543817642926bcf16ada84009e00d784e0/src/Traits/ModelDataTrait.php#L221-L237
train
erenmustafaozdal/laravel-modules-base
src/Traits/ModelDataTrait.php
ModelDataTrait.setSlugAttribute
public function setSlugAttribute($slug) { if ( ! $slug) { $title = is_null($this->name) ? $this->title : $this->name; $slug = str_slug($title, '-'); } $this->attributes['slug'] = $slug; }
php
public function setSlugAttribute($slug) { if ( ! $slug) { $title = is_null($this->name) ? $this->title : $this->name; $slug = str_slug($title, '-'); } $this->attributes['slug'] = $slug; }
[ "public", "function", "setSlugAttribute", "(", "$", "slug", ")", "{", "if", "(", "!", "$", "slug", ")", "{", "$", "title", "=", "is_null", "(", "$", "this", "->", "name", ")", "?", "$", "this", "->", "title", ":", "$", "this", "->", "name", ";", ...
Set slug encrypted @param $slug
[ "Set", "slug", "encrypted" ]
c26600543817642926bcf16ada84009e00d784e0
https://github.com/erenmustafaozdal/laravel-modules-base/blob/c26600543817642926bcf16ada84009e00d784e0/src/Traits/ModelDataTrait.php#L331-L339
train
erenmustafaozdal/laravel-modules-base
src/Traits/ModelDataTrait.php
ModelDataTrait.setIsActiveAttribute
public function setIsActiveAttribute($value) { $this->attributes['is_active'] = $value == 1 || $value === 'true' || $value === true ? true : false; }
php
public function setIsActiveAttribute($value) { $this->attributes['is_active'] = $value == 1 || $value === 'true' || $value === true ? true : false; }
[ "public", "function", "setIsActiveAttribute", "(", "$", "value", ")", "{", "$", "this", "->", "attributes", "[", "'is_active'", "]", "=", "$", "value", "==", "1", "||", "$", "value", "===", "'true'", "||", "$", "value", "===", "true", "?", "true", ":",...
Set the is_active attribute. @param boolean $value @return string
[ "Set", "the", "is_active", "attribute", "." ]
c26600543817642926bcf16ada84009e00d784e0
https://github.com/erenmustafaozdal/laravel-modules-base/blob/c26600543817642926bcf16ada84009e00d784e0/src/Traits/ModelDataTrait.php#L347-L350
train
erenmustafaozdal/laravel-modules-base
src/Traits/ModelDataTrait.php
ModelDataTrait.setIsPublishAttribute
public function setIsPublishAttribute($is_publish) { $this->attributes['is_publish'] = $is_publish == 1 || $is_publish === 'true' || $is_publish === true ? true : false; }
php
public function setIsPublishAttribute($is_publish) { $this->attributes['is_publish'] = $is_publish == 1 || $is_publish === 'true' || $is_publish === true ? true : false; }
[ "public", "function", "setIsPublishAttribute", "(", "$", "is_publish", ")", "{", "$", "this", "->", "attributes", "[", "'is_publish'", "]", "=", "$", "is_publish", "==", "1", "||", "$", "is_publish", "===", "'true'", "||", "$", "is_publish", "===", "true", ...
Set the is_publish attribute. @param boolean $is_publish @return string
[ "Set", "the", "is_publish", "attribute", "." ]
c26600543817642926bcf16ada84009e00d784e0
https://github.com/erenmustafaozdal/laravel-modules-base/blob/c26600543817642926bcf16ada84009e00d784e0/src/Traits/ModelDataTrait.php#L369-L372
train
erenmustafaozdal/laravel-modules-base
src/Traits/ModelDataTrait.php
ModelDataTrait.getCreatedAtAttribute
public function getCreatedAtAttribute($date) { $module = getModule(get_class()); return Carbon::parse($date)->format(config("{$module}.date_format")); }
php
public function getCreatedAtAttribute($date) { $module = getModule(get_class()); return Carbon::parse($date)->format(config("{$module}.date_format")); }
[ "public", "function", "getCreatedAtAttribute", "(", "$", "date", ")", "{", "$", "module", "=", "getModule", "(", "get_class", "(", ")", ")", ";", "return", "Carbon", "::", "parse", "(", "$", "date", ")", "->", "format", "(", "config", "(", "\"{$module}.d...
Get the created_at attribute. @param $date @return string
[ "Get", "the", "created_at", "attribute", "." ]
c26600543817642926bcf16ada84009e00d784e0
https://github.com/erenmustafaozdal/laravel-modules-base/blob/c26600543817642926bcf16ada84009e00d784e0/src/Traits/ModelDataTrait.php#L391-L395
train
erenmustafaozdal/laravel-modules-base
src/Traits/ModelDataTrait.php
ModelDataTrait.getAspectRatioAttribute
public function getAspectRatioAttribute() { if ($this->photo_width == 0 || $this->photo_height == 0) { return null; } return $this->photo_width/$this->photo_height; }
php
public function getAspectRatioAttribute() { if ($this->photo_width == 0 || $this->photo_height == 0) { return null; } return $this->photo_width/$this->photo_height; }
[ "public", "function", "getAspectRatioAttribute", "(", ")", "{", "if", "(", "$", "this", "->", "photo_width", "==", "0", "||", "$", "this", "->", "photo_height", "==", "0", ")", "{", "return", "null", ";", "}", "return", "$", "this", "->", "photo_width", ...
get the aspect ration with photo width and photo height @return float|null
[ "get", "the", "aspect", "ration", "with", "photo", "width", "and", "photo", "height" ]
c26600543817642926bcf16ada84009e00d784e0
https://github.com/erenmustafaozdal/laravel-modules-base/blob/c26600543817642926bcf16ada84009e00d784e0/src/Traits/ModelDataTrait.php#L742-L748
train
ScaraMVC/Framework
src/Scara/Pagination/Pagination.php
Pagination.setModel
public function setModel(Model $model, $capsule) { $this->_model = $model; $this->_capsule = $capsule; return $this; }
php
public function setModel(Model $model, $capsule) { $this->_model = $model; $this->_capsule = $capsule; return $this; }
[ "public", "function", "setModel", "(", "Model", "$", "model", ",", "$", "capsule", ")", "{", "$", "this", "->", "_model", "=", "$", "model", ";", "$", "this", "->", "_capsule", "=", "$", "capsule", ";", "return", "$", "this", ";", "}" ]
Sets the model instance for the Pagination class. @param \Scara\Http\Model $model @param \Illuminate\Database\Query\Builder $capsule @return \Scara\Pagination\Pagination
[ "Sets", "the", "model", "instance", "for", "the", "Pagination", "class", "." ]
199b08b45fadf5dae14ac4732af03b36e15bbef2
https://github.com/ScaraMVC/Framework/blob/199b08b45fadf5dae14ac4732af03b36e15bbef2/src/Scara/Pagination/Pagination.php#L91-L97
train
ScaraMVC/Framework
src/Scara/Pagination/Pagination.php
Pagination.paginate
public function paginate() { $count = count($this->_model->all()); $this->_totalPages = ceil($count / $this->_limit); $page_at_offset = floor($this->_page + 1 / $this->_limit); $this->_offset = ($page_at_offset - 1) * $this->_limit; $this->_results = $this->_model->select($this->_capsule, $this->_limit, $this->_offset); return $this; }
php
public function paginate() { $count = count($this->_model->all()); $this->_totalPages = ceil($count / $this->_limit); $page_at_offset = floor($this->_page + 1 / $this->_limit); $this->_offset = ($page_at_offset - 1) * $this->_limit; $this->_results = $this->_model->select($this->_capsule, $this->_limit, $this->_offset); return $this; }
[ "public", "function", "paginate", "(", ")", "{", "$", "count", "=", "count", "(", "$", "this", "->", "_model", "->", "all", "(", ")", ")", ";", "$", "this", "->", "_totalPages", "=", "ceil", "(", "$", "count", "/", "$", "this", "->", "_limit", ")...
Handles the pagination. @return \Scara\Pagination\Pagination
[ "Handles", "the", "pagination", "." ]
199b08b45fadf5dae14ac4732af03b36e15bbef2
https://github.com/ScaraMVC/Framework/blob/199b08b45fadf5dae14ac4732af03b36e15bbef2/src/Scara/Pagination/Pagination.php#L118-L128
train
ScaraMVC/Framework
src/Scara/Pagination/Pagination.php
Pagination.render
public function render($path = 'basic', $views = null) { $view = new View(); if (is_null($views)) { $views = __DIR__.'/views/'; } $view->createBlade($views, $this->_config->get('cache')); return $view->with('pagination', [ 'currentPage' => $this->_page, 'totalPages' => $this->_totalPages, ])->render($path); }
php
public function render($path = 'basic', $views = null) { $view = new View(); if (is_null($views)) { $views = __DIR__.'/views/'; } $view->createBlade($views, $this->_config->get('cache')); return $view->with('pagination', [ 'currentPage' => $this->_page, 'totalPages' => $this->_totalPages, ])->render($path); }
[ "public", "function", "render", "(", "$", "path", "=", "'basic'", ",", "$", "views", "=", "null", ")", "{", "$", "view", "=", "new", "View", "(", ")", ";", "if", "(", "is_null", "(", "$", "views", ")", ")", "{", "$", "views", "=", "__DIR__", "....
Renders pagination links. @param string $path - The view path @param string $views - Where the pagination view is stored @return mixed
[ "Renders", "pagination", "links", "." ]
199b08b45fadf5dae14ac4732af03b36e15bbef2
https://github.com/ScaraMVC/Framework/blob/199b08b45fadf5dae14ac4732af03b36e15bbef2/src/Scara/Pagination/Pagination.php#L158-L171
train
AlexanderPoellmann/Laravel-Settings
src/Driver/Driver.php
Driver.set
public function set( $key, $value = null, $group = '' ) { $this->checkLoaded(); $this->modified = true; if ( is_array($key) ) { foreach ( $key as $k => $v ) { SettingsUtilities::set($this->storage, $k, $v); } } else { SettingsUtilities::set($this->storage, $key, $value); } }
php
public function set( $key, $value = null, $group = '' ) { $this->checkLoaded(); $this->modified = true; if ( is_array($key) ) { foreach ( $key as $k => $v ) { SettingsUtilities::set($this->storage, $k, $v); } } else { SettingsUtilities::set($this->storage, $key, $value); } }
[ "public", "function", "set", "(", "$", "key", ",", "$", "value", "=", "null", ",", "$", "group", "=", "''", ")", "{", "$", "this", "->", "checkLoaded", "(", ")", ";", "$", "this", "->", "modified", "=", "true", ";", "if", "(", "is_array", "(", ...
Store an item in the configuration for a given number of minutes. @param string $key @param mixed $value @param string $group
[ "Store", "an", "item", "in", "the", "configuration", "for", "a", "given", "number", "of", "minutes", "." ]
bf06f78cbbf86adb8576a29caae496d1e03b32ab
https://github.com/AlexanderPoellmann/Laravel-Settings/blob/bf06f78cbbf86adb8576a29caae496d1e03b32ab/src/Driver/Driver.php#L77-L89
train
MasterkeyInformatica/browser-kit
History.php
History.add
public function add(Request $request) { $this->stack = array_slice($this->stack, 0, $this->position + 1); $this->stack[] = clone $request; $this->position = count($this->stack) - 1; }
php
public function add(Request $request) { $this->stack = array_slice($this->stack, 0, $this->position + 1); $this->stack[] = clone $request; $this->position = count($this->stack) - 1; }
[ "public", "function", "add", "(", "Request", "$", "request", ")", "{", "$", "this", "->", "stack", "=", "array_slice", "(", "$", "this", "->", "stack", ",", "0", ",", "$", "this", "->", "position", "+", "1", ")", ";", "$", "this", "->", "stack", ...
Adds a Request to the history. @param Request $request A Request instance
[ "Adds", "a", "Request", "to", "the", "history", "." ]
fd735ad31c00af54d5c060d01218aa48308557f7
https://github.com/MasterkeyInformatica/browser-kit/blob/fd735ad31c00af54d5c060d01218aa48308557f7/History.php#L38-L43
train
MasterkeyInformatica/browser-kit
History.php
History.forward
public function forward() { if ($this->position > count($this->stack) - 2) { throw new \LogicException('You are already on the last page.'); } return clone $this->stack[++$this->position]; }
php
public function forward() { if ($this->position > count($this->stack) - 2) { throw new \LogicException('You are already on the last page.'); } return clone $this->stack[++$this->position]; }
[ "public", "function", "forward", "(", ")", "{", "if", "(", "$", "this", "->", "position", ">", "count", "(", "$", "this", "->", "stack", ")", "-", "2", ")", "{", "throw", "new", "\\", "LogicException", "(", "'You are already on the last page.'", ")", ";"...
Goes forward in the history. @return Request A Request instance @throws \LogicException if the stack is already on the last page
[ "Goes", "forward", "in", "the", "history", "." ]
fd735ad31c00af54d5c060d01218aa48308557f7
https://github.com/MasterkeyInformatica/browser-kit/blob/fd735ad31c00af54d5c060d01218aa48308557f7/History.php#L78-L85
train
ZFrapid/zfrapid-domain
src/Storage/AbstractStorage.php
AbstractStorage.fetchAllEntities
public function fetchAllEntities() { $select = $this->tableGateway->getSql()->select(); return $this->tableGateway->fetchCollection($select); }
php
public function fetchAllEntities() { $select = $this->tableGateway->getSql()->select(); return $this->tableGateway->fetchCollection($select); }
[ "public", "function", "fetchAllEntities", "(", ")", "{", "$", "select", "=", "$", "this", "->", "tableGateway", "->", "getSql", "(", ")", "->", "select", "(", ")", ";", "return", "$", "this", "->", "tableGateway", "->", "fetchCollection", "(", "$", "sele...
Fetch all entities @return array
[ "Fetch", "all", "entities" ]
a8b0c787da9356512b6f4ee5958d6c85c3a8ecef
https://github.com/ZFrapid/zfrapid-domain/blob/a8b0c787da9356512b6f4ee5958d6c85c3a8ecef/src/Storage/AbstractStorage.php#L57-L62
train
ZFrapid/zfrapid-domain
src/Storage/AbstractStorage.php
AbstractStorage.fetchEntityById
public function fetchEntityById($id) { $select = $this->tableGateway->getSql()->select(); $select->where->equalTo($this->tableGateway->getPrimaryKey(), $id); return $this->tableGateway->fetchEntity($select); }
php
public function fetchEntityById($id) { $select = $this->tableGateway->getSql()->select(); $select->where->equalTo($this->tableGateway->getPrimaryKey(), $id); return $this->tableGateway->fetchEntity($select); }
[ "public", "function", "fetchEntityById", "(", "$", "id", ")", "{", "$", "select", "=", "$", "this", "->", "tableGateway", "->", "getSql", "(", ")", "->", "select", "(", ")", ";", "$", "select", "->", "where", "->", "equalTo", "(", "$", "this", "->", ...
Fetch entity by id @param $id @return mixed
[ "Fetch", "entity", "by", "id" ]
a8b0c787da9356512b6f4ee5958d6c85c3a8ecef
https://github.com/ZFrapid/zfrapid-domain/blob/a8b0c787da9356512b6f4ee5958d6c85c3a8ecef/src/Storage/AbstractStorage.php#L71-L77
train
wb-crowdfusion/crowdfusion
system/core/classes/libraries/utils/ArrayUtils.php
ArrayUtils.htmlArrayFlatten
public static function htmlArrayFlatten($array_to_flatten, $parents = array ()) { // Returns an array that has been "flattened", suitable for use in html forms. $flattened = array (); foreach ($array_to_flatten as $key => $value) { if (is_array($value)) { // Ugly hack. We cannot alter our $parents array, but must pass the proper array to the recursive function. // PHP provides no easy way to do this. $parent_with_child = $parents; $parent_with_child[] = $key; $flattened = array_merge($flattened, self::htmlArrayFlatten($value, $parent_with_child)); } else { $keystr = ''; // If we have parents, build the key if (count($parents) > 0) { // Extract the common parts if (!isset ($parentstr)) { // First parent is rendered as Parent reset($parents); list (, $parentstr) = each($parents); // Children build the string as Parent[Child][Child].. while (list (, $parent) = each($parents)) { $parentstr .= "[$parent]"; } } // Finally, identify the current key to build Parent[Child][...][0] $keystr = $parentstr . "[$key]"; } else { // With no parents, the key name is just Key $keystr = $key; } $flattened[$keystr] = $value; } } return $flattened; }
php
public static function htmlArrayFlatten($array_to_flatten, $parents = array ()) { // Returns an array that has been "flattened", suitable for use in html forms. $flattened = array (); foreach ($array_to_flatten as $key => $value) { if (is_array($value)) { // Ugly hack. We cannot alter our $parents array, but must pass the proper array to the recursive function. // PHP provides no easy way to do this. $parent_with_child = $parents; $parent_with_child[] = $key; $flattened = array_merge($flattened, self::htmlArrayFlatten($value, $parent_with_child)); } else { $keystr = ''; // If we have parents, build the key if (count($parents) > 0) { // Extract the common parts if (!isset ($parentstr)) { // First parent is rendered as Parent reset($parents); list (, $parentstr) = each($parents); // Children build the string as Parent[Child][Child].. while (list (, $parent) = each($parents)) { $parentstr .= "[$parent]"; } } // Finally, identify the current key to build Parent[Child][...][0] $keystr = $parentstr . "[$key]"; } else { // With no parents, the key name is just Key $keystr = $key; } $flattened[$keystr] = $value; } } return $flattened; }
[ "public", "static", "function", "htmlArrayFlatten", "(", "$", "array_to_flatten", ",", "$", "parents", "=", "array", "(", ")", ")", "{", "// Returns an array that has been \"flattened\", suitable for use in html forms.", "$", "flattened", "=", "array", "(", ")", ";", ...
Returns an array that has been "flattened", suitable for use in html forms. For example, an array like ['cache' => 'Craig', 'Fusion' => ['data' => 'fed', 'foo' => 'bar']] becomes ['cache' => 'Craig', 'Fusion[data]' => 'fed', 'Fusion[foo]' => 'bar'] @param array $array_to_flatten Array to flatten @param array $parents [NEVER SPECIFY] Only used when called recursively. Ignore this parameter @return array An array containing only keys and values, suitable to display on forms.
[ "Returns", "an", "array", "that", "has", "been", "flattened", "suitable", "for", "use", "in", "html", "forms", "." ]
8cad7988f046a6fefbed07d026cb4ae6706c1217
https://github.com/wb-crowdfusion/crowdfusion/blob/8cad7988f046a6fefbed07d026cb4ae6706c1217/system/core/classes/libraries/utils/ArrayUtils.php#L73-L118
train
wb-crowdfusion/crowdfusion
system/core/classes/libraries/utils/ArrayUtils.php
ArrayUtils.arrayMultiMergeKeys
public static function arrayMultiMergeKeys() { $args = func_get_args(); $result = array (); foreach ($args as $array) { foreach ($array as $key => $row) { foreach ($row as $name => $value) { $result[$key][$name] = $value; } } } return $result; }
php
public static function arrayMultiMergeKeys() { $args = func_get_args(); $result = array (); foreach ($args as $array) { foreach ($array as $key => $row) { foreach ($row as $name => $value) { $result[$key][$name] = $value; } } } return $result; }
[ "public", "static", "function", "arrayMultiMergeKeys", "(", ")", "{", "$", "args", "=", "func_get_args", "(", ")", ";", "$", "result", "=", "array", "(", ")", ";", "foreach", "(", "$", "args", "as", "$", "array", ")", "{", "foreach", "(", "$", "array...
Performs a recursive array_merge. Keys with the same value will be over-written with the later value Given arguments like: $one = ['key' => ['name' => value], 'key2' => ['name2' => value2] ] $two = ['key' => ['name' => value2], 'key4' => ['name4' => value4] ] Transform them into an array like: [key => ['name' => value2], 'key2' => ['name2' => value2], 'key4' => ['name4' => value4]] @params array Two or more multi-dimensional arrays @return void
[ "Performs", "a", "recursive", "array_merge", ".", "Keys", "with", "the", "same", "value", "will", "be", "over", "-", "written", "with", "the", "later", "value" ]
8cad7988f046a6fefbed07d026cb4ae6706c1217
https://github.com/wb-crowdfusion/crowdfusion/blob/8cad7988f046a6fefbed07d026cb4ae6706c1217/system/core/classes/libraries/utils/ArrayUtils.php#L254-L267
train
wb-crowdfusion/crowdfusion
system/core/classes/libraries/utils/ArrayUtils.php
ArrayUtils.arrayKeyAssoc
public static function arrayKeyAssoc($array_map, $value) { if (is_string($value)) { if (($val = array_search($value, $array_map)) === false) throw new Exception('Value string undefined: ' . $value); return $val; } else if (is_int($value)) { if (!array_key_exists('' . $value, $array_map)) throw new Exception('Key value undefined: ' . $value); return $array_map['' . $value]; } throw new Exception('Invalid type for arrayKeyAssoc: ' . ClassUtils::getQualifiedType($value)); }
php
public static function arrayKeyAssoc($array_map, $value) { if (is_string($value)) { if (($val = array_search($value, $array_map)) === false) throw new Exception('Value string undefined: ' . $value); return $val; } else if (is_int($value)) { if (!array_key_exists('' . $value, $array_map)) throw new Exception('Key value undefined: ' . $value); return $array_map['' . $value]; } throw new Exception('Invalid type for arrayKeyAssoc: ' . ClassUtils::getQualifiedType($value)); }
[ "public", "static", "function", "arrayKeyAssoc", "(", "$", "array_map", ",", "$", "value", ")", "{", "if", "(", "is_string", "(", "$", "value", ")", ")", "{", "if", "(", "(", "$", "val", "=", "array_search", "(", "$", "value", ",", "$", "array_map", ...
Returns the associated value from the array based on the type of value given @param array $array_map An array of the type [1 => string, int => string] @param string/int $value An integer or string to find the associated value for @return string or int If input was a string, the associated integer, If was integer, the associated string
[ "Returns", "the", "associated", "value", "from", "the", "array", "based", "on", "the", "type", "of", "value", "given" ]
8cad7988f046a6fefbed07d026cb4ae6706c1217
https://github.com/wb-crowdfusion/crowdfusion/blob/8cad7988f046a6fefbed07d026cb4ae6706c1217/system/core/classes/libraries/utils/ArrayUtils.php#L278-L292
train
wb-crowdfusion/crowdfusion
system/core/classes/libraries/utils/ArrayUtils.php
ArrayUtils.arraySortUsingKeys
public static function arraySortUsingKeys($arrayToSort, $arrayKeysInOrder) { $result = array(); foreach($arrayKeysInOrder as $key) if(array_key_exists($key, $arrayToSort)) $result[] = $arrayToSort[$key]; return $result; }
php
public static function arraySortUsingKeys($arrayToSort, $arrayKeysInOrder) { $result = array(); foreach($arrayKeysInOrder as $key) if(array_key_exists($key, $arrayToSort)) $result[] = $arrayToSort[$key]; return $result; }
[ "public", "static", "function", "arraySortUsingKeys", "(", "$", "arrayToSort", ",", "$", "arrayKeysInOrder", ")", "{", "$", "result", "=", "array", "(", ")", ";", "foreach", "(", "$", "arrayKeysInOrder", "as", "$", "key", ")", "if", "(", "array_key_exists", ...
Sorts an array using another array as a guide for key order @param array $arrayToSort The associative array to sort and return @param array $arrayKeysInOrder An ordered list of keys in {@link $arrayToSort} @return array A sorted array
[ "Sorts", "an", "array", "using", "another", "array", "as", "a", "guide", "for", "key", "order" ]
8cad7988f046a6fefbed07d026cb4ae6706c1217
https://github.com/wb-crowdfusion/crowdfusion/blob/8cad7988f046a6fefbed07d026cb4ae6706c1217/system/core/classes/libraries/utils/ArrayUtils.php#L302-L310
train
geega/php-simple-orm
src/Enum.php
Enum.getList
public static function getList() { $calledClass = get_called_class(); if (!isset(static::$list[$calledClass])) { $refClass = new \ReflectionClass($calledClass); $labels = static::getLabels(); foreach ($refClass->getConstants() as $constName => $constValue) { if (isset($labels[$constValue])) { $label = $labels[$constValue]; } else { $label = lcfirst(strtolower($constName)); } static::$list[$calledClass][$constValue] = $label; } } return static::$list[$calledClass]; }
php
public static function getList() { $calledClass = get_called_class(); if (!isset(static::$list[$calledClass])) { $refClass = new \ReflectionClass($calledClass); $labels = static::getLabels(); foreach ($refClass->getConstants() as $constName => $constValue) { if (isset($labels[$constValue])) { $label = $labels[$constValue]; } else { $label = lcfirst(strtolower($constName)); } static::$list[$calledClass][$constValue] = $label; } } return static::$list[$calledClass]; }
[ "public", "static", "function", "getList", "(", ")", "{", "$", "calledClass", "=", "get_called_class", "(", ")", ";", "if", "(", "!", "isset", "(", "static", "::", "$", "list", "[", "$", "calledClass", "]", ")", ")", "{", "$", "refClass", "=", "new",...
Get list constants @return mixed
[ "Get", "list", "constants" ]
8ef636fd181c16ee3936d630d99e232c53883447
https://github.com/geega/php-simple-orm/blob/8ef636fd181c16ee3936d630d99e232c53883447/src/Enum.php#L23-L39
train