repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_documentation_string
stringlengths
1
47.2k
func_code_url
stringlengths
85
339
Brainsware/sauce
lib/Sauce/SString.php
SString.equals
public function equals ($other) { ensure('Argument', $other, 'is_a_string', __CLASS__, __METHOD__); if ($other instanceof self) { return $other->to_s() === $this->string; } return $other === $this->string; }
php
public function equals ($other) { ensure('Argument', $other, 'is_a_string', __CLASS__, __METHOD__); if ($other instanceof self) { return $other->to_s() === $this->string; } return $other === $this->string; }
/* Returns whether given string (or String instance) is exactly the same string. If given argument is not a string or String instance, an InvalidArgumentException is thrown. Returns boolean. TODO: Examples
https://github.com/Brainsware/sauce/blob/2294fd27286bf42cfac6d744e242b2bd9eea353d/lib/Sauce/SString.php#L133-L142
Brainsware/sauce
lib/Sauce/SString.php
SString.replace
function replace ($search, $replace) { ensure('Search argument', $search, 'is_a_string', __CLASS__, __METHOD__); ensure('Replace argument', $replace, 'is_a_string', __CLASS__, __METHOD__); $result = str_replace($search, $replace, $this); return S($result); }
php
function replace ($search, $replace) { ensure('Search argument', $search, 'is_a_string', __CLASS__, __METHOD__); ensure('Replace argument', $replace, 'is_a_string', __CLASS__, __METHOD__); $result = str_replace($search, $replace, $this); return S($result); }
/* Returns a new String instance replacing the search string with the replacement string. If either of the arguments is not a string or an instance of String, an InvalidArgumentException is thrown.
https://github.com/Brainsware/sauce/blob/2294fd27286bf42cfac6d744e242b2bd9eea353d/lib/Sauce/SString.php#L150-L158
Brainsware/sauce
lib/Sauce/SString.php
SString.ireplace
function ireplace ($search, $replace) { ensure('Search argument', $search, 'is_a_string', __CLASS__, __METHOD__); ensure('Replace argument', $replace, 'is_a_string', __CLASS__, __METHOD__); $result = str_ireplace($search, $replace, $this); return S($result); }
php
function ireplace ($search, $replace) { ensure('Search argument', $search, 'is_a_string', __CLASS__, __METHOD__); ensure('Replace argument', $replace, 'is_a_string', __CLASS__, __METHOD__); $result = str_ireplace($search, $replace, $this); return S($result); }
/* Returns a new string instance replacing the search string with the replacement string but case insentively. If either of the arguments is not a string or an instance of String, an InvalidArgumentException is thrown.
https://github.com/Brainsware/sauce/blob/2294fd27286bf42cfac6d744e242b2bd9eea353d/lib/Sauce/SString.php#L166-L174
Brainsware/sauce
lib/Sauce/SString.php
SString.replaceF
function replaceF ($search, $replace) { ensure('Search argument', $search, 'is_a_string', __CLASS__, __METHOD__); ensure('Replace argument', $replace, 'is_a_string', __CLASS__, __METHOD__); $this->string = str_replace($search, $replace, $this); return $this; }
php
function replaceF ($search, $replace) { ensure('Search argument', $search, 'is_a_string', __CLASS__, __METHOD__); ensure('Replace argument', $replace, 'is_a_string', __CLASS__, __METHOD__); $this->string = str_replace($search, $replace, $this); return $this; }
/* Replaces the search string with the replacement and stores the result. If either of the arguments is not a string or an instance of String, an InvalidArgumentException is thrown.
https://github.com/Brainsware/sauce/blob/2294fd27286bf42cfac6d744e242b2bd9eea353d/lib/Sauce/SString.php#L181-L189
Brainsware/sauce
lib/Sauce/SString.php
SString.ireplaceF
function ireplaceF ($search, $replace) { ensure('Search argument', $search, 'is_a_string', __CLASS__, __METHOD__); ensure('Replace argument', $replace, 'is_a_string', __CLASS__, __METHOD__); $this->string = str_ireplace($search, $replace, $this); return $this; }
php
function ireplaceF ($search, $replace) { ensure('Search argument', $search, 'is_a_string', __CLASS__, __METHOD__); ensure('Replace argument', $replace, 'is_a_string', __CLASS__, __METHOD__); $this->string = str_ireplace($search, $replace, $this); return $this; }
/* Replaces the search string with the replacement case insensitively and stores the result. If either of the arguments is not a string or an instance of String, an InvalidArgumentException is thrown.
https://github.com/Brainsware/sauce/blob/2294fd27286bf42cfac6d744e242b2bd9eea353d/lib/Sauce/SString.php#L197-L205
Brainsware/sauce
lib/Sauce/SString.php
SString.slice
public function slice ($start, $end) { ensure('Start', $start, 'is_numeric', __CLASS__, __METHOD__); ensure('End', $end, 'is_numeric', __CLASS__, __METHOD__); return new self(substr($this->string, $start, $end)); }
php
public function slice ($start, $end) { ensure('Start', $start, 'is_numeric', __CLASS__, __METHOD__); ensure('End', $end, 'is_numeric', __CLASS__, __METHOD__); return new self(substr($this->string, $start, $end)); }
/* Returns a slice of the stored string as new String instance. The start and end parameters are passed to the PHP function #substr directly after they are both verified to be numeric. If either of the arguments is not numeric, an InvalidArgumentException is thrown. Returns a new String instance with the sliced string. TODO: Examples
https://github.com/Brainsware/sauce/blob/2294fd27286bf42cfac6d744e242b2bd9eea353d/lib/Sauce/SString.php#L219-L225
Brainsware/sauce
lib/Sauce/SString.php
SString.sliceF
public function sliceF ($start, $end) { ensure('Start', $start, 'is_numeric', __CLASS__, __METHOD__); ensure('End', $end, 'is_numeric', __CLASS__, __METHOD__); $this->string = substr($this->string, $start, $end); return $this; }
php
public function sliceF ($start, $end) { ensure('Start', $start, 'is_numeric', __CLASS__, __METHOD__); ensure('End', $end, 'is_numeric', __CLASS__, __METHOD__); $this->string = substr($this->string, $start, $end); return $this; }
/* Slices the stored string. The start and end parameters are passed to the PHP function #substr directly after they are both verified to be numeric. If either of the arguments is not numeric, an InvalidArgumentException is thrown. Returns this instance. TODO: Examples
https://github.com/Brainsware/sauce/blob/2294fd27286bf42cfac6d744e242b2bd9eea353d/lib/Sauce/SString.php#L239-L247
Brainsware/sauce
lib/Sauce/SString.php
SString.append
public function append ($string) { ensure('Argument', $string, 'is_a_string', __CLASS__, __METHOD__); if ($string instanceof self) { $string = $string->to_s(); } return new String($this->string . $string); }
php
public function append ($string) { ensure('Argument', $string, 'is_a_string', __CLASS__, __METHOD__); if ($string instanceof self) { $string = $string->to_s(); } return new String($this->string . $string); }
/* Appends given string to the stored string and returns the result as new String instance. If given argument is not a string or a String instance, an InvalidArgumentException is thrown. Returns a new String instance with the full string. TODO: Examples
https://github.com/Brainsware/sauce/blob/2294fd27286bf42cfac6d744e242b2bd9eea353d/lib/Sauce/SString.php#L259-L268
Brainsware/sauce
lib/Sauce/SString.php
SString.appendF
public function appendF ($string) { ensure('Argument', $string, 'is_a_string', __CLASS__, __METHOD__); if ($string instanceof self) { $string = $string->to_s(); } $this->string .= $string; return $this; }
php
public function appendF ($string) { ensure('Argument', $string, 'is_a_string', __CLASS__, __METHOD__); if ($string instanceof self) { $string = $string->to_s(); } $this->string .= $string; return $this; }
/* Appends given string to the stored string. If given argument is not a string or a String instance, an InvalidArgumentException is thrown. Returns this instance. TODO: Examples
https://github.com/Brainsware/sauce/blob/2294fd27286bf42cfac6d744e242b2bd9eea353d/lib/Sauce/SString.php#L279-L290
Brainsware/sauce
lib/Sauce/SString.php
SString.prependF
public function prependF ($string) { ensure('Argument', $string, 'is_a_string', __CLASS__, __METHOD__); if ($string instanceof self) { $string = $string->to_s(); } $this->string = $string . $this->string; return $this; }
php
public function prependF ($string) { ensure('Argument', $string, 'is_a_string', __CLASS__, __METHOD__); if ($string instanceof self) { $string = $string->to_s(); } $this->string = $string . $this->string; return $this; }
/* Prepends given string to the stored string. If given argument is not a string or a String instance, an InvalidArgumentException is thrown. Returns this instance. TODO: Examples
https://github.com/Brainsware/sauce/blob/2294fd27286bf42cfac6d744e242b2bd9eea353d/lib/Sauce/SString.php#L322-L333
Brainsware/sauce
lib/Sauce/SString.php
SString.trim
public function trim ($characters = null) { if (is_not_null($characters)) { ensure('Argument', $characters, 'is_a_string', __CLASS__, __METHOD__); } $trimmed = ''; if (null !== $characters) { $trimmed = trim($this->string, $characters); } else { $trimmed = trim($this->string); } return new String($trimmed); }
php
public function trim ($characters = null) { if (is_not_null($characters)) { ensure('Argument', $characters, 'is_a_string', __CLASS__, __METHOD__); } $trimmed = ''; if (null !== $characters) { $trimmed = trim($this->string, $characters); } else { $trimmed = trim($this->string); } return new String($trimmed); }
/* Trims whitespaces from the beginning and end of the stored string and returns the result as new String instance. Optionally, a string containing all characters (instead of whitespaces) to strip away can be passed. If given argument is not a string or a String instance, an InvalidArgumentException is thrown. Returns a new String instance with the trimmed string. TODO: Examples
https://github.com/Brainsware/sauce/blob/2294fd27286bf42cfac6d744e242b2bd9eea353d/lib/Sauce/SString.php#L346-L361
Brainsware/sauce
lib/Sauce/SString.php
SString.trimF
public function trimF ($characters = null) { if (is_not_null($characters)) { ensure('Argument', $characters, 'is_a_string', __CLASS__, __METHOD__); } if (null !== $characters) { $this->string = trim($this->string, $characters); } else { $this->string = trim($this->string); } return $this; }
php
public function trimF ($characters = null) { if (is_not_null($characters)) { ensure('Argument', $characters, 'is_a_string', __CLASS__, __METHOD__); } if (null !== $characters) { $this->string = trim($this->string, $characters); } else { $this->string = trim($this->string); } return $this; }
/* Trims whitespaces from the beginning and end of the stored string. Optionally, a string containing all characters (instead of whitespaces) to strip away can be passed. If given argument is not a string or a String instance, an InvalidArgumentException is thrown. Returns this instance. TODO: Examples
https://github.com/Brainsware/sauce/blob/2294fd27286bf42cfac6d744e242b2bd9eea353d/lib/Sauce/SString.php#L373-L386
Brainsware/sauce
lib/Sauce/SString.php
SString.split
public function split ($by = ' ') { ensure('Argument', $by, 'is_a_string', __CLASS__, __METHOD__); return V(explode($by, $this->string)); }
php
public function split ($by = ' ') { ensure('Argument', $by, 'is_a_string', __CLASS__, __METHOD__); return V(explode($by, $this->string)); }
/* Splits the stored string by given string and returns the result as new Vector instance. If given argument is not a string or a String instance, an InvalidArgumentException is thrown. Returns a new Vector instance. TODO: Examples
https://github.com/Brainsware/sauce/blob/2294fd27286bf42cfac6d744e242b2bd9eea353d/lib/Sauce/SString.php#L398-L403
codeblanche/Depend
src/Depend/CreationAction.php
CreationAction.getIdentifier
public function getIdentifier() { if (is_array($this->callback)) { $class = $this->callback[0]; if (is_object($class)) { $class = get_class($class); } return $class . '::' . $this->callback[1]; } else if (is_object($this->callback)) { return spl_object_hash((object) $this->callback); } return (string) $this->callback; }
php
public function getIdentifier() { if (is_array($this->callback)) { $class = $this->callback[0]; if (is_object($class)) { $class = get_class($class); } return $class . '::' . $this->callback[1]; } else if (is_object($this->callback)) { return spl_object_hash((object) $this->callback); } return (string) $this->callback; }
Returns an unique identifier for the function/method @return string
https://github.com/codeblanche/Depend/blob/6520d010ec71f5b2ea0d622b8abae2e029ef7f16/src/Depend/CreationAction.php#L53-L69
ARCANESOFT/SEO
src/Http/Requests/Admin/Redirects/UpdateRedirectRequest.php
UpdateRedirectRequest.rules
public function rules() { $redirect = $this->route('seo_redirect'); return [ 'old_url' => ['required', 'string', $this->getOldUrlRule()->ignore($redirect->id)], 'new_url' => ['required', 'string'], 'status' => $this->getStatusRule(), ]; }
php
public function rules() { $redirect = $this->route('seo_redirect'); return [ 'old_url' => ['required', 'string', $this->getOldUrlRule()->ignore($redirect->id)], 'new_url' => ['required', 'string'], 'status' => $this->getStatusRule(), ]; }
Get the validation rules that apply to the request. @return array
https://github.com/ARCANESOFT/SEO/blob/ce6d6135d55e8b2fd43cf7923839b4791b7c7ad2/src/Http/Requests/Admin/Redirects/UpdateRedirectRequest.php#L31-L40
togucms/TemplateBundle
Syntax/AbstractSyntax.php
AbstractSyntax.openTag
public function openTag($string) { array_push($this->context, $this->currentContext); $this->write($string); $this->write($this->innerCode); $this->innerCode = ""; }
php
public function openTag($string) { array_push($this->context, $this->currentContext); $this->write($string); $this->write($this->innerCode); $this->innerCode = ""; }
{@inheritdoc}
https://github.com/togucms/TemplateBundle/blob/b07d3bff948d547e95f81154503dfa3a333eef64/Syntax/AbstractSyntax.php#L50-L56
togucms/TemplateBundle
Syntax/AbstractSyntax.php
AbstractSyntax.closeTag
public function closeTag($string) { $this->write($string); $this->currentContext = array_pop($this->context); }
php
public function closeTag($string) { $this->write($string); $this->currentContext = array_pop($this->context); }
{@inheritdoc}
https://github.com/togucms/TemplateBundle/blob/b07d3bff948d547e95f81154503dfa3a333eef64/Syntax/AbstractSyntax.php#L61-L64
togucms/TemplateBundle
Syntax/AbstractSyntax.php
AbstractSyntax.write
public function write($string) { $context = end($this->context); if(! $context) { return; } $this->templates[$context] .= $string; }
php
public function write($string) { $context = end($this->context); if(! $context) { return; } $this->templates[$context] .= $string; }
{@inheritdoc}
https://github.com/togucms/TemplateBundle/blob/b07d3bff948d547e95f81154503dfa3a333eef64/Syntax/AbstractSyntax.php#L69-L75
togucms/TemplateBundle
Syntax/AbstractSyntax.php
AbstractSyntax.style
public function style($cssProperty, $prefix, $variable, $filter, $suffix) { return $this->callMethod('style', array($cssProperty, $prefix, $variable, $filter, $suffix)); }
php
public function style($cssProperty, $prefix, $variable, $filter, $suffix) { return $this->callMethod('style', array($cssProperty, $prefix, $variable, $filter, $suffix)); }
{@inheritdoc}
https://github.com/togucms/TemplateBundle/blob/b07d3bff948d547e95f81154503dfa3a333eef64/Syntax/AbstractSyntax.php#L87-L89
togucms/TemplateBundle
Syntax/AbstractSyntax.php
AbstractSyntax.link
public function link($attr, $prefix, $variable, $filter, $suffix) { return $this->callMethod('link', array($attr, $prefix, $variable, $filter, $suffix)); }
php
public function link($attr, $prefix, $variable, $filter, $suffix) { return $this->callMethod('link', array($attr, $prefix, $variable, $filter, $suffix)); }
{@inheritdoc}
https://github.com/togucms/TemplateBundle/blob/b07d3bff948d547e95f81154503dfa3a333eef64/Syntax/AbstractSyntax.php#L108-L110
PenoaksDev/Milky-Framework
src/Milky/Logging/LogBuilder.php
LogBuilder.build
public static function build( Framework $fw ) { $log = static::registerLogger( $fw ); // If a custom Monolog configurator has been registered for the application // we will call that, passing Monolog along. Otherwise, we will grab the // the configurations for the log system and use it for configuration. if ( $fw->hasMonologConfigurator() ) call_user_func( $fw->getMonologConfigurator(), $log->getMonolog() ); else static::configureHandlers( $fw, Config::get( 'app.log' ), $log ); return $log; }
php
public static function build( Framework $fw ) { $log = static::registerLogger( $fw ); // If a custom Monolog configurator has been registered for the application // we will call that, passing Monolog along. Otherwise, we will grab the // the configurations for the log system and use it for configuration. if ( $fw->hasMonologConfigurator() ) call_user_func( $fw->getMonologConfigurator(), $log->getMonolog() ); else static::configureHandlers( $fw, Config::get( 'app.log' ), $log ); return $log; }
Bootstrap the given application. @param Framework $fw
https://github.com/PenoaksDev/Milky-Framework/blob/8afd7156610a70371aa5b1df50b8a212bf7b142c/src/Milky/Logging/LogBuilder.php#L24-L37
PenoaksDev/Milky-Framework
src/Milky/Logging/LogBuilder.php
LogBuilder.configureHandlers
protected function configureHandlers( Framework $fw, $handler, Logger $log ) { switch ( strtolower( $handler ) ) { case "single": { $log->useFiles( $fw->buildPath( '__logs', 'http.log' ), Config::get( 'app.log_level', 'debug' ) ); break; } case "daily": { $maxFiles = Config::get( 'app.log_max_files' ); $log->useDailyFiles( $fw->buildPath( '__logs', 'http.log' ), is_null( $maxFiles ) ? 5 : $maxFiles, Config::get( 'app.log_level', 'debug' ) ); break; } case "syslog": { $log->useSyslog( 'framework', Config::get( 'app.log_level', 'debug' ) ); break; } case "errorlog": { $log->useErrorLog( Config::get( 'app.log_level', 'debug' ) ); break; } default: throw new FrameworkException( "The string [" . $handler . "] is not a valid log handler." ); } }
php
protected function configureHandlers( Framework $fw, $handler, Logger $log ) { switch ( strtolower( $handler ) ) { case "single": { $log->useFiles( $fw->buildPath( '__logs', 'http.log' ), Config::get( 'app.log_level', 'debug' ) ); break; } case "daily": { $maxFiles = Config::get( 'app.log_max_files' ); $log->useDailyFiles( $fw->buildPath( '__logs', 'http.log' ), is_null( $maxFiles ) ? 5 : $maxFiles, Config::get( 'app.log_level', 'debug' ) ); break; } case "syslog": { $log->useSyslog( 'framework', Config::get( 'app.log_level', 'debug' ) ); break; } case "errorlog": { $log->useErrorLog( Config::get( 'app.log_level', 'debug' ) ); break; } default: throw new FrameworkException( "The string [" . $handler . "] is not a valid log handler." ); } }
Configure the Monolog handlers for the application. @param string $handler @param Logger $log
https://github.com/PenoaksDev/Milky-Framework/blob/8afd7156610a70371aa5b1df50b8a212bf7b142c/src/Milky/Logging/LogBuilder.php#L56-L84
Vectrex/vxPHP
src/Form/FormElement/LabelElement.php
LabelElement.setAttribute
public function setAttribute($attr, $value) { $attr = strtolower($attr); if(is_null($value)) { unset($this->attributes[$attr]); } else { $this->attributes[$attr] = $value; } return $this; }
php
public function setAttribute($attr, $value) { $attr = strtolower($attr); if(is_null($value)) { unset($this->attributes[$attr]); } else { $this->attributes[$attr] = $value; } return $this; }
sets attributes of form label @param string $attr @param string $value @return LabelElement
https://github.com/Vectrex/vxPHP/blob/295c21b00e7ef6085efcdf5b64fabb28d499b5a6/src/Form/FormElement/LabelElement.php#L80-L94
Vectrex/vxPHP
src/Form/FormElement/LabelElement.php
LabelElement.render
public function render() { $attr = []; foreach($this->attributes as $k => $v) { $attr[] = sprintf('%s="%s"', $k, $v); } return sprintf('<label %s>%s</label>', implode(' ', $attr), trim($this->labelText) ); }
php
public function render() { $attr = []; foreach($this->attributes as $k => $v) { $attr[] = sprintf('%s="%s"', $k, $v); } return sprintf('<label %s>%s</label>', implode(' ', $attr), trim($this->labelText) ); }
render the label element if a form element was assigned a matching "for" attribute can be generated @return string
https://github.com/Vectrex/vxPHP/blob/295c21b00e7ef6085efcdf5b64fabb28d499b5a6/src/Form/FormElement/LabelElement.php#L119-L133
kambalabs/KmbPmProxy
src/KmbPmProxy/Hydrator/GroupClassHydratorFactory.php
GroupClassHydratorFactory.createService
public function createService(ServiceLocatorInterface $serviceLocator) { $service = new GroupClassHydrator(); /** @var GroupParameterHydratorInterface $groupParameterHydrator */ $groupParameterHydrator = $serviceLocator->get('pmProxyGroupParameterHydrator'); $service->setGroupParameterHydrator($groupParameterHydrator); return $service; }
php
public function createService(ServiceLocatorInterface $serviceLocator) { $service = new GroupClassHydrator(); /** @var GroupParameterHydratorInterface $groupParameterHydrator */ $groupParameterHydrator = $serviceLocator->get('pmProxyGroupParameterHydrator'); $service->setGroupParameterHydrator($groupParameterHydrator); return $service; }
Create service @param ServiceLocatorInterface $serviceLocator @return mixed
https://github.com/kambalabs/KmbPmProxy/blob/b4c664ae8b6f29e4e8768461ed99e1b0b80bde18/src/KmbPmProxy/Hydrator/GroupClassHydratorFactory.php#L34-L43
onoi/event-dispatcher
src/DispatchContext.php
DispatchContext.newFromArray
public static function newFromArray( array $container ) { $dispatchContext = new DispatchContext(); foreach ( $container as $key => $value ) { $dispatchContext->set( $key, $value ); } return $dispatchContext; }
php
public static function newFromArray( array $container ) { $dispatchContext = new DispatchContext(); foreach ( $container as $key => $value ) { $dispatchContext->set( $key, $value ); } return $dispatchContext; }
@since 1.1 @param array $container @return DispatchContext
https://github.com/onoi/event-dispatcher/blob/2af64e3997fc59b6d1e1f8f77e65fd6311c37109/src/DispatchContext.php#L30-L38
onoi/event-dispatcher
src/DispatchContext.php
DispatchContext.get
public function get( $key ) { if ( $this->has( $key ) ) { return $this->container[strtolower( $key )]; } throw new InvalidArgumentException( "{$key} is unknown" ); }
php
public function get( $key ) { if ( $this->has( $key ) ) { return $this->container[strtolower( $key )]; } throw new InvalidArgumentException( "{$key} is unknown" ); }
@since 1.0 @param string $key @return mixed @throws InvalidArgumentException
https://github.com/onoi/event-dispatcher/blob/2af64e3997fc59b6d1e1f8f77e65fd6311c37109/src/DispatchContext.php#L69-L76
vainproject/vain-user
src/User/Http/Middleware/EnsurePermission.php
EnsurePermission.handle
public function handle($request, Closure $next, $value) { if (\Gate::denies($value)) { app()->abort(403, 'Missing permission \''.$value.'\''); } return $next($request); }
php
public function handle($request, Closure $next, $value) { if (\Gate::denies($value)) { app()->abort(403, 'Missing permission \''.$value.'\''); } return $next($request); }
Handle an incoming request. @param \Illuminate\Http\Request $request @param \Closure $next @param $value @return mixed
https://github.com/vainproject/vain-user/blob/1c059faa61ebf289fcaea39a90b4523cfc9d6efc/src/User/Http/Middleware/EnsurePermission.php#L18-L25
DeimosProject/Helper
src/Helper/Helpers/Str/Str.php
Str.shorten
public function shorten($str, $length = 100, $end = '&#8230;') { if (strlen($str) > $length) { $str = \substr(trim($str), 0, $length); $str = \substr($str, 0, -\strpos(\strrev($str), ' ')); $str = \trim($str . $end); } return $str; }
php
public function shorten($str, $length = 100, $end = '&#8230;') { if (strlen($str) > $length) { $str = \substr(trim($str), 0, $length); $str = \substr($str, 0, -\strpos(\strrev($str), ' ')); $str = \trim($str . $end); } return $str; }
Shortens text to length and keeps integrity of words @param string $str @param integer $length @param string $end @return string
https://github.com/DeimosProject/Helper/blob/39c67de21a87c7c6391b2f98416063f41c94e26f/src/Helper/Helpers/Str/Str.php#L80-L91
DeimosProject/Helper
src/Helper/Helpers/Str/Str.php
Str.ucFirst
public function ucFirst($string) { $first = $this->sub($string, 0, 1); $first = $this->upp($first); return $first . $this->sub($string, 1); }
php
public function ucFirst($string) { $first = $this->sub($string, 0, 1); $first = $this->upp($first); return $first . $this->sub($string, 1); }
@param string $string @return string
https://github.com/DeimosProject/Helper/blob/39c67de21a87c7c6391b2f98416063f41c94e26f/src/Helper/Helpers/Str/Str.php#L98-L104
DeimosProject/Helper
src/Helper/Helpers/Str/Str.php
Str.lcFirst
public function lcFirst($string) { $first = $this->sub($string, 0, 1); $first = $this->low($first); return $first . $this->sub($string, 1); }
php
public function lcFirst($string) { $first = $this->sub($string, 0, 1); $first = $this->low($first); return $first . $this->sub($string, 1); }
@param string $string @return string
https://github.com/DeimosProject/Helper/blob/39c67de21a87c7c6391b2f98416063f41c94e26f/src/Helper/Helpers/Str/Str.php#L111-L117
DeimosProject/Helper
src/Helper/Helpers/Str/Str.php
Str.random
public function random($length = 32, $type = self::RAND_ALL) { $string = ''; // todo: make to halper? foreach ($this->dictionary as $pos => $item) { $key = (1 << $pos); if ($type >= $key) { $string .= $item; $type -= $key; } } if (empty($string)) { throw new \InvalidArgumentException("Invalid random string type [{$type}]."); } return $this->rand($string, $length); }
php
public function random($length = 32, $type = self::RAND_ALL) { $string = ''; // todo: make to halper? foreach ($this->dictionary as $pos => $item) { $key = (1 << $pos); if ($type >= $key) { $string .= $item; $type -= $key; } } if (empty($string)) { throw new \InvalidArgumentException("Invalid random string type [{$type}]."); } return $this->rand($string, $length); }
Return random string @param int $length @param int $type @return string @throws \InvalidArgumentException
https://github.com/DeimosProject/Helper/blob/39c67de21a87c7c6391b2f98416063f41c94e26f/src/Helper/Helpers/Str/Str.php#L129-L150
DeimosProject/Helper
src/Helper/Helpers/Str/Str.php
Str.rand
protected function rand($chars, $length) { $string = ''; $max = $this->len($chars) - 1; $i = 0; while($i < $length) { $string .= $chars[\random_int(0, $max)]; $i++; } return $string; }
php
protected function rand($chars, $length) { $string = ''; $max = $this->len($chars) - 1; $i = 0; while($i < $length) { $string .= $chars[\random_int(0, $max)]; $i++; } return $string; }
@param string $chars @param int $length @return string
https://github.com/DeimosProject/Helper/blob/39c67de21a87c7c6391b2f98416063f41c94e26f/src/Helper/Helpers/Str/Str.php#L158-L171
DeimosProject/Helper
src/Helper/Helpers/Str/Str.php
Str.fileSize
public function fileSize($size, $decimals = 2) { switch (true) { case $size >= ((1 << 50) * 10): $postfix = 'PB'; $size /= (1 << 50); break; case $size >= ((1 << 40) * 10): $postfix = 'TB'; $size /= (1 << 40); break; case $size >= ((1 << 30) * 10): $postfix = 'GB'; $size /= (1 << 30); break; case $size >= ((1 << 20) * 10): $postfix = 'MB'; $size /= (1 << 20); break; case $size >= ((1 << 10) * 10): $postfix = 'KB'; $size /= (1 << 10); break; default: $postfix = 'B'; } return \round($size, $decimals) . ' ' . $postfix; }
php
public function fileSize($size, $decimals = 2) { switch (true) { case $size >= ((1 << 50) * 10): $postfix = 'PB'; $size /= (1 << 50); break; case $size >= ((1 << 40) * 10): $postfix = 'TB'; $size /= (1 << 40); break; case $size >= ((1 << 30) * 10): $postfix = 'GB'; $size /= (1 << 30); break; case $size >= ((1 << 20) * 10): $postfix = 'MB'; $size /= (1 << 20); break; case $size >= ((1 << 10) * 10): $postfix = 'KB'; $size /= (1 << 10); break; default: $postfix = 'B'; } return \round($size, $decimals) . ' ' . $postfix; }
@param int $size @param int $decimals @return string
https://github.com/DeimosProject/Helper/blob/39c67de21a87c7c6391b2f98416063f41c94e26f/src/Helper/Helpers/Str/Str.php#L187-L222
DeimosProject/Helper
src/Helper/Helpers/Str/Str.php
Str.translit
public function translit($string) { $string = \strtr($string, $this->transliterationTable); return \iconv(\mb_internal_encoding(), 'ASCII//TRANSLIT', $string); }
php
public function translit($string) { $string = \strtr($string, $this->transliterationTable); return \iconv(\mb_internal_encoding(), 'ASCII//TRANSLIT', $string); }
transliteration cyr->lat @param $string @return string
https://github.com/DeimosProject/Helper/blob/39c67de21a87c7c6391b2f98416063f41c94e26f/src/Helper/Helpers/Str/Str.php#L231-L236
eureka-framework/component-template
src/Template/Block.php
Block.end
public function end($name, $append = true) { $content = trim(ob_get_contents()); ob_end_clean(); $hash = md5($content); if (isset($this->hashCache[$hash])) { return; } $this->hashCache[$hash] = true; if (isset($this->blocks[$name]) && $append) { $this->blocks[$name] .= $content; } else { $this->blocks[$name] = $content; } }
php
public function end($name, $append = true) { $content = trim(ob_get_contents()); ob_end_clean(); $hash = md5($content); if (isset($this->hashCache[$hash])) { return; } $this->hashCache[$hash] = true; if (isset($this->blocks[$name]) && $append) { $this->blocks[$name] .= $content; } else { $this->blocks[$name] = $content; } }
End to catch block and save it. @param string $name @param bool $append Append content to previous block. Otherwise, reset content. @return void
https://github.com/eureka-framework/component-template/blob/42e9b3954b79892ba340ba7ca909f03ee99c36fe/src/Template/Block.php#L94-L112
intpro/seo
src/Executors/UpdateExecutor.php
UpdateExecutor.update
public function update(ARef $ref, OwnField $own, $value) { $type = $ref->getType(); $type_name = $type->getName(); $id = $ref->getId(); $own_type_name = $own->getFieldTypeName(); $own_name = $own->getName(); if($own_type_name !== 'seo') { throw new UpdateException('Seo не обрабатывает тип '.$own_type_name); } if(!is_string($value)) { $value = ''; //throw new UpdateException('Seo поле '.$own_name.' типа '.$own_type_name.' должно быть задано строкой!'); } $field = Seo::firstOrNew(['entity_name' => $type_name, 'entity_id' => $id, 'name' => $own_name]); $field->value = $value; $field->save(); }
php
public function update(ARef $ref, OwnField $own, $value) { $type = $ref->getType(); $type_name = $type->getName(); $id = $ref->getId(); $own_type_name = $own->getFieldTypeName(); $own_name = $own->getName(); if($own_type_name !== 'seo') { throw new UpdateException('Seo не обрабатывает тип '.$own_type_name); } if(!is_string($value)) { $value = ''; //throw new UpdateException('Seo поле '.$own_name.' типа '.$own_type_name.' должно быть задано строкой!'); } $field = Seo::firstOrNew(['entity_name' => $type_name, 'entity_id' => $id, 'name' => $own_name]); $field->value = $value; $field->save(); }
@param \Interpro\Core\Contracts\Ref\ARef $ref @param \Interpro\Core\Contracts\Taxonomy\Fields\OwnField $own @param mixed $value @return void
https://github.com/intpro/seo/blob/5e114d50bf8a2643c4e232cb0484bc5b5e44f375/src/Executors/UpdateExecutor.php#L28-L51
cloudtek/dynamodm
lib/Cloudtek/DynamoDM/Client/Operation.php
Operation.captureResponseMetadata
protected function captureResponseMetadata($response, $key) { if ($response instanceof \Aws\Exception\AwsException) { //TODO: AwsException->getTransferInfo()['http'] only has empty arrays, even with stats enabled? $this->addTransferStats(new TransferStats($response->getTransferInfo(), $this->getExecutedCommand($key)), $key); return; } $this->addTransferStats(new TransferStats($response['@metadata']['transferStats'], $this->getExecutedCommand($key)), $key); if (isset($response['ConsumedCapacity'])) { //make array structure uniform (single table operation vs. multi) $capacityMetadatas = isset($response['ConsumedCapacity']['TableName']) ? [$response['ConsumedCapacity']] : $response['ConsumedCapacity']; foreach ($capacityMetadatas as $capacityMetadata) { //if there is existing capacity consumption data for this table it needs to be merged with the new results $previousCapacity = isset($this->consumedCapacity[$capacityMetadata['TableName']]) ? $this->consumedCapacity[$capacityMetadata['TableName']] : null; $this->consumedCapacity[$capacityMetadata['TableName']] = new ConsumedCapacity( $capacityMetadata, $this->parameters['ReturnConsumedCapacity'], $previousCapacity ); } } if (!empty($response['ItemCollectionMetrics'])) { foreach ($response['ItemCollectionMetrics'] as $tableName => $collections) { foreach ($collections as $collection) { $this->itemCollectionMetrics[$tableName][current($collection['ItemCollectionKey'])] = new ItemCollectionMetrics($collection); } } } }
php
protected function captureResponseMetadata($response, $key) { if ($response instanceof \Aws\Exception\AwsException) { //TODO: AwsException->getTransferInfo()['http'] only has empty arrays, even with stats enabled? $this->addTransferStats(new TransferStats($response->getTransferInfo(), $this->getExecutedCommand($key)), $key); return; } $this->addTransferStats(new TransferStats($response['@metadata']['transferStats'], $this->getExecutedCommand($key)), $key); if (isset($response['ConsumedCapacity'])) { //make array structure uniform (single table operation vs. multi) $capacityMetadatas = isset($response['ConsumedCapacity']['TableName']) ? [$response['ConsumedCapacity']] : $response['ConsumedCapacity']; foreach ($capacityMetadatas as $capacityMetadata) { //if there is existing capacity consumption data for this table it needs to be merged with the new results $previousCapacity = isset($this->consumedCapacity[$capacityMetadata['TableName']]) ? $this->consumedCapacity[$capacityMetadata['TableName']] : null; $this->consumedCapacity[$capacityMetadata['TableName']] = new ConsumedCapacity( $capacityMetadata, $this->parameters['ReturnConsumedCapacity'], $previousCapacity ); } } if (!empty($response['ItemCollectionMetrics'])) { foreach ($response['ItemCollectionMetrics'] as $tableName => $collections) { foreach ($collections as $collection) { $this->itemCollectionMetrics[$tableName][current($collection['ItemCollectionKey'])] = new ItemCollectionMetrics($collection); } } } }
@param \Aws\ResultInterface|\Aws\Exception\AwsException $response @param int|null $key For pooled/batched operations, the queue position of the response metadata. @return void
https://github.com/cloudtek/dynamodm/blob/119d355e2c5cbaef1f867970349b4432f5704fcd/lib/Cloudtek/DynamoDM/Client/Operation.php#L183-L219
cloudtek/dynamodm
lib/Cloudtek/DynamoDM/Client/Operation.php
Operation.getItemCollectionMetrics
public function getItemCollectionMetrics($collectionKey = null) { if ($collectionKey === null) { return $this->itemCollectionMetrics; } if (!isset($this->itemCollectionMetrics[$collectionKey])) { return null; } return $this->itemCollectionMetrics[$collectionKey]; }
php
public function getItemCollectionMetrics($collectionKey = null) { if ($collectionKey === null) { return $this->itemCollectionMetrics; } if (!isset($this->itemCollectionMetrics[$collectionKey])) { return null; } return $this->itemCollectionMetrics[$collectionKey]; }
@param mixed|null $collectionKey @return ItemCollectionMetrics|ItemCollectionMetrics[]|null
https://github.com/cloudtek/dynamodm/blob/119d355e2c5cbaef1f867970349b4432f5704fcd/lib/Cloudtek/DynamoDM/Client/Operation.php#L266-L277
cloudtek/dynamodm
lib/Cloudtek/DynamoDM/Client/Operation.php
Operation.makePrimingIterator
protected function makePrimingIterator(Iterator $iterator, ClassMetadata $class) { if (empty($this->primers)) { return $iterator; } return new PrimingIterator( $iterator, $class, new ReferencePrimer($this->dm, $this->dm->getUnitOfWork()), $this->primers, $this->refresh, $this->readOnly ); }
php
protected function makePrimingIterator(Iterator $iterator, ClassMetadata $class) { if (empty($this->primers)) { return $iterator; } return new PrimingIterator( $iterator, $class, new ReferencePrimer($this->dm, $this->dm->getUnitOfWork()), $this->primers, $this->refresh, $this->readOnly ); }
@param Iterator $iterator @return Iterator|PrimingIterator
https://github.com/cloudtek/dynamodm/blob/119d355e2c5cbaef1f867970349b4432f5704fcd/lib/Cloudtek/DynamoDM/Client/Operation.php#L326-L340
cloudtek/dynamodm
lib/Cloudtek/DynamoDM/Client/Operation.php
Operation.promise
public function promise($hydrationMode = self::RESULT_TYPE_HYDRATED) { /** @var PromiseInterface $promise */ $promise = new Promise(function () use (&$promise, $hydrationMode) { $promise->resolve($this->execute($hydrationMode)); }); return $promise; }
php
public function promise($hydrationMode = self::RESULT_TYPE_HYDRATED) { /** @var PromiseInterface $promise */ $promise = new Promise(function () use (&$promise, $hydrationMode) { $promise->resolve($this->execute($hydrationMode)); }); return $promise; }
@param int|null $hydrationMode @return PromiseInterface
https://github.com/cloudtek/dynamodm/blob/119d355e2c5cbaef1f867970349b4432f5704fcd/lib/Cloudtek/DynamoDM/Client/Operation.php#L347-L355
cloudtek/dynamodm
lib/Cloudtek/DynamoDM/Client/Operation.php
Operation.returnCapacityUsage
public function returnCapacityUsage($mode) { if ($mode === self::RETURN_CAPACITY_NONE) { unset($this->parameters['ReturnConsumedCapacity']); } else { $this->parameters['ReturnConsumedCapacity'] = $mode; } return $this; }
php
public function returnCapacityUsage($mode) { if ($mode === self::RETURN_CAPACITY_NONE) { unset($this->parameters['ReturnConsumedCapacity']); } else { $this->parameters['ReturnConsumedCapacity'] = $mode; } return $this; }
@param string $mode @return $this
https://github.com/cloudtek/dynamodm/blob/119d355e2c5cbaef1f867970349b4432f5704fcd/lib/Cloudtek/DynamoDM/Client/Operation.php#L392-L401
praxigento/mobi_mod_downline
Plugin/Magento/Framework/App/FrontControllerInterface.php
FrontControllerInterface.beforeDispatch
public function beforeDispatch( \Magento\Framework\App\FrontControllerInterface $subject, \Magento\Framework\App\RequestInterface $request ) { $code = $request->getParam(static::REQ_REFERRAL); if (!empty($code)) { $this->session->logout(); } $this->hlpRefCode->processHttpRequest($code); }
php
public function beforeDispatch( \Magento\Framework\App\FrontControllerInterface $subject, \Magento\Framework\App\RequestInterface $request ) { $code = $request->getParam(static::REQ_REFERRAL); if (!empty($code)) { $this->session->logout(); } $this->hlpRefCode->processHttpRequest($code); }
Extract referral code from GET-variable or cookie and save it into registry. @param \Magento\Framework\App\FrontControllerInterface $subject @param \Magento\Framework\App\RequestInterface $request
https://github.com/praxigento/mobi_mod_downline/blob/0f3c276dfff1aa029f9fd205ccfc56f207a2e75b/Plugin/Magento/Framework/App/FrontControllerInterface.php#L34-L43
kynx/zend-cache-psr6
src/CacheItem.php
CacheItem.expiresAfter
public function expiresAfter($time) { if ($time instanceof DateInterval) { $interval = $time; } elseif ((int) $time == $time) { $interval = new DateInterval('PT' . $time . 'S'); } else { throw new InvalidArgumentException(sprintf('Invalid $time "%s"', gettype($time))); } $this->expiration = new \DateTime(); $this->expiration->add($interval); return $this; }
php
public function expiresAfter($time) { if ($time instanceof DateInterval) { $interval = $time; } elseif ((int) $time == $time) { $interval = new DateInterval('PT' . $time . 'S'); } else { throw new InvalidArgumentException(sprintf('Invalid $time "%s"', gettype($time))); } $this->expiration = new \DateTime(); $this->expiration->add($interval); return $this; }
Sets the expiration time for this cache item. @param int|\DateInterval $time The period of time from the present after which the item MUST be considered expired. An integer parameter is understood to be the time in seconds until expiration. If null is passed explicitly, a default value MAY be used. If none is set, the value should be stored permanently or for as long as the implementation allows. @return static The called object.
https://github.com/kynx/zend-cache-psr6/blob/aa235ed01cef98e55e7e47b2b53ea7b7f88b12e9/src/CacheItem.php#L127-L140
jabernardo/lollipop-php
Library/Utils/Vars.php
Vars.fuse
static function fuse(&$opt1, $opt2) { return isset($opt1) ? $opt1 : (isset($opt2) ? $opt2 : null); }
php
static function fuse(&$opt1, $opt2) { return isset($opt1) ? $opt1 : (isset($opt2) ? $opt2 : null); }
Alternate a value to undefined variable @param reference &$opt1 Variable @param mixed $opt2 Alternative value @return mixed
https://github.com/jabernardo/lollipop-php/blob/004d80b21f7246bb3e08c7b9f74a165b0d3ca0f5/Library/Utils/Vars.php#L23-L25
rollerworks-graveyard/metadata
src/Driver/SingleBaseFileLocator.php
SingleBaseFileLocator.findMappingFile
public function findMappingFile($className) { $className = ltrim($className, '\\'); $fqcn = '\\'.$className; if (0 !== strpos($fqcn, $this->nsPrefix)) { return; } $classPath = substr($className, $this->nsPrefixLen); $filePath = $this->path.DIRECTORY_SEPARATOR.str_replace('\\', '.', $classPath).$this->fileExtension; if (is_file($filePath)) { return $filePath; } }
php
public function findMappingFile($className) { $className = ltrim($className, '\\'); $fqcn = '\\'.$className; if (0 !== strpos($fqcn, $this->nsPrefix)) { return; } $classPath = substr($className, $this->nsPrefixLen); $filePath = $this->path.DIRECTORY_SEPARATOR.str_replace('\\', '.', $classPath).$this->fileExtension; if (is_file($filePath)) { return $filePath; } }
{@inheritdoc}
https://github.com/rollerworks-graveyard/metadata/blob/5b07f564aad87709ca0d0b3e140e4dc4edf9d375/src/Driver/SingleBaseFileLocator.php#L76-L91
rollerworks-graveyard/metadata
src/Driver/SingleBaseFileLocator.php
SingleBaseFileLocator.getAllClassNames
public function getAllClassNames() { $classes = []; $nsPrefix = ltrim($this->nsPrefix.'\\', '\\'); $iterator = new \DirectoryIterator($this->path); foreach ($iterator as $file) { if (($fileName = $file->getBasename($this->fileExtension)) === $file->getBasename()) { continue; } // NOTE: All files found here means classes are not transient! $classes[] = $nsPrefix.str_replace('.', '\\', $fileName); } return $classes; }
php
public function getAllClassNames() { $classes = []; $nsPrefix = ltrim($this->nsPrefix.'\\', '\\'); $iterator = new \DirectoryIterator($this->path); foreach ($iterator as $file) { if (($fileName = $file->getBasename($this->fileExtension)) === $file->getBasename()) { continue; } // NOTE: All files found here means classes are not transient! $classes[] = $nsPrefix.str_replace('.', '\\', $fileName); } return $classes; }
{@inheritdoc}
https://github.com/rollerworks-graveyard/metadata/blob/5b07f564aad87709ca0d0b3e140e4dc4edf9d375/src/Driver/SingleBaseFileLocator.php#L96-L113
Vectrex/vxPHP
src/Template/TemplateBuffer.php
TemplateBuffer.includeFile
public function includeFile($templateFilename) { /* @deprecated use $this when accessing assigned variables */ $tpl = $this; eval('?>' . file_get_contents(Application::getInstance()->getRootPath() . (defined('TPL_PATH') ? str_replace('/', DIRECTORY_SEPARATOR, ltrim(TPL_PATH, '/')) : '') . $templateFilename )); }
php
public function includeFile($templateFilename) { /* @deprecated use $this when accessing assigned variables */ $tpl = $this; eval('?>' . file_get_contents(Application::getInstance()->getRootPath() . (defined('TPL_PATH') ? str_replace('/', DIRECTORY_SEPARATOR, ltrim(TPL_PATH, '/')) : '') . $templateFilename )); }
include another template file does only path handling included files are within the same scope as the including file @param string $templateFilename @throws \vxPHP\Application\Exception\ApplicationException
https://github.com/Vectrex/vxPHP/blob/295c21b00e7ef6085efcdf5b64fabb28d499b5a6/src/Template/TemplateBuffer.php#L44-L56
Vectrex/vxPHP
src/Template/TemplateBuffer.php
TemplateBuffer.includeControllerResponse
public function includeControllerResponse($controllerPath, $methodName = null, array $constructorArguments = null) { $namespaces = explode('\\', ltrim(str_replace('/', '\\', $controllerPath), '/\\')); if(count($namespaces) && $namespaces[0]) { $controller = '\\Controller\\'. implode('\\', array_map('ucfirst', $namespaces)) . 'Controller'; } else { throw new ConfigException(sprintf("Controller string '%s' cannot be parsed.", $controllerPath)); } // get instance and set method which will be called in render() method of controller $controllerClass = Application::getInstance()->getApplicationNamespace() . $controller; if(!$constructorArguments) { /** * @var Controller */ $instance = new $controllerClass(); } else { $instance = new $controllerClass(...$constructorArguments); } if($methodName) { return $instance->setExecutedMethod($methodName)->render(); } else { return $instance->setExecutedMethod('execute')->render(); } }
php
public function includeControllerResponse($controllerPath, $methodName = null, array $constructorArguments = null) { $namespaces = explode('\\', ltrim(str_replace('/', '\\', $controllerPath), '/\\')); if(count($namespaces) && $namespaces[0]) { $controller = '\\Controller\\'. implode('\\', array_map('ucfirst', $namespaces)) . 'Controller'; } else { throw new ConfigException(sprintf("Controller string '%s' cannot be parsed.", $controllerPath)); } // get instance and set method which will be called in render() method of controller $controllerClass = Application::getInstance()->getApplicationNamespace() . $controller; if(!$constructorArguments) { /** * @var Controller */ $instance = new $controllerClass(); } else { $instance = new $controllerClass(...$constructorArguments); } if($methodName) { return $instance->setExecutedMethod($methodName)->render(); } else { return $instance->setExecutedMethod('execute')->render(); } }
include controller output $controllerPath is [path/to/controller/]name_of_controller additional arguments can be passed on to the controller constructor @param string $controllerPath @param string $methodName @param array $constructorArguments @return string @throws ConfigException @throws \vxPHP\Application\Exception\ApplicationException
https://github.com/Vectrex/vxPHP/blob/295c21b00e7ef6085efcdf5b64fabb28d499b5a6/src/Template/TemplateBuffer.php#L71-L114
n2n/n2n-io
src/app/n2n/io/fs/FsPath.php
FsPath.createFile
public function createFile($perm) { if ($this->isFile()) return false; IoUtils::touch($this->path); IoUtils::chmod($this->path, $perm); return true; }
php
public function createFile($perm) { if ($this->isFile()) return false; IoUtils::touch($this->path); IoUtils::chmod($this->path, $perm); return true; }
Atomically creates a new, empty file named by this abstract path if and only if a file with this name does not yet exist. @return bool true if the named file does not exist and was successfully created; false if the named file already exists
https://github.com/n2n/n2n-io/blob/ff642e195f0c0db1273b6c067eff1192cf2cd987/src/app/n2n/io/fs/FsPath.php#L158-L165
phpffcms/ffcms-core
src/Helper/Mailer.php
Mailer.tpl
public function tpl(string $tpl, ?array $params = [], ?string $dir = null) { try { $this->message = App::$View->render($tpl, $params, $dir); } catch (SyntaxException $e) { } return $this; }
php
public function tpl(string $tpl, ?array $params = [], ?string $dir = null) { try { $this->message = App::$View->render($tpl, $params, $dir); } catch (SyntaxException $e) { } return $this; }
Set tpl file @param string $tpl @param array|null $params @param null|string $dir @return $this
https://github.com/phpffcms/ffcms-core/blob/44a309553ef9f115ccfcfd71f2ac6e381c612082/src/Helper/Mailer.php#L49-L56
phpffcms/ffcms-core
src/Helper/Mailer.php
Mailer.send
public function send(string $address, string $subject, ?string $message = null): bool { // try to get message from global if not passed direct if ($message === null) { $message = $this->message; } try { if ($message === null) { throw new \Exception('Message body is empty!'); } // try to build message and send it $message = (new \Swift_Message($subject)) ->setFrom($this->from) ->setTo($address) ->setBody($message, 'text/html'); $this->swift->send($message); return true; } catch (\Exception $e) { if (App::$Debug) { App::$Debug->addException($e); App::$Debug->addMessage('Send mail failed! Info: ' . $e->getMessage(), 'error'); } return false; } }
php
public function send(string $address, string $subject, ?string $message = null): bool { // try to get message from global if not passed direct if ($message === null) { $message = $this->message; } try { if ($message === null) { throw new \Exception('Message body is empty!'); } // try to build message and send it $message = (new \Swift_Message($subject)) ->setFrom($this->from) ->setTo($address) ->setBody($message, 'text/html'); $this->swift->send($message); return true; } catch (\Exception $e) { if (App::$Debug) { App::$Debug->addException($e); App::$Debug->addMessage('Send mail failed! Info: ' . $e->getMessage(), 'error'); } return false; } }
Set mail to address @param string $address @param string $subject @param null|string $message @return bool
https://github.com/phpffcms/ffcms-core/blob/44a309553ef9f115ccfcfd71f2ac6e381c612082/src/Helper/Mailer.php#L65-L91
agentmedia/phine-core
src/Core/Modules/Backend/LayoutForm.php
LayoutForm.Init
protected function Init() { $this->layout = new Layout(Request::GetData('layout')); $this->layoutRights = new LayoutRights($this->layout->GetUserGroupRights()); $this->InitAreas(); $this->AddNameField(); $this->AddAreasField(); $this->AddUserGroupField(); $this->AddSubmit(); return parent::Init(); }
php
protected function Init() { $this->layout = new Layout(Request::GetData('layout')); $this->layoutRights = new LayoutRights($this->layout->GetUserGroupRights()); $this->InitAreas(); $this->AddNameField(); $this->AddAreasField(); $this->AddUserGroupField(); $this->AddSubmit(); return parent::Init(); }
Initializes the layout form @return boolea
https://github.com/agentmedia/phine-core/blob/38c1be8d03ebffae950d00a96da3c612aff67832/src/Core/Modules/Backend/LayoutForm.php#L58-L68
agentmedia/phine-core
src/Core/Modules/Backend/LayoutForm.php
LayoutForm.AddUserGroupField
private function AddUserGroupField() { $name = 'UserGroup'; $field = new Select($name, ''); $field->AddOption('', Trans('Core.LayoutForm.NoGroup')); if ($this->layout->Exists() && $this->layout->GetUserGroup()) { $field->SetValue($this->layout->GetUserGroup()->GetID()); } DBSelectUtil::AddUserGroupOptions($field); $this->AddField($field); }
php
private function AddUserGroupField() { $name = 'UserGroup'; $field = new Select($name, ''); $field->AddOption('', Trans('Core.LayoutForm.NoGroup')); if ($this->layout->Exists() && $this->layout->GetUserGroup()) { $field->SetValue($this->layout->GetUserGroup()->GetID()); } DBSelectUtil::AddUserGroupOptions($field); $this->AddField($field); }
Adds the user group field
https://github.com/agentmedia/phine-core/blob/38c1be8d03ebffae950d00a96da3c612aff67832/src/Core/Modules/Backend/LayoutForm.php#L97-L109
agentmedia/phine-core
src/Core/Modules/Backend/LayoutForm.php
LayoutForm.AddAreasField
private function AddAreasField() { $name = 'Areas'; $field = Input::Text($name, join(', ' , $this->areaNames)); $this->AddField($field); if ($this->layout->Exists()) { $field->SetHtmlAttribute('readonly', 'readonly'); } else { $this->SetTransAttribute($name, 'placeholder'); $this->SetRequired($name); } }
php
private function AddAreasField() { $name = 'Areas'; $field = Input::Text($name, join(', ' , $this->areaNames)); $this->AddField($field); if ($this->layout->Exists()) { $field->SetHtmlAttribute('readonly', 'readonly'); } else { $this->SetTransAttribute($name, 'placeholder'); $this->SetRequired($name); } }
Adds the server path field to the form
https://github.com/agentmedia/phine-core/blob/38c1be8d03ebffae950d00a96da3c612aff67832/src/Core/Modules/Backend/LayoutForm.php#L132-L146
agentmedia/phine-core
src/Core/Modules/Backend/LayoutForm.php
LayoutForm.OnSuccess
protected function OnSuccess() { $action = Action::Update(); $isNew = !$this->layout->Exists(); if ($isNew) { $action = Action::Create(); $this->layout->SetUser(self::Guard()->GetUser()); } $oldFile = $isNew ? '' : PathUtil::LayoutTemplate($this->layout); $this->layout->SetName($this->Value('Name')); $this->layout->Save(); $logger = new Logger(self::Guard()->GetUser()); $logger->ReportLayoutAction($this->layout, $action); if ($this->CanAssignGroup()) { $this->SaveRights(); } if ($isNew) { $this->SaveAreas(); } $this->UpdateFiles($oldFile); $args = array('layout'=>$this->layout->GetID()); Response::Redirect(BackendRouter::ModuleUrl(new AreaList(), $args)); }
php
protected function OnSuccess() { $action = Action::Update(); $isNew = !$this->layout->Exists(); if ($isNew) { $action = Action::Create(); $this->layout->SetUser(self::Guard()->GetUser()); } $oldFile = $isNew ? '' : PathUtil::LayoutTemplate($this->layout); $this->layout->SetName($this->Value('Name')); $this->layout->Save(); $logger = new Logger(self::Guard()->GetUser()); $logger->ReportLayoutAction($this->layout, $action); if ($this->CanAssignGroup()) { $this->SaveRights(); } if ($isNew) { $this->SaveAreas(); } $this->UpdateFiles($oldFile); $args = array('layout'=>$this->layout->GetID()); Response::Redirect(BackendRouter::ModuleUrl(new AreaList(), $args)); }
Saves the layout
https://github.com/agentmedia/phine-core/blob/38c1be8d03ebffae950d00a96da3c612aff67832/src/Core/Modules/Backend/LayoutForm.php#L151-L176
ARCANESOFT/Blog
src/Models/Tag.php
Tag.getSelectData
public static function getSelectData() { $minutes = config('arcanesoft.blog.cache.tags.select-data', 5); /** @var \Illuminate\Database\Eloquent\Collection $categories */ return cache()->remember(self::SELECT_CACHE_NAME, $minutes, function () { $withTranslations = Blog::instance()->isTranslatable(); return self::all()->mapWithKeys(function (Tag $tag) use ($withTranslations) { return [ $tag->id => $withTranslations ? implode(' / ', $tag->getTranslations('name')) : $tag->name ]; }); })->toBase(); }
php
public static function getSelectData() { $minutes = config('arcanesoft.blog.cache.tags.select-data', 5); /** @var \Illuminate\Database\Eloquent\Collection $categories */ return cache()->remember(self::SELECT_CACHE_NAME, $minutes, function () { $withTranslations = Blog::instance()->isTranslatable(); return self::all()->mapWithKeys(function (Tag $tag) use ($withTranslations) { return [ $tag->id => $withTranslations ? implode(' / ', $tag->getTranslations('name')) : $tag->name ]; }); })->toBase(); }
Get the categories options for select input. @return \Illuminate\Support\Collection
https://github.com/ARCANESOFT/Blog/blob/2078fdfdcbccda161c02899b9e1f344f011b2859/src/Models/Tag.php#L76-L92
mrprompt/Silex-CORS
src/Cors.php
Cors.register
public function register(Application $app) { /** * Add the */ $app[self::HTTP_CORS] = $app->protect( function (Request $request, Response $response) use ($app) { $response->headers->set("Access-Control-Max-Age", "86400"); $response->headers->set("Access-Control-Allow-Origin", "*"); return $response; } ); }
php
public function register(Application $app) { /** * Add the */ $app[self::HTTP_CORS] = $app->protect( function (Request $request, Response $response) use ($app) { $response->headers->set("Access-Control-Max-Age", "86400"); $response->headers->set("Access-Control-Allow-Origin", "*"); return $response; } ); }
(non-PHPdoc) @see \Silex\ServiceProviderInterface::register()
https://github.com/mrprompt/Silex-CORS/blob/c79e8150749a7f9c19482a3879f13c2c6467e85b/src/Cors.php#L21-L34
mrprompt/Silex-CORS
src/Cors.php
Cors.boot
public function boot(Application $app) { $app->flush(); /* @var $routes \Symfony\Component\Routing\RouteCollection */ $routes = $app['routes']; /* @var $route \Silex\Route */ foreach ($routes->getIterator() as $id => $route) { $path = $route->getPath(); $headers = implode(',', [ 'Authorization', 'Accept', 'X-Request-With', 'Content-Type', 'X-Session-Token', 'X-Hmac-Hash', 'X-Time', 'X-Url' ]); /* @var $controller \Silex\Controller */ $controller = $app->match( $path, function () use ($headers) { return new Response( null, 204, [ "Allow" => "GET,POST,PUT,DELETE", "Access-Control-Max-Age" => 84600, "Access-Control-Allow-Origin" => "*", "Access-Control-Allow-Credentials" => "false", "Access-Control-Allow-Methods" => "GET,POST,PUT,DELETE", "Access-Control-Allow-Headers" => $headers ] ); } ); $controller->method('OPTIONS'); /* @var $controllerRoute \Silex\Route */ $controllerRoute = $controller->getRoute(); $controllerRoute->setCondition($route->getCondition()); $controllerRoute->setSchemes($route->getSchemes()); $controllerRoute->setMethods('OPTIONS'); } }
php
public function boot(Application $app) { $app->flush(); /* @var $routes \Symfony\Component\Routing\RouteCollection */ $routes = $app['routes']; /* @var $route \Silex\Route */ foreach ($routes->getIterator() as $id => $route) { $path = $route->getPath(); $headers = implode(',', [ 'Authorization', 'Accept', 'X-Request-With', 'Content-Type', 'X-Session-Token', 'X-Hmac-Hash', 'X-Time', 'X-Url' ]); /* @var $controller \Silex\Controller */ $controller = $app->match( $path, function () use ($headers) { return new Response( null, 204, [ "Allow" => "GET,POST,PUT,DELETE", "Access-Control-Max-Age" => 84600, "Access-Control-Allow-Origin" => "*", "Access-Control-Allow-Credentials" => "false", "Access-Control-Allow-Methods" => "GET,POST,PUT,DELETE", "Access-Control-Allow-Headers" => $headers ] ); } ); $controller->method('OPTIONS'); /* @var $controllerRoute \Silex\Route */ $controllerRoute = $controller->getRoute(); $controllerRoute->setCondition($route->getCondition()); $controllerRoute->setSchemes($route->getSchemes()); $controllerRoute->setMethods('OPTIONS'); } }
(non-PHPdoc) @see \Silex\ServiceProviderInterface::boot()
https://github.com/mrprompt/Silex-CORS/blob/c79e8150749a7f9c19482a3879f13c2c6467e85b/src/Cors.php#L40-L89
nails/module-blog
migrations/2.php
Migration2.execute
public function execute() { $this->query("ALTER TABLE `{{NAILS_DB_PREFIX}}blog_post` ADD `commentsEnabled` TINYINT(1) UNSIGNED NOT NULL DEFAULT '1' AFTER `seo_keywords`;"); $this->query("ALTER TABLE `{{NAILS_DB_PREFIX}}blog_post` ADD `commentsExpire` DATETIME NULL AFTER `commentsEnabled`;"); $this->query("ALTER TABLE `{{NAILS_DB_PREFIX}}blog_post` ADD `type` ENUM('TEXT','AUDIO','VIDEO','PHOTO') NOT NULL DEFAULT 'PHOTO' AFTER `slug`;"); $this->query("ALTER TABLE `{{NAILS_DB_PREFIX}}blog_post` ADD `video_url` VARCHAR(255) NULL DEFAULT NULL AFTER `image_id`;"); $this->query("ALTER TABLE `{{NAILS_DB_PREFIX}}blog_post` ADD `audio_url` VARCHAR(255) NULL DEFAULT NULL AFTER `video_url`;"); $this->query("UPDATE `{{NAILS_DB_PREFIX}}blog_post` SET type = 'TEXT' WHERE image_id IS NULL;"); }
php
public function execute() { $this->query("ALTER TABLE `{{NAILS_DB_PREFIX}}blog_post` ADD `commentsEnabled` TINYINT(1) UNSIGNED NOT NULL DEFAULT '1' AFTER `seo_keywords`;"); $this->query("ALTER TABLE `{{NAILS_DB_PREFIX}}blog_post` ADD `commentsExpire` DATETIME NULL AFTER `commentsEnabled`;"); $this->query("ALTER TABLE `{{NAILS_DB_PREFIX}}blog_post` ADD `type` ENUM('TEXT','AUDIO','VIDEO','PHOTO') NOT NULL DEFAULT 'PHOTO' AFTER `slug`;"); $this->query("ALTER TABLE `{{NAILS_DB_PREFIX}}blog_post` ADD `video_url` VARCHAR(255) NULL DEFAULT NULL AFTER `image_id`;"); $this->query("ALTER TABLE `{{NAILS_DB_PREFIX}}blog_post` ADD `audio_url` VARCHAR(255) NULL DEFAULT NULL AFTER `video_url`;"); $this->query("UPDATE `{{NAILS_DB_PREFIX}}blog_post` SET type = 'TEXT' WHERE image_id IS NULL;"); }
Execute the migration @return Void
https://github.com/nails/module-blog/blob/7b369c5209f4343fff7c7e2a22c237d5a95c8c24/migrations/2.php#L19-L27
itkg/core
src/Itkg/Core/CollectionAbstract.php
CollectionAbstract.getById
public function getById($id) { if (isset($this->elements[$id])) { return $this->elements[$id]; } throw new \InvalidArgumentException(sprintf('Element for id %s does not exist', $id)); }
php
public function getById($id) { if (isset($this->elements[$id])) { return $this->elements[$id]; } throw new \InvalidArgumentException(sprintf('Element for id %s does not exist', $id)); }
Get an entity by its ID @param $id @return EntityAbstract @throws \InvalidArgumentException
https://github.com/itkg/core/blob/e5e4efb05feb4d23b0df41f2b21fd095103e593b/src/Itkg/Core/CollectionAbstract.php#L47-L54
ekyna/PaymentBundle
Form/EventListener/BuildConfigSubscriber.php
BuildConfigSubscriber.buildConfigField
public function buildConfigField(FormEvent $event) { /** @var array $data */ $data = $event->getData(); if (is_null($data)) { return; } $propertyPath = is_array($data) ? '[factoryName]' : 'factoryName'; $factoryName = PropertyAccess::createPropertyAccessor()->getValue($data, $propertyPath); if (empty($factoryName)) { return; } $paymentFactory = $this->registry->getGatewayFactory($factoryName); $config = $paymentFactory->createConfig(); if (empty($config['payum.default_options'])) { return; } $form = $event->getForm(); $form->add('config', 'form', [ 'label' => 'ekyna_core.field.config', ]); $configForm = $form->get('config'); $propertyPath = is_array($data) ? '[config]' : 'config'; $firstTime = false == PropertyAccess::createPropertyAccessor()->getValue($data, $propertyPath); foreach ($config['payum.default_options'] as $name => $value) { $propertyPath = is_array($data) ? "[config][$name]" : "config[$name]"; if ($firstTime) { PropertyAccess::createPropertyAccessor()->setValue($data, $propertyPath, $value); } $type = 'text'; $options = array(); if (is_bool($value)) { $type = 'checkbox'; $options['attr'] = ['align_with_widget' => true]; } elseif(is_numeric($value)) { $type = is_float($value) ? 'number' : 'integer'; } elseif (is_array($value)) { continue; } $options['required'] = in_array($name, $config['payum.required_options']); $configForm->add($name, $type, $options); } $event->setData($data); }
php
public function buildConfigField(FormEvent $event) { /** @var array $data */ $data = $event->getData(); if (is_null($data)) { return; } $propertyPath = is_array($data) ? '[factoryName]' : 'factoryName'; $factoryName = PropertyAccess::createPropertyAccessor()->getValue($data, $propertyPath); if (empty($factoryName)) { return; } $paymentFactory = $this->registry->getGatewayFactory($factoryName); $config = $paymentFactory->createConfig(); if (empty($config['payum.default_options'])) { return; } $form = $event->getForm(); $form->add('config', 'form', [ 'label' => 'ekyna_core.field.config', ]); $configForm = $form->get('config'); $propertyPath = is_array($data) ? '[config]' : 'config'; $firstTime = false == PropertyAccess::createPropertyAccessor()->getValue($data, $propertyPath); foreach ($config['payum.default_options'] as $name => $value) { $propertyPath = is_array($data) ? "[config][$name]" : "config[$name]"; if ($firstTime) { PropertyAccess::createPropertyAccessor()->setValue($data, $propertyPath, $value); } $type = 'text'; $options = array(); if (is_bool($value)) { $type = 'checkbox'; $options['attr'] = ['align_with_widget' => true]; } elseif(is_numeric($value)) { $type = is_float($value) ? 'number' : 'integer'; } elseif (is_array($value)) { continue; } $options['required'] = in_array($name, $config['payum.required_options']); $configForm->add($name, $type, $options); } $event->setData($data); }
Builds the config field. @param FormEvent $event
https://github.com/ekyna/PaymentBundle/blob/1b4f4103b28e3a4f8dbfac2cbd872d728238f4d1/Form/EventListener/BuildConfigSubscriber.php#L38-L90
black-lamp/blcms-cart
models/SearchOrderStatus.php
SearchOrderStatus.search
public function search($params) { $query = OrderStatus::find(); // add conditions that should always apply here $dataProvider = new ActiveDataProvider([ 'query' => $query, ]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); return $dataProvider; } // grid filtering conditions $query->andFilterWhere([ 'id' => $this->id, ]); // $query->andFilterWhere(['like', 'title', $this->title]); return $dataProvider; }
php
public function search($params) { $query = OrderStatus::find(); // add conditions that should always apply here $dataProvider = new ActiveDataProvider([ 'query' => $query, ]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); return $dataProvider; } // grid filtering conditions $query->andFilterWhere([ 'id' => $this->id, ]); // $query->andFilterWhere(['like', 'title', $this->title]); return $dataProvider; }
Creates data provider instance with search query applied @param array $params @return ActiveDataProvider
https://github.com/black-lamp/blcms-cart/blob/314796eecae3ca4ed5fecfdc0231a738af50eba7/models/SearchOrderStatus.php#L40-L66
CodeMommy/TaskPHP
source/PHP.php
PHP.run
public static function run($path = '') { system(sprintf('start http://localhost')); if (empty($path)) { system(sprintf('php -S 0.0.0.0:80')); } else { system(sprintf('php -S 0.0.0.0:80 -t %s', $path)); } return 'http://localhost'; }
php
public static function run($path = '') { system(sprintf('start http://localhost')); if (empty($path)) { system(sprintf('php -S 0.0.0.0:80')); } else { system(sprintf('php -S 0.0.0.0:80 -t %s', $path)); } return 'http://localhost'; }
Run @param string $path @return string
https://github.com/CodeMommy/TaskPHP/blob/b07000e2caff89e1ea96988415ec4ac9b8880a22/source/PHP.php#L28-L37
TeknooSoftware/east-foundation
src/universal/Manager/Manager.php
Manager.receiveRequest
public function receiveRequest( ClientInterface $client, ServerRequestInterface $request ): ManagerInterface { $this->process([ 'request' => $request, 'client' => $client ]); return $this; }
php
public function receiveRequest( ClientInterface $client, ServerRequestInterface $request ): ManagerInterface { $this->process([ 'request' => $request, 'client' => $client ]); return $this; }
{@inheritdoc}
https://github.com/TeknooSoftware/east-foundation/blob/45ca97c83ba08b973877a472c731f27ca1e82cdf/src/universal/Manager/Manager.php#L58-L68
naucon/Utility
src/ArrayPath.php
ArrayPath.get
public function get($path = null) { if ($this->getShowPath()) { return $path; } else { $value = $this->array; $pathArrays = $this->explodePath('.', $path); foreach ($pathArrays as $key) { if (!empty($key) && is_array($value) && array_key_exists($key, $value) ) { $value = $value[$key]; } else { return null; } } return $value; } }
php
public function get($path = null) { if ($this->getShowPath()) { return $path; } else { $value = $this->array; $pathArrays = $this->explodePath('.', $path); foreach ($pathArrays as $key) { if (!empty($key) && is_array($value) && array_key_exists($key, $value) ) { $value = $value[$key]; } else { return null; } } return $value; } }
get a value by array path the path string contains the keys of the interlaced array - glued by a point. e.g. the path of the array $array['key1']['key2']['key3'] is 'key1.key2.key3' @param string $path array keys glued with a point @return mixed
https://github.com/naucon/Utility/blob/d225bb5d09d82400917f710c9d502949a66442c4/src/ArrayPath.php#L78-L97
Finesse/QueryScribe
src/QueryBricks/JoinTrait.php
JoinTrait.innerJoin
public function innerJoin($table, ...$criterion): self { $this->join[] = $this->joinArgumentsToJoinObject('INNER', $table, $criterion); return $this; }
php
public function innerJoin($table, ...$criterion): self { $this->join[] = $this->joinArgumentsToJoinObject('INNER', $table, $criterion); return $this; }
Adds a table joined with the "inner" rule. The first argument is a table name or an array where the first value is a table name and the second value is the table alias name. The rest arguments may have one of the following formats: - column1, rule, column1 — column compared to another column by the given rule. Include a table name to eliminate an ambiguity; - column1, column2 — column is equal to another column; - Closure – complex joining criterion; - array[] – criteria joined by the AND rule (the values are the arguments lists for this method); - Raw – raw SQL. @param string|\Closure|Query|StatementInterface|string[]|\Closure[]|self[]|StatementInterface[] $table @param string|\Closure|Query|StatementInterface|array[] $column1 @param string|\Closure|Query|StatementInterface|null $rule @param string|\Closure|Query|StatementInterface|null $column2 @return $this @throws InvalidArgumentException @throws InvalidReturnValueException
https://github.com/Finesse/QueryScribe/blob/4edba721e37693780d142229b3ecb0cd4004c7a5/src/QueryBricks/JoinTrait.php#L58-L62
Finesse/QueryScribe
src/QueryBricks/JoinTrait.php
JoinTrait.outerJoin
public function outerJoin($table, ...$criterion): self { $this->join[] = $this->joinArgumentsToJoinObject('OUTER', $table, $criterion); return $this; }
php
public function outerJoin($table, ...$criterion): self { $this->join[] = $this->joinArgumentsToJoinObject('OUTER', $table, $criterion); return $this; }
Adds a table joined with the "outer" rule. @see innerJoin The arguments format @return $this @throws InvalidArgumentException @throws InvalidReturnValueException
https://github.com/Finesse/QueryScribe/blob/4edba721e37693780d142229b3ecb0cd4004c7a5/src/QueryBricks/JoinTrait.php#L72-L76
Finesse/QueryScribe
src/QueryBricks/JoinTrait.php
JoinTrait.leftJoin
public function leftJoin($table, ...$criterion): self { $this->join[] = $this->joinArgumentsToJoinObject('LEFT', $table, $criterion); return $this; }
php
public function leftJoin($table, ...$criterion): self { $this->join[] = $this->joinArgumentsToJoinObject('LEFT', $table, $criterion); return $this; }
Adds a table joined with the "left" rule. @see innerJoin The arguments format @return $this @throws InvalidArgumentException @throws InvalidReturnValueException
https://github.com/Finesse/QueryScribe/blob/4edba721e37693780d142229b3ecb0cd4004c7a5/src/QueryBricks/JoinTrait.php#L86-L90
Finesse/QueryScribe
src/QueryBricks/JoinTrait.php
JoinTrait.rightJoin
public function rightJoin($table, ...$criterion): self { $this->join[] = $this->joinArgumentsToJoinObject('RIGHT', $table, $criterion); return $this; }
php
public function rightJoin($table, ...$criterion): self { $this->join[] = $this->joinArgumentsToJoinObject('RIGHT', $table, $criterion); return $this; }
Adds a table joined with the "right" rule. @see innerJoin The arguments format @return $this @throws InvalidArgumentException @throws InvalidReturnValueException
https://github.com/Finesse/QueryScribe/blob/4edba721e37693780d142229b3ecb0cd4004c7a5/src/QueryBricks/JoinTrait.php#L100-L104
Finesse/QueryScribe
src/QueryBricks/JoinTrait.php
JoinTrait.joinArgumentsToJoinObject
protected function joinArgumentsToJoinObject(string $type, $table, array $criterion = []): Join { if (is_array($table)) { $tableName = $table[0] ?? null; $tableAlias = $table[1] ?? null; } else { $tableName = $table; $tableAlias = null; } $tableName = $this->checkStringValue('Argument $tableName', $tableName); if ($tableAlias !== null && !is_string($tableAlias)) { return $this->handleException(InvalidArgumentException::create( 'Argument $tableAlias', $tableAlias, ['string', 'null'] )); } if ($criterion) { $criterion = $this->whereArgumentsToCriterion($criterion, 'AND', true); $criteria = ($criterion instanceof CriteriaCriterion && !$criterion->not) ? $criterion->criteria : [$criterion]; } else { $criteria = []; } return new Join($type, $tableName, $tableAlias, $criteria); }
php
protected function joinArgumentsToJoinObject(string $type, $table, array $criterion = []): Join { if (is_array($table)) { $tableName = $table[0] ?? null; $tableAlias = $table[1] ?? null; } else { $tableName = $table; $tableAlias = null; } $tableName = $this->checkStringValue('Argument $tableName', $tableName); if ($tableAlias !== null && !is_string($tableAlias)) { return $this->handleException(InvalidArgumentException::create( 'Argument $tableAlias', $tableAlias, ['string', 'null'] )); } if ($criterion) { $criterion = $this->whereArgumentsToCriterion($criterion, 'AND', true); $criteria = ($criterion instanceof CriteriaCriterion && !$criterion->not) ? $criterion->criteria : [$criterion]; } else { $criteria = []; } return new Join($type, $tableName, $tableAlias, $criteria); }
Converts `join` method arguments to a join object @see innerJoin The arguments format @params string $type The join type (INNER, LEFT, etc.) @params mixed $table The joined table @params array The join criterion arguments @return Join @throws InvalidArgumentException @throws InvalidReturnValueException
https://github.com/Finesse/QueryScribe/blob/4edba721e37693780d142229b3ecb0cd4004c7a5/src/QueryBricks/JoinTrait.php#L163-L192
benjamindulau/AnoDataGrid
src/Ano/DataGrid/Column/Column.php
Column.createView
public function createView(DataGridView $dataGrid) { $view = new ColumnView($dataGrid); $this->getType()->buildView($view, $this); return $view; }
php
public function createView(DataGridView $dataGrid) { $view = new ColumnView($dataGrid); $this->getType()->buildView($view, $this); return $view; }
{@inheritDoc}
https://github.com/benjamindulau/AnoDataGrid/blob/69b31803929b04e9d6e807bb2213b9b3477d0367/src/Ano/DataGrid/Column/Column.php#L100-L106
benjamindulau/AnoDataGrid
src/Ano/DataGrid/Column/Column.php
Column.validateOptions
public function validateOptions(array $options = array()) { $self = $this; array_walk($options, function($value, $key) use ($self) { if (!in_array($key, $self->getAllowedOptions())) { throw new NotAllowedOptionException(sprintf('Option "%s" is not allowed for column "%s"', $key, $self->getName() )); } }); }
php
public function validateOptions(array $options = array()) { $self = $this; array_walk($options, function($value, $key) use ($self) { if (!in_array($key, $self->getAllowedOptions())) { throw new NotAllowedOptionException(sprintf('Option "%s" is not allowed for column "%s"', $key, $self->getName() )); } }); }
{@inheritDoc}
https://github.com/benjamindulau/AnoDataGrid/blob/69b31803929b04e9d6e807bb2213b9b3477d0367/src/Ano/DataGrid/Column/Column.php#L133-L144
wb-crowdfusion/crowdfusion
system/core/classes/mvc/controllers/AbstractApiController.php
AbstractApiController.passthruParameter
protected function passthruParameter(&$dto, $variableName) { $reqName = str_replace('.','_', $variableName); if($this->Request->getParameter($reqName) !== null && $this->Request->getParameter($reqName) != '') $dto->setParameter($variableName, $this->Request->getParameter($reqName)); }
php
protected function passthruParameter(&$dto, $variableName) { $reqName = str_replace('.','_', $variableName); if($this->Request->getParameter($reqName) !== null && $this->Request->getParameter($reqName) != '') $dto->setParameter($variableName, $this->Request->getParameter($reqName)); }
copied from AbstractController
https://github.com/wb-crowdfusion/crowdfusion/blob/8cad7988f046a6fefbed07d026cb4ae6706c1217/system/core/classes/mvc/controllers/AbstractApiController.php#L135-L139
wb-crowdfusion/crowdfusion
system/core/classes/mvc/controllers/AbstractApiController.php
AbstractApiController.buildLimitOffset
protected function buildLimitOffset(&$dto) { $dto->isRetrieveTotalRecords(true); $offset = $this->Request->getParameter('Offset'); $maxrows = $this->Request->getParameter('MaxRows'); $page = $this->Request->getParameter('Page'); if(empty($maxrows) || !is_numeric($maxrows)) { $dto->setLimit(25); } else { $dto->setLimit($maxrows); } if(!empty($offset) && is_numeric($offset)) { $dto->setOffset($offset); } else if(empty($maxrows) || empty($page) || !is_numeric($maxrows) || !is_numeric($page)) { // nothing } else { // set StartItem & EndItem as template variables //$this->templateVars['StartItem'] = $maxrows * ($page - 1) + 1; //$this->templateVars['EndItem'] = $this->Request->getParameter('StartItem') + $maxrows - 1; $dto->setOffset($maxrows * ($page - 1)); } }
php
protected function buildLimitOffset(&$dto) { $dto->isRetrieveTotalRecords(true); $offset = $this->Request->getParameter('Offset'); $maxrows = $this->Request->getParameter('MaxRows'); $page = $this->Request->getParameter('Page'); if(empty($maxrows) || !is_numeric($maxrows)) { $dto->setLimit(25); } else { $dto->setLimit($maxrows); } if(!empty($offset) && is_numeric($offset)) { $dto->setOffset($offset); } else if(empty($maxrows) || empty($page) || !is_numeric($maxrows) || !is_numeric($page)) { // nothing } else { // set StartItem & EndItem as template variables //$this->templateVars['StartItem'] = $maxrows * ($page - 1) + 1; //$this->templateVars['EndItem'] = $this->Request->getParameter('StartItem') + $maxrows - 1; $dto->setOffset($maxrows * ($page - 1)); } }
copied from AbstractWebController changed templateVars to use Request->getParameter()
https://github.com/wb-crowdfusion/crowdfusion/blob/8cad7988f046a6fefbed07d026cb4ae6706c1217/system/core/classes/mvc/controllers/AbstractApiController.php#L403-L435
cloudtek/dynamodm
lib/Cloudtek/DynamoDM/Tool/Console/Command/Schema/UpdateCommand.php
UpdateCommand.configure
protected function configure() { $this ->setName('dynamodm:schema:update') ->addOption('class', 'c', InputOption::VALUE_OPTIONAL, 'Document class to process (default: all classes)') ->addOption(self::OPTION_DOCUMENT, 'd', InputOption::VALUE_NONE, 'Update tables mapped to document classes') ->addOption(self::OPTION_GENERATOR, 'g', InputOption::VALUE_NONE, 'Update tables used by value generators') ->setDescription('Update tables associated with your documents'); }
php
protected function configure() { $this ->setName('dynamodm:schema:update') ->addOption('class', 'c', InputOption::VALUE_OPTIONAL, 'Document class to process (default: all classes)') ->addOption(self::OPTION_DOCUMENT, 'd', InputOption::VALUE_NONE, 'Update tables mapped to document classes') ->addOption(self::OPTION_GENERATOR, 'g', InputOption::VALUE_NONE, 'Update tables used by value generators') ->setDescription('Update tables associated with your documents'); }
{@inheritdoc}
https://github.com/cloudtek/dynamodm/blob/119d355e2c5cbaef1f867970349b4432f5704fcd/lib/Cloudtek/DynamoDM/Tool/Console/Command/Schema/UpdateCommand.php#L14-L22
cloudtek/dynamodm
lib/Cloudtek/DynamoDM/Tool/Console/Command/Schema/UpdateCommand.php
UpdateCommand.execute
protected function execute(InputInterface $input, OutputInterface $output) { $modes = array_filter($this->modes, function ($option) use ($input) { return $input->getOption($option); }); // Default to all modes if none explictly specified $modes = empty($modes) ? $this->modes : $modes; $class = $input->getOption('class'); $isErrored = false; foreach ($modes as $mode) { try { $this->process($mode, $class); $output->writeln(sprintf( 'Updated <comment>%s table%s</comment> for <info>%s</info>', $mode, !isset($class) || $mode === self::OPTION_GENERATOR ? 's' : '', isset($class) ? $class : 'all classes' )); } catch (\Exception $e) { $output->writeln('<error>' . $e->getMessage() . '</error>'); $isErrored = true; } } return $isErrored ? 255 : 0; }
php
protected function execute(InputInterface $input, OutputInterface $output) { $modes = array_filter($this->modes, function ($option) use ($input) { return $input->getOption($option); }); // Default to all modes if none explictly specified $modes = empty($modes) ? $this->modes : $modes; $class = $input->getOption('class'); $isErrored = false; foreach ($modes as $mode) { try { $this->process($mode, $class); $output->writeln(sprintf( 'Updated <comment>%s table%s</comment> for <info>%s</info>', $mode, !isset($class) || $mode === self::OPTION_GENERATOR ? 's' : '', isset($class) ? $class : 'all classes' )); } catch (\Exception $e) { $output->writeln('<error>' . $e->getMessage() . '</error>'); $isErrored = true; } } return $isErrored ? 255 : 0; }
{@inheritdoc}
https://github.com/cloudtek/dynamodm/blob/119d355e2c5cbaef1f867970349b4432f5704fcd/lib/Cloudtek/DynamoDM/Tool/Console/Command/Schema/UpdateCommand.php#L27-L55
cloudtek/dynamodm
lib/Cloudtek/DynamoDM/Tool/Console/Command/Schema/UpdateCommand.php
UpdateCommand.process
private function process($mode, $class) { //TODO: implement. needs custom waiter throw new \Exception; switch ($mode) { case self::OPTION_DOCUMENT: $class !== null ? $this->sm->createDocumentTableFor($class) : $this->sm->createAllDocumentTables(); break; case self::OPTION_GENERATOR: $class !== null ? $this->sm->createGeneratorTablesFor($class) : $this->sm->createAllGeneratorTables(); break; } }
php
private function process($mode, $class) { //TODO: implement. needs custom waiter throw new \Exception; switch ($mode) { case self::OPTION_DOCUMENT: $class !== null ? $this->sm->createDocumentTableFor($class) : $this->sm->createAllDocumentTables(); break; case self::OPTION_GENERATOR: $class !== null ? $this->sm->createGeneratorTablesFor($class) : $this->sm->createAllGeneratorTables(); break; } }
@param string $mode @param string|null $class @return void
https://github.com/cloudtek/dynamodm/blob/119d355e2c5cbaef1f867970349b4432f5704fcd/lib/Cloudtek/DynamoDM/Tool/Console/Command/Schema/UpdateCommand.php#L63-L76
enikeishik/ufoframework
src/Ufo/StorableCache/ArrayStorage.php
ArrayStorage.set
public function set(string $key, string $value, int $lifetime, int $savetime): bool { return true; }
php
public function set(string $key, string $value, int $lifetime, int $savetime): bool { return true; }
Persists data in the cache, uniquely referenced by a key with an optional lifetime and time to save. @param string $key The key of the item to store. @param string $value The value of the item to store. @param int $lifetime The lifetime value of this item. The library must store items with expired lifetime. @param int $savetime The time to save value of this item. The library can delete outdated items automatically with expired savetime. @return bool True on success and false on failure.
https://github.com/enikeishik/ufoframework/blob/fb44461bcb0506dbc3257724a2281f756594f62f/src/Ufo/StorableCache/ArrayStorage.php#L55-L58
AnonymPHP/Anonym-Route
RouteMatcher.php
RouteMatcher.matchWhen
public function matchWhen($url = null) { if (null !== $url) { $this->setMatchUrl($url); } return strpos($this->getRequestedUrl(), $this->getMatchUrl()) === 0; }
php
public function matchWhen($url = null) { if (null !== $url) { $this->setMatchUrl($url); } return strpos($this->getRequestedUrl(), $this->getMatchUrl()) === 0; }
match uri for when( method @param null|string $url @return bool
https://github.com/AnonymPHP/Anonym-Route/blob/bb7f8004fbbd2998af8b0061f404f026f11466ab/RouteMatcher.php#L71-L78
AnonymPHP/Anonym-Route
RouteMatcher.php
RouteMatcher.match
public function match($matchUrl = null) { if (null !== $matchUrl) { $this->setMatchUrl($matchUrl); } if ($this->isUrlEqual()) { return true; } else { return false; } }
php
public function match($matchUrl = null) { if (null !== $matchUrl) { $this->setMatchUrl($matchUrl); } if ($this->isUrlEqual()) { return true; } else { return false; } }
Eşleşmeyi yapar @param string $matchUrl @return bool
https://github.com/AnonymPHP/Anonym-Route/blob/bb7f8004fbbd2998af8b0061f404f026f11466ab/RouteMatcher.php#L86-L98
AnonymPHP/Anonym-Route
RouteMatcher.php
RouteMatcher.setMatchUrl
public function setMatchUrl($matchUrl) { $matchUrl = trim(str_replace('/', ' ', $matchUrl)); $this->matchUrl = $matchUrl; return $this; }
php
public function setMatchUrl($matchUrl) { $matchUrl = trim(str_replace('/', ' ', $matchUrl)); $this->matchUrl = $matchUrl; return $this; }
Eşleştirilecek url i ayarlar @param string $matchUrl @return RouteMatcher
https://github.com/AnonymPHP/Anonym-Route/blob/bb7f8004fbbd2998af8b0061f404f026f11466ab/RouteMatcher.php#L156-L161
AnonymPHP/Anonym-Route
RouteMatcher.php
RouteMatcher.getFilter
public function getFilter($name = '') { return isset($this->filters[$name]) ? $this->filters[$name] : false; }
php
public function getFilter($name = '') { return isset($this->filters[$name]) ? $this->filters[$name] : false; }
$name ile girilen filter 'ı arar @param string $name @return mixed
https://github.com/AnonymPHP/Anonym-Route/blob/bb7f8004fbbd2998af8b0061f404f026f11466ab/RouteMatcher.php#L187-L190
DreadLabs/VantomasWebsite
src/Disqus/Api.php
Api.query
public function query($resourceSignature, array $parameters = array()) { $this->resource->setResourceSignature($resourceSignature); $parameters['apiKey'] = $this->configuration->getApiKey(); $this->resource->setParameters($parameters); $this->client->connectTo($this->resource); $this->client->send(); $this->client->disconnect(); return $this->client->getResponse(); }
php
public function query($resourceSignature, array $parameters = array()) { $this->resource->setResourceSignature($resourceSignature); $parameters['apiKey'] = $this->configuration->getApiKey(); $this->resource->setParameters($parameters); $this->client->connectTo($this->resource); $this->client->send(); $this->client->disconnect(); return $this->client->getResponse(); }
{@inheritdoc}
https://github.com/DreadLabs/VantomasWebsite/blob/7f85f2b45bdf5ed9fa9d320c805c416bf99cd668/src/Disqus/Api.php#L59-L72
apioo/psx-validate
src/Filter/Collection.php
Collection.apply
public function apply($value) { $modified = false; foreach ($this->filters as $filter) { $result = $filter->apply($value); if ($result === false) { return false; } elseif ($result === true) { } else { $modified = true; $value = $result; } } return $modified ? $value : true; }
php
public function apply($value) { $modified = false; foreach ($this->filters as $filter) { $result = $filter->apply($value); if ($result === false) { return false; } elseif ($result === true) { } else { $modified = true; $value = $result; } } return $modified ? $value : true; }
Returns true if all filters allow the value @param mixed $value @return boolean
https://github.com/apioo/psx-validate/blob/4860c6a2c7f7ca52d3bd6d7e6ec7d6a7ddcfd83d/src/Filter/Collection.php#L53-L70
Linkvalue-Interne/MobileNotif
src/Model/GcmMessage.php
GcmMessage.getPayload
public function getPayload() { // GCM base payload structure $payload = array(); // Payload for single recipient or multicast? if (count($tokens = $this->getTokens()) == 1) { $payload['to'] = reset($tokens); } else { $payload['registration_ids'] = $tokens; } // Build notification if ($this->getNotificationTitle()) { $payload['notification']['title'] = $this->getNotificationTitle(); } if ($this->getNotificationBody()) { $payload['notification']['body'] = $this->getNotificationBody(); } if ($this->getNotificationIcon()) { $payload['notification']['icon'] = $this->getNotificationIcon(); } if ($this->getNotificationSound()) { $payload['notification']['sound'] = $this->getNotificationSound(); } if ($this->getNotificationTag()) { $payload['notification']['tag'] = $this->getNotificationTag(); } if ($this->getNotificationBadge()) { $payload['notification']['badge'] = $this->getNotificationBadge(); } if ($this->getNotificationColor()) { $payload['notification']['color'] = $this->getNotificationColor(); } if ($this->getNotificationClickAction()) { $payload['notification']['click_action'] = $this->getNotificationClickAction(); } if ($this->getNotificationBodyLocKey()) { $payload['notification']['body_loc_key'] = $this->getNotificationBodyLocKey(); } if ($this->getNotificationBodyLocArgs()) { $payload['notification']['body_loc_args'] = $this->getNotificationBodyLocArgs(); } if ($this->getNotificationTitleLocKey()) { $payload['notification']['title_loc_key'] = $this->getNotificationTitleLocKey(); } if ($this->getNotificationTitleLocArgs()) { $payload['notification']['title_loc_args'] = $this->getNotificationTitleLocArgs(); } // Build extra content if ($this->getCollapseKey()) { $payload['collapse_key'] = $this->getCollapseKey(); } if ($this->getPriority() !== self::DEFAULT_PRIORITY) { $payload['priority'] = $this->getPriority(); } if ($this->getRestrictedPackageName()) { $payload['restricted_package_name'] = $this->getRestrictedPackageName(); } if (!is_null($this->getContentAvailable())) { $payload['content_available'] = $this->getContentAvailable(); } if (!is_null($this->getDelayWhileIdle())) { $payload['delay_while_idle'] = $this->getDelayWhileIdle(); } if (!is_null($this->getDryRun())) { $payload['dry_run'] = $this->getDryRun(); } if (!is_null($this->getTimeToLive())) { $payload['time_to_live'] = $this->getTimeToLive(); } if ($this->getData()) { $payload['data'] = $this->getData(); } // Return payload return $payload; }
php
public function getPayload() { // GCM base payload structure $payload = array(); // Payload for single recipient or multicast? if (count($tokens = $this->getTokens()) == 1) { $payload['to'] = reset($tokens); } else { $payload['registration_ids'] = $tokens; } // Build notification if ($this->getNotificationTitle()) { $payload['notification']['title'] = $this->getNotificationTitle(); } if ($this->getNotificationBody()) { $payload['notification']['body'] = $this->getNotificationBody(); } if ($this->getNotificationIcon()) { $payload['notification']['icon'] = $this->getNotificationIcon(); } if ($this->getNotificationSound()) { $payload['notification']['sound'] = $this->getNotificationSound(); } if ($this->getNotificationTag()) { $payload['notification']['tag'] = $this->getNotificationTag(); } if ($this->getNotificationBadge()) { $payload['notification']['badge'] = $this->getNotificationBadge(); } if ($this->getNotificationColor()) { $payload['notification']['color'] = $this->getNotificationColor(); } if ($this->getNotificationClickAction()) { $payload['notification']['click_action'] = $this->getNotificationClickAction(); } if ($this->getNotificationBodyLocKey()) { $payload['notification']['body_loc_key'] = $this->getNotificationBodyLocKey(); } if ($this->getNotificationBodyLocArgs()) { $payload['notification']['body_loc_args'] = $this->getNotificationBodyLocArgs(); } if ($this->getNotificationTitleLocKey()) { $payload['notification']['title_loc_key'] = $this->getNotificationTitleLocKey(); } if ($this->getNotificationTitleLocArgs()) { $payload['notification']['title_loc_args'] = $this->getNotificationTitleLocArgs(); } // Build extra content if ($this->getCollapseKey()) { $payload['collapse_key'] = $this->getCollapseKey(); } if ($this->getPriority() !== self::DEFAULT_PRIORITY) { $payload['priority'] = $this->getPriority(); } if ($this->getRestrictedPackageName()) { $payload['restricted_package_name'] = $this->getRestrictedPackageName(); } if (!is_null($this->getContentAvailable())) { $payload['content_available'] = $this->getContentAvailable(); } if (!is_null($this->getDelayWhileIdle())) { $payload['delay_while_idle'] = $this->getDelayWhileIdle(); } if (!is_null($this->getDryRun())) { $payload['dry_run'] = $this->getDryRun(); } if (!is_null($this->getTimeToLive())) { $payload['time_to_live'] = $this->getTimeToLive(); } if ($this->getData()) { $payload['data'] = $this->getData(); } // Return payload return $payload; }
Get full message payload. @return array
https://github.com/Linkvalue-Interne/MobileNotif/blob/e6e4c4219f3bbb0aee32e90e5fdfc8c6a7ed53f6/src/Model/GcmMessage.php#L148-L226
Linkvalue-Interne/MobileNotif
src/Model/GcmMessage.php
GcmMessage.setTokens
public function setTokens(array $tokens) { if (count($tokens) > self::MULTICAST_MAX_TOKENS) { throw new \RuntimeException(sprintf('Too many tokens in the list. %s tokens max.', self::MULTICAST_MAX_TOKENS)); } return parent::setTokens($tokens); }
php
public function setTokens(array $tokens) { if (count($tokens) > self::MULTICAST_MAX_TOKENS) { throw new \RuntimeException(sprintf('Too many tokens in the list. %s tokens max.', self::MULTICAST_MAX_TOKENS)); } return parent::setTokens($tokens); }
{@inheritdoc } @throws \RuntimeException
https://github.com/Linkvalue-Interne/MobileNotif/blob/e6e4c4219f3bbb0aee32e90e5fdfc8c6a7ed53f6/src/Model/GcmMessage.php#L233-L240
Linkvalue-Interne/MobileNotif
src/Model/GcmMessage.php
GcmMessage.addToken
public function addToken($token) { if (count($this->tokens) + 1 > self::MULTICAST_MAX_TOKENS) { throw new \RuntimeException(sprintf('Max token number reached. %s tokens max.', self::MULTICAST_MAX_TOKENS)); } return parent::addToken($token); }
php
public function addToken($token) { if (count($this->tokens) + 1 > self::MULTICAST_MAX_TOKENS) { throw new \RuntimeException(sprintf('Max token number reached. %s tokens max.', self::MULTICAST_MAX_TOKENS)); } return parent::addToken($token); }
{@inheritdoc } @throws \RuntimeException
https://github.com/Linkvalue-Interne/MobileNotif/blob/e6e4c4219f3bbb0aee32e90e5fdfc8c6a7ed53f6/src/Model/GcmMessage.php#L247-L254
Linkvalue-Interne/MobileNotif
src/Model/GcmMessage.php
GcmMessage.setData
public function setData(array $data) { $reservedDataKeys = array( 'from', 'notification', 'to', 'registration_ids', 'collapse_key', 'priority', 'restricted_package_name', 'content_available', 'delay_while_idle', 'dry_run', 'time_to_live', 'data', ); foreach ($data as $key => $value) { if (!is_string($key)) { throw new \InvalidArgumentException('Data keys must be of type string in order to convert data in a valid JSON Object.'); } if (in_array($key, $reservedDataKeys) || strpos($key, 'google') === 0 || strpos($key, 'gcm') === 0 ) { throw new \InvalidArgumentException(sprintf( 'The key "%s" is reserved or not recommended. Do not use it as data key.', $key )); } } $this->data = $data; return $this; }
php
public function setData(array $data) { $reservedDataKeys = array( 'from', 'notification', 'to', 'registration_ids', 'collapse_key', 'priority', 'restricted_package_name', 'content_available', 'delay_while_idle', 'dry_run', 'time_to_live', 'data', ); foreach ($data as $key => $value) { if (!is_string($key)) { throw new \InvalidArgumentException('Data keys must be of type string in order to convert data in a valid JSON Object.'); } if (in_array($key, $reservedDataKeys) || strpos($key, 'google') === 0 || strpos($key, 'gcm') === 0 ) { throw new \InvalidArgumentException(sprintf( 'The key "%s" is reserved or not recommended. Do not use it as data key.', $key )); } } $this->data = $data; return $this; }
Set the value of Data. @param array $data @return self
https://github.com/Linkvalue-Interne/MobileNotif/blob/e6e4c4219f3bbb0aee32e90e5fdfc8c6a7ed53f6/src/Model/GcmMessage.php#L733-L771
cloudtek/dynamodm
lib/Cloudtek/DynamoDM/Persister/DocumentPersister.php
DocumentPersister.addFilterToQueryBuilder
public function addFilterToQueryBuilder(QueryBuilder $qb) { $filters = $this->dm->getFilterCollection()->getFilterCriteria($this->class); foreach ($filters as $filter) { $qb->addCriteria($filter); } }
php
public function addFilterToQueryBuilder(QueryBuilder $qb) { $filters = $this->dm->getFilterCollection()->getFilterCriteria($this->class); foreach ($filters as $filter) { $qb->addCriteria($filter); } }
Adds filter criteria to a QueryBuilder instance. @param QueryBuilder $qb @return void
https://github.com/cloudtek/dynamodm/blob/119d355e2c5cbaef1f867970349b4432f5704fcd/lib/Cloudtek/DynamoDM/Persister/DocumentPersister.php#L110-L117
cloudtek/dynamodm
lib/Cloudtek/DynamoDM/Persister/DocumentPersister.php
DocumentPersister.createDocument
private function createDocument($data, $document = null, $refresh = false) { if ($this->class->isLockable) { $lockAttribute = $this->class->getLockMetadata()->attributeName; if (isset($result[$lockAttribute]) && $data[$lockAttribute] === LockMode::PESSIMISTIC_WRITE) { throw LockException::lockFailed($data); } } if ($document !== null) { $refresh = true; $identifier = $this->class->createIdentifier($data); $this->uow->registerManaged($document, $identifier, $data); } return $this->uow->getOrCreateDocument($this->class, $data, $document, $refresh); }
php
private function createDocument($data, $document = null, $refresh = false) { if ($this->class->isLockable) { $lockAttribute = $this->class->getLockMetadata()->attributeName; if (isset($result[$lockAttribute]) && $data[$lockAttribute] === LockMode::PESSIMISTIC_WRITE) { throw LockException::lockFailed($data); } } if ($document !== null) { $refresh = true; $identifier = $this->class->createIdentifier($data); $this->uow->registerManaged($document, $identifier, $data); } return $this->uow->getOrCreateDocument($this->class, $data, $document, $refresh); }
Creates or fills a single document object from a query result. @param array $data Raw result data from DynamoDB. @param object $document The document object to fill, if any. @param bool $refresh Refresh hint for UnitOfWork behavior. @return object The filled and managed document object or NULL, if the query result is empty. @throws LockException
https://github.com/cloudtek/dynamodm/blob/119d355e2c5cbaef1f867970349b4432f5704fcd/lib/Cloudtek/DynamoDM/Persister/DocumentPersister.php#L131-L149
cloudtek/dynamodm
lib/Cloudtek/DynamoDM/Persister/DocumentPersister.php
DocumentPersister.createReferenceInverseSideQuery
public function createReferenceInverseSideQuery(PropertyMetadata $mapping, $owner) { $targetClass = $this->dm->getClassMetadata($mapping->targetDocument); $mappedBy = $targetClass->getPropertyMetadata($mapping->mappedBy); $qb = $this->dm->createQueryBuilder($mapping->targetDocument); //add the owning document's identifier as criteria for the mapped reference $qb->attr($mappedBy->name)->equals($owner); if ($mapping->mappedIndex !== null) { $qb->index($mapping->mappedIndex); //if mappedIndex is not set, requireIndexes is in effect and the //querybuilder cannot find a usable index then the query will throw //an exception on execution } if ($mapping->requireIndexes !== null) { //if configured this will override any setting on the dm or class $qb->requireIndexes($mapping->requireIndexes); } $qb->addCriteria((array)$mapping->criteria); foreach ((array)$mapping->prime as $attribute) { $qb->attr($attribute)->prime(true); } $query = $qb->getQuery(); $query->reverse($mapping->reverse); $query->limit($mapping->association === PropertyMetadata::ASSOCIATION_TYPE_REFERENCE_ONE ? 1 : $mapping->limit); return $query; }
php
public function createReferenceInverseSideQuery(PropertyMetadata $mapping, $owner) { $targetClass = $this->dm->getClassMetadata($mapping->targetDocument); $mappedBy = $targetClass->getPropertyMetadata($mapping->mappedBy); $qb = $this->dm->createQueryBuilder($mapping->targetDocument); //add the owning document's identifier as criteria for the mapped reference $qb->attr($mappedBy->name)->equals($owner); if ($mapping->mappedIndex !== null) { $qb->index($mapping->mappedIndex); //if mappedIndex is not set, requireIndexes is in effect and the //querybuilder cannot find a usable index then the query will throw //an exception on execution } if ($mapping->requireIndexes !== null) { //if configured this will override any setting on the dm or class $qb->requireIndexes($mapping->requireIndexes); } $qb->addCriteria((array)$mapping->criteria); foreach ((array)$mapping->prime as $attribute) { $qb->attr($attribute)->prime(true); } $query = $qb->getQuery(); $query->reverse($mapping->reverse); $query->limit($mapping->association === PropertyMetadata::ASSOCIATION_TYPE_REFERENCE_ONE ? 1 : $mapping->limit); return $query; }
Build and return a query capable of populating the given inverse-side reference. @param PropertyMetadata $mapping @param object $owner @return Query|Scan
https://github.com/cloudtek/dynamodm/blob/119d355e2c5cbaef1f867970349b4432f5704fcd/lib/Cloudtek/DynamoDM/Persister/DocumentPersister.php#L159-L193
cloudtek/dynamodm
lib/Cloudtek/DynamoDM/Persister/DocumentPersister.php
DocumentPersister.createReferenceManyWithRepositoryMethodIterator
private function createReferenceManyWithRepositoryMethodIterator(PersistentCollectionInterface $collection) { $mapping = $collection->getMapping(); $repositoryMethod = $mapping->repositoryMethod; $repository = $this->dm->getRepository($mapping->targetDocument); $iterator = $repository->$repositoryMethod($collection->getOwner()); if (!$iterator instanceof Iterator) { throw new \BadMethodCallException(sprintf('Expected repository method %s to return an iterable object', $repositoryMethod)); } if (!empty($mapping->prime)) { $referencePrimer = new ReferencePrimer($this->dm, $this->dm->getUnitOfWork()); $primers = array_combine($mapping->prime, array_fill(0, count($mapping->prime), true)); $class = $this->dm->getClassMetadata($mapping['targetDocument']); $iterator = new PrimingIterator( $iterator, $class, $referencePrimer, $primers, $collection->isReadOnly() ); } return $iterator; }
php
private function createReferenceManyWithRepositoryMethodIterator(PersistentCollectionInterface $collection) { $mapping = $collection->getMapping(); $repositoryMethod = $mapping->repositoryMethod; $repository = $this->dm->getRepository($mapping->targetDocument); $iterator = $repository->$repositoryMethod($collection->getOwner()); if (!$iterator instanceof Iterator) { throw new \BadMethodCallException(sprintf('Expected repository method %s to return an iterable object', $repositoryMethod)); } if (!empty($mapping->prime)) { $referencePrimer = new ReferencePrimer($this->dm, $this->dm->getUnitOfWork()); $primers = array_combine($mapping->prime, array_fill(0, count($mapping->prime), true)); $class = $this->dm->getClassMetadata($mapping['targetDocument']); $iterator = new PrimingIterator( $iterator, $class, $referencePrimer, $primers, $collection->isReadOnly() ); } return $iterator; }
@param PersistentCollectionInterface $collection @return Iterator
https://github.com/cloudtek/dynamodm/blob/119d355e2c5cbaef1f867970349b4432f5704fcd/lib/Cloudtek/DynamoDM/Persister/DocumentPersister.php#L200-L226
cloudtek/dynamodm
lib/Cloudtek/DynamoDM/Persister/DocumentPersister.php
DocumentPersister.delete
public function delete($document) { $qb = $this->dm->createQueryBuilder($this->class->name); $identifier = $this->uow->getDocumentIdentifier($document); $qb->delete(); $qb->setIdentifier($identifier); if ($this->class->isLockable) { $qb->attr($this->class->lockMetadata->name)->exists(false); } try { $qb->getQuery()->execute(); } catch (\Aws\DynamoDb\Exception\DynamoDbException $e) { if ( ($this->class->isVersioned || $this->class->isLockable) && $e->getAwsErrorCode() === 'ConditionalCheckFailedException' ) { throw LockException::lockFailed($document); } throw $e; } }
php
public function delete($document) { $qb = $this->dm->createQueryBuilder($this->class->name); $identifier = $this->uow->getDocumentIdentifier($document); $qb->delete(); $qb->setIdentifier($identifier); if ($this->class->isLockable) { $qb->attr($this->class->lockMetadata->name)->exists(false); } try { $qb->getQuery()->execute(); } catch (\Aws\DynamoDb\Exception\DynamoDbException $e) { if ( ($this->class->isVersioned || $this->class->isLockable) && $e->getAwsErrorCode() === 'ConditionalCheckFailedException' ) { throw LockException::lockFailed($document); } throw $e; } }
Removes a document from DynamoDB @param object $document @return void @throws LockException
https://github.com/cloudtek/dynamodm/blob/119d355e2c5cbaef1f867970349b4432f5704fcd/lib/Cloudtek/DynamoDM/Persister/DocumentPersister.php#L237-L261
cloudtek/dynamodm
lib/Cloudtek/DynamoDM/Persister/DocumentPersister.php
DocumentPersister.exists
public function exists($document) { $identifier = $this->class->createIdentifier($document); $qb = $this->dm->createQueryBuilder($this->class->name); $query = $qb->get()->setIdentifier($identifier)->getQuery(); return (boolean)$query->getSingleMarshalledResult(); }
php
public function exists($document) { $identifier = $this->class->createIdentifier($document); $qb = $this->dm->createQueryBuilder($this->class->name); $query = $qb->get()->setIdentifier($identifier)->getQuery(); return (boolean)$query->getSingleMarshalledResult(); }
Checks whether the given managed document exists in the database. @param object $document @return bool TRUE if the document exists in the database, FALSE otherwise.
https://github.com/cloudtek/dynamodm/blob/119d355e2c5cbaef1f867970349b4432f5704fcd/lib/Cloudtek/DynamoDM/Persister/DocumentPersister.php#L270-L277
cloudtek/dynamodm
lib/Cloudtek/DynamoDM/Persister/DocumentPersister.php
DocumentPersister.handleCollections
public function handleCollections($document) { // Collection deletions (deletions of complete collections) foreach ($this->uow->getScheduledCollections($document) as $coll) { if (!$this->uow->isCollectionScheduledForDeletion($coll)) { continue; } $this->cp->delete($coll); } // Collection updates (deleteRows, updateRows, insertRows) foreach ($this->uow->getScheduledCollections($document) as $coll) { if (!$this->uow->isCollectionScheduledForUpdate($coll)) { continue; } $this->cp->update($coll); } // Take new snapshots from visited collections foreach ($this->uow->getVisitedCollections($document) as $coll) { $coll->takeSnapshot(); } }
php
public function handleCollections($document) { // Collection deletions (deletions of complete collections) foreach ($this->uow->getScheduledCollections($document) as $coll) { if (!$this->uow->isCollectionScheduledForDeletion($coll)) { continue; } $this->cp->delete($coll); } // Collection updates (deleteRows, updateRows, insertRows) foreach ($this->uow->getScheduledCollections($document) as $coll) { if (!$this->uow->isCollectionScheduledForUpdate($coll)) { continue; } $this->cp->update($coll); } // Take new snapshots from visited collections foreach ($this->uow->getVisitedCollections($document) as $coll) { $coll->takeSnapshot(); } }
@param object $document @return void
https://github.com/cloudtek/dynamodm/blob/119d355e2c5cbaef1f867970349b4432f5704fcd/lib/Cloudtek/DynamoDM/Persister/DocumentPersister.php#L284-L308
cloudtek/dynamodm
lib/Cloudtek/DynamoDM/Persister/DocumentPersister.php
DocumentPersister.insert
public function insert($document) { $class = $this->dm->getClassMetadata(get_class($document)); $changeset = $this->uow->getDocumentChangeSet($document); $qb = $this->dm->createQueryBuilder($this->class->name); foreach ($class->propertyMetadata as $mapping) { $new = isset($changeset[$mapping->name][1]) ? $changeset[$mapping->name][1] : null; if (($new === null && !$mapping->nullable) || $mapping->isInverseSide) { continue; } if ($mapping->isMany()) { if ($mapping->strategy === PropertyMetadata::STORAGE_STRATEGY_ADD_TO_SET || $new->isEmpty()) { continue; } $this->uow->unscheduleCollectionDeletion($new); $this->uow->unscheduleCollectionUpdate($new); } $qb->attr($mapping->name)->put($new); } //add a conditional preventing the resulting PutItem from overwriting //an existing record with the same primary key $class->createIdentifier($document)->addNotExistsToQueryCondition($qb->expr); $qb->getQuery()->execute(); }
php
public function insert($document) { $class = $this->dm->getClassMetadata(get_class($document)); $changeset = $this->uow->getDocumentChangeSet($document); $qb = $this->dm->createQueryBuilder($this->class->name); foreach ($class->propertyMetadata as $mapping) { $new = isset($changeset[$mapping->name][1]) ? $changeset[$mapping->name][1] : null; if (($new === null && !$mapping->nullable) || $mapping->isInverseSide) { continue; } if ($mapping->isMany()) { if ($mapping->strategy === PropertyMetadata::STORAGE_STRATEGY_ADD_TO_SET || $new->isEmpty()) { continue; } $this->uow->unscheduleCollectionDeletion($new); $this->uow->unscheduleCollectionUpdate($new); } $qb->attr($mapping->name)->put($new); } //add a conditional preventing the resulting PutItem from overwriting //an existing record with the same primary key $class->createIdentifier($document)->addNotExistsToQueryCondition($qb->expr); $qb->getQuery()->execute(); }
Insert the provided document. @param object $document @return void
https://github.com/cloudtek/dynamodm/blob/119d355e2c5cbaef1f867970349b4432f5704fcd/lib/Cloudtek/DynamoDM/Persister/DocumentPersister.php#L317-L347
cloudtek/dynamodm
lib/Cloudtek/DynamoDM/Persister/DocumentPersister.php
DocumentPersister.load
public function load(Identifier $identifier, $document = null, $lockMode = LockMode::NONE) { $qb = $this->dm->createQueryBuilder($this->class->name); $query = $qb->get()->setIdentifier($identifier)->getQuery(); $result = $query->getSingleMarshalledResult(); return $result ? $this->createDocument($result, $document) : null; }
php
public function load(Identifier $identifier, $document = null, $lockMode = LockMode::NONE) { $qb = $this->dm->createQueryBuilder($this->class->name); $query = $qb->get()->setIdentifier($identifier)->getQuery(); $result = $query->getSingleMarshalledResult(); return $result ? $this->createDocument($result, $document) : null; }
Find a document by Identifier instance. @param Identifier $identifier @param object|null $document Document to load the data into. If not specified, a new document is created. @param int $lockMode @return object|null The loaded and managed document instance or null if no document was found
https://github.com/cloudtek/dynamodm/blob/119d355e2c5cbaef1f867970349b4432f5704fcd/lib/Cloudtek/DynamoDM/Persister/DocumentPersister.php#L360-L367
cloudtek/dynamodm
lib/Cloudtek/DynamoDM/Persister/DocumentPersister.php
DocumentPersister.loadAll
public function loadAll(array $criteria = [], $limit = null) { $qb = $this->dm->createQueryBuilder($this->class->name)->addCriteria($criteria); return $qb->getQuery()->limit($limit)->execute(); }
php
public function loadAll(array $criteria = [], $limit = null) { $qb = $this->dm->createQueryBuilder($this->class->name)->addCriteria($criteria); return $qb->getQuery()->limit($limit)->execute(); }
Load all documents from a table, optionally limited by the provided criteria. @param array $criteria Query criteria. @param int|null $limit Limit the number of documents returned. @return Iterator
https://github.com/cloudtek/dynamodm/blob/119d355e2c5cbaef1f867970349b4432f5704fcd/lib/Cloudtek/DynamoDM/Persister/DocumentPersister.php#L377-L382
cloudtek/dynamodm
lib/Cloudtek/DynamoDM/Persister/DocumentPersister.php
DocumentPersister.loadCollection
public function loadCollection(PersistentCollectionInterface $collection) { $mapping = $collection->getMapping(); switch ($mapping->association) { case PropertyMetadata::ASSOCIATION_TYPE_EMBED_MANY: $this->loadEmbedManyCollection($collection); break; case PropertyMetadata::ASSOCIATION_TYPE_REFERENCE_MANY: if ($mapping->repositoryMethod !== null) { $this->loadReferenceManyWithRepositoryMethod($collection); } else { if ($mapping->isOwningSide) { $this->loadReferenceManyCollectionOwningSide($collection); } else { $this->loadReferenceManyCollectionInverseSide($collection); } } break; } }
php
public function loadCollection(PersistentCollectionInterface $collection) { $mapping = $collection->getMapping(); switch ($mapping->association) { case PropertyMetadata::ASSOCIATION_TYPE_EMBED_MANY: $this->loadEmbedManyCollection($collection); break; case PropertyMetadata::ASSOCIATION_TYPE_REFERENCE_MANY: if ($mapping->repositoryMethod !== null) { $this->loadReferenceManyWithRepositoryMethod($collection); } else { if ($mapping->isOwningSide) { $this->loadReferenceManyCollectionOwningSide($collection); } else { $this->loadReferenceManyCollectionInverseSide($collection); } } break; } }
Load PersistentCollection data. Used in the initialize() method. @param PersistentCollectionInterface $collection @return void
https://github.com/cloudtek/dynamodm/blob/119d355e2c5cbaef1f867970349b4432f5704fcd/lib/Cloudtek/DynamoDM/Persister/DocumentPersister.php#L391-L411