id
int32
0
241k
repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
sequence
docstring
stringlengths
3
47.2k
docstring_tokens
sequence
sha
stringlengths
40
40
url
stringlengths
91
247
4,600
easy-system/es-http
src/Uploading/AbstractUploadStrategy.php
AbstractUploadStrategy.decideOnSuccess
protected function decideOnSuccess() { $this->state = static::STATE_SUCCESS; $this->operationError = null; $this->operationErrorDescription = null; }
php
protected function decideOnSuccess() { $this->state = static::STATE_SUCCESS; $this->operationError = null; $this->operationErrorDescription = null; }
[ "protected", "function", "decideOnSuccess", "(", ")", "{", "$", "this", "->", "state", "=", "static", "::", "STATE_SUCCESS", ";", "$", "this", "->", "operationError", "=", "null", ";", "$", "this", "->", "operationErrorDescription", "=", "null", ";", "}" ]
Decides on success.
[ "Decides", "on", "success", "." ]
dd5852e94901e147a7546a8715133408ece767a1
https://github.com/easy-system/es-http/blob/dd5852e94901e147a7546a8715133408ece767a1/src/Uploading/AbstractUploadStrategy.php#L148-L154
4,601
marando/phpSOFA
src/Marando/IAU/iauGd2gc.php
iauGd2gc.Gd2gc
public static function Gd2gc(iauRefEllips $n, $elong, $phi, $height, array &$xyz) { $j; $a; $f; /* Obtain reference ellipsoid parameters. */ $j = IAU::Eform($n, $a, $f); /* If OK, transform longitude, geodetic latitude, height to x,y,z. */ if ($j == 0) { $j = IAU::Gd2gce($a, $f, $elong, $phi, $height, $xyz); if ($j != 0) $j = -2; } /* Deal with any errors. */ if ($j != 0) IAU::Zp($xyz); /* Return the status. */ return $j; }
php
public static function Gd2gc(iauRefEllips $n, $elong, $phi, $height, array &$xyz) { $j; $a; $f; /* Obtain reference ellipsoid parameters. */ $j = IAU::Eform($n, $a, $f); /* If OK, transform longitude, geodetic latitude, height to x,y,z. */ if ($j == 0) { $j = IAU::Gd2gce($a, $f, $elong, $phi, $height, $xyz); if ($j != 0) $j = -2; } /* Deal with any errors. */ if ($j != 0) IAU::Zp($xyz); /* Return the status. */ return $j; }
[ "public", "static", "function", "Gd2gc", "(", "iauRefEllips", "$", "n", ",", "$", "elong", ",", "$", "phi", ",", "$", "height", ",", "array", "&", "$", "xyz", ")", "{", "$", "j", ";", "$", "a", ";", "$", "f", ";", "/* Obtain reference ellipsoid parameters. */", "$", "j", "=", "IAU", "::", "Eform", "(", "$", "n", ",", "$", "a", ",", "$", "f", ")", ";", "/* If OK, transform longitude, geodetic latitude, height to x,y,z. */", "if", "(", "$", "j", "==", "0", ")", "{", "$", "j", "=", "IAU", "::", "Gd2gce", "(", "$", "a", ",", "$", "f", ",", "$", "elong", ",", "$", "phi", ",", "$", "height", ",", "$", "xyz", ")", ";", "if", "(", "$", "j", "!=", "0", ")", "$", "j", "=", "-", "2", ";", "}", "/* Deal with any errors. */", "if", "(", "$", "j", "!=", "0", ")", "IAU", "::", "Zp", "(", "$", "xyz", ")", ";", "/* Return the status. */", "return", "$", "j", ";", "}" ]
- - - - - - - - - i a u G d 2 g c - - - - - - - - - Transform geodetic coordinates to geocentric using the specified reference ellipsoid. This function is part of the International Astronomical Union's SOFA (Standards of Fundamental Astronomy) software collection. Status: canonical transformation. Given: n int ellipsoid identifier (Note 1) elong double longitude (radians, east +ve) phi double latitude (geodetic, radians, Note 3) height double height above ellipsoid (geodetic, Notes 2,3) Returned: xyz double[3] geocentric vector (Note 2) Returned (function value): int status: 0 = OK -1 = illegal identifier (Note 3) -2 = illegal case (Note 3) Notes: 1) The identifier n is a number that specifies the choice of reference ellipsoid. The following are supported: n ellipsoid 1 WGS84 2 GRS80 3 WGS72 The n value has no significance outside the SOFA software. For convenience, symbols WGS84 etc. are defined in sofam.h. 2) The height (height, given) and the geocentric vector (xyz, returned) are in meters. 3) No validation is performed on the arguments elong, phi and height. An error status -1 means that the identifier n is illegal. An error status -2 protects against cases that would lead to arithmetic exceptions. In all error cases, xyz is set to zeros. 4) The inverse transformation is performed in the function iauGc2gd. Called: iauEform Earth reference ellipsoids iauGd2gce geodetic to geocentric transformation, general iauZp zero p-vector This revision: 2013 June 18 SOFA release 2015-02-09 Copyright (C) 2015 IAU SOFA Board. See notes at end.
[ "-", "-", "-", "-", "-", "-", "-", "-", "-", "i", "a", "u", "G", "d", "2", "g", "c", "-", "-", "-", "-", "-", "-", "-", "-", "-" ]
757fa49fe335ae1210eaa7735473fd4388b13f07
https://github.com/marando/phpSOFA/blob/757fa49fe335ae1210eaa7735473fd4388b13f07/src/Marando/IAU/iauGd2gc.php#L72-L95
4,602
jmikola/JmikolaInsecureRoutesBundle
Routing/HttpsRemovalLoader.php
HttpsRemovalLoader.load
public function load($resource, $type = null) { $collection = $this->loader->load($resource, $type); foreach ($collection->all() as $route) { if ('https' === $route->getRequirement('_scheme')) { $requirements = $route->getRequirements(); unset($requirements['_scheme']); $route->setRequirements($requirements); } } return $collection; }
php
public function load($resource, $type = null) { $collection = $this->loader->load($resource, $type); foreach ($collection->all() as $route) { if ('https' === $route->getRequirement('_scheme')) { $requirements = $route->getRequirements(); unset($requirements['_scheme']); $route->setRequirements($requirements); } } return $collection; }
[ "public", "function", "load", "(", "$", "resource", ",", "$", "type", "=", "null", ")", "{", "$", "collection", "=", "$", "this", "->", "loader", "->", "load", "(", "$", "resource", ",", "$", "type", ")", ";", "foreach", "(", "$", "collection", "->", "all", "(", ")", "as", "$", "route", ")", "{", "if", "(", "'https'", "===", "$", "route", "->", "getRequirement", "(", "'_scheme'", ")", ")", "{", "$", "requirements", "=", "$", "route", "->", "getRequirements", "(", ")", ";", "unset", "(", "$", "requirements", "[", "'_scheme'", "]", ")", ";", "$", "route", "->", "setRequirements", "(", "$", "requirements", ")", ";", "}", "}", "return", "$", "collection", ";", "}" ]
Loads a RouteCollection but removes HTTPS scheme requirements from its routes before returning the collection. @see Symfony\Component\Config\Loader\LoaderInterface::load()
[ "Loads", "a", "RouteCollection", "but", "removes", "HTTPS", "scheme", "requirements", "from", "its", "routes", "before", "returning", "the", "collection", "." ]
aa8e4438b7743ef69fb0a17442dda31c50a3326f
https://github.com/jmikola/JmikolaInsecureRoutesBundle/blob/aa8e4438b7743ef69fb0a17442dda31c50a3326f/Routing/HttpsRemovalLoader.php#L28-L41
4,603
cityware/city-mvc
src/Controller/Plugins/GetAllParams.php
GetAllParams.getEvent
protected function getEvent() { if ($this->event) { return $this->event; } $controller = $this->getController(); if (!$controller instanceof InjectApplicationEventInterface) { throw new Exception\DomainException('getParam plugin requires a controller that implements InjectApplicationEventInterface'); } $event = $controller->getEvent(); if (!$event instanceof MvcEvent) { $params = $event->getParams(); $event = new MvcEvent(); $event->setParams($params); } $this->event = $event; return $this->event; }
php
protected function getEvent() { if ($this->event) { return $this->event; } $controller = $this->getController(); if (!$controller instanceof InjectApplicationEventInterface) { throw new Exception\DomainException('getParam plugin requires a controller that implements InjectApplicationEventInterface'); } $event = $controller->getEvent(); if (!$event instanceof MvcEvent) { $params = $event->getParams(); $event = new MvcEvent(); $event->setParams($params); } $this->event = $event; return $this->event; }
[ "protected", "function", "getEvent", "(", ")", "{", "if", "(", "$", "this", "->", "event", ")", "{", "return", "$", "this", "->", "event", ";", "}", "$", "controller", "=", "$", "this", "->", "getController", "(", ")", ";", "if", "(", "!", "$", "controller", "instanceof", "InjectApplicationEventInterface", ")", "{", "throw", "new", "Exception", "\\", "DomainException", "(", "'getParam plugin requires a controller that implements InjectApplicationEventInterface'", ")", ";", "}", "$", "event", "=", "$", "controller", "->", "getEvent", "(", ")", ";", "if", "(", "!", "$", "event", "instanceof", "MvcEvent", ")", "{", "$", "params", "=", "$", "event", "->", "getParams", "(", ")", ";", "$", "event", "=", "new", "MvcEvent", "(", ")", ";", "$", "event", "->", "setParams", "(", "$", "params", ")", ";", "}", "$", "this", "->", "event", "=", "$", "event", ";", "return", "$", "this", "->", "event", ";", "}" ]
Get the event @return MvcEvent @throws Exception\DomainException if unable to find event
[ "Get", "the", "event" ]
2d1bf8b6b6d5411fac9717a1df2b9b43bc92903f
https://github.com/cityware/city-mvc/blob/2d1bf8b6b6d5411fac9717a1df2b9b43bc92903f/src/Controller/Plugins/GetAllParams.php#L65-L81
4,604
ARCANESOFT/Core
src/Helpers/UI/Button.php
Button.setType
public function setType($type) { $this->type = in_array($type = strtolower($type), ['button', 'submit', 'reset']) ? $type : 'button'; return $this; }
php
public function setType($type) { $this->type = in_array($type = strtolower($type), ['button', 'submit', 'reset']) ? $type : 'button'; return $this; }
[ "public", "function", "setType", "(", "$", "type", ")", "{", "$", "this", "->", "type", "=", "in_array", "(", "$", "type", "=", "strtolower", "(", "$", "type", ")", ",", "[", "'button'", ",", "'submit'", ",", "'reset'", "]", ")", "?", "$", "type", ":", "'button'", ";", "return", "$", "this", ";", "}" ]
Set the button type. @param string $type @return self
[ "Set", "the", "button", "type", "." ]
d0798074d47785cf0a768f51d82c0315363213be
https://github.com/ARCANESOFT/Core/blob/d0798074d47785cf0a768f51d82c0315363213be/src/Helpers/UI/Button.php#L52-L57
4,605
ARCANESOFT/Core
src/Helpers/UI/Button.php
Button.make
public static function make($action, $type = 'button', array $attributes = [], $disabled = false) { return new static($action, $type, $attributes, $disabled); }
php
public static function make($action, $type = 'button', array $attributes = [], $disabled = false) { return new static($action, $type, $attributes, $disabled); }
[ "public", "static", "function", "make", "(", "$", "action", ",", "$", "type", "=", "'button'", ",", "array", "$", "attributes", "=", "[", "]", ",", "$", "disabled", "=", "false", ")", "{", "return", "new", "static", "(", "$", "action", ",", "$", "type", ",", "$", "attributes", ",", "$", "disabled", ")", ";", "}" ]
Make a button instance. @param string $action @param string $type @param array $attributes @param bool $disabled @return self
[ "Make", "a", "button", "instance", "." ]
d0798074d47785cf0a768f51d82c0315363213be
https://github.com/ARCANESOFT/Core/blob/d0798074d47785cf0a768f51d82c0315363213be/src/Helpers/UI/Button.php#L74-L77
4,606
ARCANESOFT/Core
src/Helpers/UI/Button.php
Button.renderAttributes
protected function renderAttributes() { $attributes = collect(); $attributes->put('type', $this->type); $attributes->put('class', $this->getStyleClass()); if ($this->withTooltip) { // This is for Bootstrap $attributes->put('data-toggle', 'tooltip'); $attributes->put('data-original-title', $this->getTitle()); } if ($this->disabled) { $attributes->put('type', 'button'); $attributes->put('disabled', 'disabled'); } return html()->attributes($attributes->merge($this->attributes)->toArray()); }
php
protected function renderAttributes() { $attributes = collect(); $attributes->put('type', $this->type); $attributes->put('class', $this->getStyleClass()); if ($this->withTooltip) { // This is for Bootstrap $attributes->put('data-toggle', 'tooltip'); $attributes->put('data-original-title', $this->getTitle()); } if ($this->disabled) { $attributes->put('type', 'button'); $attributes->put('disabled', 'disabled'); } return html()->attributes($attributes->merge($this->attributes)->toArray()); }
[ "protected", "function", "renderAttributes", "(", ")", "{", "$", "attributes", "=", "collect", "(", ")", ";", "$", "attributes", "->", "put", "(", "'type'", ",", "$", "this", "->", "type", ")", ";", "$", "attributes", "->", "put", "(", "'class'", ",", "$", "this", "->", "getStyleClass", "(", ")", ")", ";", "if", "(", "$", "this", "->", "withTooltip", ")", "{", "// This is for Bootstrap", "$", "attributes", "->", "put", "(", "'data-toggle'", ",", "'tooltip'", ")", ";", "$", "attributes", "->", "put", "(", "'data-original-title'", ",", "$", "this", "->", "getTitle", "(", ")", ")", ";", "}", "if", "(", "$", "this", "->", "disabled", ")", "{", "$", "attributes", "->", "put", "(", "'type'", ",", "'button'", ")", ";", "$", "attributes", "->", "put", "(", "'disabled'", ",", "'disabled'", ")", ";", "}", "return", "html", "(", ")", "->", "attributes", "(", "$", "attributes", "->", "merge", "(", "$", "this", "->", "attributes", ")", "->", "toArray", "(", ")", ")", ";", "}" ]
Render the attributes. @return string
[ "Render", "the", "attributes", "." ]
d0798074d47785cf0a768f51d82c0315363213be
https://github.com/ARCANESOFT/Core/blob/d0798074d47785cf0a768f51d82c0315363213be/src/Helpers/UI/Button.php#L99-L117
4,607
GodsDev/backyard
GodsDev/Backyard/BackyardMysqli.php
BackyardMysqli.query
public function query($sql, $ERROR_LOG_OUTPUT = true) { //111010 - function is called even before error_log is initialized, therefore it is necessary to mute my_error_log, hence call make_mysql_query($sql,false); 160625 - is it still necessary? if ($ERROR_LOG_OUTPUT) { $this->BackyardError->log(5, "Start of query {$sql}", array(11)); } if (empty($sql) || !is_string($sql)) { if ($ERROR_LOG_OUTPUT) { $this->BackyardError->log(1, "No mysql_query_string set. End of query", array(11)); //debug //my_error_log("End of query", 6, 11); } return false; } //if ($sql != "") { // here, we could log the query to sql.log file // note that, no error check is being made for this file //file_put_contents('/tmp/sql.log', $sql . "\n", FILE_APPEND); //if ($ERROR_LOG_OUTPUT) { // my_error_log($sql, 5, 11); //} $result = parent::query($sql); if ($this->errno != 0) { if ($ERROR_LOG_OUTPUT) { $this->BackyardError->log(1, "{$this->errno} : {$this->error} /with query: {$sql}", array(11)); } } //} if ($ERROR_LOG_OUTPUT) { $this->BackyardError->log(6, "End of query {$sql}", array(11)); } return $result; }
php
public function query($sql, $ERROR_LOG_OUTPUT = true) { //111010 - function is called even before error_log is initialized, therefore it is necessary to mute my_error_log, hence call make_mysql_query($sql,false); 160625 - is it still necessary? if ($ERROR_LOG_OUTPUT) { $this->BackyardError->log(5, "Start of query {$sql}", array(11)); } if (empty($sql) || !is_string($sql)) { if ($ERROR_LOG_OUTPUT) { $this->BackyardError->log(1, "No mysql_query_string set. End of query", array(11)); //debug //my_error_log("End of query", 6, 11); } return false; } //if ($sql != "") { // here, we could log the query to sql.log file // note that, no error check is being made for this file //file_put_contents('/tmp/sql.log', $sql . "\n", FILE_APPEND); //if ($ERROR_LOG_OUTPUT) { // my_error_log($sql, 5, 11); //} $result = parent::query($sql); if ($this->errno != 0) { if ($ERROR_LOG_OUTPUT) { $this->BackyardError->log(1, "{$this->errno} : {$this->error} /with query: {$sql}", array(11)); } } //} if ($ERROR_LOG_OUTPUT) { $this->BackyardError->log(6, "End of query {$sql}", array(11)); } return $result; }
[ "public", "function", "query", "(", "$", "sql", ",", "$", "ERROR_LOG_OUTPUT", "=", "true", ")", "{", "//111010 - function is called even before error_log is initialized, therefore it is necessary to mute my_error_log, hence call make_mysql_query($sql,false); 160625 - is it still necessary?", "if", "(", "$", "ERROR_LOG_OUTPUT", ")", "{", "$", "this", "->", "BackyardError", "->", "log", "(", "5", ",", "\"Start of query {$sql}\"", ",", "array", "(", "11", ")", ")", ";", "}", "if", "(", "empty", "(", "$", "sql", ")", "||", "!", "is_string", "(", "$", "sql", ")", ")", "{", "if", "(", "$", "ERROR_LOG_OUTPUT", ")", "{", "$", "this", "->", "BackyardError", "->", "log", "(", "1", ",", "\"No mysql_query_string set. End of query\"", ",", "array", "(", "11", ")", ")", ";", "//debug", "//my_error_log(\"End of query\", 6, 11); ", "}", "return", "false", ";", "}", "//if ($sql != \"\") {", "// here, we could log the query to sql.log file", "// note that, no error check is being made for this file", "//file_put_contents('/tmp/sql.log', $sql . \"\\n\", FILE_APPEND);", "//if ($ERROR_LOG_OUTPUT) {", "// my_error_log($sql, 5, 11);", "//}", "$", "result", "=", "parent", "::", "query", "(", "$", "sql", ")", ";", "if", "(", "$", "this", "->", "errno", "!=", "0", ")", "{", "if", "(", "$", "ERROR_LOG_OUTPUT", ")", "{", "$", "this", "->", "BackyardError", "->", "log", "(", "1", ",", "\"{$this->errno} : {$this->error} /with query: {$sql}\"", ",", "array", "(", "11", ")", ")", ";", "}", "}", "//}", "if", "(", "$", "ERROR_LOG_OUTPUT", ")", "{", "$", "this", "->", "BackyardError", "->", "log", "(", "6", ",", "\"End of query {$sql}\"", ",", "array", "(", "11", ")", ")", ";", "}", "return", "$", "result", ";", "}" ]
Query method if everything is OK, return the mysqli_result object that is returned from parent query method 120914, inspired by http://www.blrf.net/blog/223/code/php/extending-mysqli-class-with-example/ @param string $sql SQL to execute @return mysqli_result Object|false @throws DBQueryException
[ "Query", "method", "if", "everything", "is", "OK", "return", "the", "mysqli_result", "object", "that", "is", "returned", "from", "parent", "query", "method" ]
992da766a50fca04e9c6e963cbe98d37e3d47f8f
https://github.com/GodsDev/backyard/blob/992da766a50fca04e9c6e963cbe98d37e3d47f8f/GodsDev/Backyard/BackyardMysqli.php#L92-L123
4,608
docit/core
src/Extensions.php
Extensions.addHook
public static function addHook($point, $handler) { if (! $handler instanceof \Closure and ! in_array(Hook::class, class_implements($handler), false)) { throw new \InvalidArgumentException("Failed adding hook. Provided handler for [{$point}] is not valid. Either provider a \\Closure or classpath that impelments \\Docit\\Docit\\Contracts\\Hook"); } static::ensureHookPoint($point); static::$hooks[ $point ][] = $handler; }
php
public static function addHook($point, $handler) { if (! $handler instanceof \Closure and ! in_array(Hook::class, class_implements($handler), false)) { throw new \InvalidArgumentException("Failed adding hook. Provided handler for [{$point}] is not valid. Either provider a \\Closure or classpath that impelments \\Docit\\Docit\\Contracts\\Hook"); } static::ensureHookPoint($point); static::$hooks[ $point ][] = $handler; }
[ "public", "static", "function", "addHook", "(", "$", "point", ",", "$", "handler", ")", "{", "if", "(", "!", "$", "handler", "instanceof", "\\", "Closure", "and", "!", "in_array", "(", "Hook", "::", "class", ",", "class_implements", "(", "$", "handler", ")", ",", "false", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "\"Failed adding hook. Provided handler for [{$point}] is not valid. Either provider a \\\\Closure or classpath that impelments \\\\Docit\\\\Docit\\\\Contracts\\\\Hook\"", ")", ";", "}", "static", "::", "ensureHookPoint", "(", "$", "point", ")", ";", "static", "::", "$", "hooks", "[", "$", "point", "]", "[", "]", "=", "$", "handler", ";", "}" ]
Register a hook instance. @param string $point @param string|\Closure $handler @return void
[ "Register", "a", "hook", "instance", "." ]
448e1cdca18a8ffb6c08430cad8d22162171ac35
https://github.com/docit/core/blob/448e1cdca18a8ffb6c08430cad8d22162171ac35/src/Extensions.php#L61-L69
4,609
docit/core
src/Extensions.php
Extensions.runHook
public static function runHook($name, array $params = [ ]) { static::ensureHookPoint($name); foreach (static::$hooks[ $name ] as $handler) { if ($handler instanceof \Closure) { call_user_func_array($handler, $params); } elseif (class_exists($handler)) { $instance = app()->make($handler); call_user_func_array([ $instance, 'handle' ], $params); } } }
php
public static function runHook($name, array $params = [ ]) { static::ensureHookPoint($name); foreach (static::$hooks[ $name ] as $handler) { if ($handler instanceof \Closure) { call_user_func_array($handler, $params); } elseif (class_exists($handler)) { $instance = app()->make($handler); call_user_func_array([ $instance, 'handle' ], $params); } } }
[ "public", "static", "function", "runHook", "(", "$", "name", ",", "array", "$", "params", "=", "[", "]", ")", "{", "static", "::", "ensureHookPoint", "(", "$", "name", ")", ";", "foreach", "(", "static", "::", "$", "hooks", "[", "$", "name", "]", "as", "$", "handler", ")", "{", "if", "(", "$", "handler", "instanceof", "\\", "Closure", ")", "{", "call_user_func_array", "(", "$", "handler", ",", "$", "params", ")", ";", "}", "elseif", "(", "class_exists", "(", "$", "handler", ")", ")", "{", "$", "instance", "=", "app", "(", ")", "->", "make", "(", "$", "handler", ")", ";", "call_user_func_array", "(", "[", "$", "instance", ",", "'handle'", "]", ",", "$", "params", ")", ";", "}", "}", "}" ]
Run the given hook. @param string $name @param array $params @return void
[ "Run", "the", "given", "hook", "." ]
448e1cdca18a8ffb6c08430cad8d22162171ac35
https://github.com/docit/core/blob/448e1cdca18a8ffb6c08430cad8d22162171ac35/src/Extensions.php#L78-L92
4,610
docit/core
src/Extensions.php
Extensions.filter
public static function filter($name, $handler) { if (! $handler instanceof \Closure and ! in_array(Filter::class, class_implements($handler), false)) { throw new \InvalidArgumentException("Failed adding Filter. Provided handler for [{$name}] is not valid. Must either provide a \\Closure or classpath that impelments \\Docit\\Docit\\Contracts\\Filter"); } static::$filters[ $name ] = $handler; }
php
public static function filter($name, $handler) { if (! $handler instanceof \Closure and ! in_array(Filter::class, class_implements($handler), false)) { throw new \InvalidArgumentException("Failed adding Filter. Provided handler for [{$name}] is not valid. Must either provide a \\Closure or classpath that impelments \\Docit\\Docit\\Contracts\\Filter"); } static::$filters[ $name ] = $handler; }
[ "public", "static", "function", "filter", "(", "$", "name", ",", "$", "handler", ")", "{", "if", "(", "!", "$", "handler", "instanceof", "\\", "Closure", "and", "!", "in_array", "(", "Filter", "::", "class", ",", "class_implements", "(", "$", "handler", ")", ",", "false", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "\"Failed adding Filter. Provided handler for [{$name}] is not valid. Must either provide a \\\\Closure or classpath that impelments \\\\Docit\\\\Docit\\\\Contracts\\\\Filter\"", ")", ";", "}", "static", "::", "$", "filters", "[", "$", "name", "]", "=", "$", "handler", ";", "}" ]
Add a new filter to the registered filters list. @param string $name @param \Closure|\Docit\Core\Contracts\Filter $handler @return void
[ "Add", "a", "new", "filter", "to", "the", "registered", "filters", "list", "." ]
448e1cdca18a8ffb6c08430cad8d22162171ac35
https://github.com/docit/core/blob/448e1cdca18a8ffb6c08430cad8d22162171ac35/src/Extensions.php#L143-L150
4,611
docit/core
src/Extensions.php
Extensions.getFilters
public static function getFilters($filterNames = null) { if (! is_null($filterNames)) { if (! is_array($filterNames)) { $filterNames = [ $filterNames ]; } return array_only(static::$filters, $filterNames); } else { return static::$filters; } }
php
public static function getFilters($filterNames = null) { if (! is_null($filterNames)) { if (! is_array($filterNames)) { $filterNames = [ $filterNames ]; } return array_only(static::$filters, $filterNames); } else { return static::$filters; } }
[ "public", "static", "function", "getFilters", "(", "$", "filterNames", "=", "null", ")", "{", "if", "(", "!", "is_null", "(", "$", "filterNames", ")", ")", "{", "if", "(", "!", "is_array", "(", "$", "filterNames", ")", ")", "{", "$", "filterNames", "=", "[", "$", "filterNames", "]", ";", "}", "return", "array_only", "(", "static", "::", "$", "filters", ",", "$", "filterNames", ")", ";", "}", "else", "{", "return", "static", "::", "$", "filters", ";", "}", "}" ]
get filters value @return array
[ "get", "filters", "value" ]
448e1cdca18a8ffb6c08430cad8d22162171ac35
https://github.com/docit/core/blob/448e1cdca18a8ffb6c08430cad8d22162171ac35/src/Extensions.php#L157-L168
4,612
horse-php/horse
src/Horse/Transformers/ElementTransformer.php
ElementTransformer.transform
public function transform(array $element) { // argument: [name, mode, description, default] // option: [name, shortcut, mode, description, default] $isArgument = $this->isArgument($element[0]); $class = 'Symfony\Component\Console\Input\Input'.($isArgument ? 'Argument' : 'Option'); $reflector = new \ReflectionClass($class); if ($isArgument) { $element[1] = $this->transformMode($element[1]); } else { $element[2] = $this->transformMode($element[2]); } $element[0] = $this->cleanName($element[0]); return $reflector->newInstanceArgs($element); }
php
public function transform(array $element) { // argument: [name, mode, description, default] // option: [name, shortcut, mode, description, default] $isArgument = $this->isArgument($element[0]); $class = 'Symfony\Component\Console\Input\Input'.($isArgument ? 'Argument' : 'Option'); $reflector = new \ReflectionClass($class); if ($isArgument) { $element[1] = $this->transformMode($element[1]); } else { $element[2] = $this->transformMode($element[2]); } $element[0] = $this->cleanName($element[0]); return $reflector->newInstanceArgs($element); }
[ "public", "function", "transform", "(", "array", "$", "element", ")", "{", "// argument: [name, mode, description, default]", "// option: [name, shortcut, mode, description, default]", "$", "isArgument", "=", "$", "this", "->", "isArgument", "(", "$", "element", "[", "0", "]", ")", ";", "$", "class", "=", "'Symfony\\Component\\Console\\Input\\Input'", ".", "(", "$", "isArgument", "?", "'Argument'", ":", "'Option'", ")", ";", "$", "reflector", "=", "new", "\\", "ReflectionClass", "(", "$", "class", ")", ";", "if", "(", "$", "isArgument", ")", "{", "$", "element", "[", "1", "]", "=", "$", "this", "->", "transformMode", "(", "$", "element", "[", "1", "]", ")", ";", "}", "else", "{", "$", "element", "[", "2", "]", "=", "$", "this", "->", "transformMode", "(", "$", "element", "[", "2", "]", ")", ";", "}", "$", "element", "[", "0", "]", "=", "$", "this", "->", "cleanName", "(", "$", "element", "[", "0", "]", ")", ";", "return", "$", "reflector", "->", "newInstanceArgs", "(", "$", "element", ")", ";", "}" ]
Transform the element to an instance of InputArgument or InputOption. @param array $element @return mixed
[ "Transform", "the", "element", "to", "an", "instance", "of", "InputArgument", "or", "InputOption", "." ]
e2b72508dde353de6cacfbed852aa3de3fc06eff
https://github.com/horse-php/horse/blob/e2b72508dde353de6cacfbed852aa3de3fc06eff/src/Horse/Transformers/ElementTransformer.php#L28-L51
4,613
tagadvance/Gilligan
src/tagadvance/gilligan/io/File.php
File.getTotalSpace
function getTotalSpace(): float { $directory = $this->isDirectory () ? $this->fileName : $this->getParent (); return disk_total_space ( $directory ); }
php
function getTotalSpace(): float { $directory = $this->isDirectory () ? $this->fileName : $this->getParent (); return disk_total_space ( $directory ); }
[ "function", "getTotalSpace", "(", ")", ":", "float", "{", "$", "directory", "=", "$", "this", "->", "isDirectory", "(", ")", "?", "$", "this", "->", "fileName", ":", "$", "this", "->", "getParent", "(", ")", ";", "return", "disk_total_space", "(", "$", "directory", ")", ";", "}" ]
Returns the size of the partition named by this path. @return float @see http://php.net/disk_total_space
[ "Returns", "the", "size", "of", "the", "partition", "named", "by", "this", "path", "." ]
470c82b1ef16d0f839ba2245cd96cd414792483b
https://github.com/tagadvance/Gilligan/blob/470c82b1ef16d0f839ba2245cd96cd414792483b/src/tagadvance/gilligan/io/File.php#L89-L92
4,614
tagadvance/Gilligan
src/tagadvance/gilligan/io/File.php
File.getFreeSpace
function getFreeSpace() { $directory = $this->isDirectory () ? $this->fileName : $this->getParent (); return disk_free_space ( $directory ); }
php
function getFreeSpace() { $directory = $this->isDirectory () ? $this->fileName : $this->getParent (); return disk_free_space ( $directory ); }
[ "function", "getFreeSpace", "(", ")", "{", "$", "directory", "=", "$", "this", "->", "isDirectory", "(", ")", "?", "$", "this", "->", "fileName", ":", "$", "this", "->", "getParent", "(", ")", ";", "return", "disk_free_space", "(", "$", "directory", ")", ";", "}" ]
Returns the number of unallocated bytes in the partition named by this path. @return float @see http://php.net/disk_free_space
[ "Returns", "the", "number", "of", "unallocated", "bytes", "in", "the", "partition", "named", "by", "this", "path", "." ]
470c82b1ef16d0f839ba2245cd96cd414792483b
https://github.com/tagadvance/Gilligan/blob/470c82b1ef16d0f839ba2245cd96cd414792483b/src/tagadvance/gilligan/io/File.php#L101-L104
4,615
antwebes/ChateaClientLib
src/Ant/ChateaClient/Service/Client/ChateaOAuth2Client.php
ChateaOAuth2Client.factory
public static function factory($config = array()) { // Provide a hash of default client configuration options $default = array( 'Accept'=>'application/json', 'environment'=>'prod', 'service-description-name' => Client::NAME_SERVICE_AUTH, 'ssl'=>false ); $required = array( 'base_url', 'Accept', 'environment', 'client_id', 'secret', 'ssl' ); // Merge in default settings and validate the config $config = Collection::fromConfig($config, $default, $required); if($config['environment'] == 'dev' && $config['ssl'] == false ){ $config['ssl.certificate_authority'] = 'system'; $config['curl.options'] = array(CURLOPT_SSL_VERIFYHOST=>false,CURLOPT_SSL_VERIFYPEER=>false); } // Create a new ChateaOAuth2 client $client = new ChateaOAuth2Client ($config->get('base_url'),$config ); $client->addSubscriber(new AcceptHeaderPluging($config->toArray())); return $client; }
php
public static function factory($config = array()) { // Provide a hash of default client configuration options $default = array( 'Accept'=>'application/json', 'environment'=>'prod', 'service-description-name' => Client::NAME_SERVICE_AUTH, 'ssl'=>false ); $required = array( 'base_url', 'Accept', 'environment', 'client_id', 'secret', 'ssl' ); // Merge in default settings and validate the config $config = Collection::fromConfig($config, $default, $required); if($config['environment'] == 'dev' && $config['ssl'] == false ){ $config['ssl.certificate_authority'] = 'system'; $config['curl.options'] = array(CURLOPT_SSL_VERIFYHOST=>false,CURLOPT_SSL_VERIFYPEER=>false); } // Create a new ChateaOAuth2 client $client = new ChateaOAuth2Client ($config->get('base_url'),$config ); $client->addSubscriber(new AcceptHeaderPluging($config->toArray())); return $client; }
[ "public", "static", "function", "factory", "(", "$", "config", "=", "array", "(", ")", ")", "{", "// Provide a hash of default client configuration options", "$", "default", "=", "array", "(", "'Accept'", "=>", "'application/json'", ",", "'environment'", "=>", "'prod'", ",", "'service-description-name'", "=>", "Client", "::", "NAME_SERVICE_AUTH", ",", "'ssl'", "=>", "false", ")", ";", "$", "required", "=", "array", "(", "'base_url'", ",", "'Accept'", ",", "'environment'", ",", "'client_id'", ",", "'secret'", ",", "'ssl'", ")", ";", "// Merge in default settings and validate the config", "$", "config", "=", "Collection", "::", "fromConfig", "(", "$", "config", ",", "$", "default", ",", "$", "required", ")", ";", "if", "(", "$", "config", "[", "'environment'", "]", "==", "'dev'", "&&", "$", "config", "[", "'ssl'", "]", "==", "false", ")", "{", "$", "config", "[", "'ssl.certificate_authority'", "]", "=", "'system'", ";", "$", "config", "[", "'curl.options'", "]", "=", "array", "(", "CURLOPT_SSL_VERIFYHOST", "=>", "false", ",", "CURLOPT_SSL_VERIFYPEER", "=>", "false", ")", ";", "}", "// Create a new ChateaOAuth2 client", "$", "client", "=", "new", "ChateaOAuth2Client", "(", "$", "config", "->", "get", "(", "'base_url'", ")", ",", "$", "config", ")", ";", "$", "client", "->", "addSubscriber", "(", "new", "AcceptHeaderPluging", "(", "$", "config", "->", "toArray", "(", ")", ")", ")", ";", "return", "$", "client", ";", "}" ]
Build new class ChateaOAuth2Client, this provides user authentication for ApiChateaClient @param array $config Associative array can configure the client. The parameters are: client_id The public key of client. This parameter is required secret The private key of client. This parameter is required base_url The server endpoind url. This parameter is optional Accept The accept header, default value is json. This parameter is optional environment Set mode production [prod] or developing [dev] default value is prod. This parameter is optional scheme Set server schema communication [http|https] for default https. This parameter is optional subdomain Set server subdomain if this exist. For default is api. This parameter is optional @return ChateaOAuth2Client|\Guzzle\Service\Client
[ "Build", "new", "class", "ChateaOAuth2Client", "this", "provides", "user", "authentication", "for", "ApiChateaClient" ]
b08b207886f4a9f79a0719e8c7b20e79a1b1732d
https://github.com/antwebes/ChateaClientLib/blob/b08b207886f4a9f79a0719e8c7b20e79a1b1732d/src/Ant/ChateaClient/Service/Client/ChateaOAuth2Client.php#L49-L80
4,616
antwebes/ChateaClientLib
src/Ant/ChateaClient/Service/Client/ChateaOAuth2Client.php
ChateaOAuth2Client.withClientCredentials
public function withClientCredentials() { $command = $this->getCommand('withClientCredentials', array('client_id'=>$this->getClientId(),'client_secret'=>$this->getSecret()) ); try{ return $command->execute(); }catch (ServerErrorResponseException $ex){ throw new AuthenticationException($ex->getResponse()->getBody(true), $ex->getResponse()->getStatusCode(), $ex); }catch (BadResponseException $ex){ throw new AuthenticationException($ex->getMessage(), 400, $ex); }catch(ClientErrorResponseException $ex){ throw new AuthenticationException($ex->getResponse()->getBody(true), $ex->getResponse()->getStatusCode(), $ex); }catch(CurlException $ex){ throw new AuthenticationException($ex->getMessage(), 400, $ex); } }
php
public function withClientCredentials() { $command = $this->getCommand('withClientCredentials', array('client_id'=>$this->getClientId(),'client_secret'=>$this->getSecret()) ); try{ return $command->execute(); }catch (ServerErrorResponseException $ex){ throw new AuthenticationException($ex->getResponse()->getBody(true), $ex->getResponse()->getStatusCode(), $ex); }catch (BadResponseException $ex){ throw new AuthenticationException($ex->getMessage(), 400, $ex); }catch(ClientErrorResponseException $ex){ throw new AuthenticationException($ex->getResponse()->getBody(true), $ex->getResponse()->getStatusCode(), $ex); }catch(CurlException $ex){ throw new AuthenticationException($ex->getMessage(), 400, $ex); } }
[ "public", "function", "withClientCredentials", "(", ")", "{", "$", "command", "=", "$", "this", "->", "getCommand", "(", "'withClientCredentials'", ",", "array", "(", "'client_id'", "=>", "$", "this", "->", "getClientId", "(", ")", ",", "'client_secret'", "=>", "$", "this", "->", "getSecret", "(", ")", ")", ")", ";", "try", "{", "return", "$", "command", "->", "execute", "(", ")", ";", "}", "catch", "(", "ServerErrorResponseException", "$", "ex", ")", "{", "throw", "new", "AuthenticationException", "(", "$", "ex", "->", "getResponse", "(", ")", "->", "getBody", "(", "true", ")", ",", "$", "ex", "->", "getResponse", "(", ")", "->", "getStatusCode", "(", ")", ",", "$", "ex", ")", ";", "}", "catch", "(", "BadResponseException", "$", "ex", ")", "{", "throw", "new", "AuthenticationException", "(", "$", "ex", "->", "getMessage", "(", ")", ",", "400", ",", "$", "ex", ")", ";", "}", "catch", "(", "ClientErrorResponseException", "$", "ex", ")", "{", "throw", "new", "AuthenticationException", "(", "$", "ex", "->", "getResponse", "(", ")", "->", "getBody", "(", "true", ")", ",", "$", "ex", "->", "getResponse", "(", ")", "->", "getStatusCode", "(", ")", ",", "$", "ex", ")", ";", "}", "catch", "(", "CurlException", "$", "ex", ")", "{", "throw", "new", "AuthenticationException", "(", "$", "ex", "->", "getMessage", "(", ")", ",", "400", ",", "$", "ex", ")", ";", "}", "}" ]
Enables the apps to get service credentials as well as service credential authentication settings for use on the apps side of communication. @return array|string Associative array with client credentials | Message with error in json format @throws AuthenticationException This exception is thrown if you do not credentials or you cannot use this method @example Get client credentials $clientInstande->withClientCredentials(); array("access_token" => access-token-demo, "expires_in" => 3600, "token_type" => bearer, "scope" => password, "refresh_token" => refresh-token-demo );
[ "Enables", "the", "apps", "to", "get", "service", "credentials", "as", "well", "as", "service", "credential", "authentication", "settings", "for", "use", "on", "the", "apps", "side", "of", "communication", "." ]
b08b207886f4a9f79a0719e8c7b20e79a1b1732d
https://github.com/antwebes/ChateaClientLib/blob/b08b207886f4a9f79a0719e8c7b20e79a1b1732d/src/Ant/ChateaClient/Service/Client/ChateaOAuth2Client.php#L223-L240
4,617
antwebes/ChateaClientLib
src/Ant/ChateaClient/Service/Client/ChateaOAuth2Client.php
ChateaOAuth2Client.withRefreshToken
public function withRefreshToken($refresh_token) { if (!is_string($refresh_token) || 0 >= strlen($refresh_token)) { throw new InvalidArgumentException("refresh_token must be a non-empty string"); } $command = $this->getCommand('withRefreshToken', array('client_id'=>$this->getClientId(),'client_secret'=>$this->getSecret(),'refresh_token'=>$refresh_token) ); try{ return $command->execute(); }catch (ServerErrorResponseException $ex){ throw new AuthenticationException($ex->getMessage(), 400, $ex); }catch (BadResponseException $ex){ throw new AuthenticationException($ex->getMessage(), 400, $ex); }catch(ClientErrorResponseException $ex){ throw new AuthenticationException($ex->getMessage(), 400, $ex); }catch(CurlException $ex){ throw new AuthenticationException($ex->getMessage(), 400, $ex); } }
php
public function withRefreshToken($refresh_token) { if (!is_string($refresh_token) || 0 >= strlen($refresh_token)) { throw new InvalidArgumentException("refresh_token must be a non-empty string"); } $command = $this->getCommand('withRefreshToken', array('client_id'=>$this->getClientId(),'client_secret'=>$this->getSecret(),'refresh_token'=>$refresh_token) ); try{ return $command->execute(); }catch (ServerErrorResponseException $ex){ throw new AuthenticationException($ex->getMessage(), 400, $ex); }catch (BadResponseException $ex){ throw new AuthenticationException($ex->getMessage(), 400, $ex); }catch(ClientErrorResponseException $ex){ throw new AuthenticationException($ex->getMessage(), 400, $ex); }catch(CurlException $ex){ throw new AuthenticationException($ex->getMessage(), 400, $ex); } }
[ "public", "function", "withRefreshToken", "(", "$", "refresh_token", ")", "{", "if", "(", "!", "is_string", "(", "$", "refresh_token", ")", "||", "0", ">=", "strlen", "(", "$", "refresh_token", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "\"refresh_token must be a non-empty string\"", ")", ";", "}", "$", "command", "=", "$", "this", "->", "getCommand", "(", "'withRefreshToken'", ",", "array", "(", "'client_id'", "=>", "$", "this", "->", "getClientId", "(", ")", ",", "'client_secret'", "=>", "$", "this", "->", "getSecret", "(", ")", ",", "'refresh_token'", "=>", "$", "refresh_token", ")", ")", ";", "try", "{", "return", "$", "command", "->", "execute", "(", ")", ";", "}", "catch", "(", "ServerErrorResponseException", "$", "ex", ")", "{", "throw", "new", "AuthenticationException", "(", "$", "ex", "->", "getMessage", "(", ")", ",", "400", ",", "$", "ex", ")", ";", "}", "catch", "(", "BadResponseException", "$", "ex", ")", "{", "throw", "new", "AuthenticationException", "(", "$", "ex", "->", "getMessage", "(", ")", ",", "400", ",", "$", "ex", ")", ";", "}", "catch", "(", "ClientErrorResponseException", "$", "ex", ")", "{", "throw", "new", "AuthenticationException", "(", "$", "ex", "->", "getMessage", "(", ")", ",", "400", ",", "$", "ex", ")", ";", "}", "catch", "(", "CurlException", "$", "ex", ")", "{", "throw", "new", "AuthenticationException", "(", "$", "ex", "->", "getMessage", "(", ")", ",", "400", ",", "$", "ex", ")", ";", "}", "}" ]
After the client has been authorized for access, they can use a refresh token to get a new access token. @param string $refresh_token The client refresh token that you obtain in first request of credentials. @return array|string Associative array with client credentials | Message with error in json format @throws InvalidArgumentException This exception is thrown if any parameter has errors @throws AuthenticationException This exception is thrown if you do not credentials or you cannot use this method @example Get client credentials $clientInstande->withRefreshToken('refresh-token-demo'); array("access_token" => access-token-demo, "expires_in" => 3600, "token_type" => bearer, "scope" => password, "refresh_token" => refresh-token-demo );
[ "After", "the", "client", "has", "been", "authorized", "for", "access", "they", "can", "use", "a", "refresh", "token", "to", "get", "a", "new", "access", "token", "." ]
b08b207886f4a9f79a0719e8c7b20e79a1b1732d
https://github.com/antwebes/ChateaClientLib/blob/b08b207886f4a9f79a0719e8c7b20e79a1b1732d/src/Ant/ChateaClient/Service/Client/ChateaOAuth2Client.php#L302-L323
4,618
mlocati/composer-patcher
src/PatchExecutor.php
PatchExecutor.applyPatch
public function applyPatch(Patch $patch, $baseDirectory) { $error = null; foreach ($patch->getLevels() as $patchLevel) { try { $this->applyPatchLevel($patch, $baseDirectory, $patchLevel); return; } catch (Exception\PatchAlreadyApplied $x) { throw $x; } catch (Exception\PatchNotApplied $x) { if ($error === null) { $error = $x; } } } throw $error; }
php
public function applyPatch(Patch $patch, $baseDirectory) { $error = null; foreach ($patch->getLevels() as $patchLevel) { try { $this->applyPatchLevel($patch, $baseDirectory, $patchLevel); return; } catch (Exception\PatchAlreadyApplied $x) { throw $x; } catch (Exception\PatchNotApplied $x) { if ($error === null) { $error = $x; } } } throw $error; }
[ "public", "function", "applyPatch", "(", "Patch", "$", "patch", ",", "$", "baseDirectory", ")", "{", "$", "error", "=", "null", ";", "foreach", "(", "$", "patch", "->", "getLevels", "(", ")", "as", "$", "patchLevel", ")", "{", "try", "{", "$", "this", "->", "applyPatchLevel", "(", "$", "patch", ",", "$", "baseDirectory", ",", "$", "patchLevel", ")", ";", "return", ";", "}", "catch", "(", "Exception", "\\", "PatchAlreadyApplied", "$", "x", ")", "{", "throw", "$", "x", ";", "}", "catch", "(", "Exception", "\\", "PatchNotApplied", "$", "x", ")", "{", "if", "(", "$", "error", "===", "null", ")", "{", "$", "error", "=", "$", "x", ";", "}", "}", "}", "throw", "$", "error", ";", "}" ]
Apply a patch to a base directory. @param \ComposerPatcher\Patch $patch the patch to be applied @param string $baseDirectory the directory where the patch should be applied @throws \ComposerPatcher\Exception\PatchAlreadyApplied if the patch is already applied @throws \ComposerPatcher\Exception\PatchNotApplied if the patch could not be applied @return bool
[ "Apply", "a", "patch", "to", "a", "base", "directory", "." ]
d8ba45c10b5cf8ac8da3591e09b6afd47fc10667
https://github.com/mlocati/composer-patcher/blob/d8ba45c10b5cf8ac8da3591e09b6afd47fc10667/src/PatchExecutor.php#L46-L63
4,619
mlocati/composer-patcher
src/PatchExecutor.php
PatchExecutor.run
protected function run($command, $standardInput = null) { $stdOut = ''; $stdErr = ''; $stdOut = array(); $rc = $this->processExecutor->execute($command, $stdOut); $stdOut = (string) $stdOut; $stdErr = (string) $this->processExecutor->getErrorOutput(); return array($rc, $stdOut, $stdErr); }
php
protected function run($command, $standardInput = null) { $stdOut = ''; $stdErr = ''; $stdOut = array(); $rc = $this->processExecutor->execute($command, $stdOut); $stdOut = (string) $stdOut; $stdErr = (string) $this->processExecutor->getErrorOutput(); return array($rc, $stdOut, $stdErr); }
[ "protected", "function", "run", "(", "$", "command", ",", "$", "standardInput", "=", "null", ")", "{", "$", "stdOut", "=", "''", ";", "$", "stdErr", "=", "''", ";", "$", "stdOut", "=", "array", "(", ")", ";", "$", "rc", "=", "$", "this", "->", "processExecutor", "->", "execute", "(", "$", "command", ",", "$", "stdOut", ")", ";", "$", "stdOut", "=", "(", "string", ")", "$", "stdOut", ";", "$", "stdErr", "=", "(", "string", ")", "$", "this", "->", "processExecutor", "->", "getErrorOutput", "(", ")", ";", "return", "array", "(", "$", "rc", ",", "$", "stdOut", ",", "$", "stdErr", ")", ";", "}" ]
Run a command and return the exit code. @param string $command The command to be executed @param null|mixed $standardInput @return array First element is the command return code, second element is the standard output, thirg element is the standard error
[ "Run", "a", "command", "and", "return", "the", "exit", "code", "." ]
d8ba45c10b5cf8ac8da3591e09b6afd47fc10667
https://github.com/mlocati/composer-patcher/blob/d8ba45c10b5cf8ac8da3591e09b6afd47fc10667/src/PatchExecutor.php#L85-L95
4,620
mlocati/composer-patcher
src/PatchExecutor.php
PatchExecutor.checkCommandExists
protected function checkCommandExists($commandName, $argument = '--version') { $command = $commandName; $argument = (string) $argument; if ($argument !== '') { $command .= ' '.$argument; } list($rc, , $stdErr) = $this->run($command); if ($rc !== 0) { throw new Exception\CommandNotFound($commandName, $stdErr ? $stdErr : null); } }
php
protected function checkCommandExists($commandName, $argument = '--version') { $command = $commandName; $argument = (string) $argument; if ($argument !== '') { $command .= ' '.$argument; } list($rc, , $stdErr) = $this->run($command); if ($rc !== 0) { throw new Exception\CommandNotFound($commandName, $stdErr ? $stdErr : null); } }
[ "protected", "function", "checkCommandExists", "(", "$", "commandName", ",", "$", "argument", "=", "'--version'", ")", "{", "$", "command", "=", "$", "commandName", ";", "$", "argument", "=", "(", "string", ")", "$", "argument", ";", "if", "(", "$", "argument", "!==", "''", ")", "{", "$", "command", ".=", "' '", ".", "$", "argument", ";", "}", "list", "(", "$", "rc", ",", ",", "$", "stdErr", ")", "=", "$", "this", "->", "run", "(", "$", "command", ")", ";", "if", "(", "$", "rc", "!==", "0", ")", "{", "throw", "new", "Exception", "\\", "CommandNotFound", "(", "$", "commandName", ",", "$", "stdErr", "?", "$", "stdErr", ":", "null", ")", ";", "}", "}" ]
Check if a command exists. @param string $commandName the command name @param string $argument the argument to be used to run the command @throws \ComposerPatcher\Exception\CommandNotFound
[ "Check", "if", "a", "command", "exists", "." ]
d8ba45c10b5cf8ac8da3591e09b6afd47fc10667
https://github.com/mlocati/composer-patcher/blob/d8ba45c10b5cf8ac8da3591e09b6afd47fc10667/src/PatchExecutor.php#L105-L116
4,621
0x20h/phloppy
src/Cache/FileCache.php
FileCache.read
private function read() { flock($this->file, LOCK_SH); rewind($this->file); $content = fgets($this->file); flock($this->file, LOCK_UN); $this->records = unserialize($content); }
php
private function read() { flock($this->file, LOCK_SH); rewind($this->file); $content = fgets($this->file); flock($this->file, LOCK_UN); $this->records = unserialize($content); }
[ "private", "function", "read", "(", ")", "{", "flock", "(", "$", "this", "->", "file", ",", "LOCK_SH", ")", ";", "rewind", "(", "$", "this", "->", "file", ")", ";", "$", "content", "=", "fgets", "(", "$", "this", "->", "file", ")", ";", "flock", "(", "$", "this", "->", "file", ",", "LOCK_UN", ")", ";", "$", "this", "->", "records", "=", "unserialize", "(", "$", "content", ")", ";", "}" ]
Read cache from disk.
[ "Read", "cache", "from", "disk", "." ]
d917f0578360395899bd583724046d36ac459535
https://github.com/0x20h/phloppy/blob/d917f0578360395899bd583724046d36ac459535/src/Cache/FileCache.php#L56-L64
4,622
0x20h/phloppy
src/Cache/FileCache.php
FileCache.write
private function write() { $cache = serialize($this->records); flock($this->file, LOCK_EX); rewind($this->file); ftruncate($this->file, 0); $bytes = fwrite($this->file, $cache); flock($this->file, LOCK_UN); return $bytes === strlen($cache); }
php
private function write() { $cache = serialize($this->records); flock($this->file, LOCK_EX); rewind($this->file); ftruncate($this->file, 0); $bytes = fwrite($this->file, $cache); flock($this->file, LOCK_UN); return $bytes === strlen($cache); }
[ "private", "function", "write", "(", ")", "{", "$", "cache", "=", "serialize", "(", "$", "this", "->", "records", ")", ";", "flock", "(", "$", "this", "->", "file", ",", "LOCK_EX", ")", ";", "rewind", "(", "$", "this", "->", "file", ")", ";", "ftruncate", "(", "$", "this", "->", "file", ",", "0", ")", ";", "$", "bytes", "=", "fwrite", "(", "$", "this", "->", "file", ",", "$", "cache", ")", ";", "flock", "(", "$", "this", "->", "file", ",", "LOCK_UN", ")", ";", "return", "$", "bytes", "===", "strlen", "(", "$", "cache", ")", ";", "}" ]
Write cache to disk. @return bool
[ "Write", "cache", "to", "disk", "." ]
d917f0578360395899bd583724046d36ac459535
https://github.com/0x20h/phloppy/blob/d917f0578360395899bd583724046d36ac459535/src/Cache/FileCache.php#L83-L93
4,623
webriq/core
module/Tag/src/Grid/Tag/Controller/ListController.php
ListController.listAction
public function listAction() { $params = $this->params(); $page = (int) $params->fromRoute( 'page' ); $mode = $params->fromRoute( 'mode' ); $all = $mode == 'all'; $tags = array_map( 'rawurldecode', explode( '/', $params->fromRoute( 'tags' ) ) ); $paginator = $this->getServiceLocator() ->get( 'Grid\Paragraph\Model\Paragraph\Model' ) ->getContentPaginatorByTags( $tags, $all ); $this->paragraphLayout(); return array( 'paginator' => $paginator, 'page' => $page, 'mode' => $mode, 'tags' => $tags, ); }
php
public function listAction() { $params = $this->params(); $page = (int) $params->fromRoute( 'page' ); $mode = $params->fromRoute( 'mode' ); $all = $mode == 'all'; $tags = array_map( 'rawurldecode', explode( '/', $params->fromRoute( 'tags' ) ) ); $paginator = $this->getServiceLocator() ->get( 'Grid\Paragraph\Model\Paragraph\Model' ) ->getContentPaginatorByTags( $tags, $all ); $this->paragraphLayout(); return array( 'paginator' => $paginator, 'page' => $page, 'mode' => $mode, 'tags' => $tags, ); }
[ "public", "function", "listAction", "(", ")", "{", "$", "params", "=", "$", "this", "->", "params", "(", ")", ";", "$", "page", "=", "(", "int", ")", "$", "params", "->", "fromRoute", "(", "'page'", ")", ";", "$", "mode", "=", "$", "params", "->", "fromRoute", "(", "'mode'", ")", ";", "$", "all", "=", "$", "mode", "==", "'all'", ";", "$", "tags", "=", "array_map", "(", "'rawurldecode'", ",", "explode", "(", "'/'", ",", "$", "params", "->", "fromRoute", "(", "'tags'", ")", ")", ")", ";", "$", "paginator", "=", "$", "this", "->", "getServiceLocator", "(", ")", "->", "get", "(", "'Grid\\Paragraph\\Model\\Paragraph\\Model'", ")", "->", "getContentPaginatorByTags", "(", "$", "tags", ",", "$", "all", ")", ";", "$", "this", "->", "paragraphLayout", "(", ")", ";", "return", "array", "(", "'paginator'", "=>", "$", "paginator", ",", "'page'", "=>", "$", "page", ",", "'mode'", "=>", "$", "mode", ",", "'tags'", "=>", "$", "tags", ",", ")", ";", "}" ]
List contents by tags
[ "List", "contents", "by", "tags" ]
cfeb6e8a4732561c2215ec94e736c07f9b8bc990
https://github.com/webriq/core/blob/cfeb6e8a4732561c2215ec94e736c07f9b8bc990/module/Tag/src/Grid/Tag/Controller/ListController.php#L18-L41
4,624
legraxieux53/IO
src/Files/File.php
File.create
public function create() { if(!$this->isFile($this->getName())){ $this->createPath($this->path); $file = fopen($this->getName(), "w"); fclose($file); } }
php
public function create() { if(!$this->isFile($this->getName())){ $this->createPath($this->path); $file = fopen($this->getName(), "w"); fclose($file); } }
[ "public", "function", "create", "(", ")", "{", "if", "(", "!", "$", "this", "->", "isFile", "(", "$", "this", "->", "getName", "(", ")", ")", ")", "{", "$", "this", "->", "createPath", "(", "$", "this", "->", "path", ")", ";", "$", "file", "=", "fopen", "(", "$", "this", "->", "getName", "(", ")", ",", "\"w\"", ")", ";", "fclose", "(", "$", "file", ")", ";", "}", "}" ]
cree le ficher @param string $content [description] @return [type] [description]
[ "cree", "le", "ficher" ]
c3f1890f33817642ba9ab52bf247b7cdd5dda9c4
https://github.com/legraxieux53/IO/blob/c3f1890f33817642ba9ab52bf247b7cdd5dda9c4/src/Files/File.php#L45-L52
4,625
legraxieux53/IO
src/Files/File.php
File.writeOver
public function writeOver($content) { $this->createPath($this->path); file_put_contents($this->getName(), $content); }
php
public function writeOver($content) { $this->createPath($this->path); file_put_contents($this->getName(), $content); }
[ "public", "function", "writeOver", "(", "$", "content", ")", "{", "$", "this", "->", "createPath", "(", "$", "this", "->", "path", ")", ";", "file_put_contents", "(", "$", "this", "->", "getName", "(", ")", ",", "$", "content", ")", ";", "}" ]
Ecrit dans un fichier En ecrasant son contenu @param string $content [description] @return [type] [description]
[ "Ecrit", "dans", "un", "fichier", "En", "ecrasant", "son", "contenu" ]
c3f1890f33817642ba9ab52bf247b7cdd5dda9c4
https://github.com/legraxieux53/IO/blob/c3f1890f33817642ba9ab52bf247b7cdd5dda9c4/src/Files/File.php#L59-L63
4,626
legraxieux53/IO
src/Files/File.php
File.write
public function write ($content) { $this->createPath($this->path); file_put_contents($this->getName(), $content, FILE_APPEND); }
php
public function write ($content) { $this->createPath($this->path); file_put_contents($this->getName(), $content, FILE_APPEND); }
[ "public", "function", "write", "(", "$", "content", ")", "{", "$", "this", "->", "createPath", "(", "$", "this", "->", "path", ")", ";", "file_put_contents", "(", "$", "this", "->", "getName", "(", ")", ",", "$", "content", ",", "FILE_APPEND", ")", ";", "}" ]
Ecrire dans le fichier @param string $content [description] @return [type] [description]
[ "Ecrire", "dans", "le", "fichier" ]
c3f1890f33817642ba9ab52bf247b7cdd5dda9c4
https://github.com/legraxieux53/IO/blob/c3f1890f33817642ba9ab52bf247b7cdd5dda9c4/src/Files/File.php#L70-L74
4,627
legraxieux53/IO
src/Files/File.php
File.generateName
public function generateName () { $chars = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','0','1','2','3','4','5','6','7','8','9']; $cod = self::DEFAULT_AGENT; for ($i=0; $i < 5; $i++) { $cod .= $chars[mt_rand(0, count($chars) - 1)]; } $cod .= '_'; $cod .= time(); return $cod; }
php
public function generateName () { $chars = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','0','1','2','3','4','5','6','7','8','9']; $cod = self::DEFAULT_AGENT; for ($i=0; $i < 5; $i++) { $cod .= $chars[mt_rand(0, count($chars) - 1)]; } $cod .= '_'; $cod .= time(); return $cod; }
[ "public", "function", "generateName", "(", ")", "{", "$", "chars", "=", "[", "'a'", ",", "'b'", ",", "'c'", ",", "'d'", ",", "'e'", ",", "'f'", ",", "'g'", ",", "'h'", ",", "'i'", ",", "'j'", ",", "'k'", ",", "'l'", ",", "'m'", ",", "'n'", ",", "'o'", ",", "'p'", ",", "'q'", ",", "'r'", ",", "'s'", ",", "'t'", ",", "'u'", ",", "'v'", ",", "'w'", ",", "'x'", ",", "'y'", ",", "'z'", ",", "'A'", ",", "'B'", ",", "'C'", ",", "'D'", ",", "'E'", ",", "'F'", ",", "'G'", ",", "'H'", ",", "'I'", ",", "'J'", ",", "'K'", ",", "'L'", ",", "'M'", ",", "'N'", ",", "'O'", ",", "'P'", ",", "'Q'", ",", "'R'", ",", "'S'", ",", "'T'", ",", "'U'", ",", "'V'", ",", "'W'", ",", "'X'", ",", "'Y'", ",", "'Z'", ",", "'0'", ",", "'1'", ",", "'2'", ",", "'3'", ",", "'4'", ",", "'5'", ",", "'6'", ",", "'7'", ",", "'8'", ",", "'9'", "]", ";", "$", "cod", "=", "self", "::", "DEFAULT_AGENT", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "5", ";", "$", "i", "++", ")", "{", "$", "cod", ".=", "$", "chars", "[", "mt_rand", "(", "0", ",", "count", "(", "$", "chars", ")", "-", "1", ")", "]", ";", "}", "$", "cod", ".=", "'_'", ";", "$", "cod", ".=", "time", "(", ")", ";", "return", "$", "cod", ";", "}" ]
genere un nom de fichier @return [type] [description]
[ "genere", "un", "nom", "de", "fichier" ]
c3f1890f33817642ba9ab52bf247b7cdd5dda9c4
https://github.com/legraxieux53/IO/blob/c3f1890f33817642ba9ab52bf247b7cdd5dda9c4/src/Files/File.php#L132-L142
4,628
codebobbly/metaseo_vhs
Classes/Signals/MetaseoExtend.php
MetaseoExtend.metatagOutput
public function metatagOutput($args, $obj) { // Modify the parameter $args here // There is a Issue in the mateseo extension. If the pageTitle is replaced, then the meta.title is wrong $rawTitle = !empty($GLOBALS['TSFE']->altPageTitle) ? $GLOBALS['TSFE']->altPageTitle : $GLOBALS['TSFE']->page['title']; if ($args['meta.title'] && $args['meta.title']['attributes']['content'] !== $rawTitle) { $args['meta.title']['attributes']['content'] = $rawTitle; } return [$args, $obj]; }
php
public function metatagOutput($args, $obj) { // Modify the parameter $args here // There is a Issue in the mateseo extension. If the pageTitle is replaced, then the meta.title is wrong $rawTitle = !empty($GLOBALS['TSFE']->altPageTitle) ? $GLOBALS['TSFE']->altPageTitle : $GLOBALS['TSFE']->page['title']; if ($args['meta.title'] && $args['meta.title']['attributes']['content'] !== $rawTitle) { $args['meta.title']['attributes']['content'] = $rawTitle; } return [$args, $obj]; }
[ "public", "function", "metatagOutput", "(", "$", "args", ",", "$", "obj", ")", "{", "// Modify the parameter $args here", "// There is a Issue in the mateseo extension. If the pageTitle is replaced, then the meta.title is wrong", "$", "rawTitle", "=", "!", "empty", "(", "$", "GLOBALS", "[", "'TSFE'", "]", "->", "altPageTitle", ")", "?", "$", "GLOBALS", "[", "'TSFE'", "]", "->", "altPageTitle", ":", "$", "GLOBALS", "[", "'TSFE'", "]", "->", "page", "[", "'title'", "]", ";", "if", "(", "$", "args", "[", "'meta.title'", "]", "&&", "$", "args", "[", "'meta.title'", "]", "[", "'attributes'", "]", "[", "'content'", "]", "!==", "$", "rawTitle", ")", "{", "$", "args", "[", "'meta.title'", "]", "[", "'attributes'", "]", "[", "'content'", "]", "=", "$", "rawTitle", ";", "}", "return", "[", "$", "args", ",", "$", "obj", "]", ";", "}" ]
Metaseo Signal for page metadata see -> \Metaseo\Metaseo\Page\Part\MetatagPart->processMetaTags @param $args @param $obj @return array
[ "Metaseo", "Signal", "for", "page", "metadata", "see", "-", ">", "\\", "Metaseo", "\\", "Metaseo", "\\", "Page", "\\", "Part", "\\", "MetatagPart", "-", ">", "processMetaTags" ]
d5b65576cb24e7e854753adafc6c4bcc01e82634
https://github.com/codebobbly/metaseo_vhs/blob/d5b65576cb24e7e854753adafc6c4bcc01e82634/Classes/Signals/MetaseoExtend.php#L15-L27
4,629
integratedfordevelopers/integrated-solr-bundle
Command/IndexerQueueCommand.php
IndexerQueueCommand.executeValidation
protected function executeValidation(InputInterface $input, OutputInterface $output) { $types = []; foreach ($this->getResolver()->getTypes() as $type) { $types[$type->getType()] = $type->getType(); } $invalid = []; foreach ($input->getArgument('id') as $id) { if (!isset($types[$id])) { $invalid[] = $id; } } if ($invalid) { $text = sprintf('The content types "%s" do not exists', implode(', ', $invalid)); if ($input->getOption('no-interaction')) { throw new InvalidArgumentException($text); } // ask the user if he/she want to continue or not. $output->writeln($text); if (!$this->getQuestion()->ask( $input, $output, new ConfirmationQuestion('Would you want to continue? [y/N] ', false) )) { return 1; } } return 0; }
php
protected function executeValidation(InputInterface $input, OutputInterface $output) { $types = []; foreach ($this->getResolver()->getTypes() as $type) { $types[$type->getType()] = $type->getType(); } $invalid = []; foreach ($input->getArgument('id') as $id) { if (!isset($types[$id])) { $invalid[] = $id; } } if ($invalid) { $text = sprintf('The content types "%s" do not exists', implode(', ', $invalid)); if ($input->getOption('no-interaction')) { throw new InvalidArgumentException($text); } // ask the user if he/she want to continue or not. $output->writeln($text); if (!$this->getQuestion()->ask( $input, $output, new ConfirmationQuestion('Would you want to continue? [y/N] ', false) )) { return 1; } } return 0; }
[ "protected", "function", "executeValidation", "(", "InputInterface", "$", "input", ",", "OutputInterface", "$", "output", ")", "{", "$", "types", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "getResolver", "(", ")", "->", "getTypes", "(", ")", "as", "$", "type", ")", "{", "$", "types", "[", "$", "type", "->", "getType", "(", ")", "]", "=", "$", "type", "->", "getType", "(", ")", ";", "}", "$", "invalid", "=", "[", "]", ";", "foreach", "(", "$", "input", "->", "getArgument", "(", "'id'", ")", "as", "$", "id", ")", "{", "if", "(", "!", "isset", "(", "$", "types", "[", "$", "id", "]", ")", ")", "{", "$", "invalid", "[", "]", "=", "$", "id", ";", "}", "}", "if", "(", "$", "invalid", ")", "{", "$", "text", "=", "sprintf", "(", "'The content types \"%s\" do not exists'", ",", "implode", "(", "', '", ",", "$", "invalid", ")", ")", ";", "if", "(", "$", "input", "->", "getOption", "(", "'no-interaction'", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "$", "text", ")", ";", "}", "// ask the user if he/she want to continue or not.", "$", "output", "->", "writeln", "(", "$", "text", ")", ";", "if", "(", "!", "$", "this", "->", "getQuestion", "(", ")", "->", "ask", "(", "$", "input", ",", "$", "output", ",", "new", "ConfirmationQuestion", "(", "'Would you want to continue? [y/N] '", ",", "false", ")", ")", ")", "{", "return", "1", ";", "}", "}", "return", "0", ";", "}" ]
validate the ids in de input @param InputInterface $input @param OutputInterface $output @return int @throws InvalidArgumentException
[ "validate", "the", "ids", "in", "de", "input" ]
9d9bb4071e13ed4686fbc97b6286a475ac5b2162
https://github.com/integratedfordevelopers/integrated-solr-bundle/blob/9d9bb4071e13ed4686fbc97b6286a475ac5b2162/Command/IndexerQueueCommand.php#L114-L151
4,630
integratedfordevelopers/integrated-solr-bundle
Command/IndexerQueueCommand.php
IndexerQueueCommand.executeDelete
protected function executeDelete(InputInterface $input, OutputInterface $output) { $this->doIndexCleanup($input->getArgument('id')); $this->doIndexCommit(); return 0; }
php
protected function executeDelete(InputInterface $input, OutputInterface $output) { $this->doIndexCleanup($input->getArgument('id')); $this->doIndexCommit(); return 0; }
[ "protected", "function", "executeDelete", "(", "InputInterface", "$", "input", ",", "OutputInterface", "$", "output", ")", "{", "$", "this", "->", "doIndexCleanup", "(", "$", "input", "->", "getArgument", "(", "'id'", ")", ")", ";", "$", "this", "->", "doIndexCommit", "(", ")", ";", "return", "0", ";", "}" ]
queue a delete on the solr index @param InputInterface $input @param OutputInterface $output @return int
[ "queue", "a", "delete", "on", "the", "solr", "index" ]
9d9bb4071e13ed4686fbc97b6286a475ac5b2162
https://github.com/integratedfordevelopers/integrated-solr-bundle/blob/9d9bb4071e13ed4686fbc97b6286a475ac5b2162/Command/IndexerQueueCommand.php#L161-L167
4,631
integratedfordevelopers/integrated-solr-bundle
Command/IndexerQueueCommand.php
IndexerQueueCommand.executeIndex
protected function executeIndex(InputInterface $input, OutputInterface $output) { // Don't hydrate for performance reasons $builder = $this->getDocumentManager()->createQueryBuilder(Content::class); $builder->select('id', 'contentType', 'class')->hydrate(false); if ($input->getOption('full')) { $result = $builder->getQuery()->execute(); // The entire site is going to be reindex so everything that is now in the queue // will be redone so just clear it so content is not double indexed. $this->getQueue()->clear(); } else { $builder->field('contentType')->in($input->getArgument('id')); $result = $builder->getQuery()->execute(); } if ($count = $result->count()) { $progress = $this->getProgress(); $progress->setRedrawFrequency(min(max(floor($count / 250), 1), 100)); $progress->setFormat(ProgressHelper::FORMAT_VERBOSE); $progress->start($output, $count); // get the current time as it will be required at the end for the solr clean up. $date = new DateTime(); $this->doIndex($result, $progress); $this->doIndexCleanup($input->getArgument('id'), $date); $this->doIndexCommit(); $progress->display(); $progress->finish(); } else { // No content was found but that does not mean nothing should be done. As the solr // index should reflect the database so delete all the content for the matching // content types out the solr index. $this->doIndexCleanup($input->getArgument('id')); $this->doIndexCommit(); } $this->getDocumentManager()->clear(); return 0; }
php
protected function executeIndex(InputInterface $input, OutputInterface $output) { // Don't hydrate for performance reasons $builder = $this->getDocumentManager()->createQueryBuilder(Content::class); $builder->select('id', 'contentType', 'class')->hydrate(false); if ($input->getOption('full')) { $result = $builder->getQuery()->execute(); // The entire site is going to be reindex so everything that is now in the queue // will be redone so just clear it so content is not double indexed. $this->getQueue()->clear(); } else { $builder->field('contentType')->in($input->getArgument('id')); $result = $builder->getQuery()->execute(); } if ($count = $result->count()) { $progress = $this->getProgress(); $progress->setRedrawFrequency(min(max(floor($count / 250), 1), 100)); $progress->setFormat(ProgressHelper::FORMAT_VERBOSE); $progress->start($output, $count); // get the current time as it will be required at the end for the solr clean up. $date = new DateTime(); $this->doIndex($result, $progress); $this->doIndexCleanup($input->getArgument('id'), $date); $this->doIndexCommit(); $progress->display(); $progress->finish(); } else { // No content was found but that does not mean nothing should be done. As the solr // index should reflect the database so delete all the content for the matching // content types out the solr index. $this->doIndexCleanup($input->getArgument('id')); $this->doIndexCommit(); } $this->getDocumentManager()->clear(); return 0; }
[ "protected", "function", "executeIndex", "(", "InputInterface", "$", "input", ",", "OutputInterface", "$", "output", ")", "{", "// Don't hydrate for performance reasons", "$", "builder", "=", "$", "this", "->", "getDocumentManager", "(", ")", "->", "createQueryBuilder", "(", "Content", "::", "class", ")", ";", "$", "builder", "->", "select", "(", "'id'", ",", "'contentType'", ",", "'class'", ")", "->", "hydrate", "(", "false", ")", ";", "if", "(", "$", "input", "->", "getOption", "(", "'full'", ")", ")", "{", "$", "result", "=", "$", "builder", "->", "getQuery", "(", ")", "->", "execute", "(", ")", ";", "// The entire site is going to be reindex so everything that is now in the queue", "// will be redone so just clear it so content is not double indexed.", "$", "this", "->", "getQueue", "(", ")", "->", "clear", "(", ")", ";", "}", "else", "{", "$", "builder", "->", "field", "(", "'contentType'", ")", "->", "in", "(", "$", "input", "->", "getArgument", "(", "'id'", ")", ")", ";", "$", "result", "=", "$", "builder", "->", "getQuery", "(", ")", "->", "execute", "(", ")", ";", "}", "if", "(", "$", "count", "=", "$", "result", "->", "count", "(", ")", ")", "{", "$", "progress", "=", "$", "this", "->", "getProgress", "(", ")", ";", "$", "progress", "->", "setRedrawFrequency", "(", "min", "(", "max", "(", "floor", "(", "$", "count", "/", "250", ")", ",", "1", ")", ",", "100", ")", ")", ";", "$", "progress", "->", "setFormat", "(", "ProgressHelper", "::", "FORMAT_VERBOSE", ")", ";", "$", "progress", "->", "start", "(", "$", "output", ",", "$", "count", ")", ";", "// get the current time as it will be required at the end for the solr clean up.", "$", "date", "=", "new", "DateTime", "(", ")", ";", "$", "this", "->", "doIndex", "(", "$", "result", ",", "$", "progress", ")", ";", "$", "this", "->", "doIndexCleanup", "(", "$", "input", "->", "getArgument", "(", "'id'", ")", ",", "$", "date", ")", ";", "$", "this", "->", "doIndexCommit", "(", ")", ";", "$", "progress", "->", "display", "(", ")", ";", "$", "progress", "->", "finish", "(", ")", ";", "}", "else", "{", "// No content was found but that does not mean nothing should be done. As the solr", "// index should reflect the database so delete all the content for the matching", "// content types out the solr index.", "$", "this", "->", "doIndexCleanup", "(", "$", "input", "->", "getArgument", "(", "'id'", ")", ")", ";", "$", "this", "->", "doIndexCommit", "(", ")", ";", "}", "$", "this", "->", "getDocumentManager", "(", ")", "->", "clear", "(", ")", ";", "return", "0", ";", "}" ]
queue the indexing of content in to solr @param InputInterface $input @param OutputInterface $output @return int
[ "queue", "the", "indexing", "of", "content", "in", "to", "solr" ]
9d9bb4071e13ed4686fbc97b6286a475ac5b2162
https://github.com/integratedfordevelopers/integrated-solr-bundle/blob/9d9bb4071e13ed4686fbc97b6286a475ac5b2162/Command/IndexerQueueCommand.php#L177-L226
4,632
integratedfordevelopers/integrated-solr-bundle
Command/IndexerQueueCommand.php
IndexerQueueCommand.doIndex
protected function doIndex(Cursor $cursor, ProgressHelper $progress) { $queue = $this->getQueue(); // the document manager need to be cleared from time to time so this counter keeps // track of that. $count = 0; $manager = $this->getDocumentManager(); foreach ($cursor as $document) { $progress->advance(); $job = new Job('ADD'); $contentType = isset($document['contentType']) ? $document['contentType'] : ''; $job->setOption('document.id', $contentType . '-' . $document['_id']); $job->setOption('document.data', json_encode(['id' => $document['_id']])); $job->setOption('document.class', $document['class']); $job->setOption('document.format', 'json'); $queue->push($job); if (($count++ % 1000) == 0) { $manager->clear(); } } }
php
protected function doIndex(Cursor $cursor, ProgressHelper $progress) { $queue = $this->getQueue(); // the document manager need to be cleared from time to time so this counter keeps // track of that. $count = 0; $manager = $this->getDocumentManager(); foreach ($cursor as $document) { $progress->advance(); $job = new Job('ADD'); $contentType = isset($document['contentType']) ? $document['contentType'] : ''; $job->setOption('document.id', $contentType . '-' . $document['_id']); $job->setOption('document.data', json_encode(['id' => $document['_id']])); $job->setOption('document.class', $document['class']); $job->setOption('document.format', 'json'); $queue->push($job); if (($count++ % 1000) == 0) { $manager->clear(); } } }
[ "protected", "function", "doIndex", "(", "Cursor", "$", "cursor", ",", "ProgressHelper", "$", "progress", ")", "{", "$", "queue", "=", "$", "this", "->", "getQueue", "(", ")", ";", "// the document manager need to be cleared from time to time so this counter keeps", "// track of that.", "$", "count", "=", "0", ";", "$", "manager", "=", "$", "this", "->", "getDocumentManager", "(", ")", ";", "foreach", "(", "$", "cursor", "as", "$", "document", ")", "{", "$", "progress", "->", "advance", "(", ")", ";", "$", "job", "=", "new", "Job", "(", "'ADD'", ")", ";", "$", "contentType", "=", "isset", "(", "$", "document", "[", "'contentType'", "]", ")", "?", "$", "document", "[", "'contentType'", "]", ":", "''", ";", "$", "job", "->", "setOption", "(", "'document.id'", ",", "$", "contentType", ".", "'-'", ".", "$", "document", "[", "'_id'", "]", ")", ";", "$", "job", "->", "setOption", "(", "'document.data'", ",", "json_encode", "(", "[", "'id'", "=>", "$", "document", "[", "'_id'", "]", "]", ")", ")", ";", "$", "job", "->", "setOption", "(", "'document.class'", ",", "$", "document", "[", "'class'", "]", ")", ";", "$", "job", "->", "setOption", "(", "'document.format'", ",", "'json'", ")", ";", "$", "queue", "->", "push", "(", "$", "job", ")", ";", "if", "(", "(", "$", "count", "++", "%", "1000", ")", "==", "0", ")", "{", "$", "manager", "->", "clear", "(", ")", ";", "}", "}", "}" ]
Add all the documents in the cursor to the solr queue @param Cursor $cursor @param ProgressHelper $progress
[ "Add", "all", "the", "documents", "in", "the", "cursor", "to", "the", "solr", "queue" ]
9d9bb4071e13ed4686fbc97b6286a475ac5b2162
https://github.com/integratedfordevelopers/integrated-solr-bundle/blob/9d9bb4071e13ed4686fbc97b6286a475ac5b2162/Command/IndexerQueueCommand.php#L234-L263
4,633
integratedfordevelopers/integrated-solr-bundle
Command/IndexerQueueCommand.php
IndexerQueueCommand.doIndexCleanup
protected function doIndexCleanup(array $types, DateTime $date = null) { $query = []; if ($types) { $query[] = 'type_name:("' . implode('" OR "', $types) . '")'; } else { $query[] = '*:*'; } if ($date) { $date = clone $date; $date->setTimezone(new DateTimeZone('UTC')); $query[] = '-_time_:[' . $date->format('Y-m-d\TG:i:s\Z') . ' TO *]'; } // Delete everything else that did not got a update or does not exist anymore in the // database. $job = new Job('DELETE'); $job->setOption('query', implode(' ', $query)); $this->getQueue()->push($job, 1); }
php
protected function doIndexCleanup(array $types, DateTime $date = null) { $query = []; if ($types) { $query[] = 'type_name:("' . implode('" OR "', $types) . '")'; } else { $query[] = '*:*'; } if ($date) { $date = clone $date; $date->setTimezone(new DateTimeZone('UTC')); $query[] = '-_time_:[' . $date->format('Y-m-d\TG:i:s\Z') . ' TO *]'; } // Delete everything else that did not got a update or does not exist anymore in the // database. $job = new Job('DELETE'); $job->setOption('query', implode(' ', $query)); $this->getQueue()->push($job, 1); }
[ "protected", "function", "doIndexCleanup", "(", "array", "$", "types", ",", "DateTime", "$", "date", "=", "null", ")", "{", "$", "query", "=", "[", "]", ";", "if", "(", "$", "types", ")", "{", "$", "query", "[", "]", "=", "'type_name:(\"'", ".", "implode", "(", "'\" OR \"'", ",", "$", "types", ")", ".", "'\")'", ";", "}", "else", "{", "$", "query", "[", "]", "=", "'*:*'", ";", "}", "if", "(", "$", "date", ")", "{", "$", "date", "=", "clone", "$", "date", ";", "$", "date", "->", "setTimezone", "(", "new", "DateTimeZone", "(", "'UTC'", ")", ")", ";", "$", "query", "[", "]", "=", "'-_time_:['", ".", "$", "date", "->", "format", "(", "'Y-m-d\\TG:i:s\\Z'", ")", ".", "' TO *]'", ";", "}", "// Delete everything else that did not got a update or does not exist anymore in the", "// database.", "$", "job", "=", "new", "Job", "(", "'DELETE'", ")", ";", "$", "job", "->", "setOption", "(", "'query'", ",", "implode", "(", "' '", ",", "$", "query", ")", ")", ";", "$", "this", "->", "getQueue", "(", ")", "->", "push", "(", "$", "job", ",", "1", ")", ";", "}" ]
delete all the types or everything if none is given @param array $types @param DateTime $date
[ "delete", "all", "the", "types", "or", "everything", "if", "none", "is", "given" ]
9d9bb4071e13ed4686fbc97b6286a475ac5b2162
https://github.com/integratedfordevelopers/integrated-solr-bundle/blob/9d9bb4071e13ed4686fbc97b6286a475ac5b2162/Command/IndexerQueueCommand.php#L271-L295
4,634
InnoGr/FivePercent-Api
src/Handler/Parameter/ObjectMapperParameterResolverAndExtractor.php
ObjectMapperParameterResolverAndExtractor.resolveRequest
private function resolveRequest( ActionInterface $action, CallableInterface $callable, array $inputArguments, \ReflectionParameter $parameter ) { $class = $parameter->getClass(); if ($class->isInterface()) { throw new \RuntimeException(sprintf( 'Could not create instance via interface for parameter "%s" in method "%s". ' . 'You must set the class for type hinting.', $parameter->getName(), Reflection::getCalledMethod($callable->getReflection()) )); } if ($class->isAbstract()) { throw new \RuntimeException(sprintf( 'Could not create instance via abstract class for parameter "%s" in method "%s". ' . 'You must set the real class for type hinting.', $parameter->getName(), Reflection::getCalledMethod($callable->getReflection()) )); } /** @var RequestInterface $request */ $request = $class->newInstance(); // Map arguments $this->objectMapper->map($request, $inputArguments, $action->getRequestMappingGroup()); // First step validation: Strict mode if ($this->validator && $action->isStrictValidation()) { $this->strictRequestValidate($request); } // Second step validation: Base validation if ($this->validator && $action->getValidationGroups()) { $violationList = $this->validator->validate($request, null, $action->getValidationGroups()); if (count($violationList)) { throw ViolationListException::create($violationList); } } // Convert request properties if ($this->propertyConverter) { try { $this->propertyConverter->convertProperties( $request, PropertyConverterManagerInterface::GROUP_DEFAULT ); } catch (InvalidArgumentException $e) { $constraintViolation = new ConstraintViolation( $e->getMessage(), null, [], null, $e->getName(), $e->getInvalidValue() ); $constraintViolationList = new ConstraintViolationList([$constraintViolation]); throw ViolationListException::create($constraintViolationList); } catch (ConverterNotFoundException $e) { if ($this->logger) { $this->logger->warning(sprintf( 'Could not convert properties with message: %s.', rtrim($e->getMessage(), '.') )); } // Nothing action } } return $request; }
php
private function resolveRequest( ActionInterface $action, CallableInterface $callable, array $inputArguments, \ReflectionParameter $parameter ) { $class = $parameter->getClass(); if ($class->isInterface()) { throw new \RuntimeException(sprintf( 'Could not create instance via interface for parameter "%s" in method "%s". ' . 'You must set the class for type hinting.', $parameter->getName(), Reflection::getCalledMethod($callable->getReflection()) )); } if ($class->isAbstract()) { throw new \RuntimeException(sprintf( 'Could not create instance via abstract class for parameter "%s" in method "%s". ' . 'You must set the real class for type hinting.', $parameter->getName(), Reflection::getCalledMethod($callable->getReflection()) )); } /** @var RequestInterface $request */ $request = $class->newInstance(); // Map arguments $this->objectMapper->map($request, $inputArguments, $action->getRequestMappingGroup()); // First step validation: Strict mode if ($this->validator && $action->isStrictValidation()) { $this->strictRequestValidate($request); } // Second step validation: Base validation if ($this->validator && $action->getValidationGroups()) { $violationList = $this->validator->validate($request, null, $action->getValidationGroups()); if (count($violationList)) { throw ViolationListException::create($violationList); } } // Convert request properties if ($this->propertyConverter) { try { $this->propertyConverter->convertProperties( $request, PropertyConverterManagerInterface::GROUP_DEFAULT ); } catch (InvalidArgumentException $e) { $constraintViolation = new ConstraintViolation( $e->getMessage(), null, [], null, $e->getName(), $e->getInvalidValue() ); $constraintViolationList = new ConstraintViolationList([$constraintViolation]); throw ViolationListException::create($constraintViolationList); } catch (ConverterNotFoundException $e) { if ($this->logger) { $this->logger->warning(sprintf( 'Could not convert properties with message: %s.', rtrim($e->getMessage(), '.') )); } // Nothing action } } return $request; }
[ "private", "function", "resolveRequest", "(", "ActionInterface", "$", "action", ",", "CallableInterface", "$", "callable", ",", "array", "$", "inputArguments", ",", "\\", "ReflectionParameter", "$", "parameter", ")", "{", "$", "class", "=", "$", "parameter", "->", "getClass", "(", ")", ";", "if", "(", "$", "class", "->", "isInterface", "(", ")", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "sprintf", "(", "'Could not create instance via interface for parameter \"%s\" in method \"%s\". '", ".", "'You must set the class for type hinting.'", ",", "$", "parameter", "->", "getName", "(", ")", ",", "Reflection", "::", "getCalledMethod", "(", "$", "callable", "->", "getReflection", "(", ")", ")", ")", ")", ";", "}", "if", "(", "$", "class", "->", "isAbstract", "(", ")", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "sprintf", "(", "'Could not create instance via abstract class for parameter \"%s\" in method \"%s\". '", ".", "'You must set the real class for type hinting.'", ",", "$", "parameter", "->", "getName", "(", ")", ",", "Reflection", "::", "getCalledMethod", "(", "$", "callable", "->", "getReflection", "(", ")", ")", ")", ")", ";", "}", "/** @var RequestInterface $request */", "$", "request", "=", "$", "class", "->", "newInstance", "(", ")", ";", "// Map arguments", "$", "this", "->", "objectMapper", "->", "map", "(", "$", "request", ",", "$", "inputArguments", ",", "$", "action", "->", "getRequestMappingGroup", "(", ")", ")", ";", "// First step validation: Strict mode", "if", "(", "$", "this", "->", "validator", "&&", "$", "action", "->", "isStrictValidation", "(", ")", ")", "{", "$", "this", "->", "strictRequestValidate", "(", "$", "request", ")", ";", "}", "// Second step validation: Base validation", "if", "(", "$", "this", "->", "validator", "&&", "$", "action", "->", "getValidationGroups", "(", ")", ")", "{", "$", "violationList", "=", "$", "this", "->", "validator", "->", "validate", "(", "$", "request", ",", "null", ",", "$", "action", "->", "getValidationGroups", "(", ")", ")", ";", "if", "(", "count", "(", "$", "violationList", ")", ")", "{", "throw", "ViolationListException", "::", "create", "(", "$", "violationList", ")", ";", "}", "}", "// Convert request properties", "if", "(", "$", "this", "->", "propertyConverter", ")", "{", "try", "{", "$", "this", "->", "propertyConverter", "->", "convertProperties", "(", "$", "request", ",", "PropertyConverterManagerInterface", "::", "GROUP_DEFAULT", ")", ";", "}", "catch", "(", "InvalidArgumentException", "$", "e", ")", "{", "$", "constraintViolation", "=", "new", "ConstraintViolation", "(", "$", "e", "->", "getMessage", "(", ")", ",", "null", ",", "[", "]", ",", "null", ",", "$", "e", "->", "getName", "(", ")", ",", "$", "e", "->", "getInvalidValue", "(", ")", ")", ";", "$", "constraintViolationList", "=", "new", "ConstraintViolationList", "(", "[", "$", "constraintViolation", "]", ")", ";", "throw", "ViolationListException", "::", "create", "(", "$", "constraintViolationList", ")", ";", "}", "catch", "(", "ConverterNotFoundException", "$", "e", ")", "{", "if", "(", "$", "this", "->", "logger", ")", "{", "$", "this", "->", "logger", "->", "warning", "(", "sprintf", "(", "'Could not convert properties with message: %s.'", ",", "rtrim", "(", "$", "e", "->", "getMessage", "(", ")", ",", "'.'", ")", ")", ")", ";", "}", "// Nothing action", "}", "}", "return", "$", "request", ";", "}" ]
Resolve request parameter @param ActionInterface $action @param CallableInterface $callable @param array $inputArguments @param \ReflectionParameter $parameter @return object @throws \Exception
[ "Resolve", "request", "parameter" ]
57b78ddc3c9d91a7139c276711e5792824ceab9c
https://github.com/InnoGr/FivePercent-Api/blob/57b78ddc3c9d91a7139c276711e5792824ceab9c/src/Handler/Parameter/ObjectMapperParameterResolverAndExtractor.php#L264-L343
4,635
InnoGr/FivePercent-Api
src/Handler/Parameter/ObjectMapperParameterResolverAndExtractor.php
ObjectMapperParameterResolverAndExtractor.strictRequestValidate
private function strictRequestValidate(RequestInterface $request) { $requestMetadata = $this->validator->getMetadataFor($request); $useStrictGroup = false; // Search constraints by group "Strict" if ($requestMetadata instanceof ClassMetadata) { foreach ($requestMetadata->getConstrainedProperties() as $propertyName) { $propertyMetadata = $requestMetadata->getPropertyMetadata($propertyName); if (count($propertyMetadata)) { $propertyMetadata = array_shift($propertyMetadata); } else { continue; } $constraintsInStrictGroup = $propertyMetadata->findConstraints('Strict'); if (count($constraintsInStrictGroup)) { $useStrictGroup = true; break; } } } if ($useStrictGroup) { // The any properties in request class have a "Strict" group validation $violationList = $this->validator->validate($request, null, ['Strict']); if (count($violationList)) { throw ViolationListException::create($violationList); } return; } if ($this->validator instanceof VarTagValidatorInterface) { $violationList = $this->validator->validateObjectByVarTags($request); if (count($violationList)) { throw ViolationListException::create($violationList); } } }
php
private function strictRequestValidate(RequestInterface $request) { $requestMetadata = $this->validator->getMetadataFor($request); $useStrictGroup = false; // Search constraints by group "Strict" if ($requestMetadata instanceof ClassMetadata) { foreach ($requestMetadata->getConstrainedProperties() as $propertyName) { $propertyMetadata = $requestMetadata->getPropertyMetadata($propertyName); if (count($propertyMetadata)) { $propertyMetadata = array_shift($propertyMetadata); } else { continue; } $constraintsInStrictGroup = $propertyMetadata->findConstraints('Strict'); if (count($constraintsInStrictGroup)) { $useStrictGroup = true; break; } } } if ($useStrictGroup) { // The any properties in request class have a "Strict" group validation $violationList = $this->validator->validate($request, null, ['Strict']); if (count($violationList)) { throw ViolationListException::create($violationList); } return; } if ($this->validator instanceof VarTagValidatorInterface) { $violationList = $this->validator->validateObjectByVarTags($request); if (count($violationList)) { throw ViolationListException::create($violationList); } } }
[ "private", "function", "strictRequestValidate", "(", "RequestInterface", "$", "request", ")", "{", "$", "requestMetadata", "=", "$", "this", "->", "validator", "->", "getMetadataFor", "(", "$", "request", ")", ";", "$", "useStrictGroup", "=", "false", ";", "// Search constraints by group \"Strict\"", "if", "(", "$", "requestMetadata", "instanceof", "ClassMetadata", ")", "{", "foreach", "(", "$", "requestMetadata", "->", "getConstrainedProperties", "(", ")", "as", "$", "propertyName", ")", "{", "$", "propertyMetadata", "=", "$", "requestMetadata", "->", "getPropertyMetadata", "(", "$", "propertyName", ")", ";", "if", "(", "count", "(", "$", "propertyMetadata", ")", ")", "{", "$", "propertyMetadata", "=", "array_shift", "(", "$", "propertyMetadata", ")", ";", "}", "else", "{", "continue", ";", "}", "$", "constraintsInStrictGroup", "=", "$", "propertyMetadata", "->", "findConstraints", "(", "'Strict'", ")", ";", "if", "(", "count", "(", "$", "constraintsInStrictGroup", ")", ")", "{", "$", "useStrictGroup", "=", "true", ";", "break", ";", "}", "}", "}", "if", "(", "$", "useStrictGroup", ")", "{", "// The any properties in request class have a \"Strict\" group validation", "$", "violationList", "=", "$", "this", "->", "validator", "->", "validate", "(", "$", "request", ",", "null", ",", "[", "'Strict'", "]", ")", ";", "if", "(", "count", "(", "$", "violationList", ")", ")", "{", "throw", "ViolationListException", "::", "create", "(", "$", "violationList", ")", ";", "}", "return", ";", "}", "if", "(", "$", "this", "->", "validator", "instanceof", "VarTagValidatorInterface", ")", "{", "$", "violationList", "=", "$", "this", "->", "validator", "->", "validateObjectByVarTags", "(", "$", "request", ")", ";", "if", "(", "count", "(", "$", "violationList", ")", ")", "{", "throw", "ViolationListException", "::", "create", "(", "$", "violationList", ")", ";", "}", "}", "}" ]
Strict request validation @param RequestInterface $request @throws ViolationListException
[ "Strict", "request", "validation" ]
57b78ddc3c9d91a7139c276711e5792824ceab9c
https://github.com/InnoGr/FivePercent-Api/blob/57b78ddc3c9d91a7139c276711e5792824ceab9c/src/Handler/Parameter/ObjectMapperParameterResolverAndExtractor.php#L352-L396
4,636
InnoGr/FivePercent-Api
src/Handler/Parameter/ObjectMapperParameterResolverAndExtractor.php
ObjectMapperParameterResolverAndExtractor.isPropertyRequired
private function isPropertyRequired(\ReflectionProperty $property, array $groups) { if (!$this->validator) { // Can not check... return true; } $metadata = $this->validator->getMetadataFor($property->getDeclaringClass()->getName()); if (!$metadata instanceof ClassMetadata) { return true; } $propertyMetadata = $metadata->getPropertyMetadata($property->getName()); if ($propertyMetadata) { // @todo: merge all metadata? $propertyMetadata = array_pop($propertyMetadata); foreach ($groups as $group) { $constraints = $propertyMetadata->findConstraints($group); foreach ($constraints as $constraint) { if ($constraint instanceof NotBlank) { return true; } } } } return false; }
php
private function isPropertyRequired(\ReflectionProperty $property, array $groups) { if (!$this->validator) { // Can not check... return true; } $metadata = $this->validator->getMetadataFor($property->getDeclaringClass()->getName()); if (!$metadata instanceof ClassMetadata) { return true; } $propertyMetadata = $metadata->getPropertyMetadata($property->getName()); if ($propertyMetadata) { // @todo: merge all metadata? $propertyMetadata = array_pop($propertyMetadata); foreach ($groups as $group) { $constraints = $propertyMetadata->findConstraints($group); foreach ($constraints as $constraint) { if ($constraint instanceof NotBlank) { return true; } } } } return false; }
[ "private", "function", "isPropertyRequired", "(", "\\", "ReflectionProperty", "$", "property", ",", "array", "$", "groups", ")", "{", "if", "(", "!", "$", "this", "->", "validator", ")", "{", "// Can not check...", "return", "true", ";", "}", "$", "metadata", "=", "$", "this", "->", "validator", "->", "getMetadataFor", "(", "$", "property", "->", "getDeclaringClass", "(", ")", "->", "getName", "(", ")", ")", ";", "if", "(", "!", "$", "metadata", "instanceof", "ClassMetadata", ")", "{", "return", "true", ";", "}", "$", "propertyMetadata", "=", "$", "metadata", "->", "getPropertyMetadata", "(", "$", "property", "->", "getName", "(", ")", ")", ";", "if", "(", "$", "propertyMetadata", ")", "{", "// @todo: merge all metadata?", "$", "propertyMetadata", "=", "array_pop", "(", "$", "propertyMetadata", ")", ";", "foreach", "(", "$", "groups", "as", "$", "group", ")", "{", "$", "constraints", "=", "$", "propertyMetadata", "->", "findConstraints", "(", "$", "group", ")", ";", "foreach", "(", "$", "constraints", "as", "$", "constraint", ")", "{", "if", "(", "$", "constraint", "instanceof", "NotBlank", ")", "{", "return", "true", ";", "}", "}", "}", "}", "return", "false", ";", "}" ]
Is required property @param \ReflectionProperty $property @param array $groups @return bool
[ "Is", "required", "property" ]
57b78ddc3c9d91a7139c276711e5792824ceab9c
https://github.com/InnoGr/FivePercent-Api/blob/57b78ddc3c9d91a7139c276711e5792824ceab9c/src/Handler/Parameter/ObjectMapperParameterResolverAndExtractor.php#L406-L437
4,637
flowcode/enlace
src/flowcode/enlace/controller/BaseController.php
BaseController.canAccess
public function canAccess(array $user) { $can = false; foreach ($user["roles"] as $userRole) { foreach ($userRole["permissions"] as $permission) { if (in_array($permission, $this->permissions)) { $can = true; break; } } } return $can; }
php
public function canAccess(array $user) { $can = false; foreach ($user["roles"] as $userRole) { foreach ($userRole["permissions"] as $permission) { if (in_array($permission, $this->permissions)) { $can = true; break; } } } return $can; }
[ "public", "function", "canAccess", "(", "array", "$", "user", ")", "{", "$", "can", "=", "false", ";", "foreach", "(", "$", "user", "[", "\"roles\"", "]", "as", "$", "userRole", ")", "{", "foreach", "(", "$", "userRole", "[", "\"permissions\"", "]", "as", "$", "permission", ")", "{", "if", "(", "in_array", "(", "$", "permission", ",", "$", "this", "->", "permissions", ")", ")", "{", "$", "can", "=", "true", ";", "break", ";", "}", "}", "}", "return", "$", "can", ";", "}" ]
Test if the user has the required permissions to access. @param type $user @return boolean
[ "Test", "if", "the", "user", "has", "the", "required", "permissions", "to", "access", "." ]
2dacd15cd3cf32171a19695c331487e1620eacb8
https://github.com/flowcode/enlace/blob/2dacd15cd3cf32171a19695c331487e1620eacb8/src/flowcode/enlace/controller/BaseController.php#L56-L67
4,638
tekkla/core-security
Core/Security/Ban/BanLogEntry.php
BanLogEntry.setCode
public function setCode(int $code) { $allowed_codes = [ 0, 1, 2 ]; if (!in_array($code, $allowed_codes)) { $code = 1; } $this->code = $code; }
php
public function setCode(int $code) { $allowed_codes = [ 0, 1, 2 ]; if (!in_array($code, $allowed_codes)) { $code = 1; } $this->code = $code; }
[ "public", "function", "setCode", "(", "int", "$", "code", ")", "{", "$", "allowed_codes", "=", "[", "0", ",", "1", ",", "2", "]", ";", "if", "(", "!", "in_array", "(", "$", "code", ",", "$", "allowed_codes", ")", ")", "{", "$", "code", "=", "1", ";", "}", "$", "this", "->", "code", "=", "$", "code", ";", "}" ]
Sets banlog code 0 = Notice 1 = Banable event 2 = Enty activates ban @param int $code
[ "Sets", "banlog", "code" ]
66a09ca63a2f5a2239ea7537d2d6bdaa89b0a582
https://github.com/tekkla/core-security/blob/66a09ca63a2f5a2239ea7537d2d6bdaa89b0a582/Core/Security/Ban/BanLogEntry.php#L245-L258
4,639
tekkla/core-security
Core/Security/Ban/BanLogEntry.php
BanLogEntry.add
public function add(): int { if (empty($this->logdate) || empty($this->logstamp)) { $time = time(); if (empty($this->logdate)) { $this->logdate = date('Y-m-d H:i:s', $time); } if (empty($this->logstamp)) { $this->logstamp = $time; } } if (empty($this->client)) { $this->client = $_SERVER['HTTP_USER_AGENT']; } if (empty($this->ip)) { $this->ip = $_SERVER['REMOTE_ADDR']; } if (empty($this->url)) { $this->url = $_SERVER['REQUEST_URI']; } $this->db->qb([ 'table' => 'core_bans', 'data' => [ 'text' => $this->text, 'logdate' => $this->logdate, 'logstamp' => $this->logstamp, 'client' => $this->client, 'ip' => $this->ip, 'url' => $this->url, 'id_user' => $this->id_user, 'code' => $this->code ] ], true); return $this->db->lastInsertId(); }
php
public function add(): int { if (empty($this->logdate) || empty($this->logstamp)) { $time = time(); if (empty($this->logdate)) { $this->logdate = date('Y-m-d H:i:s', $time); } if (empty($this->logstamp)) { $this->logstamp = $time; } } if (empty($this->client)) { $this->client = $_SERVER['HTTP_USER_AGENT']; } if (empty($this->ip)) { $this->ip = $_SERVER['REMOTE_ADDR']; } if (empty($this->url)) { $this->url = $_SERVER['REQUEST_URI']; } $this->db->qb([ 'table' => 'core_bans', 'data' => [ 'text' => $this->text, 'logdate' => $this->logdate, 'logstamp' => $this->logstamp, 'client' => $this->client, 'ip' => $this->ip, 'url' => $this->url, 'id_user' => $this->id_user, 'code' => $this->code ] ], true); return $this->db->lastInsertId(); }
[ "public", "function", "add", "(", ")", ":", "int", "{", "if", "(", "empty", "(", "$", "this", "->", "logdate", ")", "||", "empty", "(", "$", "this", "->", "logstamp", ")", ")", "{", "$", "time", "=", "time", "(", ")", ";", "if", "(", "empty", "(", "$", "this", "->", "logdate", ")", ")", "{", "$", "this", "->", "logdate", "=", "date", "(", "'Y-m-d H:i:s'", ",", "$", "time", ")", ";", "}", "if", "(", "empty", "(", "$", "this", "->", "logstamp", ")", ")", "{", "$", "this", "->", "logstamp", "=", "$", "time", ";", "}", "}", "if", "(", "empty", "(", "$", "this", "->", "client", ")", ")", "{", "$", "this", "->", "client", "=", "$", "_SERVER", "[", "'HTTP_USER_AGENT'", "]", ";", "}", "if", "(", "empty", "(", "$", "this", "->", "ip", ")", ")", "{", "$", "this", "->", "ip", "=", "$", "_SERVER", "[", "'REMOTE_ADDR'", "]", ";", "}", "if", "(", "empty", "(", "$", "this", "->", "url", ")", ")", "{", "$", "this", "->", "url", "=", "$", "_SERVER", "[", "'REQUEST_URI'", "]", ";", "}", "$", "this", "->", "db", "->", "qb", "(", "[", "'table'", "=>", "'core_bans'", ",", "'data'", "=>", "[", "'text'", "=>", "$", "this", "->", "text", ",", "'logdate'", "=>", "$", "this", "->", "logdate", ",", "'logstamp'", "=>", "$", "this", "->", "logstamp", ",", "'client'", "=>", "$", "this", "->", "client", ",", "'ip'", "=>", "$", "this", "->", "ip", ",", "'url'", "=>", "$", "this", "->", "url", ",", "'id_user'", "=>", "$", "this", "->", "id_user", ",", "'code'", "=>", "$", "this", "->", "code", "]", "]", ",", "true", ")", ";", "return", "$", "this", "->", "db", "->", "lastInsertId", "(", ")", ";", "}" ]
Creates log entry in Db and return log id @return int
[ "Creates", "log", "entry", "in", "Db", "and", "return", "log", "id" ]
66a09ca63a2f5a2239ea7537d2d6bdaa89b0a582
https://github.com/tekkla/core-security/blob/66a09ca63a2f5a2239ea7537d2d6bdaa89b0a582/Core/Security/Ban/BanLogEntry.php#L265-L307
4,640
jingwu15/phpbeanstalk
src/phpbeanstalk/Client.php
Client.disconnect
public function disconnect() { if (!is_resource($this->_connection)) { $this->connected = false; } else { $this->connected = !fclose($this->_connection); if (!$this->connected) { $this->_connection = null; } } return !$this->connected; }
php
public function disconnect() { if (!is_resource($this->_connection)) { $this->connected = false; } else { $this->connected = !fclose($this->_connection); if (!$this->connected) { $this->_connection = null; } } return !$this->connected; }
[ "public", "function", "disconnect", "(", ")", "{", "if", "(", "!", "is_resource", "(", "$", "this", "->", "_connection", ")", ")", "{", "$", "this", "->", "connected", "=", "false", ";", "}", "else", "{", "$", "this", "->", "connected", "=", "!", "fclose", "(", "$", "this", "->", "_connection", ")", ";", "if", "(", "!", "$", "this", "->", "connected", ")", "{", "$", "this", "->", "_connection", "=", "null", ";", "}", "}", "return", "!", "$", "this", "->", "connected", ";", "}" ]
Closes the connection to the beanstalk server. @return boolean `true` if diconnecting was successful.
[ "Closes", "the", "connection", "to", "the", "beanstalk", "server", "." ]
1be1810c34883e8a54ced60f748c736af87c9609
https://github.com/jingwu15/phpbeanstalk/blob/1be1810c34883e8a54ced60f748c736af87c9609/src/phpbeanstalk/Client.php#L133-L144
4,641
jingwu15/phpbeanstalk
src/phpbeanstalk/Client.php
Client.reconnect
public function reconnect() { $this->disconnect(); $this->connect(); $stats = $this->stats(); return $stats === false ? false : true; }
php
public function reconnect() { $this->disconnect(); $this->connect(); $stats = $this->stats(); return $stats === false ? false : true; }
[ "public", "function", "reconnect", "(", ")", "{", "$", "this", "->", "disconnect", "(", ")", ";", "$", "this", "->", "connect", "(", ")", ";", "$", "stats", "=", "$", "this", "->", "stats", "(", ")", ";", "return", "$", "stats", "===", "false", "?", "false", ":", "true", ";", "}" ]
reset the connection to the beanstalk server. @return boolean true/false
[ "reset", "the", "connection", "to", "the", "beanstalk", "server", "." ]
1be1810c34883e8a54ced60f748c736af87c9609
https://github.com/jingwu15/phpbeanstalk/blob/1be1810c34883e8a54ced60f748c736af87c9609/src/phpbeanstalk/Client.php#L150-L155
4,642
jingwu15/phpbeanstalk
src/phpbeanstalk/Client.php
Client.usePut
public function usePut($tube, $data, $pri=0, $delay=0, $ttr=30) { $result = $this->useTube($tube); if($result === false) return false; $jobId = $this->put($pri, $delay, $ttr, $data); return $jobId; }
php
public function usePut($tube, $data, $pri=0, $delay=0, $ttr=30) { $result = $this->useTube($tube); if($result === false) return false; $jobId = $this->put($pri, $delay, $ttr, $data); return $jobId; }
[ "public", "function", "usePut", "(", "$", "tube", ",", "$", "data", ",", "$", "pri", "=", "0", ",", "$", "delay", "=", "0", ",", "$", "ttr", "=", "30", ")", "{", "$", "result", "=", "$", "this", "->", "useTube", "(", "$", "tube", ")", ";", "if", "(", "$", "result", "===", "false", ")", "return", "false", ";", "$", "jobId", "=", "$", "this", "->", "put", "(", "$", "pri", ",", "$", "delay", ",", "$", "ttr", ",", "$", "data", ")", ";", "return", "$", "jobId", ";", "}" ]
useTube and put @param string $tube @param integer $pri Jobs with smaller priority values will be scheduled before jobs with larger priorities. The most urgent priority is 0; the least urgent priority is 4294967295. @param integer $delay Seconds to wait before putting the job in the ready queue. The job will be in the "delayed" state during this time. @param integer $ttr Time to run - Number of seconds to allow a worker to run this job. The minimum ttr is 1. @param string $data The job body. @return integer|boolean `false` on error otherwise an integer indicating the job id.
[ "useTube", "and", "put" ]
1be1810c34883e8a54ced60f748c736af87c9609
https://github.com/jingwu15/phpbeanstalk/blob/1be1810c34883e8a54ced60f748c736af87c9609/src/phpbeanstalk/Client.php#L308-L313
4,643
ekyna/UserBundle
Controller/Admin/UserController.php
UserController.generatePasswordAction
public function generatePasswordAction(Request $request) { $context = $this->loadContext($request); $resourceName = $this->config->getResourceName(); /** @var \Ekyna\Bundle\UserBundle\Model\UserInterface $resource */ $resource = $context->getResource($resourceName); $this->isGranted('EDIT', $resource); if (in_array('ROLE_SUPER_ADMIN', $resource->getGroup()->getRoles())) { throw new AccessDeniedHttpException(); } $this->get('fos_user.user_manager')->generatePassword($resource); $password = $resource->getPlainPassword(); $event = new UserEvent($resource); $event ->addMessage(new ResourceMessage( sprintf('Generated password : "%s".', $password), ResourceMessage::TYPE_INFO )) ->addData('password', $password) ; // TODO use ResourceManager $this->getOperator()->update($event); $event->toFlashes($this->getFlashBag()); return $this->redirect($this->generateResourcePath($resource)); }
php
public function generatePasswordAction(Request $request) { $context = $this->loadContext($request); $resourceName = $this->config->getResourceName(); /** @var \Ekyna\Bundle\UserBundle\Model\UserInterface $resource */ $resource = $context->getResource($resourceName); $this->isGranted('EDIT', $resource); if (in_array('ROLE_SUPER_ADMIN', $resource->getGroup()->getRoles())) { throw new AccessDeniedHttpException(); } $this->get('fos_user.user_manager')->generatePassword($resource); $password = $resource->getPlainPassword(); $event = new UserEvent($resource); $event ->addMessage(new ResourceMessage( sprintf('Generated password : "%s".', $password), ResourceMessage::TYPE_INFO )) ->addData('password', $password) ; // TODO use ResourceManager $this->getOperator()->update($event); $event->toFlashes($this->getFlashBag()); return $this->redirect($this->generateResourcePath($resource)); }
[ "public", "function", "generatePasswordAction", "(", "Request", "$", "request", ")", "{", "$", "context", "=", "$", "this", "->", "loadContext", "(", "$", "request", ")", ";", "$", "resourceName", "=", "$", "this", "->", "config", "->", "getResourceName", "(", ")", ";", "/** @var \\Ekyna\\Bundle\\UserBundle\\Model\\UserInterface $resource */", "$", "resource", "=", "$", "context", "->", "getResource", "(", "$", "resourceName", ")", ";", "$", "this", "->", "isGranted", "(", "'EDIT'", ",", "$", "resource", ")", ";", "if", "(", "in_array", "(", "'ROLE_SUPER_ADMIN'", ",", "$", "resource", "->", "getGroup", "(", ")", "->", "getRoles", "(", ")", ")", ")", "{", "throw", "new", "AccessDeniedHttpException", "(", ")", ";", "}", "$", "this", "->", "get", "(", "'fos_user.user_manager'", ")", "->", "generatePassword", "(", "$", "resource", ")", ";", "$", "password", "=", "$", "resource", "->", "getPlainPassword", "(", ")", ";", "$", "event", "=", "new", "UserEvent", "(", "$", "resource", ")", ";", "$", "event", "->", "addMessage", "(", "new", "ResourceMessage", "(", "sprintf", "(", "'Generated password : \"%s\".'", ",", "$", "password", ")", ",", "ResourceMessage", "::", "TYPE_INFO", ")", ")", "->", "addData", "(", "'password'", ",", "$", "password", ")", ";", "// TODO use ResourceManager", "$", "this", "->", "getOperator", "(", ")", "->", "update", "(", "$", "event", ")", ";", "$", "event", "->", "toFlashes", "(", "$", "this", "->", "getFlashBag", "(", ")", ")", ";", "return", "$", "this", "->", "redirect", "(", "$", "this", "->", "generateResourcePath", "(", "$", "resource", ")", ")", ";", "}" ]
Generates a new password for the user. @param Request $request @return \Symfony\Component\HttpFoundation\RedirectResponse
[ "Generates", "a", "new", "password", "for", "the", "user", "." ]
e38d56aee978148a312a923b9e70bdaad1a381bf
https://github.com/ekyna/UserBundle/blob/e38d56aee978148a312a923b9e70bdaad1a381bf/Controller/Admin/UserController.php#L49-L79
4,644
ekyna/UserBundle
Controller/Admin/UserController.php
UserController.clearPasswordRequestAction
public function clearPasswordRequestAction(Request $request) { $context = $this->loadContext($request); $resourceName = $this->config->getResourceName(); /** @var \Ekyna\Bundle\UserBundle\Model\UserInterface $resource */ $resource = $context->getResource($resourceName); $this->isGranted('EDIT', $resource); if ($resource->isPasswordRequestNonExpired($this->container->getParameter('fos_user.resetting.token_ttl'))) { $resource ->setConfirmationToken(null) ->setPasswordRequestedAt(null) ; // TODO use ResourceManager $event = $this->getOperator()->update($resource); $event->toFlashes($this->getFlashBag()); $this->addFlash('ekyna_user.user.alert.password_request_cleared', 'success'); } else { $this->addFlash('ekyna_user.user.alert.no_password_request', 'warning'); } return $this->redirect($this->generateResourcePath($resource)); }
php
public function clearPasswordRequestAction(Request $request) { $context = $this->loadContext($request); $resourceName = $this->config->getResourceName(); /** @var \Ekyna\Bundle\UserBundle\Model\UserInterface $resource */ $resource = $context->getResource($resourceName); $this->isGranted('EDIT', $resource); if ($resource->isPasswordRequestNonExpired($this->container->getParameter('fos_user.resetting.token_ttl'))) { $resource ->setConfirmationToken(null) ->setPasswordRequestedAt(null) ; // TODO use ResourceManager $event = $this->getOperator()->update($resource); $event->toFlashes($this->getFlashBag()); $this->addFlash('ekyna_user.user.alert.password_request_cleared', 'success'); } else { $this->addFlash('ekyna_user.user.alert.no_password_request', 'warning'); } return $this->redirect($this->generateResourcePath($resource)); }
[ "public", "function", "clearPasswordRequestAction", "(", "Request", "$", "request", ")", "{", "$", "context", "=", "$", "this", "->", "loadContext", "(", "$", "request", ")", ";", "$", "resourceName", "=", "$", "this", "->", "config", "->", "getResourceName", "(", ")", ";", "/** @var \\Ekyna\\Bundle\\UserBundle\\Model\\UserInterface $resource */", "$", "resource", "=", "$", "context", "->", "getResource", "(", "$", "resourceName", ")", ";", "$", "this", "->", "isGranted", "(", "'EDIT'", ",", "$", "resource", ")", ";", "if", "(", "$", "resource", "->", "isPasswordRequestNonExpired", "(", "$", "this", "->", "container", "->", "getParameter", "(", "'fos_user.resetting.token_ttl'", ")", ")", ")", "{", "$", "resource", "->", "setConfirmationToken", "(", "null", ")", "->", "setPasswordRequestedAt", "(", "null", ")", ";", "// TODO use ResourceManager", "$", "event", "=", "$", "this", "->", "getOperator", "(", ")", "->", "update", "(", "$", "resource", ")", ";", "$", "event", "->", "toFlashes", "(", "$", "this", "->", "getFlashBag", "(", ")", ")", ";", "$", "this", "->", "addFlash", "(", "'ekyna_user.user.alert.password_request_cleared'", ",", "'success'", ")", ";", "}", "else", "{", "$", "this", "->", "addFlash", "(", "'ekyna_user.user.alert.no_password_request'", ",", "'warning'", ")", ";", "}", "return", "$", "this", "->", "redirect", "(", "$", "this", "->", "generateResourcePath", "(", "$", "resource", ")", ")", ";", "}" ]
Clears the user password request. @param Request $request @return \Symfony\Component\HttpFoundation\RedirectResponse
[ "Clears", "the", "user", "password", "request", "." ]
e38d56aee978148a312a923b9e70bdaad1a381bf
https://github.com/ekyna/UserBundle/blob/e38d56aee978148a312a923b9e70bdaad1a381bf/Controller/Admin/UserController.php#L87-L111
4,645
oliviermadre/dic-it
src/DICIT/Registry.php
Registry.get
public function get($key, $throwIfNotFound = false) { if ($this->has($key)) { return $this->data[$key]; } else if ($throwIfNotFound) { throw new \RuntimeException('Key ' . $key . ' not found in DI Container registry'); } else { return null; } }
php
public function get($key, $throwIfNotFound = false) { if ($this->has($key)) { return $this->data[$key]; } else if ($throwIfNotFound) { throw new \RuntimeException('Key ' . $key . ' not found in DI Container registry'); } else { return null; } }
[ "public", "function", "get", "(", "$", "key", ",", "$", "throwIfNotFound", "=", "false", ")", "{", "if", "(", "$", "this", "->", "has", "(", "$", "key", ")", ")", "{", "return", "$", "this", "->", "data", "[", "$", "key", "]", ";", "}", "else", "if", "(", "$", "throwIfNotFound", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "'Key '", ".", "$", "key", ".", "' not found in DI Container registry'", ")", ";", "}", "else", "{", "return", "null", ";", "}", "}" ]
Fetches an object from the registry. @param string $key @return mixed
[ "Fetches", "an", "object", "from", "the", "registry", "." ]
a3e11305660ca87d296672948ba491b6296cc967
https://github.com/oliviermadre/dic-it/blob/a3e11305660ca87d296672948ba491b6296cc967/src/DICIT/Registry.php#L28-L39
4,646
SergioMadness/framework
framework/facades/Route.php
Route.to
public static function to($path) { $currentLanguage = \Translation::getLanguage(); if (\Translation::getDefaultLanguage() === $currentLanguage) { $currentLanguage = ''; } else { $currentLanguage = '/'.$currentLanguage; } return $currentLanguage.$path; }
php
public static function to($path) { $currentLanguage = \Translation::getLanguage(); if (\Translation::getDefaultLanguage() === $currentLanguage) { $currentLanguage = ''; } else { $currentLanguage = '/'.$currentLanguage; } return $currentLanguage.$path; }
[ "public", "static", "function", "to", "(", "$", "path", ")", "{", "$", "currentLanguage", "=", "\\", "Translation", "::", "getLanguage", "(", ")", ";", "if", "(", "\\", "Translation", "::", "getDefaultLanguage", "(", ")", "===", "$", "currentLanguage", ")", "{", "$", "currentLanguage", "=", "''", ";", "}", "else", "{", "$", "currentLanguage", "=", "'/'", ".", "$", "currentLanguage", ";", "}", "return", "$", "currentLanguage", ".", "$", "path", ";", "}" ]
Append with language @param string $path @return string
[ "Append", "with", "language" ]
a5038eb926a5038b9a331d0cb6a68d7fc3cf1f1e
https://github.com/SergioMadness/framework/blob/a5038eb926a5038b9a331d0cb6a68d7fc3cf1f1e/framework/facades/Route.php#L17-L26
4,647
gliverphp/helpers
src/Form/Form.php
Form.open
public static function open($form_attr=array()) { //this try block is excecuted to enable throwing and catching of errors as appropriate try { //this block throwing exception if method argument is not an array if(! is_array($form_attr)){ throw new HelperException(sprintf('Expecting array of form attributes.e.g.$form_attr = array(\'name\'=>\'form1\',\'action\'=>\'post\')',$form_attr)); } $form_attr_str=''; foreach($form_attr as $key=>$val){ $form_attr_str .= $key.'="'.$val.'" '; } //$form_attr_str = implode('= ',$form_attr); return "<form ".$form_attr_str.' >'; } catch(BaseException $e) { //echo $e->getMessage(); $e->show(); } catch(Exception $e) { echo $e->getMessage(); } }
php
public static function open($form_attr=array()) { //this try block is excecuted to enable throwing and catching of errors as appropriate try { //this block throwing exception if method argument is not an array if(! is_array($form_attr)){ throw new HelperException(sprintf('Expecting array of form attributes.e.g.$form_attr = array(\'name\'=>\'form1\',\'action\'=>\'post\')',$form_attr)); } $form_attr_str=''; foreach($form_attr as $key=>$val){ $form_attr_str .= $key.'="'.$val.'" '; } //$form_attr_str = implode('= ',$form_attr); return "<form ".$form_attr_str.' >'; } catch(BaseException $e) { //echo $e->getMessage(); $e->show(); } catch(Exception $e) { echo $e->getMessage(); } }
[ "public", "static", "function", "open", "(", "$", "form_attr", "=", "array", "(", ")", ")", "{", "//this try block is excecuted to enable throwing and catching of errors as appropriate", "try", "{", "//this block throwing exception if method argument is not an array", "if", "(", "!", "is_array", "(", "$", "form_attr", ")", ")", "{", "throw", "new", "HelperException", "(", "sprintf", "(", "'Expecting array of form attributes.e.g.$form_attr = array(\\'name\\'=>\\'form1\\',\\'action\\'=>\\'post\\')'", ",", "$", "form_attr", ")", ")", ";", "}", "$", "form_attr_str", "=", "''", ";", "foreach", "(", "$", "form_attr", "as", "$", "key", "=>", "$", "val", ")", "{", "$", "form_attr_str", ".=", "$", "key", ".", "'=\"'", ".", "$", "val", ".", "'\" '", ";", "}", "//$form_attr_str = implode('= ',$form_attr);", "return", "\"<form \"", ".", "$", "form_attr_str", ".", "' >'", ";", "}", "catch", "(", "BaseException", "$", "e", ")", "{", "//echo $e->getMessage();", "$", "e", "->", "show", "(", ")", ";", "}", "catch", "(", "Exception", "$", "e", ")", "{", "echo", "$", "e", "->", "getMessage", "(", ")", ";", "}", "}" ]
Ths method create form open tag with attributes in view. @param array $form_attr Form attributes e.g. $form_attr = array('name'=>'form1','action'=>'post')
[ "Ths", "method", "create", "form", "open", "tag", "with", "attributes", "in", "view", "." ]
c5204df8169fad55f5b273422e45f56164373ab8
https://github.com/gliverphp/helpers/blob/c5204df8169fad55f5b273422e45f56164373ab8/src/Form/Form.php#L42-L72
4,648
joomlatools/joomlatools-platform-categories
administrator/components/com_categories/controller.php
CategoriesController.display
public function display($cachable = false, $urlparams = array()) { // Get the document object. $document = JFactory::getDocument(); // Set the default view name and format from the Request. $vName = $this->input->get('view', 'categories'); $vFormat = $document->getType(); $lName = $this->input->get('layout', 'default', 'string'); $id = $this->input->getInt('id'); // Check for edit form. if ($vName == 'category' && $lName == 'edit' && !$this->checkEditId('com_categories.edit.category', $id)) { // Somehow the person just went to the form - we don't allow that. $this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID', $id)); $this->setMessage($this->getError(), 'error'); $this->setRedirect(JRoute::_('index.php?option=com_categories&view=categories&extension=' . $this->extension, false)); return false; } // Get and render the view. if ($view = $this->getView($vName, $vFormat)) { // Get the model for the view. $model = $this->getModel($vName, 'CategoriesModel', array('name' => $vName . '.' . substr($this->extension, 4))); // Push the model into the view (as default). $view->setModel($model, true); $view->setLayout($lName); // Push document object into the view. $view->document = $document; // Load the submenu. JLoader::register('CategoriesHelper', JPATH_ADMINISTRATOR . '/components/com_categories/helpers/categories.php'); CategoriesHelper::addSubmenu($model->getState('filter.extension')); $view->display(); } return $this; }
php
public function display($cachable = false, $urlparams = array()) { // Get the document object. $document = JFactory::getDocument(); // Set the default view name and format from the Request. $vName = $this->input->get('view', 'categories'); $vFormat = $document->getType(); $lName = $this->input->get('layout', 'default', 'string'); $id = $this->input->getInt('id'); // Check for edit form. if ($vName == 'category' && $lName == 'edit' && !$this->checkEditId('com_categories.edit.category', $id)) { // Somehow the person just went to the form - we don't allow that. $this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID', $id)); $this->setMessage($this->getError(), 'error'); $this->setRedirect(JRoute::_('index.php?option=com_categories&view=categories&extension=' . $this->extension, false)); return false; } // Get and render the view. if ($view = $this->getView($vName, $vFormat)) { // Get the model for the view. $model = $this->getModel($vName, 'CategoriesModel', array('name' => $vName . '.' . substr($this->extension, 4))); // Push the model into the view (as default). $view->setModel($model, true); $view->setLayout($lName); // Push document object into the view. $view->document = $document; // Load the submenu. JLoader::register('CategoriesHelper', JPATH_ADMINISTRATOR . '/components/com_categories/helpers/categories.php'); CategoriesHelper::addSubmenu($model->getState('filter.extension')); $view->display(); } return $this; }
[ "public", "function", "display", "(", "$", "cachable", "=", "false", ",", "$", "urlparams", "=", "array", "(", ")", ")", "{", "// Get the document object.", "$", "document", "=", "JFactory", "::", "getDocument", "(", ")", ";", "// Set the default view name and format from the Request.", "$", "vName", "=", "$", "this", "->", "input", "->", "get", "(", "'view'", ",", "'categories'", ")", ";", "$", "vFormat", "=", "$", "document", "->", "getType", "(", ")", ";", "$", "lName", "=", "$", "this", "->", "input", "->", "get", "(", "'layout'", ",", "'default'", ",", "'string'", ")", ";", "$", "id", "=", "$", "this", "->", "input", "->", "getInt", "(", "'id'", ")", ";", "// Check for edit form.", "if", "(", "$", "vName", "==", "'category'", "&&", "$", "lName", "==", "'edit'", "&&", "!", "$", "this", "->", "checkEditId", "(", "'com_categories.edit.category'", ",", "$", "id", ")", ")", "{", "// Somehow the person just went to the form - we don't allow that.", "$", "this", "->", "setError", "(", "JText", "::", "sprintf", "(", "'JLIB_APPLICATION_ERROR_UNHELD_ID'", ",", "$", "id", ")", ")", ";", "$", "this", "->", "setMessage", "(", "$", "this", "->", "getError", "(", ")", ",", "'error'", ")", ";", "$", "this", "->", "setRedirect", "(", "JRoute", "::", "_", "(", "'index.php?option=com_categories&view=categories&extension='", ".", "$", "this", "->", "extension", ",", "false", ")", ")", ";", "return", "false", ";", "}", "// Get and render the view.", "if", "(", "$", "view", "=", "$", "this", "->", "getView", "(", "$", "vName", ",", "$", "vFormat", ")", ")", "{", "// Get the model for the view.", "$", "model", "=", "$", "this", "->", "getModel", "(", "$", "vName", ",", "'CategoriesModel'", ",", "array", "(", "'name'", "=>", "$", "vName", ".", "'.'", ".", "substr", "(", "$", "this", "->", "extension", ",", "4", ")", ")", ")", ";", "// Push the model into the view (as default).", "$", "view", "->", "setModel", "(", "$", "model", ",", "true", ")", ";", "$", "view", "->", "setLayout", "(", "$", "lName", ")", ";", "// Push document object into the view.", "$", "view", "->", "document", "=", "$", "document", ";", "// Load the submenu.", "JLoader", "::", "register", "(", "'CategoriesHelper'", ",", "JPATH_ADMINISTRATOR", ".", "'/components/com_categories/helpers/categories.php'", ")", ";", "CategoriesHelper", "::", "addSubmenu", "(", "$", "model", "->", "getState", "(", "'filter.extension'", ")", ")", ";", "$", "view", "->", "display", "(", ")", ";", "}", "return", "$", "this", ";", "}" ]
Method to display a view. @param boolean $cachable If true, the view output will be cached @param array $urlparams An array of safe url parameters and their variable types, for valid values see {@link JFilterInput::clean()}. @return CategoriesController This object to support chaining. @since 1.5
[ "Method", "to", "display", "a", "view", "." ]
9fe50b6c4ebe6ebfcf98e50067922fcf4a76d350
https://github.com/joomlatools/joomlatools-platform-categories/blob/9fe50b6c4ebe6ebfcf98e50067922fcf4a76d350/administrator/components/com_categories/controller.php#L56-L99
4,649
bkdotcom/Form
src/Output.php
Output.buildOutput
public function buildOutput($form) { $this->debug->groupCollapsed(__METHOD__); $this->debug->groupUncollapse(); $str = ''; foreach ($form->currentFields as $field) { $str .= $field->build()."\n"; } $this->debug->groupEnd(); return $str; }
php
public function buildOutput($form) { $this->debug->groupCollapsed(__METHOD__); $this->debug->groupUncollapse(); $str = ''; foreach ($form->currentFields as $field) { $str .= $field->build()."\n"; } $this->debug->groupEnd(); return $str; }
[ "public", "function", "buildOutput", "(", "$", "form", ")", "{", "$", "this", "->", "debug", "->", "groupCollapsed", "(", "__METHOD__", ")", ";", "$", "this", "->", "debug", "->", "groupUncollapse", "(", ")", ";", "$", "str", "=", "''", ";", "foreach", "(", "$", "form", "->", "currentFields", "as", "$", "field", ")", "{", "$", "str", ".=", "$", "field", "->", "build", "(", ")", ".", "\"\\n\"", ";", "}", "$", "this", "->", "debug", "->", "groupEnd", "(", ")", ";", "return", "$", "str", ";", "}" ]
Default fields builder @param Form $form form instance @return string html
[ "Default", "fields", "builder" ]
6aa5704b20300e1c8bd1c187a4fa88db9d442cee
https://github.com/bkdotcom/Form/blob/6aa5704b20300e1c8bd1c187a4fa88db9d442cee/src/Output.php#L133-L143
4,650
bkdotcom/Form
src/Output.php
Output.buildHiddenFields
private function buildHiddenFields() { $this->debug->groupCollapsed(__METHOD__); $cfg = $this->form->cfg; $printOpts = &$cfg['output']; $hiddenFields = ''; if ($printOpts['inputKey']) { // && $cfg['persist_method'] != 'none' $hiddenFields .= '<input type="hidden" name="_key_" value="'.\htmlspecialchars($this->keyValue).'" />'; } if (\strtolower($cfg['attribs']['method']) == 'get') { $this->debug->warn('get method'); $urlParts = \parse_url(\html_entity_decode($cfg['attribs']['action'])); // $attribs['action'] = $urlParts['path']; if (!empty($urlParts['query'])) { \parse_str($urlParts['query'], $params); $fieldNames = array(); foreach ($this->form->currentFields as $field) { $fieldNames[] = $field->attribs['name']; } foreach ($params as $k => $v) { if (\in_array($k, $fieldNames)) { continue; } $hiddenFields .= '<input type="hidden" name="'.\htmlspecialchars($k).'" value="'.\htmlspecialchars($v).'" />'."\n"; } } } $this->debug->log('hiddenFields', $hiddenFields); $this->debug->groupEnd(); return $hiddenFields; }
php
private function buildHiddenFields() { $this->debug->groupCollapsed(__METHOD__); $cfg = $this->form->cfg; $printOpts = &$cfg['output']; $hiddenFields = ''; if ($printOpts['inputKey']) { // && $cfg['persist_method'] != 'none' $hiddenFields .= '<input type="hidden" name="_key_" value="'.\htmlspecialchars($this->keyValue).'" />'; } if (\strtolower($cfg['attribs']['method']) == 'get') { $this->debug->warn('get method'); $urlParts = \parse_url(\html_entity_decode($cfg['attribs']['action'])); // $attribs['action'] = $urlParts['path']; if (!empty($urlParts['query'])) { \parse_str($urlParts['query'], $params); $fieldNames = array(); foreach ($this->form->currentFields as $field) { $fieldNames[] = $field->attribs['name']; } foreach ($params as $k => $v) { if (\in_array($k, $fieldNames)) { continue; } $hiddenFields .= '<input type="hidden" name="'.\htmlspecialchars($k).'" value="'.\htmlspecialchars($v).'" />'."\n"; } } } $this->debug->log('hiddenFields', $hiddenFields); $this->debug->groupEnd(); return $hiddenFields; }
[ "private", "function", "buildHiddenFields", "(", ")", "{", "$", "this", "->", "debug", "->", "groupCollapsed", "(", "__METHOD__", ")", ";", "$", "cfg", "=", "$", "this", "->", "form", "->", "cfg", ";", "$", "printOpts", "=", "&", "$", "cfg", "[", "'output'", "]", ";", "$", "hiddenFields", "=", "''", ";", "if", "(", "$", "printOpts", "[", "'inputKey'", "]", ")", "{", "// && $cfg['persist_method'] != 'none'", "$", "hiddenFields", ".=", "'<input type=\"hidden\" name=\"_key_\" value=\"'", ".", "\\", "htmlspecialchars", "(", "$", "this", "->", "keyValue", ")", ".", "'\" />'", ";", "}", "if", "(", "\\", "strtolower", "(", "$", "cfg", "[", "'attribs'", "]", "[", "'method'", "]", ")", "==", "'get'", ")", "{", "$", "this", "->", "debug", "->", "warn", "(", "'get method'", ")", ";", "$", "urlParts", "=", "\\", "parse_url", "(", "\\", "html_entity_decode", "(", "$", "cfg", "[", "'attribs'", "]", "[", "'action'", "]", ")", ")", ";", "// $attribs['action'] = $urlParts['path'];", "if", "(", "!", "empty", "(", "$", "urlParts", "[", "'query'", "]", ")", ")", "{", "\\", "parse_str", "(", "$", "urlParts", "[", "'query'", "]", ",", "$", "params", ")", ";", "$", "fieldNames", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "form", "->", "currentFields", "as", "$", "field", ")", "{", "$", "fieldNames", "[", "]", "=", "$", "field", "->", "attribs", "[", "'name'", "]", ";", "}", "foreach", "(", "$", "params", "as", "$", "k", "=>", "$", "v", ")", "{", "if", "(", "\\", "in_array", "(", "$", "k", ",", "$", "fieldNames", ")", ")", "{", "continue", ";", "}", "$", "hiddenFields", ".=", "'<input type=\"hidden\" name=\"'", ".", "\\", "htmlspecialchars", "(", "$", "k", ")", ".", "'\" value=\"'", ".", "\\", "htmlspecialchars", "(", "$", "v", ")", ".", "'\" />'", ".", "\"\\n\"", ";", "}", "}", "}", "$", "this", "->", "debug", "->", "log", "(", "'hiddenFields'", ",", "$", "hiddenFields", ")", ";", "$", "this", "->", "debug", "->", "groupEnd", "(", ")", ";", "return", "$", "hiddenFields", ";", "}" ]
Generate hidden fields not related to inputs @return string
[ "Generate", "hidden", "fields", "not", "related", "to", "inputs" ]
6aa5704b20300e1c8bd1c187a4fa88db9d442cee
https://github.com/bkdotcom/Form/blob/6aa5704b20300e1c8bd1c187a4fa88db9d442cee/src/Output.php#L150-L180
4,651
jhorlima/wp-mocabonita
src/tools/MbPath.php
MbPath.pName
public static function pName() { if (is_null(self::$pluginName)) { self::$pluginName = explode('/', plugin_basename(__FILE__))[0]; } return self::$pluginName; }
php
public static function pName() { if (is_null(self::$pluginName)) { self::$pluginName = explode('/', plugin_basename(__FILE__))[0]; } return self::$pluginName; }
[ "public", "static", "function", "pName", "(", ")", "{", "if", "(", "is_null", "(", "self", "::", "$", "pluginName", ")", ")", "{", "self", "::", "$", "pluginName", "=", "explode", "(", "'/'", ",", "plugin_basename", "(", "__FILE__", ")", ")", "[", "0", "]", ";", "}", "return", "self", "::", "$", "pluginName", ";", "}" ]
Get plugin name @return string
[ "Get", "plugin", "name" ]
a864b40d5452bc9b892f02a6bb28c02639f25fa8
https://github.com/jhorlima/wp-mocabonita/blob/a864b40d5452bc9b892f02a6bb28c02639f25fa8/src/tools/MbPath.php#L55-L62
4,652
jhorlima/wp-mocabonita
src/tools/MbPath.php
MbPath.pBaseN
public static function pBaseN() { if (is_null(self::$pluginBaseName)) { self::$pluginBaseName = self::pName() . "/index.php"; } return self::$pluginBaseName; }
php
public static function pBaseN() { if (is_null(self::$pluginBaseName)) { self::$pluginBaseName = self::pName() . "/index.php"; } return self::$pluginBaseName; }
[ "public", "static", "function", "pBaseN", "(", ")", "{", "if", "(", "is_null", "(", "self", "::", "$", "pluginBaseName", ")", ")", "{", "self", "::", "$", "pluginBaseName", "=", "self", "::", "pName", "(", ")", ".", "\"/index.php\"", ";", "}", "return", "self", "::", "$", "pluginBaseName", ";", "}" ]
Get plugin base name @return string
[ "Get", "plugin", "base", "name" ]
a864b40d5452bc9b892f02a6bb28c02639f25fa8
https://github.com/jhorlima/wp-mocabonita/blob/a864b40d5452bc9b892f02a6bb28c02639f25fa8/src/tools/MbPath.php#L69-L76
4,653
jhorlima/wp-mocabonita
src/tools/MbPath.php
MbPath.pDir
public static function pDir($complement = "") { if (is_null(self::$pluginDirectory)) { self::$pluginDirectory = WP_PLUGIN_DIR . "/" . self::pName(); } return self::$pluginDirectory . $complement; }
php
public static function pDir($complement = "") { if (is_null(self::$pluginDirectory)) { self::$pluginDirectory = WP_PLUGIN_DIR . "/" . self::pName(); } return self::$pluginDirectory . $complement; }
[ "public", "static", "function", "pDir", "(", "$", "complement", "=", "\"\"", ")", "{", "if", "(", "is_null", "(", "self", "::", "$", "pluginDirectory", ")", ")", "{", "self", "::", "$", "pluginDirectory", "=", "WP_PLUGIN_DIR", ".", "\"/\"", ".", "self", "::", "pName", "(", ")", ";", "}", "return", "self", "::", "$", "pluginDirectory", ".", "$", "complement", ";", "}" ]
Get plugin directory @param string $complement @return string
[ "Get", "plugin", "directory" ]
a864b40d5452bc9b892f02a6bb28c02639f25fa8
https://github.com/jhorlima/wp-mocabonita/blob/a864b40d5452bc9b892f02a6bb28c02639f25fa8/src/tools/MbPath.php#L85-L92
4,654
jhorlima/wp-mocabonita
src/tools/MbPath.php
MbPath.pUrl
public static function pUrl($complement = "") { if (is_null(self::$pluginUrl)) { self::$pluginUrl = WP_PLUGIN_URL . "/" . self::pName(); } return self::$pluginUrl . $complement; }
php
public static function pUrl($complement = "") { if (is_null(self::$pluginUrl)) { self::$pluginUrl = WP_PLUGIN_URL . "/" . self::pName(); } return self::$pluginUrl . $complement; }
[ "public", "static", "function", "pUrl", "(", "$", "complement", "=", "\"\"", ")", "{", "if", "(", "is_null", "(", "self", "::", "$", "pluginUrl", ")", ")", "{", "self", "::", "$", "pluginUrl", "=", "WP_PLUGIN_URL", ".", "\"/\"", ".", "self", "::", "pName", "(", ")", ";", "}", "return", "self", "::", "$", "pluginUrl", ".", "$", "complement", ";", "}" ]
Get plugin url @param string $complement @return string
[ "Get", "plugin", "url" ]
a864b40d5452bc9b892f02a6bb28c02639f25fa8
https://github.com/jhorlima/wp-mocabonita/blob/a864b40d5452bc9b892f02a6bb28c02639f25fa8/src/tools/MbPath.php#L101-L108
4,655
canis-io/yii2-canis-lib
lib/db/behaviors/ActiveArchivable.php
ActiveArchivable.getArchived
public function getArchived() { if (!$this->isArchivable()) { return false; } if (empty($this->owner->{$this->archiveField})) { return false; } return true; }
php
public function getArchived() { if (!$this->isArchivable()) { return false; } if (empty($this->owner->{$this->archiveField})) { return false; } return true; }
[ "public", "function", "getArchived", "(", ")", "{", "if", "(", "!", "$", "this", "->", "isArchivable", "(", ")", ")", "{", "return", "false", ";", "}", "if", "(", "empty", "(", "$", "this", "->", "owner", "->", "{", "$", "this", "->", "archiveField", "}", ")", ")", "{", "return", "false", ";", "}", "return", "true", ";", "}" ]
Get archived. @return [[@doctodo return_type:getArchived]] [[@doctodo return_description:getArchived]]
[ "Get", "archived", "." ]
97d533521f65b084dc805c5f312c364b469142d2
https://github.com/canis-io/yii2-canis-lib/blob/97d533521f65b084dc805c5f312c364b469142d2/lib/db/behaviors/ActiveArchivable.php#L79-L89
4,656
teamelf/core
src/Router/Router.php
Router.add
public function add($method, $name, $path, $controller = null, array $requirements = [], array $options = [], $host = '', array $schemas = [], $condition = '') { if (!in_array(strtoupper($method), $this->allowedMethod)) { throw new HttpMethodNotAllowedException(); } $this->routes->add( $name, new Route( $this->prefix . $path, ['_controller' => $controller], $requirements, $options, $host, $schemas, [strtoupper($method)], $condition ) ); return $this; }
php
public function add($method, $name, $path, $controller = null, array $requirements = [], array $options = [], $host = '', array $schemas = [], $condition = '') { if (!in_array(strtoupper($method), $this->allowedMethod)) { throw new HttpMethodNotAllowedException(); } $this->routes->add( $name, new Route( $this->prefix . $path, ['_controller' => $controller], $requirements, $options, $host, $schemas, [strtoupper($method)], $condition ) ); return $this; }
[ "public", "function", "add", "(", "$", "method", ",", "$", "name", ",", "$", "path", ",", "$", "controller", "=", "null", ",", "array", "$", "requirements", "=", "[", "]", ",", "array", "$", "options", "=", "[", "]", ",", "$", "host", "=", "''", ",", "array", "$", "schemas", "=", "[", "]", ",", "$", "condition", "=", "''", ")", "{", "if", "(", "!", "in_array", "(", "strtoupper", "(", "$", "method", ")", ",", "$", "this", "->", "allowedMethod", ")", ")", "{", "throw", "new", "HttpMethodNotAllowedException", "(", ")", ";", "}", "$", "this", "->", "routes", "->", "add", "(", "$", "name", ",", "new", "Route", "(", "$", "this", "->", "prefix", ".", "$", "path", ",", "[", "'_controller'", "=>", "$", "controller", "]", ",", "$", "requirements", ",", "$", "options", ",", "$", "host", ",", "$", "schemas", ",", "[", "strtoupper", "(", "$", "method", ")", "]", ",", "$", "condition", ")", ")", ";", "return", "$", "this", ";", "}" ]
add a route rule @param string $method @param string $name @param string $path @param string $controller @param array $requirements @param array $options @param string $host @param array $schemas @param string $condition @return $this @throws HttpMethodNotAllowedException
[ "add", "a", "route", "rule" ]
653fc6e27f42239c2a8998a5fea325480e9dd39e
https://github.com/teamelf/core/blob/653fc6e27f42239c2a8998a5fea325480e9dd39e/src/Router/Router.php#L104-L124
4,657
teamelf/core
src/Router/Router.php
Router.get
public function get($name, $path, $controller = null) { $this->add('GET', $name, $path, $controller); return $this; }
php
public function get($name, $path, $controller = null) { $this->add('GET', $name, $path, $controller); return $this; }
[ "public", "function", "get", "(", "$", "name", ",", "$", "path", ",", "$", "controller", "=", "null", ")", "{", "$", "this", "->", "add", "(", "'GET'", ",", "$", "name", ",", "$", "path", ",", "$", "controller", ")", ";", "return", "$", "this", ";", "}" ]
add a get rule in route @param string $name @param string $path @param string $controller @return $this
[ "add", "a", "get", "rule", "in", "route" ]
653fc6e27f42239c2a8998a5fea325480e9dd39e
https://github.com/teamelf/core/blob/653fc6e27f42239c2a8998a5fea325480e9dd39e/src/Router/Router.php#L134-L138
4,658
teamelf/core
src/Router/Router.php
Router.post
public function post($name, $path, $controller = null) { $this->add('POST', $name, $path, $controller); return $this; }
php
public function post($name, $path, $controller = null) { $this->add('POST', $name, $path, $controller); return $this; }
[ "public", "function", "post", "(", "$", "name", ",", "$", "path", ",", "$", "controller", "=", "null", ")", "{", "$", "this", "->", "add", "(", "'POST'", ",", "$", "name", ",", "$", "path", ",", "$", "controller", ")", ";", "return", "$", "this", ";", "}" ]
add a post rule in route @param string $name @param string $path @param string $controller @return $this
[ "add", "a", "post", "rule", "in", "route" ]
653fc6e27f42239c2a8998a5fea325480e9dd39e
https://github.com/teamelf/core/blob/653fc6e27f42239c2a8998a5fea325480e9dd39e/src/Router/Router.php#L148-L152
4,659
teamelf/core
src/Router/Router.php
Router.put
public function put($name, $path, $controller = null) { $this->add('PUT', $name, $path, $controller); return $this; }
php
public function put($name, $path, $controller = null) { $this->add('PUT', $name, $path, $controller); return $this; }
[ "public", "function", "put", "(", "$", "name", ",", "$", "path", ",", "$", "controller", "=", "null", ")", "{", "$", "this", "->", "add", "(", "'PUT'", ",", "$", "name", ",", "$", "path", ",", "$", "controller", ")", ";", "return", "$", "this", ";", "}" ]
add a put rule in route @param string $name @param string $path @param string $controller @return $this
[ "add", "a", "put", "rule", "in", "route" ]
653fc6e27f42239c2a8998a5fea325480e9dd39e
https://github.com/teamelf/core/blob/653fc6e27f42239c2a8998a5fea325480e9dd39e/src/Router/Router.php#L162-L166
4,660
teamelf/core
src/Router/Router.php
Router.delete
public function delete($name, $path, $controller = null) { $this->add('DELETE', $name, $path, $controller); return $this; }
php
public function delete($name, $path, $controller = null) { $this->add('DELETE', $name, $path, $controller); return $this; }
[ "public", "function", "delete", "(", "$", "name", ",", "$", "path", ",", "$", "controller", "=", "null", ")", "{", "$", "this", "->", "add", "(", "'DELETE'", ",", "$", "name", ",", "$", "path", ",", "$", "controller", ")", ";", "return", "$", "this", ";", "}" ]
add a delete rule in route @param string $name @param string $path @param string $controller @return $this
[ "add", "a", "delete", "rule", "in", "route" ]
653fc6e27f42239c2a8998a5fea325480e9dd39e
https://github.com/teamelf/core/blob/653fc6e27f42239c2a8998a5fea325480e9dd39e/src/Router/Router.php#L176-L180
4,661
teamelf/core
src/Router/Router.php
Router.patch
public function patch($name, $path, $controller = null) { $this->add('PATCH', $name, $path, $controller); return $this; }
php
public function patch($name, $path, $controller = null) { $this->add('PATCH', $name, $path, $controller); return $this; }
[ "public", "function", "patch", "(", "$", "name", ",", "$", "path", ",", "$", "controller", "=", "null", ")", "{", "$", "this", "->", "add", "(", "'PATCH'", ",", "$", "name", ",", "$", "path", ",", "$", "controller", ")", ";", "return", "$", "this", ";", "}" ]
add a patch rule in route @param string $name @param string $path @param string $controller @return $this
[ "add", "a", "patch", "rule", "in", "route" ]
653fc6e27f42239c2a8998a5fea325480e9dd39e
https://github.com/teamelf/core/blob/653fc6e27f42239c2a8998a5fea325480e9dd39e/src/Router/Router.php#L190-L194
4,662
teamelf/core
src/Router/Router.php
Router.getResponse
public function getResponse() { $this->matcher = new UrlMatcher($this->routes, $this->context); $this->parameters = $this->matcher->matchRequest($this->request); $controller = $this->parameters['_controller']; if ($controller === null) { $response = new Response(); } else { $this->controller = new $controller($this->request, $this->parameters); $response = $this->controller->handler(); } return $response; }
php
public function getResponse() { $this->matcher = new UrlMatcher($this->routes, $this->context); $this->parameters = $this->matcher->matchRequest($this->request); $controller = $this->parameters['_controller']; if ($controller === null) { $response = new Response(); } else { $this->controller = new $controller($this->request, $this->parameters); $response = $this->controller->handler(); } return $response; }
[ "public", "function", "getResponse", "(", ")", "{", "$", "this", "->", "matcher", "=", "new", "UrlMatcher", "(", "$", "this", "->", "routes", ",", "$", "this", "->", "context", ")", ";", "$", "this", "->", "parameters", "=", "$", "this", "->", "matcher", "->", "matchRequest", "(", "$", "this", "->", "request", ")", ";", "$", "controller", "=", "$", "this", "->", "parameters", "[", "'_controller'", "]", ";", "if", "(", "$", "controller", "===", "null", ")", "{", "$", "response", "=", "new", "Response", "(", ")", ";", "}", "else", "{", "$", "this", "->", "controller", "=", "new", "$", "controller", "(", "$", "this", "->", "request", ",", "$", "this", "->", "parameters", ")", ";", "$", "response", "=", "$", "this", "->", "controller", "->", "handler", "(", ")", ";", "}", "return", "$", "response", ";", "}" ]
get response in controller's handler @return Response
[ "get", "response", "in", "controller", "s", "handler" ]
653fc6e27f42239c2a8998a5fea325480e9dd39e
https://github.com/teamelf/core/blob/653fc6e27f42239c2a8998a5fea325480e9dd39e/src/Router/Router.php#L201-L216
4,663
Novusvetus/ClassHelper
src/ClassHelper.php
ClassHelper.create
public static function create() { $args = func_get_args(); // Class to create should be the calling class if not Object, // otherwise the first parameter $class = get_called_class(); if ($class == 'Novusvetus\\ClassHelper\\ClassHelper') { $class = array_shift($args); } $class = self::getOverwriteClass($class); $r = new ReflectionClass($class); return $r->newInstanceArgs($args); }
php
public static function create() { $args = func_get_args(); // Class to create should be the calling class if not Object, // otherwise the first parameter $class = get_called_class(); if ($class == 'Novusvetus\\ClassHelper\\ClassHelper') { $class = array_shift($args); } $class = self::getOverwriteClass($class); $r = new ReflectionClass($class); return $r->newInstanceArgs($args); }
[ "public", "static", "function", "create", "(", ")", "{", "$", "args", "=", "func_get_args", "(", ")", ";", "// Class to create should be the calling class if not Object,", "// otherwise the first parameter", "$", "class", "=", "get_called_class", "(", ")", ";", "if", "(", "$", "class", "==", "'Novusvetus\\\\ClassHelper\\\\ClassHelper'", ")", "{", "$", "class", "=", "array_shift", "(", "$", "args", ")", ";", "}", "$", "class", "=", "self", "::", "getOverwriteClass", "(", "$", "class", ")", ";", "$", "r", "=", "new", "ReflectionClass", "(", "$", "class", ")", ";", "return", "$", "r", "->", "newInstanceArgs", "(", "$", "args", ")", ";", "}" ]
The factory method, allows you to create an instance of a class. This can be called in two ways - calling via the class directly, or calling on Object and passing the class name as the first parameter. @param string $classOrArgument The first argument, or class name (if called directly on Object). @param mixed $argument,... arguments to pass to the constructor @return static
[ "The", "factory", "method", "allows", "you", "to", "create", "an", "instance", "of", "a", "class", "." ]
caf06e41ff9825b8ee2b13f85032155246afd2e2
https://github.com/Novusvetus/ClassHelper/blob/caf06e41ff9825b8ee2b13f85032155246afd2e2/src/ClassHelper.php#L36-L51
4,664
canis-io/yii2-canis-lib
lib/db/behaviors/TagBehavior.php
TagBehavior.getCurrentTags
public function getCurrentTags() { if (!isset($this->_currentTags)) { if (!$this->viaClass) { return []; } $viaClass = $this->viaClass; $params = [$this->viaLocalField => $this->owner->primaryKey]; $rawTags = $viaClass::find()->disableAccessCheck()->where($params)->select($this->viaForeignField)->column(); $this->_currentTags = []; foreach ($rawTags as $tag) { $this->_currentTags[$tag] = $tag; } } return $this->_currentTags; }
php
public function getCurrentTags() { if (!isset($this->_currentTags)) { if (!$this->viaClass) { return []; } $viaClass = $this->viaClass; $params = [$this->viaLocalField => $this->owner->primaryKey]; $rawTags = $viaClass::find()->disableAccessCheck()->where($params)->select($this->viaForeignField)->column(); $this->_currentTags = []; foreach ($rawTags as $tag) { $this->_currentTags[$tag] = $tag; } } return $this->_currentTags; }
[ "public", "function", "getCurrentTags", "(", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "_currentTags", ")", ")", "{", "if", "(", "!", "$", "this", "->", "viaClass", ")", "{", "return", "[", "]", ";", "}", "$", "viaClass", "=", "$", "this", "->", "viaClass", ";", "$", "params", "=", "[", "$", "this", "->", "viaLocalField", "=>", "$", "this", "->", "owner", "->", "primaryKey", "]", ";", "$", "rawTags", "=", "$", "viaClass", "::", "find", "(", ")", "->", "disableAccessCheck", "(", ")", "->", "where", "(", "$", "params", ")", "->", "select", "(", "$", "this", "->", "viaForeignField", ")", "->", "column", "(", ")", ";", "$", "this", "->", "_currentTags", "=", "[", "]", ";", "foreach", "(", "$", "rawTags", "as", "$", "tag", ")", "{", "$", "this", "->", "_currentTags", "[", "$", "tag", "]", "=", "$", "tag", ";", "}", "}", "return", "$", "this", "->", "_currentTags", ";", "}" ]
Get current tags. @throws \ [[@doctodo exception_description:\]] @return [[@doctodo return_type:getCurrentTags]] [[@doctodo return_description:getCurrentTags]]
[ "Get", "current", "tags", "." ]
97d533521f65b084dc805c5f312c364b469142d2
https://github.com/canis-io/yii2-canis-lib/blob/97d533521f65b084dc805c5f312c364b469142d2/lib/db/behaviors/TagBehavior.php#L194-L211
4,665
MindyPHP/Application
App.php
App.run
public function run() { if ('cli' === php_sapi_name()) { // do run console application $input = new ArgvInput(); $env = $input->getParameterOption(['--env', '-e'], getenv('SYMFONY_ENV') ?: 'dev'); $debug = '0' !== getenv('SYMFONY_DEBUG') && !$input->hasParameterOption(['--no-debug', '']) && 'prod' !== $env; if ($debug || $this->debug) { Debug::enable(); } $application = new Application($this->getKernel()); $application->run($input); } else { // do run web application $request = Request::createFromGlobals(); $kernel = $this->getKernel(); if (!$this->debug) { $kernel->loadClassCache(); } if ($this->cacheClass && class_exists($this->cacheClass)) { // add (or uncomment) this new line! // wrap the default AppKernel with the AppCache one $cacheClass = $this->cacheClass; $kernel = new $cacheClass($kernel); } // actually execute the kernel, which turns the request into a response // by dispatching events, calling a controller, and returning the response $response = $kernel->handle($request); // send the headers and echo the content $response->send(); // triggers the kernel.terminate event $kernel->terminate($request, $response); } }
php
public function run() { if ('cli' === php_sapi_name()) { // do run console application $input = new ArgvInput(); $env = $input->getParameterOption(['--env', '-e'], getenv('SYMFONY_ENV') ?: 'dev'); $debug = '0' !== getenv('SYMFONY_DEBUG') && !$input->hasParameterOption(['--no-debug', '']) && 'prod' !== $env; if ($debug || $this->debug) { Debug::enable(); } $application = new Application($this->getKernel()); $application->run($input); } else { // do run web application $request = Request::createFromGlobals(); $kernel = $this->getKernel(); if (!$this->debug) { $kernel->loadClassCache(); } if ($this->cacheClass && class_exists($this->cacheClass)) { // add (or uncomment) this new line! // wrap the default AppKernel with the AppCache one $cacheClass = $this->cacheClass; $kernel = new $cacheClass($kernel); } // actually execute the kernel, which turns the request into a response // by dispatching events, calling a controller, and returning the response $response = $kernel->handle($request); // send the headers and echo the content $response->send(); // triggers the kernel.terminate event $kernel->terminate($request, $response); } }
[ "public", "function", "run", "(", ")", "{", "if", "(", "'cli'", "===", "php_sapi_name", "(", ")", ")", "{", "// do run console application", "$", "input", "=", "new", "ArgvInput", "(", ")", ";", "$", "env", "=", "$", "input", "->", "getParameterOption", "(", "[", "'--env'", ",", "'-e'", "]", ",", "getenv", "(", "'SYMFONY_ENV'", ")", "?", ":", "'dev'", ")", ";", "$", "debug", "=", "'0'", "!==", "getenv", "(", "'SYMFONY_DEBUG'", ")", "&&", "!", "$", "input", "->", "hasParameterOption", "(", "[", "'--no-debug'", ",", "''", "]", ")", "&&", "'prod'", "!==", "$", "env", ";", "if", "(", "$", "debug", "||", "$", "this", "->", "debug", ")", "{", "Debug", "::", "enable", "(", ")", ";", "}", "$", "application", "=", "new", "Application", "(", "$", "this", "->", "getKernel", "(", ")", ")", ";", "$", "application", "->", "run", "(", "$", "input", ")", ";", "}", "else", "{", "// do run web application", "$", "request", "=", "Request", "::", "createFromGlobals", "(", ")", ";", "$", "kernel", "=", "$", "this", "->", "getKernel", "(", ")", ";", "if", "(", "!", "$", "this", "->", "debug", ")", "{", "$", "kernel", "->", "loadClassCache", "(", ")", ";", "}", "if", "(", "$", "this", "->", "cacheClass", "&&", "class_exists", "(", "$", "this", "->", "cacheClass", ")", ")", "{", "// add (or uncomment) this new line!", "// wrap the default AppKernel with the AppCache one", "$", "cacheClass", "=", "$", "this", "->", "cacheClass", ";", "$", "kernel", "=", "new", "$", "cacheClass", "(", "$", "kernel", ")", ";", "}", "// actually execute the kernel, which turns the request into a response", "// by dispatching events, calling a controller, and returning the response", "$", "response", "=", "$", "kernel", "->", "handle", "(", "$", "request", ")", ";", "// send the headers and echo the content", "$", "response", "->", "send", "(", ")", ";", "// triggers the kernel.terminate event", "$", "kernel", "->", "terminate", "(", "$", "request", ",", "$", "response", ")", ";", "}", "}" ]
Start application. @throws \Exception
[ "Start", "application", "." ]
69528a93d68d9bf897382c6afe6f46acda94c076
https://github.com/MindyPHP/Application/blob/69528a93d68d9bf897382c6afe6f46acda94c076/App.php#L137-L179
4,666
aruberutochan/repository
src/Eloquent/BaseRepository.php
BaseRepository.firstOrCreate
public function firstOrCreate(array $attributes = []) { $this->applyCriteria(); $this->applyScope(); $model = $this->model->firstOrCreate($attributes); $this->resetModel(); return $this->parserResult($model); }
php
public function firstOrCreate(array $attributes = []) { $this->applyCriteria(); $this->applyScope(); $model = $this->model->firstOrCreate($attributes); $this->resetModel(); return $this->parserResult($model); }
[ "public", "function", "firstOrCreate", "(", "array", "$", "attributes", "=", "[", "]", ")", "{", "$", "this", "->", "applyCriteria", "(", ")", ";", "$", "this", "->", "applyScope", "(", ")", ";", "$", "model", "=", "$", "this", "->", "model", "->", "firstOrCreate", "(", "$", "attributes", ")", ";", "$", "this", "->", "resetModel", "(", ")", ";", "return", "$", "this", "->", "parserResult", "(", "$", "model", ")", ";", "}" ]
Retrieve first data of repository, or create new Entity @param array $attributes @return mixed
[ "Retrieve", "first", "data", "of", "repository", "or", "create", "new", "Entity" ]
4ecc5eb37377af8f000af76c886c217479dcf454
https://github.com/aruberutochan/repository/blob/4ecc5eb37377af8f000af76c886c217479dcf454/src/Eloquent/BaseRepository.php#L276-L285
4,667
chestnut-framework/container
src/Builder.php
Builder.dispatchRequirements
public function dispatchRequirements($dependencies, $parameters) { $dispatches = []; foreach ($dependencies as $dependency) { list($name, $instance) = $this->extractDependency($dependency, $parameters); $dispatches[$name] = $instance; } return $dispatches; }
php
public function dispatchRequirements($dependencies, $parameters) { $dispatches = []; foreach ($dependencies as $dependency) { list($name, $instance) = $this->extractDependency($dependency, $parameters); $dispatches[$name] = $instance; } return $dispatches; }
[ "public", "function", "dispatchRequirements", "(", "$", "dependencies", ",", "$", "parameters", ")", "{", "$", "dispatches", "=", "[", "]", ";", "foreach", "(", "$", "dependencies", "as", "$", "dependency", ")", "{", "list", "(", "$", "name", ",", "$", "instance", ")", "=", "$", "this", "->", "extractDependency", "(", "$", "dependency", ",", "$", "parameters", ")", ";", "$", "dispatches", "[", "$", "name", "]", "=", "$", "instance", ";", "}", "return", "$", "dispatches", ";", "}" ]
Dispacth require dependencies @param array $dependencies @param array $parameters @return array
[ "Dispacth", "require", "dependencies" ]
c64f09256ca316a64adc30c08c0457c49e974f66
https://github.com/chestnut-framework/container/blob/c64f09256ca316a64adc30c08c0457c49e974f66/src/Builder.php#L63-L73
4,668
chestnut-framework/container
src/Builder.php
Builder.generateReflector
public function generateReflector($type, $factory) { switch ($type) { case 'callback': return $this->generateCallbackReflector($factory); case 'class': return $this->generateClassReflector($factory); } }
php
public function generateReflector($type, $factory) { switch ($type) { case 'callback': return $this->generateCallbackReflector($factory); case 'class': return $this->generateClassReflector($factory); } }
[ "public", "function", "generateReflector", "(", "$", "type", ",", "$", "factory", ")", "{", "switch", "(", "$", "type", ")", "{", "case", "'callback'", ":", "return", "$", "this", "->", "generateCallbackReflector", "(", "$", "factory", ")", ";", "case", "'class'", ":", "return", "$", "this", "->", "generateClassReflector", "(", "$", "factory", ")", ";", "}", "}" ]
Generate factory's reflector @param string $type @param string|Closure $factory @return array
[ "Generate", "factory", "s", "reflector" ]
c64f09256ca316a64adc30c08c0457c49e974f66
https://github.com/chestnut-framework/container/blob/c64f09256ca316a64adc30c08c0457c49e974f66/src/Builder.php#L123-L130
4,669
chestnut-framework/container
src/Builder.php
Builder.generateCallbackReflector
public function generateCallbackReflector($factory) { $reflector = new ReflectionFunction($factory); $dependencies = $reflector->getParameters(); return [$factory, $dependencies]; }
php
public function generateCallbackReflector($factory) { $reflector = new ReflectionFunction($factory); $dependencies = $reflector->getParameters(); return [$factory, $dependencies]; }
[ "public", "function", "generateCallbackReflector", "(", "$", "factory", ")", "{", "$", "reflector", "=", "new", "ReflectionFunction", "(", "$", "factory", ")", ";", "$", "dependencies", "=", "$", "reflector", "->", "getParameters", "(", ")", ";", "return", "[", "$", "factory", ",", "$", "dependencies", "]", ";", "}" ]
Generate callback reflector @param Closure $factory @return ReflectionFunction
[ "Generate", "callback", "reflector" ]
c64f09256ca316a64adc30c08c0457c49e974f66
https://github.com/chestnut-framework/container/blob/c64f09256ca316a64adc30c08c0457c49e974f66/src/Builder.php#L139-L145
4,670
chestnut-framework/container
src/Builder.php
Builder.generateClassReflector
public function generateClassReflector($factory) { $reflector = new ReflectionClass($factory); $constructor = $reflector->getConstructor(); $dependencies = is_null($constructor) ? [] : $constructor->getParameters(); return [$reflector, $dependencies]; }
php
public function generateClassReflector($factory) { $reflector = new ReflectionClass($factory); $constructor = $reflector->getConstructor(); $dependencies = is_null($constructor) ? [] : $constructor->getParameters(); return [$reflector, $dependencies]; }
[ "public", "function", "generateClassReflector", "(", "$", "factory", ")", "{", "$", "reflector", "=", "new", "ReflectionClass", "(", "$", "factory", ")", ";", "$", "constructor", "=", "$", "reflector", "->", "getConstructor", "(", ")", ";", "$", "dependencies", "=", "is_null", "(", "$", "constructor", ")", "?", "[", "]", ":", "$", "constructor", "->", "getParameters", "(", ")", ";", "return", "[", "$", "reflector", ",", "$", "dependencies", "]", ";", "}" ]
Generate class reflector @param string $factory @return ReflectionClass
[ "Generate", "class", "reflector" ]
c64f09256ca316a64adc30c08c0457c49e974f66
https://github.com/chestnut-framework/container/blob/c64f09256ca316a64adc30c08c0457c49e974f66/src/Builder.php#L154-L161
4,671
samurai-fw/samurai
src/Samurai/Component/Routing/Rule/GroupRule.php
GroupRule.get
public function get($path, $action = null) { return $this->match($path, HttpMethodRule::HTTP_METHOD_GET, $action); }
php
public function get($path, $action = null) { return $this->match($path, HttpMethodRule::HTTP_METHOD_GET, $action); }
[ "public", "function", "get", "(", "$", "path", ",", "$", "action", "=", "null", ")", "{", "return", "$", "this", "->", "match", "(", "$", "path", ",", "HttpMethodRule", "::", "HTTP_METHOD_GET", ",", "$", "action", ")", ";", "}" ]
get method matching @param string $path @param string|Closure $action @return Rule
[ "get", "method", "matching" ]
7ca3847b13f86e2847a17ab5e8e4e20893021d5a
https://github.com/samurai-fw/samurai/blob/7ca3847b13f86e2847a17ab5e8e4e20893021d5a/src/Samurai/Component/Routing/Rule/GroupRule.php#L93-L96
4,672
samurai-fw/samurai
src/Samurai/Component/Routing/Rule/GroupRule.php
GroupRule.post
public function post($path, $action = null) { return $this->match($path, HttpMethodRule::HTTP_METHOD_POST, $action); }
php
public function post($path, $action = null) { return $this->match($path, HttpMethodRule::HTTP_METHOD_POST, $action); }
[ "public", "function", "post", "(", "$", "path", ",", "$", "action", "=", "null", ")", "{", "return", "$", "this", "->", "match", "(", "$", "path", ",", "HttpMethodRule", "::", "HTTP_METHOD_POST", ",", "$", "action", ")", ";", "}" ]
post method matching @param string $path @param string|Closure $action @return Rule
[ "post", "method", "matching" ]
7ca3847b13f86e2847a17ab5e8e4e20893021d5a
https://github.com/samurai-fw/samurai/blob/7ca3847b13f86e2847a17ab5e8e4e20893021d5a/src/Samurai/Component/Routing/Rule/GroupRule.php#L105-L108
4,673
samurai-fw/samurai
src/Samurai/Component/Routing/Rule/GroupRule.php
GroupRule.put
public function put($path, $action = null) { return $this->match($path, HttpMethodRule::HTTP_METHOD_PUT, $action); }
php
public function put($path, $action = null) { return $this->match($path, HttpMethodRule::HTTP_METHOD_PUT, $action); }
[ "public", "function", "put", "(", "$", "path", ",", "$", "action", "=", "null", ")", "{", "return", "$", "this", "->", "match", "(", "$", "path", ",", "HttpMethodRule", "::", "HTTP_METHOD_PUT", ",", "$", "action", ")", ";", "}" ]
put method matching @param string $path @param string|Closure $action @return Rule
[ "put", "method", "matching" ]
7ca3847b13f86e2847a17ab5e8e4e20893021d5a
https://github.com/samurai-fw/samurai/blob/7ca3847b13f86e2847a17ab5e8e4e20893021d5a/src/Samurai/Component/Routing/Rule/GroupRule.php#L117-L120
4,674
samurai-fw/samurai
src/Samurai/Component/Routing/Rule/GroupRule.php
GroupRule.delete
public function delete($path, $action = null) { return $this->match($path, HttpMethodRule::HTTP_METHOD_DELETE, $action); }
php
public function delete($path, $action = null) { return $this->match($path, HttpMethodRule::HTTP_METHOD_DELETE, $action); }
[ "public", "function", "delete", "(", "$", "path", ",", "$", "action", "=", "null", ")", "{", "return", "$", "this", "->", "match", "(", "$", "path", ",", "HttpMethodRule", "::", "HTTP_METHOD_DELETE", ",", "$", "action", ")", ";", "}" ]
delete method matching @param string $path @param string|Closure $action @return Rule
[ "delete", "method", "matching" ]
7ca3847b13f86e2847a17ab5e8e4e20893021d5a
https://github.com/samurai-fw/samurai/blob/7ca3847b13f86e2847a17ab5e8e4e20893021d5a/src/Samurai/Component/Routing/Rule/GroupRule.php#L141-L144
4,675
samurai-fw/samurai
src/Samurai/Component/Routing/Rule/GroupRule.php
GroupRule.any
public function any($path, $action = null) { return $this->match($path, HttpMethodRule::HTTP_METHOD_ANY, $action); }
php
public function any($path, $action = null) { return $this->match($path, HttpMethodRule::HTTP_METHOD_ANY, $action); }
[ "public", "function", "any", "(", "$", "path", ",", "$", "action", "=", "null", ")", "{", "return", "$", "this", "->", "match", "(", "$", "path", ",", "HttpMethodRule", "::", "HTTP_METHOD_ANY", ",", "$", "action", ")", ";", "}" ]
any method matching @param string $path @param string|Closure $action @return Rule
[ "any", "method", "matching" ]
7ca3847b13f86e2847a17ab5e8e4e20893021d5a
https://github.com/samurai-fw/samurai/blob/7ca3847b13f86e2847a17ab5e8e4e20893021d5a/src/Samurai/Component/Routing/Rule/GroupRule.php#L153-L156
4,676
white-frame/helloquent
src/Model/IsResource.php
IsResource.controller
public function controller() { if(!$this->hasController()) { throw new InvalidControllerException('Could get controller of ' . get_class($this) . '. Please fill $controller property.'); } return app()->make($this->controller); }
php
public function controller() { if(!$this->hasController()) { throw new InvalidControllerException('Could get controller of ' . get_class($this) . '. Please fill $controller property.'); } return app()->make($this->controller); }
[ "public", "function", "controller", "(", ")", "{", "if", "(", "!", "$", "this", "->", "hasController", "(", ")", ")", "{", "throw", "new", "InvalidControllerException", "(", "'Could get controller of '", ".", "get_class", "(", "$", "this", ")", ".", "'. Please fill $controller property.'", ")", ";", "}", "return", "app", "(", ")", "->", "make", "(", "$", "this", "->", "controller", ")", ";", "}" ]
Get the controller linked from @return mixed @throws InvalidControllerException
[ "Get", "the", "controller", "linked", "from" ]
34dddd0fe9b85f038b897497042161251c61f188
https://github.com/white-frame/helloquent/blob/34dddd0fe9b85f038b897497042161251c61f188/src/Model/IsResource.php#L27-L34
4,677
jeurboy/object-field-selector
src/Util.php
Util._mergeRecursively
private function _mergeRecursively($obj1, $obj2) { if(empty($obj1)) return $obj2; if (is_object($obj2)) { $keys = array_keys(get_object_vars($obj2)); foreach ($keys as $key) { if ( isset($obj1->{$key}) && is_object($obj1->{$key}) && is_object($obj2->{$key}) ) { $obj1->{$key} = $this->_mergeRecursively($obj1->{$key}, $obj2->{$key}); } elseif (isset($obj1->{$key}) && is_array($obj1->{$key}) && is_array($obj2->{$key}) ) { $obj1->{$key} = $this->_mergeRecursively($obj1->{$key}, $obj2->{$key}); } else if(!empty($obj2->{$key})) { $obj1->{$key} = $obj2->{$key}; } } } elseif (is_array($obj2)) { if ( is_array($obj1) && is_array($obj2) ) { foreach ($obj2 as $key => $value){ if (empty($obj1[$key])) { $obj1[$key] = $obj2[$key]; } if(!empty($obj2[$key])) { $obj1[$key] = $this->mergeObjectsRecursively($obj1[$key], $obj2[$key]); } } } else { $obj1 = $obj2; } } return $obj1; }
php
private function _mergeRecursively($obj1, $obj2) { if(empty($obj1)) return $obj2; if (is_object($obj2)) { $keys = array_keys(get_object_vars($obj2)); foreach ($keys as $key) { if ( isset($obj1->{$key}) && is_object($obj1->{$key}) && is_object($obj2->{$key}) ) { $obj1->{$key} = $this->_mergeRecursively($obj1->{$key}, $obj2->{$key}); } elseif (isset($obj1->{$key}) && is_array($obj1->{$key}) && is_array($obj2->{$key}) ) { $obj1->{$key} = $this->_mergeRecursively($obj1->{$key}, $obj2->{$key}); } else if(!empty($obj2->{$key})) { $obj1->{$key} = $obj2->{$key}; } } } elseif (is_array($obj2)) { if ( is_array($obj1) && is_array($obj2) ) { foreach ($obj2 as $key => $value){ if (empty($obj1[$key])) { $obj1[$key] = $obj2[$key]; } if(!empty($obj2[$key])) { $obj1[$key] = $this->mergeObjectsRecursively($obj1[$key], $obj2[$key]); } } } else { $obj1 = $obj2; } } return $obj1; }
[ "private", "function", "_mergeRecursively", "(", "$", "obj1", ",", "$", "obj2", ")", "{", "if", "(", "empty", "(", "$", "obj1", ")", ")", "return", "$", "obj2", ";", "if", "(", "is_object", "(", "$", "obj2", ")", ")", "{", "$", "keys", "=", "array_keys", "(", "get_object_vars", "(", "$", "obj2", ")", ")", ";", "foreach", "(", "$", "keys", "as", "$", "key", ")", "{", "if", "(", "isset", "(", "$", "obj1", "->", "{", "$", "key", "}", ")", "&&", "is_object", "(", "$", "obj1", "->", "{", "$", "key", "}", ")", "&&", "is_object", "(", "$", "obj2", "->", "{", "$", "key", "}", ")", ")", "{", "$", "obj1", "->", "{", "$", "key", "}", "=", "$", "this", "->", "_mergeRecursively", "(", "$", "obj1", "->", "{", "$", "key", "}", ",", "$", "obj2", "->", "{", "$", "key", "}", ")", ";", "}", "elseif", "(", "isset", "(", "$", "obj1", "->", "{", "$", "key", "}", ")", "&&", "is_array", "(", "$", "obj1", "->", "{", "$", "key", "}", ")", "&&", "is_array", "(", "$", "obj2", "->", "{", "$", "key", "}", ")", ")", "{", "$", "obj1", "->", "{", "$", "key", "}", "=", "$", "this", "->", "_mergeRecursively", "(", "$", "obj1", "->", "{", "$", "key", "}", ",", "$", "obj2", "->", "{", "$", "key", "}", ")", ";", "}", "else", "if", "(", "!", "empty", "(", "$", "obj2", "->", "{", "$", "key", "}", ")", ")", "{", "$", "obj1", "->", "{", "$", "key", "}", "=", "$", "obj2", "->", "{", "$", "key", "}", ";", "}", "}", "}", "elseif", "(", "is_array", "(", "$", "obj2", ")", ")", "{", "if", "(", "is_array", "(", "$", "obj1", ")", "&&", "is_array", "(", "$", "obj2", ")", ")", "{", "foreach", "(", "$", "obj2", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "empty", "(", "$", "obj1", "[", "$", "key", "]", ")", ")", "{", "$", "obj1", "[", "$", "key", "]", "=", "$", "obj2", "[", "$", "key", "]", ";", "}", "if", "(", "!", "empty", "(", "$", "obj2", "[", "$", "key", "]", ")", ")", "{", "$", "obj1", "[", "$", "key", "]", "=", "$", "this", "->", "mergeObjectsRecursively", "(", "$", "obj1", "[", "$", "key", "]", ",", "$", "obj2", "[", "$", "key", "]", ")", ";", "}", "}", "}", "else", "{", "$", "obj1", "=", "$", "obj2", ";", "}", "}", "return", "$", "obj1", ";", "}" ]
Recursively merges two objects and returns a resulting object. @param object $obj1 The base object @param object $obj2 The merge object @return object The merged object
[ "Recursively", "merges", "two", "objects", "and", "returns", "a", "resulting", "object", "." ]
7db12ef511a6099c2b62c1fdf7cf4accb2560c30
https://github.com/jeurboy/object-field-selector/blob/7db12ef511a6099c2b62c1fdf7cf4accb2560c30/src/Util.php#L32-L74
4,678
andela-womokoro/potato-orm
src/Connection.php
Connection.connect
public static function connect() { try { /** * Check if the APP_ENV variable is set. If not found or it has a value of 'local' * then load variable values from app's .env file. Else load server server environment variables. */ if (! getenv('APP_ENV') || getenv('APP_ENV')=="local") { $dotenv = new Dotenv($_SERVER['DOCUMENT_ROOT']); $dotenv->load(); } $host = getenv('DB_HOST'); $db = getenv('DB_NAME'); $username = getenv('DB_USERNAME'); $password = getenv('DB_PASSWORD'); $driver = getenv('DB_DRIVER'); return new PDO($driver.':host='.$host.';dbname='.$db, $username, $password); } catch (PDOException $e) { return $e->getMessage(); } }
php
public static function connect() { try { /** * Check if the APP_ENV variable is set. If not found or it has a value of 'local' * then load variable values from app's .env file. Else load server server environment variables. */ if (! getenv('APP_ENV') || getenv('APP_ENV')=="local") { $dotenv = new Dotenv($_SERVER['DOCUMENT_ROOT']); $dotenv->load(); } $host = getenv('DB_HOST'); $db = getenv('DB_NAME'); $username = getenv('DB_USERNAME'); $password = getenv('DB_PASSWORD'); $driver = getenv('DB_DRIVER'); return new PDO($driver.':host='.$host.';dbname='.$db, $username, $password); } catch (PDOException $e) { return $e->getMessage(); } }
[ "public", "static", "function", "connect", "(", ")", "{", "try", "{", "/**\n * Check if the APP_ENV variable is set. If not found or it has a value of 'local'\n * then load variable values from app's .env file. Else load server server environment variables.\n */", "if", "(", "!", "getenv", "(", "'APP_ENV'", ")", "||", "getenv", "(", "'APP_ENV'", ")", "==", "\"local\"", ")", "{", "$", "dotenv", "=", "new", "Dotenv", "(", "$", "_SERVER", "[", "'DOCUMENT_ROOT'", "]", ")", ";", "$", "dotenv", "->", "load", "(", ")", ";", "}", "$", "host", "=", "getenv", "(", "'DB_HOST'", ")", ";", "$", "db", "=", "getenv", "(", "'DB_NAME'", ")", ";", "$", "username", "=", "getenv", "(", "'DB_USERNAME'", ")", ";", "$", "password", "=", "getenv", "(", "'DB_PASSWORD'", ")", ";", "$", "driver", "=", "getenv", "(", "'DB_DRIVER'", ")", ";", "return", "new", "PDO", "(", "$", "driver", ".", "':host='", ".", "$", "host", ".", "';dbname='", ".", "$", "db", ",", "$", "username", ",", "$", "password", ")", ";", "}", "catch", "(", "PDOException", "$", "e", ")", "{", "return", "$", "e", "->", "getMessage", "(", ")", ";", "}", "}" ]
This method creates and returns a connection to the database
[ "This", "method", "creates", "and", "returns", "a", "connection", "to", "the", "database" ]
b8e8757fa8e520efdd61583c2ba489bc76f291ae
https://github.com/andela-womokoro/potato-orm/blob/b8e8757fa8e520efdd61583c2ba489bc76f291ae/src/Connection.php#L14-L39
4,679
oaugustus/direct-silex-provider
src/Direct/Api.php
Api.getApi
public function getApi() { if ($this->app['debug']){ $exceptionLogStr = 'Ext.direct.Manager.on("exception", function(error){console.error(Ext.util.Format.format("Remote Call: {0}.{1}\n{2}", error.action, error.method, error.message, error.where)); return false;});'; }else { $exceptionLogStr = sprintf('Ext.direct.Manager.on("exception", function(error){alert("%s");});', $this->app['direct.exception.message']); } $apiStr = sprintf("Ext.Direct.addProvider(%s);\n%s", $this, $exceptionLogStr); // force convertion of api to string $response = new Response($apiStr); // set the response header $response->headers->set('Content-Type', 'text/javascript'); return $response; }
php
public function getApi() { if ($this->app['debug']){ $exceptionLogStr = 'Ext.direct.Manager.on("exception", function(error){console.error(Ext.util.Format.format("Remote Call: {0}.{1}\n{2}", error.action, error.method, error.message, error.where)); return false;});'; }else { $exceptionLogStr = sprintf('Ext.direct.Manager.on("exception", function(error){alert("%s");});', $this->app['direct.exception.message']); } $apiStr = sprintf("Ext.Direct.addProvider(%s);\n%s", $this, $exceptionLogStr); // force convertion of api to string $response = new Response($apiStr); // set the response header $response->headers->set('Content-Type', 'text/javascript'); return $response; }
[ "public", "function", "getApi", "(", ")", "{", "if", "(", "$", "this", "->", "app", "[", "'debug'", "]", ")", "{", "$", "exceptionLogStr", "=", "'Ext.direct.Manager.on(\"exception\", function(error){console.error(Ext.util.Format.format(\"Remote Call: {0}.{1}\\n{2}\", error.action, error.method, error.message, error.where)); return false;});'", ";", "}", "else", "{", "$", "exceptionLogStr", "=", "sprintf", "(", "'Ext.direct.Manager.on(\"exception\", function(error){alert(\"%s\");});'", ",", "$", "this", "->", "app", "[", "'direct.exception.message'", "]", ")", ";", "}", "$", "apiStr", "=", "sprintf", "(", "\"Ext.Direct.addProvider(%s);\\n%s\"", ",", "$", "this", ",", "$", "exceptionLogStr", ")", ";", "// force convertion of api to string", "$", "response", "=", "new", "Response", "(", "$", "apiStr", ")", ";", "// set the response header", "$", "response", "->", "headers", "->", "set", "(", "'Content-Type'", ",", "'text/javascript'", ")", ";", "return", "$", "response", ";", "}" ]
Get the ExtDirect API response. @return String
[ "Get", "the", "ExtDirect", "API", "response", "." ]
8d92afdf5ede04c3048cde82b9879de7e1d6c153
https://github.com/oaugustus/direct-silex-provider/blob/8d92afdf5ede04c3048cde82b9879de7e1d6c153/src/Direct/Api.php#L69-L88
4,680
oaugustus/direct-silex-provider
src/Direct/Api.php
Api.getRemoting
public function getRemoting() { $apiStr = sprintf("Ext.app.REMOTING_API =%s;", $this); $response = new Response($apiStr); // set the response header $response->headers->set('Content-Type', 'text/javascript'); // return the response return $response; }
php
public function getRemoting() { $apiStr = sprintf("Ext.app.REMOTING_API =%s;", $this); $response = new Response($apiStr); // set the response header $response->headers->set('Content-Type', 'text/javascript'); // return the response return $response; }
[ "public", "function", "getRemoting", "(", ")", "{", "$", "apiStr", "=", "sprintf", "(", "\"Ext.app.REMOTING_API =%s;\"", ",", "$", "this", ")", ";", "$", "response", "=", "new", "Response", "(", "$", "apiStr", ")", ";", "// set the response header", "$", "response", "->", "headers", "->", "set", "(", "'Content-Type'", ",", "'text/javascript'", ")", ";", "// return the response", "return", "$", "response", ";", "}" ]
Get the ExtDirect Api response Remoting descriptor. @return string;
[ "Get", "the", "ExtDirect", "Api", "response", "Remoting", "descriptor", "." ]
8d92afdf5ede04c3048cde82b9879de7e1d6c153
https://github.com/oaugustus/direct-silex-provider/blob/8d92afdf5ede04c3048cde82b9879de7e1d6c153/src/Direct/Api.php#L95-L106
4,681
oaugustus/direct-silex-provider
src/Direct/Api.php
Api.createApi
private function createApi() { $routes = $this->app["routes"]; $actions = $this->getRouteActions($routes); return array( 'url' => $this->app['request']->getBaseUrl(). $this->app['direct.route.pattern'], 'type' => $this->app['direct.api.type'], 'namespace' => $this->app['direct.api.namespace'], 'id' => $this->app['direct.api.id'], 'actions' => $actions ); }
php
private function createApi() { $routes = $this->app["routes"]; $actions = $this->getRouteActions($routes); return array( 'url' => $this->app['request']->getBaseUrl(). $this->app['direct.route.pattern'], 'type' => $this->app['direct.api.type'], 'namespace' => $this->app['direct.api.namespace'], 'id' => $this->app['direct.api.id'], 'actions' => $actions ); }
[ "private", "function", "createApi", "(", ")", "{", "$", "routes", "=", "$", "this", "->", "app", "[", "\"routes\"", "]", ";", "$", "actions", "=", "$", "this", "->", "getRouteActions", "(", "$", "routes", ")", ";", "return", "array", "(", "'url'", "=>", "$", "this", "->", "app", "[", "'request'", "]", "->", "getBaseUrl", "(", ")", ".", "$", "this", "->", "app", "[", "'direct.route.pattern'", "]", ",", "'type'", "=>", "$", "this", "->", "app", "[", "'direct.api.type'", "]", ",", "'namespace'", "=>", "$", "this", "->", "app", "[", "'direct.api.namespace'", "]", ",", "'id'", "=>", "$", "this", "->", "app", "[", "'direct.api.id'", "]", ",", "'actions'", "=>", "$", "actions", ")", ";", "}" ]
Create the ExtDirect API based on controllers files. @return string JSON description of Direct API
[ "Create", "the", "ExtDirect", "API", "based", "on", "controllers", "files", "." ]
8d92afdf5ede04c3048cde82b9879de7e1d6c153
https://github.com/oaugustus/direct-silex-provider/blob/8d92afdf5ede04c3048cde82b9879de7e1d6c153/src/Direct/Api.php#L126-L140
4,682
oaugustus/direct-silex-provider
src/Direct/Api.php
Api.getRouteActions
protected function getRouteActions($routes) { $actions = array(); // iterate for all routes foreach ($routes->all() as $route){ // if route is post and is direct exposed if (in_array('POST', $route->getMethods()) == true && $route->isDirect()){ $apiParts = $this->getRouteApiParts($route); if ($apiParts['exposed']){ $path = $apiParts['path']; unset($apiParts['path']); unset($apiParts['exposed']); $actions[$path][] = $apiParts; } } } return $actions; }
php
protected function getRouteActions($routes) { $actions = array(); // iterate for all routes foreach ($routes->all() as $route){ // if route is post and is direct exposed if (in_array('POST', $route->getMethods()) == true && $route->isDirect()){ $apiParts = $this->getRouteApiParts($route); if ($apiParts['exposed']){ $path = $apiParts['path']; unset($apiParts['path']); unset($apiParts['exposed']); $actions[$path][] = $apiParts; } } } return $actions; }
[ "protected", "function", "getRouteActions", "(", "$", "routes", ")", "{", "$", "actions", "=", "array", "(", ")", ";", "// iterate for all routes", "foreach", "(", "$", "routes", "->", "all", "(", ")", "as", "$", "route", ")", "{", "// if route is post and is direct exposed", "if", "(", "in_array", "(", "'POST'", ",", "$", "route", "->", "getMethods", "(", ")", ")", "==", "true", "&&", "$", "route", "->", "isDirect", "(", ")", ")", "{", "$", "apiParts", "=", "$", "this", "->", "getRouteApiParts", "(", "$", "route", ")", ";", "if", "(", "$", "apiParts", "[", "'exposed'", "]", ")", "{", "$", "path", "=", "$", "apiParts", "[", "'path'", "]", ";", "unset", "(", "$", "apiParts", "[", "'path'", "]", ")", ";", "unset", "(", "$", "apiParts", "[", "'exposed'", "]", ")", ";", "$", "actions", "[", "$", "path", "]", "[", "]", "=", "$", "apiParts", ";", "}", "}", "}", "return", "$", "actions", ";", "}" ]
Get the route API definition @param array @return array Controllers list
[ "Get", "the", "route", "API", "definition" ]
8d92afdf5ede04c3048cde82b9879de7e1d6c153
https://github.com/oaugustus/direct-silex-provider/blob/8d92afdf5ede04c3048cde82b9879de7e1d6c153/src/Direct/Api.php#L159-L182
4,683
oaugustus/direct-silex-provider
src/Direct/Api.php
Api.getRouteApiParts
protected function getRouteApiParts($route) { $name = explode('/', $route->getPattern()); $parts = array( 'exposed' => false ); // if the name has more than one string pattern if (count($name) > 2){ // get the method name $method = array_pop($name); // upcase the namespace names array_walk($name, function(&$n){ $n = ucfirst($n); }); $path = implode('', $name); $parts = array( 'path' => $path, 'exposed' => true, 'name' => $method, 'len' => 1 ); if ($route->isFormDirect()){ $parts['formHandler'] = true; } } return $parts; }
php
protected function getRouteApiParts($route) { $name = explode('/', $route->getPattern()); $parts = array( 'exposed' => false ); // if the name has more than one string pattern if (count($name) > 2){ // get the method name $method = array_pop($name); // upcase the namespace names array_walk($name, function(&$n){ $n = ucfirst($n); }); $path = implode('', $name); $parts = array( 'path' => $path, 'exposed' => true, 'name' => $method, 'len' => 1 ); if ($route->isFormDirect()){ $parts['formHandler'] = true; } } return $parts; }
[ "protected", "function", "getRouteApiParts", "(", "$", "route", ")", "{", "$", "name", "=", "explode", "(", "'/'", ",", "$", "route", "->", "getPattern", "(", ")", ")", ";", "$", "parts", "=", "array", "(", "'exposed'", "=>", "false", ")", ";", "// if the name has more than one string pattern", "if", "(", "count", "(", "$", "name", ")", ">", "2", ")", "{", "// get the method name", "$", "method", "=", "array_pop", "(", "$", "name", ")", ";", "// upcase the namespace names", "array_walk", "(", "$", "name", ",", "function", "(", "&", "$", "n", ")", "{", "$", "n", "=", "ucfirst", "(", "$", "n", ")", ";", "}", ")", ";", "$", "path", "=", "implode", "(", "''", ",", "$", "name", ")", ";", "$", "parts", "=", "array", "(", "'path'", "=>", "$", "path", ",", "'exposed'", "=>", "true", ",", "'name'", "=>", "$", "method", ",", "'len'", "=>", "1", ")", ";", "if", "(", "$", "route", "->", "isFormDirect", "(", ")", ")", "{", "$", "parts", "[", "'formHandler'", "]", "=", "true", ";", "}", "}", "return", "$", "parts", ";", "}" ]
Return the route extdirect api parts. @param $route @return mixed
[ "Return", "the", "route", "extdirect", "api", "parts", "." ]
8d92afdf5ede04c3048cde82b9879de7e1d6c153
https://github.com/oaugustus/direct-silex-provider/blob/8d92afdf5ede04c3048cde82b9879de7e1d6c153/src/Direct/Api.php#L190-L224
4,684
OWeb/OWeb-Framework
OWeb/defaults/models/programs/Programs.php
Programs.getprogram
public function getprogram($id) { if (isset($this->programs[$id])) return $this->programs[$id]; else { try { $programs = $this->getProgramsArray(array($id)); if(isset($programs[$id])){ return $programs[$id]; }else{ throw new ProgramNotFound("Couldn't get Program with id : $id . NO such program", 0); } } catch (\Exception $ex) { throw new ProgramNotFound("Couldn't get Program with id : $id . ERROR", 0, $ex); } } }
php
public function getprogram($id) { if (isset($this->programs[$id])) return $this->programs[$id]; else { try { $programs = $this->getProgramsArray(array($id)); if(isset($programs[$id])){ return $programs[$id]; }else{ throw new ProgramNotFound("Couldn't get Program with id : $id . NO such program", 0); } } catch (\Exception $ex) { throw new ProgramNotFound("Couldn't get Program with id : $id . ERROR", 0, $ex); } } }
[ "public", "function", "getprogram", "(", "$", "id", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "programs", "[", "$", "id", "]", ")", ")", "return", "$", "this", "->", "programs", "[", "$", "id", "]", ";", "else", "{", "try", "{", "$", "programs", "=", "$", "this", "->", "getProgramsArray", "(", "array", "(", "$", "id", ")", ")", ";", "if", "(", "isset", "(", "$", "programs", "[", "$", "id", "]", ")", ")", "{", "return", "$", "programs", "[", "$", "id", "]", ";", "}", "else", "{", "throw", "new", "ProgramNotFound", "(", "\"Couldn't get Program with id : $id . NO such program\"", ",", "0", ")", ";", "}", "}", "catch", "(", "\\", "Exception", "$", "ex", ")", "{", "throw", "new", "ProgramNotFound", "(", "\"Couldn't get Program with id : $id . ERROR\"", ",", "0", ",", "$", "ex", ")", ";", "}", "}", "}" ]
Recovers the Program with the demanded ID @param $id @return Program @throws exception\ProgramNotFound thrown if this program doesn't exist or there is a problem with the DB
[ "Recovers", "the", "Program", "with", "the", "demanded", "ID" ]
fb441f51afb16860b0c946a55c36c789fbb125fa
https://github.com/OWeb/OWeb-Framework/blob/fb441f51afb16860b0c946a55c36c789fbb125fa/OWeb/defaults/models/programs/Programs.php#L73-L94
4,685
nano7/Database
src/Model/Model.php
Model.toClone
public function toClone() { $attributes = $this->toArray(false); unset($attributes['id']); unset($attributes['_id']); return $this->create($attributes, false); }
php
public function toClone() { $attributes = $this->toArray(false); unset($attributes['id']); unset($attributes['_id']); return $this->create($attributes, false); }
[ "public", "function", "toClone", "(", ")", "{", "$", "attributes", "=", "$", "this", "->", "toArray", "(", "false", ")", ";", "unset", "(", "$", "attributes", "[", "'id'", "]", ")", ";", "unset", "(", "$", "attributes", "[", "'_id'", "]", ")", ";", "return", "$", "this", "->", "create", "(", "$", "attributes", ",", "false", ")", ";", "}" ]
Create clone this model. @return Model
[ "Create", "clone", "this", "model", "." ]
7d8c10af415c469a317f40471f657104e4d5b52a
https://github.com/nano7/Database/blob/7d8c10af415c469a317f40471f657104e4d5b52a/src/Model/Model.php#L171-L179
4,686
nano7/Database
src/Model/Model.php
Model.getCollection
public function getCollection() { if (! isset($this->collection)) { return str_replace( '\\', '', Str::snake(Str::plural(class_basename($this))) ); } return $this->collection; }
php
public function getCollection() { if (! isset($this->collection)) { return str_replace( '\\', '', Str::snake(Str::plural(class_basename($this))) ); } return $this->collection; }
[ "public", "function", "getCollection", "(", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "collection", ")", ")", "{", "return", "str_replace", "(", "'\\\\'", ",", "''", ",", "Str", "::", "snake", "(", "Str", "::", "plural", "(", "class_basename", "(", "$", "this", ")", ")", ")", ")", ";", "}", "return", "$", "this", "->", "collection", ";", "}" ]
Get the collection associated with the model. @return string
[ "Get", "the", "collection", "associated", "with", "the", "model", "." ]
7d8c10af415c469a317f40471f657104e4d5b52a
https://github.com/nano7/Database/blob/7d8c10af415c469a317f40471f657104e4d5b52a/src/Model/Model.php#L186-L195
4,687
nano7/Database
src/Model/Model.php
Model.performDelete
protected function performDelete(QueryBuilder $query) { // Verificar se documento existe (que já foi carregado ou salvo) if (! $this->exists) { return true; } // Disparar evento que o documento esta sendo excluido if ($this->fireModelEvent('deleting') === false) { return false; } // Excluir registro $query->where('_id', $this->getId()); $query->delete(); // Marcar como documento nao existe $this->exists = false; // Disparar evento que o documento foi excluido $this->fireModelEvent('deleted', false); return true; }
php
protected function performDelete(QueryBuilder $query) { // Verificar se documento existe (que já foi carregado ou salvo) if (! $this->exists) { return true; } // Disparar evento que o documento esta sendo excluido if ($this->fireModelEvent('deleting') === false) { return false; } // Excluir registro $query->where('_id', $this->getId()); $query->delete(); // Marcar como documento nao existe $this->exists = false; // Disparar evento que o documento foi excluido $this->fireModelEvent('deleted', false); return true; }
[ "protected", "function", "performDelete", "(", "QueryBuilder", "$", "query", ")", "{", "// Verificar se documento existe (que já foi carregado ou salvo)", "if", "(", "!", "$", "this", "->", "exists", ")", "{", "return", "true", ";", "}", "// Disparar evento que o documento esta sendo excluido", "if", "(", "$", "this", "->", "fireModelEvent", "(", "'deleting'", ")", "===", "false", ")", "{", "return", "false", ";", "}", "// Excluir registro", "$", "query", "->", "where", "(", "'_id'", ",", "$", "this", "->", "getId", "(", ")", ")", ";", "$", "query", "->", "delete", "(", ")", ";", "// Marcar como documento nao existe", "$", "this", "->", "exists", "=", "false", ";", "// Disparar evento que o documento foi excluido", "$", "this", "->", "fireModelEvent", "(", "'deleted'", ",", "false", ")", ";", "return", "true", ";", "}" ]
Processar exclusao do documento. @param QueryBuilder $query @return bool
[ "Processar", "exclusao", "do", "documento", "." ]
7d8c10af415c469a317f40471f657104e4d5b52a
https://github.com/nano7/Database/blob/7d8c10af415c469a317f40471f657104e4d5b52a/src/Model/Model.php#L376-L399
4,688
mszewcz/php-json-schema-validator
src/Validators/StringValidators/PatternValidator.php
PatternValidator.validate
public function validate($subject): bool { if (\is_string($this->schema['pattern'])) { if (!\preg_match(sprintf('/%s/i', $this->schema['pattern']), $subject)) { return false; } } return true; }
php
public function validate($subject): bool { if (\is_string($this->schema['pattern'])) { if (!\preg_match(sprintf('/%s/i', $this->schema['pattern']), $subject)) { return false; } } return true; }
[ "public", "function", "validate", "(", "$", "subject", ")", ":", "bool", "{", "if", "(", "\\", "is_string", "(", "$", "this", "->", "schema", "[", "'pattern'", "]", ")", ")", "{", "if", "(", "!", "\\", "preg_match", "(", "sprintf", "(", "'/%s/i'", ",", "$", "this", "->", "schema", "[", "'pattern'", "]", ")", ",", "$", "subject", ")", ")", "{", "return", "false", ";", "}", "}", "return", "true", ";", "}" ]
Validates subject against pattern @param $subject @return bool
[ "Validates", "subject", "against", "pattern" ]
f7768bfe07ce6508bb1ff36163560a5e5791de7d
https://github.com/mszewcz/php-json-schema-validator/blob/f7768bfe07ce6508bb1ff36163560a5e5791de7d/src/Validators/StringValidators/PatternValidator.php#L47-L55
4,689
indigophp-archive/codeception-fuel-module
fuel/fuel/core/classes/cache/storage/redis.php
Cache_Storage_Redis._get_key
protected function _get_key($remove = false) { // get the current index information list($identifier, $sections, $index) = $this->_get_index(); $index = $index === null ? array() : $index = $this->_unserialize($index); // get the key from the index $key = isset($index[$identifier][0]) ? $index[$identifier][0] : false; if ($remove === true) { if ( $key !== false ) { unset($index[$identifier]); static::$redis->set($this->config['cache_id'].':index:'.$sections, $this->_serialize($index)); } } else { // create a new key if needed $key === false and $key = $this->_new_key(); } return $key; }
php
protected function _get_key($remove = false) { // get the current index information list($identifier, $sections, $index) = $this->_get_index(); $index = $index === null ? array() : $index = $this->_unserialize($index); // get the key from the index $key = isset($index[$identifier][0]) ? $index[$identifier][0] : false; if ($remove === true) { if ( $key !== false ) { unset($index[$identifier]); static::$redis->set($this->config['cache_id'].':index:'.$sections, $this->_serialize($index)); } } else { // create a new key if needed $key === false and $key = $this->_new_key(); } return $key; }
[ "protected", "function", "_get_key", "(", "$", "remove", "=", "false", ")", "{", "// get the current index information", "list", "(", "$", "identifier", ",", "$", "sections", ",", "$", "index", ")", "=", "$", "this", "->", "_get_index", "(", ")", ";", "$", "index", "=", "$", "index", "===", "null", "?", "array", "(", ")", ":", "$", "index", "=", "$", "this", "->", "_unserialize", "(", "$", "index", ")", ";", "// get the key from the index", "$", "key", "=", "isset", "(", "$", "index", "[", "$", "identifier", "]", "[", "0", "]", ")", "?", "$", "index", "[", "$", "identifier", "]", "[", "0", "]", ":", "false", ";", "if", "(", "$", "remove", "===", "true", ")", "{", "if", "(", "$", "key", "!==", "false", ")", "{", "unset", "(", "$", "index", "[", "$", "identifier", "]", ")", ";", "static", "::", "$", "redis", "->", "set", "(", "$", "this", "->", "config", "[", "'cache_id'", "]", ".", "':index:'", ".", "$", "sections", ",", "$", "this", "->", "_serialize", "(", "$", "index", ")", ")", ";", "}", "}", "else", "{", "// create a new key if needed", "$", "key", "===", "false", "and", "$", "key", "=", "$", "this", "->", "_new_key", "(", ")", ";", "}", "return", "$", "key", ";", "}" ]
get's the redis key belonging to the cache identifier @param bool if true, remove the key retrieved from the index @return string
[ "get", "s", "the", "redis", "key", "belonging", "to", "the", "cache", "identifier" ]
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/cache/storage/redis.php#L351-L375
4,690
indigophp-archive/codeception-fuel-module
fuel/fuel/core/classes/cache/storage/redis.php
Cache_Storage_Redis._new_key
protected function _new_key() { $key = ''; while (strlen($key) < 32) { $key .= mt_rand(0, mt_getrandmax()); } return md5($this->config['cache_id'].'_'.uniqid($key, TRUE)); }
php
protected function _new_key() { $key = ''; while (strlen($key) < 32) { $key .= mt_rand(0, mt_getrandmax()); } return md5($this->config['cache_id'].'_'.uniqid($key, TRUE)); }
[ "protected", "function", "_new_key", "(", ")", "{", "$", "key", "=", "''", ";", "while", "(", "strlen", "(", "$", "key", ")", "<", "32", ")", "{", "$", "key", ".=", "mt_rand", "(", "0", ",", "mt_getrandmax", "(", ")", ")", ";", "}", "return", "md5", "(", "$", "this", "->", "config", "[", "'cache_id'", "]", ".", "'_'", ".", "uniqid", "(", "$", "key", ",", "TRUE", ")", ")", ";", "}" ]
generate a new unique key for the current identifier @return string
[ "generate", "a", "new", "unique", "key", "for", "the", "current", "identifier" ]
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/cache/storage/redis.php#L382-L390
4,691
loyals-online/silverstripe-jsend
code/service/JSendResponse.php
JSendResponse.parse
public static function parse($json) { $json = json_decode($json); if (!isset($json->status)) { throw new JSendParseException('Could not parse data; required element \'status\' missing.'); } $instance = new static($json->status); if (!isset($json->code)) { $json->code = 200; } $instance->setCode($json->code); if ($instance->isError()) { if (!isset($json->message)) { throw new JSendParseException('Could not parse data; required element \'message\' missing.'); } $instance->setMessage($json->message); } if ($instance->isSuccess() || $instance->isFail()) { if (!isset($json->data)) { throw new JSendParseException('Could not parse data; required element \'data\' missing.'); } $instance->setData($json->data); } else { if ($instance->isError()) { if (isset($json->data)) { $instance->setData($json->data); } } } return $instance; }
php
public static function parse($json) { $json = json_decode($json); if (!isset($json->status)) { throw new JSendParseException('Could not parse data; required element \'status\' missing.'); } $instance = new static($json->status); if (!isset($json->code)) { $json->code = 200; } $instance->setCode($json->code); if ($instance->isError()) { if (!isset($json->message)) { throw new JSendParseException('Could not parse data; required element \'message\' missing.'); } $instance->setMessage($json->message); } if ($instance->isSuccess() || $instance->isFail()) { if (!isset($json->data)) { throw new JSendParseException('Could not parse data; required element \'data\' missing.'); } $instance->setData($json->data); } else { if ($instance->isError()) { if (isset($json->data)) { $instance->setData($json->data); } } } return $instance; }
[ "public", "static", "function", "parse", "(", "$", "json", ")", "{", "$", "json", "=", "json_decode", "(", "$", "json", ")", ";", "if", "(", "!", "isset", "(", "$", "json", "->", "status", ")", ")", "{", "throw", "new", "JSendParseException", "(", "'Could not parse data; required element \\'status\\' missing.'", ")", ";", "}", "$", "instance", "=", "new", "static", "(", "$", "json", "->", "status", ")", ";", "if", "(", "!", "isset", "(", "$", "json", "->", "code", ")", ")", "{", "$", "json", "->", "code", "=", "200", ";", "}", "$", "instance", "->", "setCode", "(", "$", "json", "->", "code", ")", ";", "if", "(", "$", "instance", "->", "isError", "(", ")", ")", "{", "if", "(", "!", "isset", "(", "$", "json", "->", "message", ")", ")", "{", "throw", "new", "JSendParseException", "(", "'Could not parse data; required element \\'message\\' missing.'", ")", ";", "}", "$", "instance", "->", "setMessage", "(", "$", "json", "->", "message", ")", ";", "}", "if", "(", "$", "instance", "->", "isSuccess", "(", ")", "||", "$", "instance", "->", "isFail", "(", ")", ")", "{", "if", "(", "!", "isset", "(", "$", "json", "->", "data", ")", ")", "{", "throw", "new", "JSendParseException", "(", "'Could not parse data; required element \\'data\\' missing.'", ")", ";", "}", "$", "instance", "->", "setData", "(", "$", "json", "->", "data", ")", ";", "}", "else", "{", "if", "(", "$", "instance", "->", "isError", "(", ")", ")", "{", "if", "(", "isset", "(", "$", "json", "->", "data", ")", ")", "{", "$", "instance", "->", "setData", "(", "$", "json", "->", "data", ")", ";", "}", "}", "}", "return", "$", "instance", ";", "}" ]
Parse a JSend response json @param $json @return static @throws \JSendParseException
[ "Parse", "a", "JSend", "response", "json" ]
32a33333e827dc2fe99c83d70109ee116d458bd0
https://github.com/loyals-online/silverstripe-jsend/blob/32a33333e827dc2fe99c83d70109ee116d458bd0/code/service/JSendResponse.php#L55-L91
4,692
loyals-online/silverstripe-jsend
code/service/JSendResponse.php
JSendResponse.getJson
public function getJson() { $response = [ 'status' => $this->status, ]; switch ($this->status) { case self::STATUS_SUCCESS: case self::STATUS_FAIL: $response = array_merge( $response, [ 'data' => $this->data, ] ); break; case self::STATUS_ERROR; $code = $this->code ? ['code' => $this->code] : []; $data = $this->data ? ['data' => $this->data] : []; $response = array_merge( $response, [ 'message' => $this->message, ], $code, $data ); break; default: // because of the check in setStatus, this should never occur $response = [ 'status' => self::STATUS_ERROR, 'code' => 500, 'message' => 'JSend response was built illegally', 'data' => [ 'original-data' => [ 'status' => $this->status, 'code' => $this->code, 'message' => $this->message, 'data' => $this->data, ], ], ]; break; } return json_encode($response); }
php
public function getJson() { $response = [ 'status' => $this->status, ]; switch ($this->status) { case self::STATUS_SUCCESS: case self::STATUS_FAIL: $response = array_merge( $response, [ 'data' => $this->data, ] ); break; case self::STATUS_ERROR; $code = $this->code ? ['code' => $this->code] : []; $data = $this->data ? ['data' => $this->data] : []; $response = array_merge( $response, [ 'message' => $this->message, ], $code, $data ); break; default: // because of the check in setStatus, this should never occur $response = [ 'status' => self::STATUS_ERROR, 'code' => 500, 'message' => 'JSend response was built illegally', 'data' => [ 'original-data' => [ 'status' => $this->status, 'code' => $this->code, 'message' => $this->message, 'data' => $this->data, ], ], ]; break; } return json_encode($response); }
[ "public", "function", "getJson", "(", ")", "{", "$", "response", "=", "[", "'status'", "=>", "$", "this", "->", "status", ",", "]", ";", "switch", "(", "$", "this", "->", "status", ")", "{", "case", "self", "::", "STATUS_SUCCESS", ":", "case", "self", "::", "STATUS_FAIL", ":", "$", "response", "=", "array_merge", "(", "$", "response", ",", "[", "'data'", "=>", "$", "this", "->", "data", ",", "]", ")", ";", "break", ";", "case", "self", "::", "STATUS_ERROR", ";", "$", "code", "=", "$", "this", "->", "code", "?", "[", "'code'", "=>", "$", "this", "->", "code", "]", ":", "[", "]", ";", "$", "data", "=", "$", "this", "->", "data", "?", "[", "'data'", "=>", "$", "this", "->", "data", "]", ":", "[", "]", ";", "$", "response", "=", "array_merge", "(", "$", "response", ",", "[", "'message'", "=>", "$", "this", "->", "message", ",", "]", ",", "$", "code", ",", "$", "data", ")", ";", "break", ";", "default", ":", "// because of the check in setStatus, this should never occur", "$", "response", "=", "[", "'status'", "=>", "self", "::", "STATUS_ERROR", ",", "'code'", "=>", "500", ",", "'message'", "=>", "'JSend response was built illegally'", ",", "'data'", "=>", "[", "'original-data'", "=>", "[", "'status'", "=>", "$", "this", "->", "status", ",", "'code'", "=>", "$", "this", "->", "code", ",", "'message'", "=>", "$", "this", "->", "message", ",", "'data'", "=>", "$", "this", "->", "data", ",", "]", ",", "]", ",", "]", ";", "break", ";", "}", "return", "json_encode", "(", "$", "response", ")", ";", "}" ]
Retrieve the json response @return string
[ "Retrieve", "the", "json", "response" ]
32a33333e827dc2fe99c83d70109ee116d458bd0
https://github.com/loyals-online/silverstripe-jsend/blob/32a33333e827dc2fe99c83d70109ee116d458bd0/code/service/JSendResponse.php#L120-L167
4,693
loyals-online/silverstripe-jsend
code/service/JSendResponse.php
JSendResponse.setStatus
public function setStatus($status) { if (!in_array($status, $this->getStatusses())) { throw new Exception(sprintf('Illegal status %1$s given. Must be one of %2$s', $status, implode(', ', $this->getStatusses()))); } $this->status = $status; return $this; }
php
public function setStatus($status) { if (!in_array($status, $this->getStatusses())) { throw new Exception(sprintf('Illegal status %1$s given. Must be one of %2$s', $status, implode(', ', $this->getStatusses()))); } $this->status = $status; return $this; }
[ "public", "function", "setStatus", "(", "$", "status", ")", "{", "if", "(", "!", "in_array", "(", "$", "status", ",", "$", "this", "->", "getStatusses", "(", ")", ")", ")", "{", "throw", "new", "Exception", "(", "sprintf", "(", "'Illegal status %1$s given. Must be one of %2$s'", ",", "$", "status", ",", "implode", "(", "', '", ",", "$", "this", "->", "getStatusses", "(", ")", ")", ")", ")", ";", "}", "$", "this", "->", "status", "=", "$", "status", ";", "return", "$", "this", ";", "}" ]
Set the status for this response @param string $status @throws \Exception @return $this
[ "Set", "the", "status", "for", "this", "response" ]
32a33333e827dc2fe99c83d70109ee116d458bd0
https://github.com/loyals-online/silverstripe-jsend/blob/32a33333e827dc2fe99c83d70109ee116d458bd0/code/service/JSendResponse.php#L177-L186
4,694
weew/http-client
src/Weew/HttpClient/Drivers/Curl/RequestBuilder.php
RequestBuilder.setOptions
protected function setOptions() { $this->resource->setOption(CURLOPT_URL, $this->createUrl()); $this->resource->setOption(CURLOPT_CUSTOMREQUEST, $this->request->getMethod()); $this->resource->setOption(CURLOPT_RETURNTRANSFER, true); $this->resource->setOption(CURLOPT_HEADER, true); $this->resource->setOption( CURLOPT_FOLLOWLOCATION, $this->options->get(HttpClientOptions::FOLLOW_REDIRECT, false) ); if ($this->options->get(HttpClientOptions::VERIFY_SSL, true)) { $this->resource->setOption(CURLOPT_SSL_VERIFYPEER, true); $this->resource->setOption(CURLOPT_SSL_VERIFYHOST, 2); } else { $this->resource->setOption(CURLOPT_SSL_VERIFYPEER, false); $this->resource->setOption(CURLOPT_SSL_VERIFYHOST, false); } foreach ($this->options->toArray() as $option => $value) { if (str_starts_with($option, 'CURLOPT_') && defined($option)) { $this->resource->setOption(constant($option), $value); } } }
php
protected function setOptions() { $this->resource->setOption(CURLOPT_URL, $this->createUrl()); $this->resource->setOption(CURLOPT_CUSTOMREQUEST, $this->request->getMethod()); $this->resource->setOption(CURLOPT_RETURNTRANSFER, true); $this->resource->setOption(CURLOPT_HEADER, true); $this->resource->setOption( CURLOPT_FOLLOWLOCATION, $this->options->get(HttpClientOptions::FOLLOW_REDIRECT, false) ); if ($this->options->get(HttpClientOptions::VERIFY_SSL, true)) { $this->resource->setOption(CURLOPT_SSL_VERIFYPEER, true); $this->resource->setOption(CURLOPT_SSL_VERIFYHOST, 2); } else { $this->resource->setOption(CURLOPT_SSL_VERIFYPEER, false); $this->resource->setOption(CURLOPT_SSL_VERIFYHOST, false); } foreach ($this->options->toArray() as $option => $value) { if (str_starts_with($option, 'CURLOPT_') && defined($option)) { $this->resource->setOption(constant($option), $value); } } }
[ "protected", "function", "setOptions", "(", ")", "{", "$", "this", "->", "resource", "->", "setOption", "(", "CURLOPT_URL", ",", "$", "this", "->", "createUrl", "(", ")", ")", ";", "$", "this", "->", "resource", "->", "setOption", "(", "CURLOPT_CUSTOMREQUEST", ",", "$", "this", "->", "request", "->", "getMethod", "(", ")", ")", ";", "$", "this", "->", "resource", "->", "setOption", "(", "CURLOPT_RETURNTRANSFER", ",", "true", ")", ";", "$", "this", "->", "resource", "->", "setOption", "(", "CURLOPT_HEADER", ",", "true", ")", ";", "$", "this", "->", "resource", "->", "setOption", "(", "CURLOPT_FOLLOWLOCATION", ",", "$", "this", "->", "options", "->", "get", "(", "HttpClientOptions", "::", "FOLLOW_REDIRECT", ",", "false", ")", ")", ";", "if", "(", "$", "this", "->", "options", "->", "get", "(", "HttpClientOptions", "::", "VERIFY_SSL", ",", "true", ")", ")", "{", "$", "this", "->", "resource", "->", "setOption", "(", "CURLOPT_SSL_VERIFYPEER", ",", "true", ")", ";", "$", "this", "->", "resource", "->", "setOption", "(", "CURLOPT_SSL_VERIFYHOST", ",", "2", ")", ";", "}", "else", "{", "$", "this", "->", "resource", "->", "setOption", "(", "CURLOPT_SSL_VERIFYPEER", ",", "false", ")", ";", "$", "this", "->", "resource", "->", "setOption", "(", "CURLOPT_SSL_VERIFYHOST", ",", "false", ")", ";", "}", "foreach", "(", "$", "this", "->", "options", "->", "toArray", "(", ")", "as", "$", "option", "=>", "$", "value", ")", "{", "if", "(", "str_starts_with", "(", "$", "option", ",", "'CURLOPT_'", ")", "&&", "defined", "(", "$", "option", ")", ")", "{", "$", "this", "->", "resource", "->", "setOption", "(", "constant", "(", "$", "option", ")", ",", "$", "value", ")", ";", "}", "}", "}" ]
Process and client settings.
[ "Process", "and", "client", "settings", "." ]
bbe5d9d9dc143cc1a46be53ebd1c294d9390d267
https://github.com/weew/http-client/blob/bbe5d9d9dc143cc1a46be53ebd1c294d9390d267/src/Weew/HttpClient/Drivers/Curl/RequestBuilder.php#L80-L104
4,695
weew/http-client
src/Weew/HttpClient/Drivers/Curl/RequestBuilder.php
RequestBuilder.setHeaders
protected function setHeaders() { $headers = $this->request->getHeaders()->toFlatArray(); $this->resource->setOption(CURLOPT_HTTPHEADER, $headers); }
php
protected function setHeaders() { $headers = $this->request->getHeaders()->toFlatArray(); $this->resource->setOption(CURLOPT_HTTPHEADER, $headers); }
[ "protected", "function", "setHeaders", "(", ")", "{", "$", "headers", "=", "$", "this", "->", "request", "->", "getHeaders", "(", ")", "->", "toFlatArray", "(", ")", ";", "$", "this", "->", "resource", "->", "setOption", "(", "CURLOPT_HTTPHEADER", ",", "$", "headers", ")", ";", "}" ]
Process and apply request headers.
[ "Process", "and", "apply", "request", "headers", "." ]
bbe5d9d9dc143cc1a46be53ebd1c294d9390d267
https://github.com/weew/http-client/blob/bbe5d9d9dc143cc1a46be53ebd1c294d9390d267/src/Weew/HttpClient/Drivers/Curl/RequestBuilder.php#L109-L112
4,696
weew/http-client
src/Weew/HttpClient/Drivers/Curl/RequestBuilder.php
RequestBuilder.setContent
protected function setContent() { $body = null; if ($this->request->hasContent()) { $body = $this->request->getContent(); } if ($body !== null) { $this->resource->setOption(CURLOPT_POST, true); $this->resource->setOption(CURLOPT_POSTFIELDS, $body); } }
php
protected function setContent() { $body = null; if ($this->request->hasContent()) { $body = $this->request->getContent(); } if ($body !== null) { $this->resource->setOption(CURLOPT_POST, true); $this->resource->setOption(CURLOPT_POSTFIELDS, $body); } }
[ "protected", "function", "setContent", "(", ")", "{", "$", "body", "=", "null", ";", "if", "(", "$", "this", "->", "request", "->", "hasContent", "(", ")", ")", "{", "$", "body", "=", "$", "this", "->", "request", "->", "getContent", "(", ")", ";", "}", "if", "(", "$", "body", "!==", "null", ")", "{", "$", "this", "->", "resource", "->", "setOption", "(", "CURLOPT_POST", ",", "true", ")", ";", "$", "this", "->", "resource", "->", "setOption", "(", "CURLOPT_POSTFIELDS", ",", "$", "body", ")", ";", "}", "}" ]
Send request content.
[ "Send", "request", "content", "." ]
bbe5d9d9dc143cc1a46be53ebd1c294d9390d267
https://github.com/weew/http-client/blob/bbe5d9d9dc143cc1a46be53ebd1c294d9390d267/src/Weew/HttpClient/Drivers/Curl/RequestBuilder.php#L117-L128
4,697
open-orchestra/open-orchestra-elastica-admin-bundle
ElasticaAdmin/Mapper/FieldToElasticaTypeMapper.php
FieldToElasticaTypeMapper.map
public function map($formType) { $this->mapping = array_merge(array($formType => 'string'), $this->mapping); return $this->mapping[$formType]; }
php
public function map($formType) { $this->mapping = array_merge(array($formType => 'string'), $this->mapping); return $this->mapping[$formType]; }
[ "public", "function", "map", "(", "$", "formType", ")", "{", "$", "this", "->", "mapping", "=", "array_merge", "(", "array", "(", "$", "formType", "=>", "'string'", ")", ",", "$", "this", "->", "mapping", ")", ";", "return", "$", "this", "->", "mapping", "[", "$", "formType", "]", ";", "}" ]
Returns the Elastica type linked to a form type @param string $formType @return string
[ "Returns", "the", "Elastica", "type", "linked", "to", "a", "form", "type" ]
6d14beec9d78410e62549d6645d213548e4001a3
https://github.com/open-orchestra/open-orchestra-elastica-admin-bundle/blob/6d14beec9d78410e62549d6645d213548e4001a3/ElasticaAdmin/Mapper/FieldToElasticaTypeMapper.php#L19-L24
4,698
quantaphp/class-names
src/Psr4Namespace.php
Psr4Namespace.directories
private function directories(): \Generator { foreach ($this->directories as $root) { if (is_dir($root)) { yield $root => new \RecursiveIteratorIterator( new \RecursiveDirectoryIterator($root) ); } } }
php
private function directories(): \Generator { foreach ($this->directories as $root) { if (is_dir($root)) { yield $root => new \RecursiveIteratorIterator( new \RecursiveDirectoryIterator($root) ); } } }
[ "private", "function", "directories", "(", ")", ":", "\\", "Generator", "{", "foreach", "(", "$", "this", "->", "directories", "as", "$", "root", ")", "{", "if", "(", "is_dir", "(", "$", "root", ")", ")", "{", "yield", "$", "root", "=>", "new", "\\", "RecursiveIteratorIterator", "(", "new", "\\", "RecursiveDirectoryIterator", "(", "$", "root", ")", ")", ";", "}", "}", "}" ]
Yield an iterator for each directory. @return \Generator
[ "Yield", "an", "iterator", "for", "each", "directory", "." ]
2c0aea13ff82aa70df0fe6f78247415d15a994d1
https://github.com/quantaphp/class-names/blob/2c0aea13ff82aa70df0fe6f78247415d15a994d1/src/Psr4Namespace.php#L62-L71
4,699
quantaphp/class-names
src/Psr4Namespace.php
Psr4Namespace.paths
private function paths(): \Generator { foreach ($this->directories() as $root => $directory) { foreach ($directory as $file) { if (preg_match(self::PATTERN, $file->getFilename()) === 1) { yield $root => $file->getPathname(); } } } }
php
private function paths(): \Generator { foreach ($this->directories() as $root => $directory) { foreach ($directory as $file) { if (preg_match(self::PATTERN, $file->getFilename()) === 1) { yield $root => $file->getPathname(); } } } }
[ "private", "function", "paths", "(", ")", ":", "\\", "Generator", "{", "foreach", "(", "$", "this", "->", "directories", "(", ")", "as", "$", "root", "=>", "$", "directory", ")", "{", "foreach", "(", "$", "directory", "as", "$", "file", ")", "{", "if", "(", "preg_match", "(", "self", "::", "PATTERN", ",", "$", "file", "->", "getFilename", "(", ")", ")", "===", "1", ")", "{", "yield", "$", "root", "=>", "$", "file", "->", "getPathname", "(", ")", ";", "}", "}", "}", "}" ]
Yield paths of the files declaring classes for each directory. @return \Generator
[ "Yield", "paths", "of", "the", "files", "declaring", "classes", "for", "each", "directory", "." ]
2c0aea13ff82aa70df0fe6f78247415d15a994d1
https://github.com/quantaphp/class-names/blob/2c0aea13ff82aa70df0fe6f78247415d15a994d1/src/Psr4Namespace.php#L78-L87