repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
partition
stringclasses
1 value
rosasurfer/ministruts
src/ministruts/Module.php
Module.findForward
public function findForward($name) { if (isset($this->globalForwards[$name])) return $this->globalForwards[$name]; return null; }
php
public function findForward($name) { if (isset($this->globalForwards[$name])) return $this->globalForwards[$name]; return null; }
[ "public", "function", "findForward", "(", "$", "name", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "globalForwards", "[", "$", "name", "]", ")", ")", "return", "$", "this", "->", "globalForwards", "[", "$", "name", "]", ";", "return", "null...
Sucht und gibt den globalen ActionForward mit dem angegebenen Namen zurueck. Wird kein Forward gefunden, wird NULL zurueckgegeben. @param string $name - logischer Name des ActionForwards @return ActionForward|null
[ "Sucht", "und", "gibt", "den", "globalen", "ActionForward", "mit", "dem", "angegebenen", "Namen", "zurueck", ".", "Wird", "kein", "Forward", "gefunden", "wird", "NULL", "zurueckgegeben", "." ]
9d27f93dd53d2d626c75c92cfde9d004bab34d30
https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/ministruts/Module.php#L1081-L1085
train
rosasurfer/ministruts
src/ministruts/Module.php
Module.findTile
public function findTile($name) { if (isset($this->tiles[$name])) return $this->tiles[$name]; return null; }
php
public function findTile($name) { if (isset($this->tiles[$name])) return $this->tiles[$name]; return null; }
[ "public", "function", "findTile", "(", "$", "name", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "tiles", "[", "$", "name", "]", ")", ")", "return", "$", "this", "->", "tiles", "[", "$", "name", "]", ";", "return", "null", ";", "}" ]
Gibt die Tile mit dem angegebenen Namen zurueck oder NULL, wenn keine Tile mit diesem Namen gefunden wurde. @param string $name - logischer Name der Tile @return Tile|null
[ "Gibt", "die", "Tile", "mit", "dem", "angegebenen", "Namen", "zurueck", "oder", "NULL", "wenn", "keine", "Tile", "mit", "diesem", "Namen", "gefunden", "wurde", "." ]
9d27f93dd53d2d626c75c92cfde9d004bab34d30
https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/ministruts/Module.php#L1096-L1100
train
rosasurfer/ministruts
src/ministruts/Module.php
Module.isIncludable
private function isIncludable($name, \SimpleXMLElement $xml) { return $this->isTileDefinition($name, $xml) || $this->isFile($name); }
php
private function isIncludable($name, \SimpleXMLElement $xml) { return $this->isTileDefinition($name, $xml) || $this->isFile($name); }
[ "private", "function", "isIncludable", "(", "$", "name", ",", "\\", "SimpleXMLElement", "$", "xml", ")", "{", "return", "$", "this", "->", "isTileDefinition", "(", "$", "name", ",", "$", "xml", ")", "||", "$", "this", "->", "isFile", "(", "$", "name", ...
Ob unter dem angegebenen Namen eine inkludierbare Resource existiert. Dies kann entweder eine Tiles-Definition oder eine Datei sein. @param string $name - Name der Resource @param \SimpleXMLElement $xml - XML-Objekt mit der Konfiguration @return bool
[ "Ob", "unter", "dem", "angegebenen", "Namen", "eine", "inkludierbare", "Resource", "existiert", ".", "Dies", "kann", "entweder", "eine", "Tiles", "-", "Definition", "oder", "eine", "Datei", "sein", "." ]
9d27f93dd53d2d626c75c92cfde9d004bab34d30
https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/ministruts/Module.php#L1112-L1114
train
rosasurfer/ministruts
src/ministruts/Module.php
Module.isTileDefinition
private function isTileDefinition($name, \SimpleXMLElement $xml) { $nodes = $xml->xpath("/struts-config/tiles/tile[@name='".$name."']") ?: []; return (bool) sizeof($nodes); }
php
private function isTileDefinition($name, \SimpleXMLElement $xml) { $nodes = $xml->xpath("/struts-config/tiles/tile[@name='".$name."']") ?: []; return (bool) sizeof($nodes); }
[ "private", "function", "isTileDefinition", "(", "$", "name", ",", "\\", "SimpleXMLElement", "$", "xml", ")", "{", "$", "nodes", "=", "$", "xml", "->", "xpath", "(", "\"/struts-config/tiles/tile[@name='\"", ".", "$", "name", ".", "\"']\"", ")", "?", ":", "[...
Ob unter dem angegebenen Namen eine Tile definiert ist. @param string $name - Name der Tile @param \SimpleXMLElement $xml - XML-Objekt mit der Konfiguration @return bool @throws StrutsConfigException on configuration errors
[ "Ob", "unter", "dem", "angegebenen", "Namen", "eine", "Tile", "definiert", "ist", "." ]
9d27f93dd53d2d626c75c92cfde9d004bab34d30
https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/ministruts/Module.php#L1127-L1130
train
rosasurfer/ministruts
src/ministruts/Module.php
Module.findFile
private function findFile($name) { // strip query string $parts = explode('?', $name, 2); foreach ($this->resourceLocations as $location) { if (is_file($location.DIRECTORY_SEPARATOR.$parts[0])) { $name = realpath($location.DIRECTORY_SEPARATOR.\array_shift($parts)); if ($parts) $name .= '?'.$parts[0]; return $name; } } return null; }
php
private function findFile($name) { // strip query string $parts = explode('?', $name, 2); foreach ($this->resourceLocations as $location) { if (is_file($location.DIRECTORY_SEPARATOR.$parts[0])) { $name = realpath($location.DIRECTORY_SEPARATOR.\array_shift($parts)); if ($parts) $name .= '?'.$parts[0]; return $name; } } return null; }
[ "private", "function", "findFile", "(", "$", "name", ")", "{", "// strip query string", "$", "parts", "=", "explode", "(", "'?'", ",", "$", "name", ",", "2", ")", ";", "foreach", "(", "$", "this", "->", "resourceLocations", "as", "$", "location", ")", ...
Sucht in den Resource-Verzeichnissen dieses Modules nach einer Datei mit dem angegebenen Namen und gibt den vollstaendigen Dateinamen zurueck, oder NULL, wenn keine Datei mit diesem Namen gefunden wurde. @param string $name - relativer Dateiname @return string|null - Dateiname
[ "Sucht", "in", "den", "Resource", "-", "Verzeichnissen", "dieses", "Modules", "nach", "einer", "Datei", "mit", "dem", "angegebenen", "Namen", "und", "gibt", "den", "vollstaendigen", "Dateinamen", "zurueck", "oder", "NULL", "wenn", "keine", "Datei", "mit", "diese...
9d27f93dd53d2d626c75c92cfde9d004bab34d30
https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/ministruts/Module.php#L1155-L1168
train
rosasurfer/ministruts
src/ministruts/Module.php
Module.resolveClassName
private function resolveClassName($name) { $name = str_replace('/', '\\', trim($name)); // no need to resolve a qualified name if (strContains($name, '\\')) return is_class($name) ? [$name] : []; // unqualified name, check "use" declarations $lowerName = strtolower($name); if (isset($this->uses[$lowerName])) return [$this->uses[$lowerName]]; // unqualified name, check imported namespaces $results = []; foreach ($this->imports as $namespace) { $class = $namespace.$name; if (is_class($class)) $results[] = $class; } return $results; }
php
private function resolveClassName($name) { $name = str_replace('/', '\\', trim($name)); // no need to resolve a qualified name if (strContains($name, '\\')) return is_class($name) ? [$name] : []; // unqualified name, check "use" declarations $lowerName = strtolower($name); if (isset($this->uses[$lowerName])) return [$this->uses[$lowerName]]; // unqualified name, check imported namespaces $results = []; foreach ($this->imports as $namespace) { $class = $namespace.$name; if (is_class($class)) $results[] = $class; } return $results; }
[ "private", "function", "resolveClassName", "(", "$", "name", ")", "{", "$", "name", "=", "str_replace", "(", "'/'", ",", "'\\\\'", ",", "trim", "(", "$", "name", ")", ")", ";", "// no need to resolve a qualified name", "if", "(", "strContains", "(", "$", "...
Resolves a simple class name and returns all found fully qualified class names. @param string $name @return string[] - found class names or an empty array if the class name cannot be resolved
[ "Resolves", "a", "simple", "class", "name", "and", "returns", "all", "found", "fully", "qualified", "class", "names", "." ]
9d27f93dd53d2d626c75c92cfde9d004bab34d30
https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/ministruts/Module.php#L1191-L1211
train
rosasurfer/ministruts
src/db/pgsql/PostgresResult.php
PostgresResult.statusToStr
public static function statusToStr($status) { if (!is_int($status)) throw new IllegalTypeException('Illegal type of parameter $status: '.gettype($status)); switch ($status) { case PGSQL_EMPTY_QUERY : return 'PGSQL_EMPTY_QUERY'; case PGSQL_COMMAND_OK : return 'PGSQL_COMMAND_OK'; case PGSQL_TUPLES_OK : return 'PGSQL_TUPLES_OK'; case PGSQL_COPY_OUT : return 'PGSQL_COPY_OUT'; case PGSQL_COPY_IN : return 'PGSQL_COPY_IN'; case PGSQL_BAD_RESPONSE : return 'PGSQL_BAD_RESPONSE'; case PGSQL_NONFATAL_ERROR: return 'PGSQL_NONFATAL_ERROR'; case PGSQL_FATAL_ERROR : return 'PGSQL_FATAL_ERROR'; } return (string) $status; }
php
public static function statusToStr($status) { if (!is_int($status)) throw new IllegalTypeException('Illegal type of parameter $status: '.gettype($status)); switch ($status) { case PGSQL_EMPTY_QUERY : return 'PGSQL_EMPTY_QUERY'; case PGSQL_COMMAND_OK : return 'PGSQL_COMMAND_OK'; case PGSQL_TUPLES_OK : return 'PGSQL_TUPLES_OK'; case PGSQL_COPY_OUT : return 'PGSQL_COPY_OUT'; case PGSQL_COPY_IN : return 'PGSQL_COPY_IN'; case PGSQL_BAD_RESPONSE : return 'PGSQL_BAD_RESPONSE'; case PGSQL_NONFATAL_ERROR: return 'PGSQL_NONFATAL_ERROR'; case PGSQL_FATAL_ERROR : return 'PGSQL_FATAL_ERROR'; } return (string) $status; }
[ "public", "static", "function", "statusToStr", "(", "$", "status", ")", "{", "if", "(", "!", "is_int", "(", "$", "status", ")", ")", "throw", "new", "IllegalTypeException", "(", "'Illegal type of parameter $status: '", ".", "gettype", "(", "$", "status", ")", ...
Return a readable version of a result status code. @param int $status - status code as returned by pg_result_status(PGSQL_STATUS_LONG) @return string
[ "Return", "a", "readable", "version", "of", "a", "result", "status", "code", "." ]
9d27f93dd53d2d626c75c92cfde9d004bab34d30
https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/db/pgsql/PostgresResult.php#L187-L201
train
timble/kodekit
code/template/filter/asset.php
TemplateFilterAsset.addScheme
public function addScheme($alias, $path, $prepend = false) { if($prepend) { $this->_schemes = array($alias => $path) + $this->_schemes; } else { $this->_schemes = $this->_schemes + array($alias => $path); } return $this; }
php
public function addScheme($alias, $path, $prepend = false) { if($prepend) { $this->_schemes = array($alias => $path) + $this->_schemes; } else { $this->_schemes = $this->_schemes + array($alias => $path); } return $this; }
[ "public", "function", "addScheme", "(", "$", "alias", ",", "$", "path", ",", "$", "prepend", "=", "false", ")", "{", "if", "(", "$", "prepend", ")", "{", "$", "this", "->", "_schemes", "=", "array", "(", "$", "alias", "=>", "$", "path", ")", "+",...
Add a url scheme @param string $alias Scheme to be appended @param mixed $path The path to replace the scheme @param boolean $prepend Whether to prepend the autoloader or not @return TemplateFilterAsset
[ "Add", "a", "url", "scheme" ]
4c376f8873f8d10c55e3d290616ff622605cd246
https://github.com/timble/kodekit/blob/4c376f8873f8d10c55e3d290616ff622605cd246/code/template/filter/asset.php#L72-L81
train
rosasurfer/ministruts
src/db/orm/meta/PropertyMapping.php
PropertyMapping.convertToDBValue
public function convertToDBValue($value, IConnector $connector) { if ($value === null) { $value = 'null'; } else { $type = $this->mapping['type']; switch ($type) { case 'bool' : case 'boolean': $value = $connector->escapeLiteral((bool) $value); break; case 'int' : case 'integer': $value = (string)(int) $value; break; case 'real' : case 'float' : case 'double' : $value = (string)(float) $value; break; case 'string' : $value = $connector->escapeLiteral((string) $value); break; default: if (is_class($type)) { $value = (new $type())->convertToDBValue($value, $this, $connector); break; } throw new RuntimeException('Unsupported type "'.$type.'" for database mapping of '.$this->entityMapping->getClassName().'::'.$this->getName()); } } return $value; }
php
public function convertToDBValue($value, IConnector $connector) { if ($value === null) { $value = 'null'; } else { $type = $this->mapping['type']; switch ($type) { case 'bool' : case 'boolean': $value = $connector->escapeLiteral((bool) $value); break; case 'int' : case 'integer': $value = (string)(int) $value; break; case 'real' : case 'float' : case 'double' : $value = (string)(float) $value; break; case 'string' : $value = $connector->escapeLiteral((string) $value); break; default: if (is_class($type)) { $value = (new $type())->convertToDBValue($value, $this, $connector); break; } throw new RuntimeException('Unsupported type "'.$type.'" for database mapping of '.$this->entityMapping->getClassName().'::'.$this->getName()); } } return $value; }
[ "public", "function", "convertToDBValue", "(", "$", "value", ",", "IConnector", "$", "connector", ")", "{", "if", "(", "$", "value", "===", "null", ")", "{", "$", "value", "=", "'null'", ";", "}", "else", "{", "$", "type", "=", "$", "this", "->", "...
Convert a PHP value to its SQL representation. @param mixed $value - PHP representation of a property value @param IConnector $connector - the used database connector @return string - database representation
[ "Convert", "a", "PHP", "value", "to", "its", "SQL", "representation", "." ]
9d27f93dd53d2d626c75c92cfde9d004bab34d30
https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/db/orm/meta/PropertyMapping.php#L82-L110
train
timble/kodekit
code/dispatcher/request/abstract.php
DispatcherRequestAbstract.receive
public function receive() { foreach($this->_queue as $transport) { if($transport instanceof DispatcherRequestTransportInterface) { $transport->receive($this); } } return $this; }
php
public function receive() { foreach($this->_queue as $transport) { if($transport instanceof DispatcherRequestTransportInterface) { $transport->receive($this); } } return $this; }
[ "public", "function", "receive", "(", ")", "{", "foreach", "(", "$", "this", "->", "_queue", "as", "$", "transport", ")", "{", "if", "(", "$", "transport", "instanceof", "DispatcherRequestTransportInterface", ")", "{", "$", "transport", "->", "receive", "(",...
Receive the request by passing it through transports @return DispatcherRequestTransportInterface
[ "Receive", "the", "request", "by", "passing", "it", "through", "transports" ]
4c376f8873f8d10c55e3d290616ff622605cd246
https://github.com/timble/kodekit/blob/4c376f8873f8d10c55e3d290616ff622605cd246/code/dispatcher/request/abstract.php#L211-L221
train
timble/kodekit
code/dispatcher/request/abstract.php
DispatcherRequestAbstract.getOrigin
public function getOrigin($isInternal = true) { $origin = null; if ($this->_headers->has('Origin')) { try { $origin = $this->getObject('lib:http.url', [ 'url' => $this->getObject('lib:filter.url')->sanitize($this->_headers->get('Origin')) ]); if($isInternal) { $target_origin = $this->getUrl()->getHost(); $source_origin = $origin->getHost(); // Check if the source matches the target if($target_origin !== $source_origin) { // Special case: check if the source is a subdomain of the target origin if ('.'.$target_origin !== substr($source_origin, -1 * (strlen($target_origin)+1))) { $origin = null; } } } } catch (\UnexpectedValueException $e) {} } return $origin; }
php
public function getOrigin($isInternal = true) { $origin = null; if ($this->_headers->has('Origin')) { try { $origin = $this->getObject('lib:http.url', [ 'url' => $this->getObject('lib:filter.url')->sanitize($this->_headers->get('Origin')) ]); if($isInternal) { $target_origin = $this->getUrl()->getHost(); $source_origin = $origin->getHost(); // Check if the source matches the target if($target_origin !== $source_origin) { // Special case: check if the source is a subdomain of the target origin if ('.'.$target_origin !== substr($source_origin, -1 * (strlen($target_origin)+1))) { $origin = null; } } } } catch (\UnexpectedValueException $e) {} } return $origin; }
[ "public", "function", "getOrigin", "(", "$", "isInternal", "=", "true", ")", "{", "$", "origin", "=", "null", ";", "if", "(", "$", "this", "->", "_headers", "->", "has", "(", "'Origin'", ")", ")", "{", "try", "{", "$", "origin", "=", "$", "this", ...
Returns the HTTP origin header. @param boolean $isInternal Only allow internal URLs @return HttpUrl|null A HttpUrl object or NULL if no origin header could be found
[ "Returns", "the", "HTTP", "origin", "header", "." ]
4c376f8873f8d10c55e3d290616ff622605cd246
https://github.com/timble/kodekit/blob/4c376f8873f8d10c55e3d290616ff622605cd246/code/dispatcher/request/abstract.php#L653-L683
train
timble/kodekit
code/dispatcher/request/abstract.php
DispatcherRequestAbstract.getFormat
public function getFormat($mediatype = false) { if (!isset($this->_format)) { if(!$this->query->has('format')) { $format = pathinfo($this->getUrl()->getPath(), PATHINFO_EXTENSION); if(empty($format) || !isset(static::$_formats[$format])) { $format = 'html'; //define html default if ($this->_headers->has('Accept')) { $accept = $this->_headers->get('Accept'); $formats = $this->__parseAccept($accept); /** * If the browser is requested text/html serve it at all times * * @hotfix #409 : Android 2.3 requesting application/xml */ if (!isset($formats['text/html'])) { //Get the highest quality format $mime_type = key($formats); foreach (static::$_formats as $value => $mime_types) { if (in_array($mime_type, (array)$mime_types)) { $format = $value; break; } } } } } } else $format = $this->query->get('format', 'word'); $this->setFormat($format); } return $mediatype ? static::$_formats[$this->_format][0] : $this->_format; }
php
public function getFormat($mediatype = false) { if (!isset($this->_format)) { if(!$this->query->has('format')) { $format = pathinfo($this->getUrl()->getPath(), PATHINFO_EXTENSION); if(empty($format) || !isset(static::$_formats[$format])) { $format = 'html'; //define html default if ($this->_headers->has('Accept')) { $accept = $this->_headers->get('Accept'); $formats = $this->__parseAccept($accept); /** * If the browser is requested text/html serve it at all times * * @hotfix #409 : Android 2.3 requesting application/xml */ if (!isset($formats['text/html'])) { //Get the highest quality format $mime_type = key($formats); foreach (static::$_formats as $value => $mime_types) { if (in_array($mime_type, (array)$mime_types)) { $format = $value; break; } } } } } } else $format = $this->query->get('format', 'word'); $this->setFormat($format); } return $mediatype ? static::$_formats[$this->_format][0] : $this->_format; }
[ "public", "function", "getFormat", "(", "$", "mediatype", "=", "false", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "_format", ")", ")", "{", "if", "(", "!", "$", "this", "->", "query", "->", "has", "(", "'format'", ")", ")", "{", ...
Return the request format or mediatype Find the format by using following sequence : 1. Use the the 'format' request parameter 2. Use the URL path extension 3. Use the accept header with the highest quality apply the reverse format map to find the format. @param bool $mediatype Get the media type @return string The request format or NULL if no format could be found
[ "Return", "the", "request", "format", "or", "mediatype" ]
4c376f8873f8d10c55e3d290616ff622605cd246
https://github.com/timble/kodekit/blob/4c376f8873f8d10c55e3d290616ff622605cd246/code/dispatcher/request/abstract.php#L816-L860
train
timble/kodekit
code/dispatcher/request/abstract.php
DispatcherRequestAbstract.getTimezones
public function getTimezones() { $country = locale_get_region($this->getLanguage()); $timezones = timezone_identifiers_list(\DateTimeZone::PER_COUNTRY, $country); return $timezones; }
php
public function getTimezones() { $country = locale_get_region($this->getLanguage()); $timezones = timezone_identifiers_list(\DateTimeZone::PER_COUNTRY, $country); return $timezones; }
[ "public", "function", "getTimezones", "(", ")", "{", "$", "country", "=", "locale_get_region", "(", "$", "this", "->", "getLanguage", "(", ")", ")", ";", "$", "timezones", "=", "timezone_identifiers_list", "(", "\\", "DateTimeZone", "::", "PER_COUNTRY", ",", ...
Get a list of timezones acceptable by the client @return array|false
[ "Get", "a", "list", "of", "timezones", "acceptable", "by", "the", "client" ]
4c376f8873f8d10c55e3d290616ff622605cd246
https://github.com/timble/kodekit/blob/4c376f8873f8d10c55e3d290616ff622605cd246/code/dispatcher/request/abstract.php#L976-L982
train
timble/kodekit
code/dispatcher/request/abstract.php
DispatcherRequestAbstract.isDownload
public function isDownload() { $result = $this->query->has('force-download'); if($this->headers->has('Accept')) { $accept = $this->headers->get('Accept'); $types = $this->__parseAccept($accept); //Get the highest quality format $type = key($types); if(in_array($type, array('application/force-download', 'application/octet-stream'))) { return $result = true; } } return $result; }
php
public function isDownload() { $result = $this->query->has('force-download'); if($this->headers->has('Accept')) { $accept = $this->headers->get('Accept'); $types = $this->__parseAccept($accept); //Get the highest quality format $type = key($types); if(in_array($type, array('application/force-download', 'application/octet-stream'))) { return $result = true; } } return $result; }
[ "public", "function", "isDownload", "(", ")", "{", "$", "result", "=", "$", "this", "->", "query", "->", "has", "(", "'force-download'", ")", ";", "if", "(", "$", "this", "->", "headers", "->", "has", "(", "'Accept'", ")", ")", "{", "$", "accept", ...
Check if the request is downloadable or not. A request is downloading if one of the following conditions are met : 1. The request query contains a 'force-download' parameter 2. The request accepts specifies either the application/force-download or application/octet-stream mime types @return bool Returns TRUE If the request is downloadable. FALSE otherwise.
[ "Check", "if", "the", "request", "is", "downloadable", "or", "not", "." ]
4c376f8873f8d10c55e3d290616ff622605cd246
https://github.com/timble/kodekit/blob/4c376f8873f8d10c55e3d290616ff622605cd246/code/dispatcher/request/abstract.php#L1168-L1186
train
rosasurfer/ministruts
src/cache/ApcCache.php
ApcCache.isCached
public function isCached($key) { // The actual working horse. The method does not only check existence of the key. It retrieves the value and stores // it in the local reference pool, so following cache queries can use the local reference. // check local reference pool if ($this->getReferencePool()->isCached($key)) return true; // query APC cache $data = apc_fetch($this->namespace.'::'.$key); if (!$data) // cache miss return false; // cache hit $created = $data[0]; // data: [created, expires, serialized([$value, $dependency])] $expires = $data[1]; // check expiration if ($expires && $created+$expires < time()) { $this->drop($key); return false; } // unpack serialized value $data[2] = unserialize($data[2]); $value = $data[2][0]; $dependency = $data[2][1]; // check dependency if ($dependency) { $minValid = $dependency->getMinValidity(); if ($minValid) { if (time() > $created+$minValid) { if (!$dependency->isValid()) { $this->drop($key); return false; } // reset the creation time by writing back to the cache (resets $minValid period) return $this->set($key, $value, $expires, $dependency); } } elseif (!$dependency->isValid()) { $this->drop($key); return false; } } // store the validated value in the local reference pool $this->getReferencePool()->set($key, $value, Cache::EXPIRES_NEVER, $dependency); return true; }
php
public function isCached($key) { // The actual working horse. The method does not only check existence of the key. It retrieves the value and stores // it in the local reference pool, so following cache queries can use the local reference. // check local reference pool if ($this->getReferencePool()->isCached($key)) return true; // query APC cache $data = apc_fetch($this->namespace.'::'.$key); if (!$data) // cache miss return false; // cache hit $created = $data[0]; // data: [created, expires, serialized([$value, $dependency])] $expires = $data[1]; // check expiration if ($expires && $created+$expires < time()) { $this->drop($key); return false; } // unpack serialized value $data[2] = unserialize($data[2]); $value = $data[2][0]; $dependency = $data[2][1]; // check dependency if ($dependency) { $minValid = $dependency->getMinValidity(); if ($minValid) { if (time() > $created+$minValid) { if (!$dependency->isValid()) { $this->drop($key); return false; } // reset the creation time by writing back to the cache (resets $minValid period) return $this->set($key, $value, $expires, $dependency); } } elseif (!$dependency->isValid()) { $this->drop($key); return false; } } // store the validated value in the local reference pool $this->getReferencePool()->set($key, $value, Cache::EXPIRES_NEVER, $dependency); return true; }
[ "public", "function", "isCached", "(", "$", "key", ")", "{", "// The actual working horse. The method does not only check existence of the key. It retrieves the value and stores", "// it in the local reference pool, so following cache queries can use the local reference.", "// check local refere...
Whether a value with the specified key exists in the cache. @param string $key @return bool
[ "Whether", "a", "value", "with", "the", "specified", "key", "exists", "in", "the", "cache", "." ]
9d27f93dd53d2d626c75c92cfde9d004bab34d30
https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/cache/ApcCache.php#L36-L87
train
rosasurfer/ministruts
src/cache/ApcCache.php
ApcCache.set
public function set($key, &$value, $expires=Cache::EXPIRES_NEVER, Dependency $dependency=null) { if (!is_string($key)) throw new IllegalTypeException('Illegal type of parameter $key: '.gettype($key)); if (!is_int($expires)) throw new IllegalTypeException('Illegal type of parameter $expires: '.gettype($expires)); // data format in the cache: [created, expires, serialized([value, dependency])] $fullKey = $this->namespace.'::'.$key; $created = time(); $data = array($value, $dependency); /** * PHP 5.3.3/APC 3.1.3 * ------------------- * Bug: warning "Potential cache slam averted for key '...'" * - apc_add() and apc_store() return FALSE if called multiple times for the same key * * @see http://bugs.php.net/bug.php?id=58832 * @see http://stackoverflow.com/questions/4983370/php-apc-potential-cache-slam-averted-for-key * * - solution for APC >= 3.1.7: re-introduced setting apc.slam_defense=0 * - no solution yet for APC 3.1.3-3.1.6 * * @see http://serverfault.com/questions/342295/apc-keeps-crashing * @see http://stackoverflow.com/questions/1670034/why-would-apc-store-return-false * @see http://notmysock.org/blog/php/user-cache-timebomb.html */ // store value: // - If possible use apc_add() which causes less memory fragmentation and minimizes lock waits. // - Don't use APC-TTL as the real TTL is checked in self::isCached(). APC-TTL causes various APC bugs. if (function_exists('apc_add')) { // APC >= 3.0.13 if (function_exists('apc_exists')) $isKey = apc_exists($fullKey); // APC >= 3.1.4 else $isKey = (bool) apc_fetch ($fullKey); if ($isKey) apc_delete($fullKey); // apc_delete()+apc_add() result in less memory fragmentation than apc_store() if (!apc_add($fullKey, array($created, $expires, serialize($data)))) { //Logger::log('apc_add() unexpectedly returned FALSE for $key "'.$fullKey.'" '.($isKey ? '(did exist and was deleted)':'(did not exist)'), L_WARN); return false; } } elseif (!apc_store($fullKey, array($created, $expires, serialize($data)))) { //Logger::log('apc_store() unexpectedly returned FALSE for $key "'.$fullKey.'" '.($isKey ? '(did exist and was deleted)':'(did not exist)'), L_WARN); return false; } $this->getReferencePool()->set($key, $value, $expires, $dependency); return true; }
php
public function set($key, &$value, $expires=Cache::EXPIRES_NEVER, Dependency $dependency=null) { if (!is_string($key)) throw new IllegalTypeException('Illegal type of parameter $key: '.gettype($key)); if (!is_int($expires)) throw new IllegalTypeException('Illegal type of parameter $expires: '.gettype($expires)); // data format in the cache: [created, expires, serialized([value, dependency])] $fullKey = $this->namespace.'::'.$key; $created = time(); $data = array($value, $dependency); /** * PHP 5.3.3/APC 3.1.3 * ------------------- * Bug: warning "Potential cache slam averted for key '...'" * - apc_add() and apc_store() return FALSE if called multiple times for the same key * * @see http://bugs.php.net/bug.php?id=58832 * @see http://stackoverflow.com/questions/4983370/php-apc-potential-cache-slam-averted-for-key * * - solution for APC >= 3.1.7: re-introduced setting apc.slam_defense=0 * - no solution yet for APC 3.1.3-3.1.6 * * @see http://serverfault.com/questions/342295/apc-keeps-crashing * @see http://stackoverflow.com/questions/1670034/why-would-apc-store-return-false * @see http://notmysock.org/blog/php/user-cache-timebomb.html */ // store value: // - If possible use apc_add() which causes less memory fragmentation and minimizes lock waits. // - Don't use APC-TTL as the real TTL is checked in self::isCached(). APC-TTL causes various APC bugs. if (function_exists('apc_add')) { // APC >= 3.0.13 if (function_exists('apc_exists')) $isKey = apc_exists($fullKey); // APC >= 3.1.4 else $isKey = (bool) apc_fetch ($fullKey); if ($isKey) apc_delete($fullKey); // apc_delete()+apc_add() result in less memory fragmentation than apc_store() if (!apc_add($fullKey, array($created, $expires, serialize($data)))) { //Logger::log('apc_add() unexpectedly returned FALSE for $key "'.$fullKey.'" '.($isKey ? '(did exist and was deleted)':'(did not exist)'), L_WARN); return false; } } elseif (!apc_store($fullKey, array($created, $expires, serialize($data)))) { //Logger::log('apc_store() unexpectedly returned FALSE for $key "'.$fullKey.'" '.($isKey ? '(did exist and was deleted)':'(did not exist)'), L_WARN); return false; } $this->getReferencePool()->set($key, $value, $expires, $dependency); return true; }
[ "public", "function", "set", "(", "$", "key", ",", "&", "$", "value", ",", "$", "expires", "=", "Cache", "::", "EXPIRES_NEVER", ",", "Dependency", "$", "dependency", "=", "null", ")", "{", "if", "(", "!", "is_string", "(", "$", "key", ")", ")", "th...
Store a value under the specified key in the cache. An existing value already stored under the key is overwritten. If expiration time or dependency are provided and those conditions are met the value is automatically invalidated but not automatically removed from the cache. @param string $key - key @param mixed $value - value @param int $expires [optional] - time in seconds after which the value becomes invalid (default: never) @param Dependency $dependency [optional] - a dependency object monitoring validity of the value (default: none) @return bool - TRUE on successful storage; FALSE otherwise
[ "Store", "a", "value", "under", "the", "specified", "key", "in", "the", "cache", ".", "An", "existing", "value", "already", "stored", "under", "the", "key", "is", "overwritten", ".", "If", "expiration", "time", "or", "dependency", "are", "provided", "and", ...
9d27f93dd53d2d626c75c92cfde9d004bab34d30
https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/cache/ApcCache.php#L132-L180
train
timble/kodekit
code/model/entity/composite.php
ModelEntityComposite.insert
public function insert($entity, $status = null) { if(!$entity instanceof ModelEntityInterface) { if (!is_array($entity) && !$entity instanceof \Traversable) { throw new \InvalidArgumentException(sprintf( 'Entity must be an array or an object implementing the Traversable interface; received "%s"', gettype($entity) )); } if($this->_prototypable) { if(!$this->_prototype instanceof ModelEntityInterface) { $identifier = $this->getIdentifier()->toArray(); $identifier['path'] = array('model', 'entity'); $identifier['name'] = StringInflector::singularize($this->getIdentifier()->name); //The entity default options $options = array( 'identity_key' => $this->getIdentityKey() ); $this->_prototype = $this->getObject($identifier, $options); } $prototype = clone $this->_prototype; $prototype->setStatus($status); $prototype->setProperties($entity, $prototype->isNew()); $entity = $prototype; } else { $identifier = $this->getIdentifier()->toArray(); $identifier['path'] = array('model', 'entity'); $identifier['name'] = StringInflector::singularize($this->getIdentifier()->name); //The entity default options $options = array( 'data' => $entity, 'status' => $status, 'identity_key' => $this->getIdentityKey() ); $entity = $this->getObject($identifier, $options); } } //Insert the entity into the collection $this->__entities->insert($entity); return $this; }
php
public function insert($entity, $status = null) { if(!$entity instanceof ModelEntityInterface) { if (!is_array($entity) && !$entity instanceof \Traversable) { throw new \InvalidArgumentException(sprintf( 'Entity must be an array or an object implementing the Traversable interface; received "%s"', gettype($entity) )); } if($this->_prototypable) { if(!$this->_prototype instanceof ModelEntityInterface) { $identifier = $this->getIdentifier()->toArray(); $identifier['path'] = array('model', 'entity'); $identifier['name'] = StringInflector::singularize($this->getIdentifier()->name); //The entity default options $options = array( 'identity_key' => $this->getIdentityKey() ); $this->_prototype = $this->getObject($identifier, $options); } $prototype = clone $this->_prototype; $prototype->setStatus($status); $prototype->setProperties($entity, $prototype->isNew()); $entity = $prototype; } else { $identifier = $this->getIdentifier()->toArray(); $identifier['path'] = array('model', 'entity'); $identifier['name'] = StringInflector::singularize($this->getIdentifier()->name); //The entity default options $options = array( 'data' => $entity, 'status' => $status, 'identity_key' => $this->getIdentityKey() ); $entity = $this->getObject($identifier, $options); } } //Insert the entity into the collection $this->__entities->insert($entity); return $this; }
[ "public", "function", "insert", "(", "$", "entity", ",", "$", "status", "=", "null", ")", "{", "if", "(", "!", "$", "entity", "instanceof", "ModelEntityInterface", ")", "{", "if", "(", "!", "is_array", "(", "$", "entity", ")", "&&", "!", "$", "entity...
Insert a new entity This function will either clone a entity prototype or create a new instance of the entity object for each entity being inserted. By default the entity will be cloned. The entity will be stored by it's identity_key if set or otherwise by it's object handle. @param ModelEntityInterface|array $entity A ModelEntityInterface object or an array of entity properties @param string $status The entity status @return ModelEntityComposite
[ "Insert", "a", "new", "entity" ]
4c376f8873f8d10c55e3d290616ff622605cd246
https://github.com/timble/kodekit/blob/4c376f8873f8d10c55e3d290616ff622605cd246/code/model/entity/composite.php#L103-L157
train
timble/kodekit
code/user/provider/model.php
UserProviderModel.setUser
public function setUser(UserInterface $user) { parent::setUser($user); //Store the user by email if($email = $user->getEmail()) { $this->_emails[$email] = $user; } return $this; }
php
public function setUser(UserInterface $user) { parent::setUser($user); //Store the user by email if($email = $user->getEmail()) { $this->_emails[$email] = $user; } return $this; }
[ "public", "function", "setUser", "(", "UserInterface", "$", "user", ")", "{", "parent", "::", "setUser", "(", "$", "user", ")", ";", "//Store the user by email", "if", "(", "$", "email", "=", "$", "user", "->", "getEmail", "(", ")", ")", "{", "$", "thi...
Set a user in the provider @param UserInterface $user @return boolean
[ "Set", "a", "user", "in", "the", "provider" ]
4c376f8873f8d10c55e3d290616ff622605cd246
https://github.com/timble/kodekit/blob/4c376f8873f8d10c55e3d290616ff622605cd246/code/user/provider/model.php#L112-L122
train
timble/kodekit
code/user/provider/model.php
UserProviderModel.findUser
public function findUser($identifier) { $user = null; if($this->isLoaded($identifier)) { if (!is_numeric($identifier)) { $user = $this->_emails[$identifier]; } else { $user = parent::findUser($identifier); } } return $user; }
php
public function findUser($identifier) { $user = null; if($this->isLoaded($identifier)) { if (!is_numeric($identifier)) { $user = $this->_emails[$identifier]; } else { $user = parent::findUser($identifier); } } return $user; }
[ "public", "function", "findUser", "(", "$", "identifier", ")", "{", "$", "user", "=", "null", ";", "if", "(", "$", "this", "->", "isLoaded", "(", "$", "identifier", ")", ")", "{", "if", "(", "!", "is_numeric", "(", "$", "identifier", ")", ")", "{",...
Find a user for the given identifier @param string $identifier A unique user identifier, (i.e a username or email address) @return UserInterface|null Returns a UserInterface object or NULL if the user hasn't been loaded yet
[ "Find", "a", "user", "for", "the", "given", "identifier" ]
4c376f8873f8d10c55e3d290616ff622605cd246
https://github.com/timble/kodekit/blob/4c376f8873f8d10c55e3d290616ff622605cd246/code/user/provider/model.php#L130-L143
train
timble/kodekit
code/object/config/factory.php
ObjectConfigFactory.createFormat
public function createFormat($format, $options = array()) { $name = strtolower($format); if (!isset($this->_formats[$name])) { throw new \RuntimeException(sprintf('Unsupported config format: %s ', $name)); } if(!isset($this->__prototypes[$name])) { $class = $this->_formats[$name]; $instance = new $class(); if(!$instance instanceof ObjectConfigSerializable) { throw new \UnexpectedValueException( 'Format: '.get_class($instance).' does not implement ObjectConfigSerializable Interface' ); } $this->__prototypes[$name] = $instance; } //Clone the object $result = clone $this->__prototypes[$name]; $result->merge($options); return $result; }
php
public function createFormat($format, $options = array()) { $name = strtolower($format); if (!isset($this->_formats[$name])) { throw new \RuntimeException(sprintf('Unsupported config format: %s ', $name)); } if(!isset($this->__prototypes[$name])) { $class = $this->_formats[$name]; $instance = new $class(); if(!$instance instanceof ObjectConfigSerializable) { throw new \UnexpectedValueException( 'Format: '.get_class($instance).' does not implement ObjectConfigSerializable Interface' ); } $this->__prototypes[$name] = $instance; } //Clone the object $result = clone $this->__prototypes[$name]; $result->merge($options); return $result; }
[ "public", "function", "createFormat", "(", "$", "format", ",", "$", "options", "=", "array", "(", ")", ")", "{", "$", "name", "=", "strtolower", "(", "$", "format", ")", ";", "if", "(", "!", "isset", "(", "$", "this", "->", "_formats", "[", "$", ...
Get a registered config object. @param string $format The format name @param array|ObjectConfig $options An associative array of configuration options or a ObjectConfig instance. @throws \InvalidArgumentException If the format isn't registered @throws \UnexpectedValueException If the format object doesn't implement the ObjectConfigSerializable @return ObjectConfigSerializable
[ "Get", "a", "registered", "config", "object", "." ]
4c376f8873f8d10c55e3d290616ff622605cd246
https://github.com/timble/kodekit/blob/4c376f8873f8d10c55e3d290616ff622605cd246/code/object/config/factory.php#L79-L107
train
timble/kodekit
code/object/config/factory.php
ObjectConfigFactory.registerFormat
public function registerFormat($format, $class) { if(!class_exists($class, true)) { throw new \InvalidArgumentException('Class : '.$class.' cannot does not exist.'); } $this->_formats[$format] = $class; //In case the format is being re-registered clear the prototype if(isset($this->__prototypes[$format])) { unset($this->__prototypes[$format]); } return $this; }
php
public function registerFormat($format, $class) { if(!class_exists($class, true)) { throw new \InvalidArgumentException('Class : '.$class.' cannot does not exist.'); } $this->_formats[$format] = $class; //In case the format is being re-registered clear the prototype if(isset($this->__prototypes[$format])) { unset($this->__prototypes[$format]); } return $this; }
[ "public", "function", "registerFormat", "(", "$", "format", ",", "$", "class", ")", "{", "if", "(", "!", "class_exists", "(", "$", "class", ",", "true", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Class : '", ".", "$", "class"...
Register config format @param string $format The name of the format @param mixed $class Class name @throws \InvalidArgumentException If the class does not exist @return ObjectConfigFactory
[ "Register", "config", "format" ]
4c376f8873f8d10c55e3d290616ff622605cd246
https://github.com/timble/kodekit/blob/4c376f8873f8d10c55e3d290616ff622605cd246/code/object/config/factory.php#L117-L131
train
timble/kodekit
code/object/config/factory.php
ObjectConfigFactory.fromFile
public function fromFile($filename, $object = true) { $pathinfo = pathinfo($filename); if (!isset($pathinfo['extension'])) { throw new \RuntimeException(sprintf( 'Filename "%s" is missing an extension and cannot be auto-detected', $filename )); } $config = $this->createFormat($pathinfo['extension'])->fromFile($filename, $object); return $config; }
php
public function fromFile($filename, $object = true) { $pathinfo = pathinfo($filename); if (!isset($pathinfo['extension'])) { throw new \RuntimeException(sprintf( 'Filename "%s" is missing an extension and cannot be auto-detected', $filename )); } $config = $this->createFormat($pathinfo['extension'])->fromFile($filename, $object); return $config; }
[ "public", "function", "fromFile", "(", "$", "filename", ",", "$", "object", "=", "true", ")", "{", "$", "pathinfo", "=", "pathinfo", "(", "$", "filename", ")", ";", "if", "(", "!", "isset", "(", "$", "pathinfo", "[", "'extension'", "]", ")", ")", "...
Read a config from a file. @param string $filename @param bool $object If TRUE return a ConfigObject, if FALSE return an array. Default TRUE. @throws \InvalidArgumentException @throws \RuntimeException @return ObjectConfigInterface|array
[ "Read", "a", "config", "from", "a", "file", "." ]
4c376f8873f8d10c55e3d290616ff622605cd246
https://github.com/timble/kodekit/blob/4c376f8873f8d10c55e3d290616ff622605cd246/code/object/config/factory.php#L158-L171
train
timble/kodekit
code/object/config/factory.php
ObjectConfigFactory.toFile
public function toFile($filename, ObjectConfigInterface $config) { $pathinfo = pathinfo($filename); if (!isset($pathinfo['extension'])) { throw new \RuntimeException(sprintf( 'Filename "%s" is missing an extension and cannot be auto-detected', $filename )); } $this->createFormat($pathinfo['extension'])->toFile($filename, $config); return $this; }
php
public function toFile($filename, ObjectConfigInterface $config) { $pathinfo = pathinfo($filename); if (!isset($pathinfo['extension'])) { throw new \RuntimeException(sprintf( 'Filename "%s" is missing an extension and cannot be auto-detected', $filename )); } $this->createFormat($pathinfo['extension'])->toFile($filename, $config); return $this; }
[ "public", "function", "toFile", "(", "$", "filename", ",", "ObjectConfigInterface", "$", "config", ")", "{", "$", "pathinfo", "=", "pathinfo", "(", "$", "filename", ")", ";", "if", "(", "!", "isset", "(", "$", "pathinfo", "[", "'extension'", "]", ")", ...
Writes a config to a file @param string $filename @param ObjectConfigInterface $config @throws \RuntimeException @return ObjectConfigFactory
[ "Writes", "a", "config", "to", "a", "file" ]
4c376f8873f8d10c55e3d290616ff622605cd246
https://github.com/timble/kodekit/blob/4c376f8873f8d10c55e3d290616ff622605cd246/code/object/config/factory.php#L181-L194
train
rosasurfer/ministruts
src/util/PHP.php
PHP.ini_set
public static function ini_set($option, $value, $throwException = true) { if (is_bool($value)) $value = (int) $value; $oldValue = ini_set($option, $value); if ($oldValue !== false) return true; $oldValue = ini_get($option); // ini_set() caused an error $newValue = (string) $value; if ($oldValue == $newValue) // the error can be ignored return true; if ($throwException) throw new RuntimeException('Cannot set php.ini option "'.$option.'" (former value="'.$oldValue.'")'); return false; }
php
public static function ini_set($option, $value, $throwException = true) { if (is_bool($value)) $value = (int) $value; $oldValue = ini_set($option, $value); if ($oldValue !== false) return true; $oldValue = ini_get($option); // ini_set() caused an error $newValue = (string) $value; if ($oldValue == $newValue) // the error can be ignored return true; if ($throwException) throw new RuntimeException('Cannot set php.ini option "'.$option.'" (former value="'.$oldValue.'")'); return false; }
[ "public", "static", "function", "ini_set", "(", "$", "option", ",", "$", "value", ",", "$", "throwException", "=", "true", ")", "{", "if", "(", "is_bool", "(", "$", "value", ")", ")", "$", "value", "=", "(", "int", ")", "$", "value", ";", "$", "o...
Set the specified php.ini setting. Opposite to the built-in PHP function this method does not return the old value but a boolean success status. Used to detect assignment errors if the access level of the specified option doesn't allow a modification. @param string $option @param bool|int|string $value @param bool $throwException [optional] - whether to throw an exception on errors (default: yes) @return bool - success status
[ "Set", "the", "specified", "php", ".", "ini", "setting", ".", "Opposite", "to", "the", "built", "-", "in", "PHP", "function", "this", "method", "does", "not", "return", "the", "old", "value", "but", "a", "boolean", "success", "status", ".", "Used", "to",...
9d27f93dd53d2d626c75c92cfde9d004bab34d30
https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/util/PHP.php#L444-L460
train
rosasurfer/ministruts
src/net/http/HttpRequest.php
HttpRequest.setMethod
public function setMethod($method) { if (!is_string($method)) throw new IllegalTypeException('Illegal type of parameter $method: '.gettype($method)); if ($method!=='GET' && $method!=='POST') throw new InvalidArgumentException('Invalid argument $method: '.$method); $this->method = $method; return $this; }
php
public function setMethod($method) { if (!is_string($method)) throw new IllegalTypeException('Illegal type of parameter $method: '.gettype($method)); if ($method!=='GET' && $method!=='POST') throw new InvalidArgumentException('Invalid argument $method: '.$method); $this->method = $method; return $this; }
[ "public", "function", "setMethod", "(", "$", "method", ")", "{", "if", "(", "!", "is_string", "(", "$", "method", ")", ")", "throw", "new", "IllegalTypeException", "(", "'Illegal type of parameter $method: '", ".", "gettype", "(", "$", "method", ")", ")", ";...
Set the request's HTTP method. Currently only GET and POST are implemented. @param string $method @return $this
[ "Set", "the", "request", "s", "HTTP", "method", ".", "Currently", "only", "GET", "and", "POST", "are", "implemented", "." ]
9d27f93dd53d2d626c75c92cfde9d004bab34d30
https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/net/http/HttpRequest.php#L68-L74
train
rosasurfer/ministruts
src/net/http/HttpRequest.php
HttpRequest.setUrl
public function setUrl($url) { if (!is_string($url)) throw new IllegalTypeException('Illegal type of parameter $url: '.gettype($url)); // TODO: validate URL if (strpos($url, ' ') !== false) throw new InvalidArgumentException('Invalid argument $url: '.$url); $this->url = $url; return $this; }
php
public function setUrl($url) { if (!is_string($url)) throw new IllegalTypeException('Illegal type of parameter $url: '.gettype($url)); // TODO: validate URL if (strpos($url, ' ') !== false) throw new InvalidArgumentException('Invalid argument $url: '.$url); $this->url = $url; return $this; }
[ "public", "function", "setUrl", "(", "$", "url", ")", "{", "if", "(", "!", "is_string", "(", "$", "url", ")", ")", "throw", "new", "IllegalTypeException", "(", "'Illegal type of parameter $url: '", ".", "gettype", "(", "$", "url", ")", ")", ";", "// TODO: ...
Set the request's URL. @param string $url @return $this
[ "Set", "the", "request", "s", "URL", "." ]
9d27f93dd53d2d626c75c92cfde9d004bab34d30
https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/net/http/HttpRequest.php#L94-L104
train
rosasurfer/ministruts
src/net/http/HttpRequest.php
HttpRequest.setHeader
public function setHeader($name, $value) { if (!is_string($name)) throw new IllegalTypeException('Illegal type of parameter $name: '.gettype($name)); if (!strlen($name)) throw new InvalidArgumentException('Invalid argument $name: '.$name); if (isset($value) && !is_string($value)) throw new IllegalTypeException('Illegal type of parameter $value: '.gettype($value)); $name = trim($name); $value = trim($value); // drop existing headers of the same name (ignore case) $existing = \array_intersect_ukey($this->headers, [$name => '1'], 'strCaseCmp'); foreach ($existing as $key => $v) { unset($this->headers[$key]); } // set new header if non-empty if (!empty($value)) { $this->headers[$name] = $value; } return $this; }
php
public function setHeader($name, $value) { if (!is_string($name)) throw new IllegalTypeException('Illegal type of parameter $name: '.gettype($name)); if (!strlen($name)) throw new InvalidArgumentException('Invalid argument $name: '.$name); if (isset($value) && !is_string($value)) throw new IllegalTypeException('Illegal type of parameter $value: '.gettype($value)); $name = trim($name); $value = trim($value); // drop existing headers of the same name (ignore case) $existing = \array_intersect_ukey($this->headers, [$name => '1'], 'strCaseCmp'); foreach ($existing as $key => $v) { unset($this->headers[$key]); } // set new header if non-empty if (!empty($value)) { $this->headers[$name] = $value; } return $this; }
[ "public", "function", "setHeader", "(", "$", "name", ",", "$", "value", ")", "{", "if", "(", "!", "is_string", "(", "$", "name", ")", ")", "throw", "new", "IllegalTypeException", "(", "'Illegal type of parameter $name: '", ".", "gettype", "(", "$", "name", ...
Set an HTTP header. This method overwrites an existing header of the same name. @param string $name - header name @param string|null $value - header value (an empty value removes an existing header) @return $this
[ "Set", "an", "HTTP", "header", ".", "This", "method", "overwrites", "an", "existing", "header", "of", "the", "same", "name", "." ]
9d27f93dd53d2d626c75c92cfde9d004bab34d30
https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/net/http/HttpRequest.php#L115-L134
train
rosasurfer/ministruts
src/net/http/HttpRequest.php
HttpRequest.addHeader
public function addHeader($name, $value) { if (!is_string($name)) throw new IllegalTypeException('Illegal type of parameter $name: '.gettype($name)); if (!strlen($name)) throw new InvalidArgumentException('Invalid argument $name: '.$name); if (!is_string($value)) throw new IllegalTypeException('Illegal type of parameter $value: '.gettype($value)); if (!strlen($value)) throw new InvalidArgumentException('Invalid argument $value: '.$value); $name = trim($name); $value = trim($value); // memorize and drop existing headers of the same name (ignore case) $existing = \array_intersect_ukey($this->headers, [$name => '1'], 'strCaseCmp'); foreach ($existing as $key => $v) { unset($this->headers[$key]); } // combine existing and new header (see RFC), set combined header $existing[] = $value; $this->headers[$name] = join(', ', $existing); return $this; }
php
public function addHeader($name, $value) { if (!is_string($name)) throw new IllegalTypeException('Illegal type of parameter $name: '.gettype($name)); if (!strlen($name)) throw new InvalidArgumentException('Invalid argument $name: '.$name); if (!is_string($value)) throw new IllegalTypeException('Illegal type of parameter $value: '.gettype($value)); if (!strlen($value)) throw new InvalidArgumentException('Invalid argument $value: '.$value); $name = trim($name); $value = trim($value); // memorize and drop existing headers of the same name (ignore case) $existing = \array_intersect_ukey($this->headers, [$name => '1'], 'strCaseCmp'); foreach ($existing as $key => $v) { unset($this->headers[$key]); } // combine existing and new header (see RFC), set combined header $existing[] = $value; $this->headers[$name] = join(', ', $existing); return $this; }
[ "public", "function", "addHeader", "(", "$", "name", ",", "$", "value", ")", "{", "if", "(", "!", "is_string", "(", "$", "name", ")", ")", "throw", "new", "IllegalTypeException", "(", "'Illegal type of parameter $name: '", ".", "gettype", "(", "$", "name", ...
Add an HTTP header to the existing ones. Existing headers of the same name are not overwritten. @param string $name - header name @param string $value - header value @return $this @see http://stackoverflow.com/questions/3241326/set-more-than-one-http-header-with-the-same-name
[ "Add", "an", "HTTP", "header", "to", "the", "existing", "ones", ".", "Existing", "headers", "of", "the", "same", "name", "are", "not", "overwritten", "." ]
9d27f93dd53d2d626c75c92cfde9d004bab34d30
https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/net/http/HttpRequest.php#L147-L168
train
rosasurfer/ministruts
src/net/http/HttpRequest.php
HttpRequest.getHeader
public function getHeader($name) { if (!is_string($name)) throw new IllegalTypeException('Illegal type of parameter $name: '.gettype($name)); if (!strlen($name)) throw new InvalidArgumentException('Invalid argument $name: '.$name); $headers = $this->getHeaders($name); if ($headers) return join(', ', $headers); // combine multiple headers of the same name according to RFC return null; }
php
public function getHeader($name) { if (!is_string($name)) throw new IllegalTypeException('Illegal type of parameter $name: '.gettype($name)); if (!strlen($name)) throw new InvalidArgumentException('Invalid argument $name: '.$name); $headers = $this->getHeaders($name); if ($headers) return join(', ', $headers); // combine multiple headers of the same name according to RFC return null; }
[ "public", "function", "getHeader", "(", "$", "name", ")", "{", "if", "(", "!", "is_string", "(", "$", "name", ")", ")", "throw", "new", "IllegalTypeException", "(", "'Illegal type of parameter $name: '", ".", "gettype", "(", "$", "name", ")", ")", ";", "if...
Return the request header with the specified name. This method returns the value of a single header. @param string $name - header name (case is ignored) @return string|null - header value or NULL if no such header was found
[ "Return", "the", "request", "header", "with", "the", "specified", "name", ".", "This", "method", "returns", "the", "value", "of", "a", "single", "header", "." ]
9d27f93dd53d2d626c75c92cfde9d004bab34d30
https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/net/http/HttpRequest.php#L178-L186
train
rosasurfer/ministruts
src/net/http/HttpRequest.php
HttpRequest.getHeaders
public function getHeaders($names = null) { if (!isset($names)) $names = []; elseif (is_string($names)) $names = [$names]; elseif (is_array($names)) { foreach ($names as $i => $name) { if (!is_string($name)) throw new IllegalTypeException('Illegal type of parameter $names['.$i.']: '.gettype($name)); } } else throw new IllegalTypeException('Illegal type of parameter $names: '.gettype($names)); // without a name return all headers if (!$names) { return $this->headers; } return \array_intersect_ukey($this->headers, \array_flip($names), 'strCaseCmp'); }
php
public function getHeaders($names = null) { if (!isset($names)) $names = []; elseif (is_string($names)) $names = [$names]; elseif (is_array($names)) { foreach ($names as $i => $name) { if (!is_string($name)) throw new IllegalTypeException('Illegal type of parameter $names['.$i.']: '.gettype($name)); } } else throw new IllegalTypeException('Illegal type of parameter $names: '.gettype($names)); // without a name return all headers if (!$names) { return $this->headers; } return \array_intersect_ukey($this->headers, \array_flip($names), 'strCaseCmp'); }
[ "public", "function", "getHeaders", "(", "$", "names", "=", "null", ")", "{", "if", "(", "!", "isset", "(", "$", "names", ")", ")", "$", "names", "=", "[", "]", ";", "elseif", "(", "is_string", "(", "$", "names", ")", ")", "$", "names", "=", "[...
Return the request headers with the specified names. This method returns a key-value pair for each found header. @param string|string[] $names [optional] - one or more header names (case is ignored) (default: without a name all headers are returned) @return string[] - array of name-value pairs or an empty array if no such headers were found
[ "Return", "the", "request", "headers", "with", "the", "specified", "names", ".", "This", "method", "returns", "a", "key", "-", "value", "pair", "for", "each", "found", "header", "." ]
9d27f93dd53d2d626c75c92cfde9d004bab34d30
https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/net/http/HttpRequest.php#L197-L212
train
timble/kodekit
code/database/behavior/identifiable.php
DatabaseBehaviorIdentifiable._afterSelect
protected function _afterSelect(DatabaseContext $context) { if($this->getMixer() instanceof DatabaseRowInterface && $this->_auto_generate && !$this->isNew()) { if($this->hasProperty('uuid') && empty($this->uuid)) { $hex = $this->getTable()->getColumn('uuid')->type == 'char' ? false : true; $this->uuid = $this->_uuid($hex); $this->save(); } } }
php
protected function _afterSelect(DatabaseContext $context) { if($this->getMixer() instanceof DatabaseRowInterface && $this->_auto_generate && !$this->isNew()) { if($this->hasProperty('uuid') && empty($this->uuid)) { $hex = $this->getTable()->getColumn('uuid')->type == 'char' ? false : true; $this->uuid = $this->_uuid($hex); $this->save(); } } }
[ "protected", "function", "_afterSelect", "(", "DatabaseContext", "$", "context", ")", "{", "if", "(", "$", "this", "->", "getMixer", "(", ")", "instanceof", "DatabaseRowInterface", "&&", "$", "this", "->", "_auto_generate", "&&", "!", "$", "this", "->", "isN...
Auto generated the uuid If the row exists and does not have a valid 'uuid' value auto generate it. Requires an 'uuid' column, if the column type is char the uuid will be a string, if the column type is binary a hex value will be returned. @param DatabaseContext $context A database context object @return void
[ "Auto", "generated", "the", "uuid" ]
4c376f8873f8d10c55e3d290616ff622605cd246
https://github.com/timble/kodekit/blob/4c376f8873f8d10c55e3d290616ff622605cd246/code/database/behavior/identifiable.php#L89-L101
train
rosasurfer/ministruts
src/cache/CachePeer.php
CachePeer.getReferencePool
protected function getReferencePool() { if (!$this->referencePool) $this->referencePool = new ReferencePool($this->label); return $this->referencePool; }
php
protected function getReferencePool() { if (!$this->referencePool) $this->referencePool = new ReferencePool($this->label); return $this->referencePool; }
[ "protected", "function", "getReferencePool", "(", ")", "{", "if", "(", "!", "$", "this", "->", "referencePool", ")", "$", "this", "->", "referencePool", "=", "new", "ReferencePool", "(", "$", "this", "->", "label", ")", ";", "return", "$", "this", "->", ...
Gibt den lokalen ReferencePool zurueck. @return ReferencePool
[ "Gibt", "den", "lokalen", "ReferencePool", "zurueck", "." ]
9d27f93dd53d2d626c75c92cfde9d004bab34d30
https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/cache/CachePeer.php#L65-L69
train
rosasurfer/ministruts
src/cache/CachePeer.php
CachePeer.add
final public function add($key, &$value, $expires = Cache::EXPIRES_NEVER, Dependency $dependency = null) { if ($this->isCached($key)) return false; return $this->set($key, $value, $expires, $dependency); }
php
final public function add($key, &$value, $expires = Cache::EXPIRES_NEVER, Dependency $dependency = null) { if ($this->isCached($key)) return false; return $this->set($key, $value, $expires, $dependency); }
[ "final", "public", "function", "add", "(", "$", "key", ",", "&", "$", "value", ",", "$", "expires", "=", "Cache", "::", "EXPIRES_NEVER", ",", "Dependency", "$", "dependency", "=", "null", ")", "{", "if", "(", "$", "this", "->", "isCached", "(", "$", ...
Speichert einen Wert im Cache nur dann, wenn noch kein Wert unter dem angegebenen Schluessel existiert. Laeuft die angegebene Zeitspanne ab oder aendert sich der Status der angegebenen Abhaengigkeit, wird der Wert automatisch ungueltig. @param string $key - Schluessel, unter dem der Wert gespeichert wird @param mixed $value - der zu speichernde Wert @param int $expires [optional] - Zeitspanne in Sekunden, nach deren Ablauf der Wert verfaellt (default: nie) @param Dependency $dependency [optional] - Abhaengigkeit der Gueltigkeit des gespeicherten Wertes @return bool - TRUE bei Erfolg, FALSE andererseits
[ "Speichert", "einen", "Wert", "im", "Cache", "nur", "dann", "wenn", "noch", "kein", "Wert", "unter", "dem", "angegebenen", "Schluessel", "existiert", ".", "Laeuft", "die", "angegebene", "Zeitspanne", "ab", "oder", "aendert", "sich", "der", "Status", "der", "an...
9d27f93dd53d2d626c75c92cfde9d004bab34d30
https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/cache/CachePeer.php#L132-L137
train
dereuromark/cakephp-feedback
src/Controller/FeedbackController.php
FeedbackController.save
public function save() { $this->request->allowMethod(['post', 'ajax']); $data = $this->request->getData(); //Is ajax action $this->viewBuilder()->setLayout('ajax'); //Save screenshot: $data['screenshot'] = str_replace('data:image/png;base64,', '', $this->request->getData('screenshot')); //Add current time to data $data['time'] = time(); //Check name if (empty($data['name'])) { $data['name'] = __d('feedback', 'Anonymous'); } if (!$this->request->getSession()->started()) { $this->request->getSession()->start(); } $data['sid'] = $this->request->getSession()->id(); //Determine method of saving $collection = new StoreCollection(); $result = $collection->save($data); if (empty($result)) { throw new NotFoundException('No stores defined.'); } // Only first result is important $result = array_shift($result); //Prepare result if (!$result['result']) { $this->response->statusCode(500); if (empty($result['msg'])) { $result['msg'] = __d('feedback', 'Error saving feedback.'); } } else { if (empty($result['msg'])) { $result['msg'] = __d('feedback', 'Your feedback was saved successfully.'); } } $this->set('msg', $result['msg']); //Send a copy to the reciever: if (!empty($data['copyme'])) { //FIXME: Move to a store class $this->Feedbackstore->mail($data, true); } }
php
public function save() { $this->request->allowMethod(['post', 'ajax']); $data = $this->request->getData(); //Is ajax action $this->viewBuilder()->setLayout('ajax'); //Save screenshot: $data['screenshot'] = str_replace('data:image/png;base64,', '', $this->request->getData('screenshot')); //Add current time to data $data['time'] = time(); //Check name if (empty($data['name'])) { $data['name'] = __d('feedback', 'Anonymous'); } if (!$this->request->getSession()->started()) { $this->request->getSession()->start(); } $data['sid'] = $this->request->getSession()->id(); //Determine method of saving $collection = new StoreCollection(); $result = $collection->save($data); if (empty($result)) { throw new NotFoundException('No stores defined.'); } // Only first result is important $result = array_shift($result); //Prepare result if (!$result['result']) { $this->response->statusCode(500); if (empty($result['msg'])) { $result['msg'] = __d('feedback', 'Error saving feedback.'); } } else { if (empty($result['msg'])) { $result['msg'] = __d('feedback', 'Your feedback was saved successfully.'); } } $this->set('msg', $result['msg']); //Send a copy to the reciever: if (!empty($data['copyme'])) { //FIXME: Move to a store class $this->Feedbackstore->mail($data, true); } }
[ "public", "function", "save", "(", ")", "{", "$", "this", "->", "request", "->", "allowMethod", "(", "[", "'post'", ",", "'ajax'", "]", ")", ";", "$", "data", "=", "$", "this", "->", "request", "->", "getData", "(", ")", ";", "//Is ajax action", "$",...
Ajax function to save the feedback form. @return \Cake\Http\Response|null
[ "Ajax", "function", "to", "save", "the", "feedback", "form", "." ]
0bd774fda38b3cdd05db8c07a06a526d3ba81879
https://github.com/dereuromark/cakephp-feedback/blob/0bd774fda38b3cdd05db8c07a06a526d3ba81879/src/Controller/FeedbackController.php#L61-L116
train
dereuromark/cakephp-feedback
src/Controller/FeedbackController.php
FeedbackController.index
public function index() { $savepath = Configure::read('Feedback.configuration.Filesystem.location'); //Check dir if (!is_dir($savepath)) { throw new NotFoundException('savepath not exists'); } //Creat feedback array in a cake-like way $feedbacks = []; //Loop through files if (!$this->request->getSession()->started()) { $this->request->getSession()->start(); } foreach (glob($savepath . '*-' . $this->request->getSession()->id() . '.feedback') as $feedbackfile) { $feedbackObject = unserialize(file_get_contents($feedbackfile)); $feedbacks[$feedbackObject['time']] = $feedbackObject; } //Sort by time krsort($feedbacks); $this->set('feedbacks', $feedbacks); }
php
public function index() { $savepath = Configure::read('Feedback.configuration.Filesystem.location'); //Check dir if (!is_dir($savepath)) { throw new NotFoundException('savepath not exists'); } //Creat feedback array in a cake-like way $feedbacks = []; //Loop through files if (!$this->request->getSession()->started()) { $this->request->getSession()->start(); } foreach (glob($savepath . '*-' . $this->request->getSession()->id() . '.feedback') as $feedbackfile) { $feedbackObject = unserialize(file_get_contents($feedbackfile)); $feedbacks[$feedbackObject['time']] = $feedbackObject; } //Sort by time krsort($feedbacks); $this->set('feedbacks', $feedbacks); }
[ "public", "function", "index", "(", ")", "{", "$", "savepath", "=", "Configure", "::", "read", "(", "'Feedback.configuration.Filesystem.location'", ")", ";", "//Check dir", "if", "(", "!", "is_dir", "(", "$", "savepath", ")", ")", "{", "throw", "new", "NotFo...
Example index function for current save in tmp dir solution. Must only display images of own session @return \Cake\Http\Response|null
[ "Example", "index", "function", "for", "current", "save", "in", "tmp", "dir", "solution", ".", "Must", "only", "display", "images", "of", "own", "session" ]
0bd774fda38b3cdd05db8c07a06a526d3ba81879
https://github.com/dereuromark/cakephp-feedback/blob/0bd774fda38b3cdd05db8c07a06a526d3ba81879/src/Controller/FeedbackController.php#L124-L148
train
dereuromark/cakephp-feedback
src/Controller/FeedbackController.php
FeedbackController.viewimage
public function viewimage($file) { $savepath = Configure::read('Feedback.configuration.Filesystem.location'); if (!file_exists($savepath . $file)) { throw new NotFoundException('Could not find that file'); } $feedbackobject = unserialize(file_get_contents($savepath . $file)); if (!isset($feedbackobject['screenshot'])) { throw new NotFoundException('No screenshot found'); } $this->set('screenshot', $feedbackobject['screenshot']); $this->viewBuilder()->setLayout('ajax'); }
php
public function viewimage($file) { $savepath = Configure::read('Feedback.configuration.Filesystem.location'); if (!file_exists($savepath . $file)) { throw new NotFoundException('Could not find that file'); } $feedbackobject = unserialize(file_get_contents($savepath . $file)); if (!isset($feedbackobject['screenshot'])) { throw new NotFoundException('No screenshot found'); } $this->set('screenshot', $feedbackobject['screenshot']); $this->viewBuilder()->setLayout('ajax'); }
[ "public", "function", "viewimage", "(", "$", "file", ")", "{", "$", "savepath", "=", "Configure", "::", "read", "(", "'Feedback.configuration.Filesystem.location'", ")", ";", "if", "(", "!", "file_exists", "(", "$", "savepath", ".", "$", "file", ")", ")", ...
Temp function to view captured image from index page @param string $file @return \Cake\Http\Response|null
[ "Temp", "function", "to", "view", "captured", "image", "from", "index", "page" ]
0bd774fda38b3cdd05db8c07a06a526d3ba81879
https://github.com/dereuromark/cakephp-feedback/blob/0bd774fda38b3cdd05db8c07a06a526d3ba81879/src/Controller/FeedbackController.php#L156-L172
train
rosasurfer/ministruts
src/net/mail/Mailer.php
Mailer.sendLater
protected function sendLater($sender, $receiver, $subject, $message, array $headers = []) { if (!empty($this->options['send-later'])) { $callable = [$this, 'sendMail']; register_shutdown_function($callable, $sender, $receiver, $subject, $message, $headers); $this->options['send-later'] = false; return true; } return false; // TODO: Not yet found a way to send a "Location" header (redirect) to the client, close the browser connection // and keep the mail script sending in background with "output_buffering" enabled. As the output buffer is // never full from just a redirect header PHP is waiting for the shutdown function to finish as it might // push more content into the buffer. Maybe "output_buffering" can be disabled when entering shutdown? }
php
protected function sendLater($sender, $receiver, $subject, $message, array $headers = []) { if (!empty($this->options['send-later'])) { $callable = [$this, 'sendMail']; register_shutdown_function($callable, $sender, $receiver, $subject, $message, $headers); $this->options['send-later'] = false; return true; } return false; // TODO: Not yet found a way to send a "Location" header (redirect) to the client, close the browser connection // and keep the mail script sending in background with "output_buffering" enabled. As the output buffer is // never full from just a redirect header PHP is waiting for the shutdown function to finish as it might // push more content into the buffer. Maybe "output_buffering" can be disabled when entering shutdown? }
[ "protected", "function", "sendLater", "(", "$", "sender", ",", "$", "receiver", ",", "$", "subject", ",", "$", "message", ",", "array", "$", "headers", "=", "[", "]", ")", "{", "if", "(", "!", "empty", "(", "$", "this", "->", "options", "[", "'send...
Delay sending of the mail to the script shutdown phase. Can be used to not to block other more important tasks. NOTE: Usage of this method is a poor man's approach and a last resort. A more professional way to decouple sending of mail is using a regular message queue. @param string $sender - mail sender @param string $receiver - mail receiver @param string $subject - mail subject @param string $message - mail body @param string[] $headers [optional] - additional MIME headers (default: none) @return bool - whether sending of the email was successfully delayed
[ "Delay", "sending", "of", "the", "mail", "to", "the", "script", "shutdown", "phase", ".", "Can", "be", "used", "to", "not", "to", "block", "other", "more", "important", "tasks", "." ]
9d27f93dd53d2d626c75c92cfde9d004bab34d30
https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/net/mail/Mailer.php#L79-L93
train
rosasurfer/ministruts
src/net/mail/Mailer.php
Mailer.getHeader
protected function getHeader(array $headers, $name) { if (!is_string($name)) throw new IllegalTypeException('Illegal type of parameter $name: '.gettype($name)); if (!preg_match('/^[a-z]+(-[a-z]+)*$/i', $name)) throw new InvalidArgumentException('Invalid parameter $name: "'.$name.'"'); // reversely iterate over the array to find the last of duplicate headers for (end($headers); key($headers)!==null; prev($headers)){ $header = current($headers); if (strStartsWithI($header, $name.':')) return trim(substr($header, strlen($name)+1)); } return null; }
php
protected function getHeader(array $headers, $name) { if (!is_string($name)) throw new IllegalTypeException('Illegal type of parameter $name: '.gettype($name)); if (!preg_match('/^[a-z]+(-[a-z]+)*$/i', $name)) throw new InvalidArgumentException('Invalid parameter $name: "'.$name.'"'); // reversely iterate over the array to find the last of duplicate headers for (end($headers); key($headers)!==null; prev($headers)){ $header = current($headers); if (strStartsWithI($header, $name.':')) return trim(substr($header, strlen($name)+1)); } return null; }
[ "protected", "function", "getHeader", "(", "array", "$", "headers", ",", "$", "name", ")", "{", "if", "(", "!", "is_string", "(", "$", "name", ")", ")", "throw", "new", "IllegalTypeException", "(", "'Illegal type of parameter $name: '", ".", "gettype", "(", ...
Search for a given header and return its value. If the array contains multiple headers of that the last such header is returned. @param string[] $headers - array of headers @param string $name - header to search for @return string|null - value of the last found header or NULL if the header was not found
[ "Search", "for", "a", "given", "header", "and", "return", "its", "value", ".", "If", "the", "array", "contains", "multiple", "headers", "of", "that", "the", "last", "such", "header", "is", "returned", "." ]
9d27f93dd53d2d626c75c92cfde9d004bab34d30
https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/net/mail/Mailer.php#L139-L150
train
rosasurfer/ministruts
src/net/mail/Mailer.php
Mailer.removeHeader
protected function removeHeader(array &$headers, $name) { if (!is_string($name)) throw new IllegalTypeException('Illegal type of parameter $name: '.gettype($name)); if (!preg_match('/^[a-z]+(-[a-z]+)*$/i', $name)) throw new InvalidArgumentException('Invalid parameter $name: "'.$name.'"'); $result = null; foreach ($headers as $i => $header) { if (strStartsWithI($header, $name.':')) { $result = trim(substr($header, strlen($name)+1)); unset($headers[$i]); } } return $result; }
php
protected function removeHeader(array &$headers, $name) { if (!is_string($name)) throw new IllegalTypeException('Illegal type of parameter $name: '.gettype($name)); if (!preg_match('/^[a-z]+(-[a-z]+)*$/i', $name)) throw new InvalidArgumentException('Invalid parameter $name: "'.$name.'"'); $result = null; foreach ($headers as $i => $header) { if (strStartsWithI($header, $name.':')) { $result = trim(substr($header, strlen($name)+1)); unset($headers[$i]); } } return $result; }
[ "protected", "function", "removeHeader", "(", "array", "&", "$", "headers", ",", "$", "name", ")", "{", "if", "(", "!", "is_string", "(", "$", "name", ")", ")", "throw", "new", "IllegalTypeException", "(", "'Illegal type of parameter $name: '", ".", "gettype",...
Remove a given header from the array and return its value. If the array contains multiple headers of that name all such headers are removed and the last removed one is returned. @param string[] $headers - reference to an array of headers @param string $name - header to remove @return string|null - value of the last removed header or NULL if the header was not found
[ "Remove", "a", "given", "header", "from", "the", "array", "and", "return", "its", "value", ".", "If", "the", "array", "contains", "multiple", "headers", "of", "that", "name", "all", "such", "headers", "are", "removed", "and", "the", "last", "removed", "one...
9d27f93dd53d2d626c75c92cfde9d004bab34d30
https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/net/mail/Mailer.php#L162-L175
train
rosasurfer/ministruts
src/net/mail/Mailer.php
Mailer.encodeNonAsciiChars
protected function encodeNonAsciiChars($value) { if (is_array($value)) { /** @var string[] */ $result = []; foreach ($value as $k => $v) { $result[$k] = $this->{__FUNCTION__}($v); } return $result; } if (preg_match('/[\x80-\xFF]/', $value)) { return '=?utf-8?B?'.base64_encode($value).'?='; //$value = '=?utf-8?Q?'.imap_8bit($value).'?='; // requires imap extension and the encoded string is longer } return $value; // TODO: see https://tools.ietf.org/html/rfc1522 // // An encoded-word may not be more than 75 characters long, including charset, // encoding, encoded-text, and delimiters. If it is desirable to encode more // text than will fit in an encoded-word of 75 characters, multiple encoded-words // (separated by SPACE or newline) may be used. Message header lines that contain // one or more encoded words should be no more than 76 characters long. // // While there is no limit to the length of a multiple-line header // field, each line of a header field that contains one or more // encoded-words is limited to 76 characters. }
php
protected function encodeNonAsciiChars($value) { if (is_array($value)) { /** @var string[] */ $result = []; foreach ($value as $k => $v) { $result[$k] = $this->{__FUNCTION__}($v); } return $result; } if (preg_match('/[\x80-\xFF]/', $value)) { return '=?utf-8?B?'.base64_encode($value).'?='; //$value = '=?utf-8?Q?'.imap_8bit($value).'?='; // requires imap extension and the encoded string is longer } return $value; // TODO: see https://tools.ietf.org/html/rfc1522 // // An encoded-word may not be more than 75 characters long, including charset, // encoding, encoded-text, and delimiters. If it is desirable to encode more // text than will fit in an encoded-word of 75 characters, multiple encoded-words // (separated by SPACE or newline) may be used. Message header lines that contain // one or more encoded words should be no more than 76 characters long. // // While there is no limit to the length of a multiple-line header // field, each line of a header field that contains one or more // encoded-words is limited to 76 characters. }
[ "protected", "function", "encodeNonAsciiChars", "(", "$", "value", ")", "{", "if", "(", "is_array", "(", "$", "value", ")", ")", "{", "/** @var string[] */", "$", "result", "=", "[", "]", ";", "foreach", "(", "$", "value", "as", "$", "k", "=>", "$", ...
Encode non-ASCII characters with UTF-8. If a string doesn't contain non-ASCII characters it is not modified. @param string|string[] $value - a single or a list of values @return string|string[] - a single or a list of encoded values
[ "Encode", "non", "-", "ASCII", "characters", "with", "UTF", "-", "8", ".", "If", "a", "string", "doesn", "t", "contain", "non", "-", "ASCII", "characters", "it", "is", "not", "modified", "." ]
9d27f93dd53d2d626c75c92cfde9d004bab34d30
https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/net/mail/Mailer.php#L185-L212
train
timble/kodekit
code/command/mixin/mixin.php
CommandMixin.invokeCommand
public function invokeCommand($command, $attributes = null, $subject = null) { //Default the subject to the mixer $subject = $subject ?: $this->getMixer(); return $this->getCommandChain()->execute($command, $attributes, $subject); }
php
public function invokeCommand($command, $attributes = null, $subject = null) { //Default the subject to the mixer $subject = $subject ?: $this->getMixer(); return $this->getCommandChain()->execute($command, $attributes, $subject); }
[ "public", "function", "invokeCommand", "(", "$", "command", ",", "$", "attributes", "=", "null", ",", "$", "subject", "=", "null", ")", "{", "//Default the subject to the mixer", "$", "subject", "=", "$", "subject", "?", ":", "$", "this", "->", "getMixer", ...
Invoke a command by calling all registered handlers If a command handler returns the 'break condition' the executing is halted. If no break condition is specified the the command chain will execute all command handlers, regardless of the handler result returned. @param string|CommandInterface $command The command name or a CommandInterface object @param array|\Traversable $attributes An associative array or a Traversable object @param ObjectInterface $subject The command subject @return mixed|null If a handler breaks, returns the break condition. NULL otherwise.
[ "Invoke", "a", "command", "by", "calling", "all", "registered", "handlers" ]
4c376f8873f8d10c55e3d290616ff622605cd246
https://github.com/timble/kodekit/blob/4c376f8873f8d10c55e3d290616ff622605cd246/code/command/mixin/mixin.php#L136-L142
train
timble/kodekit
code/command/mixin/mixin.php
CommandMixin.hasCommandHandler
public function hasCommandHandler($handler) { if($handler instanceof CommandHandlerInterface) { $identifier = $handler->getIdentifier(); } else { $identifier = $this->getIdentifier($handler); } return $this->getCommandChain()->getHandlers()->hasIdentifier($identifier); }
php
public function hasCommandHandler($handler) { if($handler instanceof CommandHandlerInterface) { $identifier = $handler->getIdentifier(); } else { $identifier = $this->getIdentifier($handler); } return $this->getCommandChain()->getHandlers()->hasIdentifier($identifier); }
[ "public", "function", "hasCommandHandler", "(", "$", "handler", ")", "{", "if", "(", "$", "handler", "instanceof", "CommandHandlerInterface", ")", "{", "$", "identifier", "=", "$", "handler", "->", "getIdentifier", "(", ")", ";", "}", "else", "{", "$", "id...
Check if a command handler exists @param mixed $handler An object that implements CommandHandlerInterface, an ObjectIdentifier or valid identifier string @return boolean TRUE if the behavior exists, FALSE otherwise
[ "Check", "if", "a", "command", "handler", "exists" ]
4c376f8873f8d10c55e3d290616ff622605cd246
https://github.com/timble/kodekit/blob/4c376f8873f8d10c55e3d290616ff622605cd246/code/command/mixin/mixin.php#L292-L301
train
rosasurfer/ministruts
src/console/io/Input.php
Input.getOption
public function getOption($name) { if (!$this->docoptResult) return false; if ($this->isOption($name)) { $value = $this->docoptResult[$name]; if (is_array($value)) // repetitive option with arguments return $value ? $value[0] : false; /* if (is_int($value)) return $value; // repetitive option without arguments if (is_bool($value)) return $value; // non-repetitive option, no arguments else return $value; // non-repetitive option with argument */ return $value; } return false; }
php
public function getOption($name) { if (!$this->docoptResult) return false; if ($this->isOption($name)) { $value = $this->docoptResult[$name]; if (is_array($value)) // repetitive option with arguments return $value ? $value[0] : false; /* if (is_int($value)) return $value; // repetitive option without arguments if (is_bool($value)) return $value; // non-repetitive option, no arguments else return $value; // non-repetitive option with argument */ return $value; } return false; }
[ "public", "function", "getOption", "(", "$", "name", ")", "{", "if", "(", "!", "$", "this", "->", "docoptResult", ")", "return", "false", ";", "if", "(", "$", "this", "->", "isOption", "(", "$", "name", ")", ")", "{", "$", "value", "=", "$", "thi...
Return the value of the option with the given name. If the option is not repetitive and has no arguments a boolean value is returned. If the option is repetitive and has no arguments an integer is returned indicating the number of times the option was specified. If the option has arguments the first argument is returned. The returned value may be the defined default value. See {@link Input::isOption()} for the definition of "option". @param string $name @return bool|int|string - option value or FALSE if the option was not specified
[ "Return", "the", "value", "of", "the", "option", "with", "the", "given", "name", "." ]
9d27f93dd53d2d626c75c92cfde9d004bab34d30
https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/console/io/Input.php#L178-L194
train
timble/kodekit
code/class/registry/cache.php
ClassRegistryCache.offsetUnset
public function offsetUnset($offset) { apc_delete($this->getNamespace().'-class_'.$offset); if(parent::offsetExists($offset)){ parent::offsetUnset($offset); } }
php
public function offsetUnset($offset) { apc_delete($this->getNamespace().'-class_'.$offset); if(parent::offsetExists($offset)){ parent::offsetUnset($offset); } }
[ "public", "function", "offsetUnset", "(", "$", "offset", ")", "{", "apc_delete", "(", "$", "this", "->", "getNamespace", "(", ")", ".", "'-class_'", ".", "$", "offset", ")", ";", "if", "(", "parent", "::", "offsetExists", "(", "$", "offset", ")", ")", ...
Unset an item from the array @param int $offset @return void
[ "Unset", "an", "item", "from", "the", "array" ]
4c376f8873f8d10c55e3d290616ff622605cd246
https://github.com/timble/kodekit/blob/4c376f8873f8d10c55e3d290616ff622605cd246/code/class/registry/cache.php#L124-L131
train
rosasurfer/ministruts
src/cache/Cache.php
Cache.me
public static function me($label = null) { // TODO: zufaellige Verwendung der Application-ID als Label abfangen // Default-Cache if ($label === null) { if (!self::$default) { // neuen Cache instantiieren if (extension_loaded('apc') && ini_get_bool(CLI ? 'apc.enable_cli':'apc.enabled')) { self::$default = new ApcCache($label); } else { self::$default = new ReferencePool($label); } } return self::$default; } // spezifischer Cache if (!is_string($label)) throw new IllegalTypeException('Illegal type of parameter $label: '.gettype($label)); if (!isset(self::$caches[$label])) { /** @var ConfigInterface $config */ $config = self::di('config'); // Cache-Konfiguration auslesen und Cache instantiieren $class = $config->get('cache.'.$label.'.class'); $options = $config->get('cache.'.$label.'.options', null); self::$caches[$label] = new $class($label, $options); } return self::$caches[$label]; }
php
public static function me($label = null) { // TODO: zufaellige Verwendung der Application-ID als Label abfangen // Default-Cache if ($label === null) { if (!self::$default) { // neuen Cache instantiieren if (extension_loaded('apc') && ini_get_bool(CLI ? 'apc.enable_cli':'apc.enabled')) { self::$default = new ApcCache($label); } else { self::$default = new ReferencePool($label); } } return self::$default; } // spezifischer Cache if (!is_string($label)) throw new IllegalTypeException('Illegal type of parameter $label: '.gettype($label)); if (!isset(self::$caches[$label])) { /** @var ConfigInterface $config */ $config = self::di('config'); // Cache-Konfiguration auslesen und Cache instantiieren $class = $config->get('cache.'.$label.'.class'); $options = $config->get('cache.'.$label.'.options', null); self::$caches[$label] = new $class($label, $options); } return self::$caches[$label]; }
[ "public", "static", "function", "me", "(", "$", "label", "=", "null", ")", "{", "// TODO: zufaellige Verwendung der Application-ID als Label abfangen", "// Default-Cache", "if", "(", "$", "label", "===", "null", ")", "{", "if", "(", "!", "self", "::", "$", "defa...
Gibt die Cache-Implementierung fuer den angegebenen Bezeichner zurueck. Verschiedene Bezeichner stehen fuer verschiedene Cache-Implementierungen, z.B. APC-Cache, Dateisystem-Cache, MemCache. @param string $label [optional] - Bezeichner @return CachePeer
[ "Gibt", "die", "Cache", "-", "Implementierung", "fuer", "den", "angegebenen", "Bezeichner", "zurueck", ".", "Verschiedene", "Bezeichner", "stehen", "fuer", "verschiedene", "Cache", "-", "Implementierungen", "z", ".", "B", ".", "APC", "-", "Cache", "Dateisystem", ...
9d27f93dd53d2d626c75c92cfde9d004bab34d30
https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/cache/Cache.php#L44-L76
train
locomotivemtl/charcoal-core
src/Charcoal/Source/Database/DatabasePagination.php
DatabasePagination.sql
public function sql() { if ($this->active() && $this->hasLimit()) { $limit = $this->limit(); $offset = $this->offset(); return 'LIMIT '.$offset.', '.$limit; } return ''; }
php
public function sql() { if ($this->active() && $this->hasLimit()) { $limit = $this->limit(); $offset = $this->offset(); return 'LIMIT '.$offset.', '.$limit; } return ''; }
[ "public", "function", "sql", "(", ")", "{", "if", "(", "$", "this", "->", "active", "(", ")", "&&", "$", "this", "->", "hasLimit", "(", ")", ")", "{", "$", "limit", "=", "$", "this", "->", "limit", "(", ")", ";", "$", "offset", "=", "$", "thi...
Converts the pagination into a SQL expression for the LIMIT clause. @return string A SQL string fragment.
[ "Converts", "the", "pagination", "into", "a", "SQL", "expression", "for", "the", "LIMIT", "clause", "." ]
db3a7af547ccf96efe2d9be028b252bc8646f5d5
https://github.com/locomotivemtl/charcoal-core/blob/db3a7af547ccf96efe2d9be028b252bc8646f5d5/src/Charcoal/Source/Database/DatabasePagination.php#L22-L31
train
locomotivemtl/charcoal-core
src/Charcoal/Source/Database/DatabasePagination.php
DatabasePagination.offset
public function offset() { $page = $this->page(); $limit = $this->numPerPage(); $offset = (($page - 1) * $limit); if (PHP_INT_MAX <= $offset) { $offset = PHP_INT_MAX; } return max(0, $offset); }
php
public function offset() { $page = $this->page(); $limit = $this->numPerPage(); $offset = (($page - 1) * $limit); if (PHP_INT_MAX <= $offset) { $offset = PHP_INT_MAX; } return max(0, $offset); }
[ "public", "function", "offset", "(", ")", "{", "$", "page", "=", "$", "this", "->", "page", "(", ")", ";", "$", "limit", "=", "$", "this", "->", "numPerPage", "(", ")", ";", "$", "offset", "=", "(", "(", "$", "page", "-", "1", ")", "*", "$", ...
Retrieve the offset from the page number and count. @return integer
[ "Retrieve", "the", "offset", "from", "the", "page", "number", "and", "count", "." ]
db3a7af547ccf96efe2d9be028b252bc8646f5d5
https://github.com/locomotivemtl/charcoal-core/blob/db3a7af547ccf96efe2d9be028b252bc8646f5d5/src/Charcoal/Source/Database/DatabasePagination.php#L58-L68
train
timble/kodekit
code/object/locator/component.php
ObjectLocatorComponent.getClassTemplates
public function getClassTemplates(ObjectIdentifier $identifier) { $templates = array(); //Identifier $component = $this->getObject('object.bootstrapper') ->getComponentIdentifier($identifier->package, $identifier->domain); //Fallback if($namespaces = $this->getIdentifierNamespaces($component)) { foreach($namespaces as $namespace) { //Handle class prefix vs class namespace if(strpos($namespace, '\\')) { $namespace .= '\\'; } $templates[] = $namespace.'<Class>'; $templates[] = $namespace.'<Package><Path><File>'; } } $templates = array_merge($templates, parent::getClassTemplates($identifier)); return $templates; }
php
public function getClassTemplates(ObjectIdentifier $identifier) { $templates = array(); //Identifier $component = $this->getObject('object.bootstrapper') ->getComponentIdentifier($identifier->package, $identifier->domain); //Fallback if($namespaces = $this->getIdentifierNamespaces($component)) { foreach($namespaces as $namespace) { //Handle class prefix vs class namespace if(strpos($namespace, '\\')) { $namespace .= '\\'; } $templates[] = $namespace.'<Class>'; $templates[] = $namespace.'<Package><Path><File>'; } } $templates = array_merge($templates, parent::getClassTemplates($identifier)); return $templates; }
[ "public", "function", "getClassTemplates", "(", "ObjectIdentifier", "$", "identifier", ")", "{", "$", "templates", "=", "array", "(", ")", ";", "//Identifier", "$", "component", "=", "$", "this", "->", "getObject", "(", "'object.bootstrapper'", ")", "->", "get...
Get the list of class templates for an identifier @param ObjectIdentifier $identifier The object identifier @return array The class templates for the identifier
[ "Get", "the", "list", "of", "class", "templates", "for", "an", "identifier" ]
4c376f8873f8d10c55e3d290616ff622605cd246
https://github.com/timble/kodekit/blob/4c376f8873f8d10c55e3d290616ff622605cd246/code/object/locator/component.php#L68-L94
train
symbiote/silverstripe-seed
code/extensions/SeedTaxonomyTermExtension.php
SeedTaxonomyTermExtension.createReverseTagField
public function createReverseTagField($name) { $belongs_many_many = $this->owner->config()->belongs_many_many; if (!isset($belongs_many_many[$name])) { return null; } $className = $belongs_many_many[$name]; $s = singleton(($className === 'SiteTree') ? 'Page' : $className); $visibleName = $s->plural_name(); $field = null; if ($className::has_extension('Hierarchy')) { $field = TreeMultiselectField::create($name, 'Tagged '.$visibleName, $className); } else { $records = array(); foreach ($className::get() as $record) { if ($record->canView()) { $records[] = $record; } } $field = ListboxField::create($name, 'Tagged '.$visibleName, $className::get()->map()->toArray())->setMultiple(true); } if ($field) { $field->setRightTitle($visibleName.' ('.$className.') using this tag'); } return $field; }
php
public function createReverseTagField($name) { $belongs_many_many = $this->owner->config()->belongs_many_many; if (!isset($belongs_many_many[$name])) { return null; } $className = $belongs_many_many[$name]; $s = singleton(($className === 'SiteTree') ? 'Page' : $className); $visibleName = $s->plural_name(); $field = null; if ($className::has_extension('Hierarchy')) { $field = TreeMultiselectField::create($name, 'Tagged '.$visibleName, $className); } else { $records = array(); foreach ($className::get() as $record) { if ($record->canView()) { $records[] = $record; } } $field = ListboxField::create($name, 'Tagged '.$visibleName, $className::get()->map()->toArray())->setMultiple(true); } if ($field) { $field->setRightTitle($visibleName.' ('.$className.') using this tag'); } return $field; }
[ "public", "function", "createReverseTagField", "(", "$", "name", ")", "{", "$", "belongs_many_many", "=", "$", "this", "->", "owner", "->", "config", "(", ")", "->", "belongs_many_many", ";", "if", "(", "!", "isset", "(", "$", "belongs_many_many", "[", "$"...
Setup the appropriate field to manage tagging for a belongs_many_many relationship.
[ "Setup", "the", "appropriate", "field", "to", "manage", "tagging", "for", "a", "belongs_many_many", "relationship", "." ]
bda0c1dab0d4cd7d8ca9a94b1a804562ecfc831d
https://github.com/symbiote/silverstripe-seed/blob/bda0c1dab0d4cd7d8ca9a94b1a804562ecfc831d/code/extensions/SeedTaxonomyTermExtension.php#L32-L63
train
timble/kodekit
code/template/template.php
Template.getContext
public function getContext(TemplateContextInterface $context = null) { $context = new TemplateContext($context); $context->setData($this->getData()); $context->setParameters($this->getParameters()); return $context; }
php
public function getContext(TemplateContextInterface $context = null) { $context = new TemplateContext($context); $context->setData($this->getData()); $context->setParameters($this->getParameters()); return $context; }
[ "public", "function", "getContext", "(", "TemplateContextInterface", "$", "context", "=", "null", ")", "{", "$", "context", "=", "new", "TemplateContext", "(", "$", "context", ")", ";", "$", "context", "->", "setData", "(", "$", "this", "->", "getData", "(...
Get the template context @param TemplateContextInterface $context Context to cast to a local context @return TemplateContext
[ "Get", "the", "template", "context" ]
4c376f8873f8d10c55e3d290616ff622605cd246
https://github.com/timble/kodekit/blob/4c376f8873f8d10c55e3d290616ff622605cd246/code/template/template.php#L177-L184
train
timble/kodekit
code/filesystem/stream/abstract.php
FilesystemStreamAbstract.getTime
public function getTime($time = self::TIME_MODIFIED) { $result = false; $info = $this->getInfo(); if(isset($info[$time])) { $result = new \DateTime('@'.$info[$time]); } return $result; }
php
public function getTime($time = self::TIME_MODIFIED) { $result = false; $info = $this->getInfo(); if(isset($info[$time])) { $result = new \DateTime('@'.$info[$time]); } return $result; }
[ "public", "function", "getTime", "(", "$", "time", "=", "self", "::", "TIME_MODIFIED", ")", "{", "$", "result", "=", "false", ";", "$", "info", "=", "$", "this", "->", "getInfo", "(", ")", ";", "if", "(", "isset", "(", "$", "info", "[", "$", "tim...
Get the streams last modified, last accessed or created time. @param string $time One of the TIME_* constants @return \DateTime|false A DateTime object or FALSE if the time could not be found
[ "Get", "the", "streams", "last", "modified", "last", "accessed", "or", "created", "time", "." ]
4c376f8873f8d10c55e3d290616ff622605cd246
https://github.com/timble/kodekit/blob/4c376f8873f8d10c55e3d290616ff622605cd246/code/filesystem/stream/abstract.php#L680-L690
train
sroze/ChainOfResponsibility
ProcessCollection.php
ProcessCollection.add
public function add($process) { if (is_array($process)) { foreach ($process as $p) { $this->add($p); } } elseif (!$process instanceof ChainProcessInterface) { throw new \RuntimeException(sprintf( 'Expect to be instance of ChainProcessInterface or array but got %s', get_class($process) )); } else { $this->processes[] = $process; } }
php
public function add($process) { if (is_array($process)) { foreach ($process as $p) { $this->add($p); } } elseif (!$process instanceof ChainProcessInterface) { throw new \RuntimeException(sprintf( 'Expect to be instance of ChainProcessInterface or array but got %s', get_class($process) )); } else { $this->processes[] = $process; } }
[ "public", "function", "add", "(", "$", "process", ")", "{", "if", "(", "is_array", "(", "$", "process", ")", ")", "{", "foreach", "(", "$", "process", "as", "$", "p", ")", "{", "$", "this", "->", "add", "(", "$", "p", ")", ";", "}", "}", "els...
Add a process to the collection. @param array|ChainProcessInterface $process
[ "Add", "a", "process", "to", "the", "collection", "." ]
d1c9743a4a7e5e63004be41d89175a05b3ea81b0
https://github.com/sroze/ChainOfResponsibility/blob/d1c9743a4a7e5e63004be41d89175a05b3ea81b0/ProcessCollection.php#L17-L31
train
locomotivemtl/charcoal-core
src/Charcoal/Source/ExpressionFieldTrait.php
ExpressionFieldTrait.setProperty
public function setProperty($property) { if ($property === null) { $this->property = $property; return $this; } if ($property instanceof PropertyInterface) { if (empty($property->ident())) { throw new InvalidArgumentException( 'Property must have an identifier.' ); } $this->property = $property; return $this; } if (!is_string($property)) { throw new InvalidArgumentException( 'Property must be a string.' ); } if ($property === '') { throw new InvalidArgumentException( 'Property can not be empty.' ); } $this->property = $property; return $this; }
php
public function setProperty($property) { if ($property === null) { $this->property = $property; return $this; } if ($property instanceof PropertyInterface) { if (empty($property->ident())) { throw new InvalidArgumentException( 'Property must have an identifier.' ); } $this->property = $property; return $this; } if (!is_string($property)) { throw new InvalidArgumentException( 'Property must be a string.' ); } if ($property === '') { throw new InvalidArgumentException( 'Property can not be empty.' ); } $this->property = $property; return $this; }
[ "public", "function", "setProperty", "(", "$", "property", ")", "{", "if", "(", "$", "property", "===", "null", ")", "{", "$", "this", "->", "property", "=", "$", "property", ";", "return", "$", "this", ";", "}", "if", "(", "$", "property", "instance...
Set model property key or source field key. @param string|PropertyInterface $property The related property. @throws InvalidArgumentException If the parameter is invalid. @return self
[ "Set", "model", "property", "key", "or", "source", "field", "key", "." ]
db3a7af547ccf96efe2d9be028b252bc8646f5d5
https://github.com/locomotivemtl/charcoal-core/blob/db3a7af547ccf96efe2d9be028b252bc8646f5d5/src/Charcoal/Source/ExpressionFieldTrait.php#L42-L74
train
locomotivemtl/charcoal-core
src/Charcoal/Source/ExpressionFieldTrait.php
ExpressionFieldTrait.setTable
public function setTable($table) { if ($table === null) { $this->table = $table; return $this; } if (!is_string($table)) { throw new InvalidArgumentException( 'Table reference must be a string.' ); } if ($table === '') { throw new InvalidArgumentException( 'Table reference can not be empty.' ); } $this->table = $table; return $this; }
php
public function setTable($table) { if ($table === null) { $this->table = $table; return $this; } if (!is_string($table)) { throw new InvalidArgumentException( 'Table reference must be a string.' ); } if ($table === '') { throw new InvalidArgumentException( 'Table reference can not be empty.' ); } $this->table = $table; return $this; }
[ "public", "function", "setTable", "(", "$", "table", ")", "{", "if", "(", "$", "table", "===", "null", ")", "{", "$", "this", "->", "table", "=", "$", "table", ";", "return", "$", "this", ";", "}", "if", "(", "!", "is_string", "(", "$", "table", ...
Set the reference to the table related to the field. @param string $table The table name or alias. @throws InvalidArgumentException If the parameter is not a string. @return self
[ "Set", "the", "reference", "to", "the", "table", "related", "to", "the", "field", "." ]
db3a7af547ccf96efe2d9be028b252bc8646f5d5
https://github.com/locomotivemtl/charcoal-core/blob/db3a7af547ccf96efe2d9be028b252bc8646f5d5/src/Charcoal/Source/ExpressionFieldTrait.php#L103-L124
train
locomotivemtl/charcoal-core
src/Charcoal/Source/ExpressionFieldTrait.php
ExpressionFieldTrait.hasFields
public function hasFields() { if ($this->hasProperty()) { $property = $this->property(); if ($property instanceof StorablePropertyInterface) { return (count($property->fieldNames()) > 0); } else { return true; } } return false; }
php
public function hasFields() { if ($this->hasProperty()) { $property = $this->property(); if ($property instanceof StorablePropertyInterface) { return (count($property->fieldNames()) > 0); } else { return true; } } return false; }
[ "public", "function", "hasFields", "(", ")", "{", "if", "(", "$", "this", "->", "hasProperty", "(", ")", ")", "{", "$", "property", "=", "$", "this", "->", "property", "(", ")", ";", "if", "(", "$", "property", "instanceof", "StorablePropertyInterface", ...
Determine if the model property has any fields. @return boolean
[ "Determine", "if", "the", "model", "property", "has", "any", "fields", "." ]
db3a7af547ccf96efe2d9be028b252bc8646f5d5
https://github.com/locomotivemtl/charcoal-core/blob/db3a7af547ccf96efe2d9be028b252bc8646f5d5/src/Charcoal/Source/ExpressionFieldTrait.php#L151-L163
train
locomotivemtl/charcoal-core
src/Charcoal/Source/ExpressionFieldTrait.php
ExpressionFieldTrait.fieldNames
public function fieldNames() { if ($this->hasProperty()) { $property = $this->property(); if ($property instanceof StorablePropertyInterface) { return $property->fieldNames(); } else { return [ $property ]; } } return []; }
php
public function fieldNames() { if ($this->hasProperty()) { $property = $this->property(); if ($property instanceof StorablePropertyInterface) { return $property->fieldNames(); } else { return [ $property ]; } } return []; }
[ "public", "function", "fieldNames", "(", ")", "{", "if", "(", "$", "this", "->", "hasProperty", "(", ")", ")", "{", "$", "property", "=", "$", "this", "->", "property", "(", ")", ";", "if", "(", "$", "property", "instanceof", "StorablePropertyInterface",...
Retrieve the model property's field names. @todo Load Property from associated model metadata. @return array
[ "Retrieve", "the", "model", "property", "s", "field", "names", "." ]
db3a7af547ccf96efe2d9be028b252bc8646f5d5
https://github.com/locomotivemtl/charcoal-core/blob/db3a7af547ccf96efe2d9be028b252bc8646f5d5/src/Charcoal/Source/ExpressionFieldTrait.php#L171-L183
train
locomotivemtl/charcoal-core
src/Charcoal/Source/ExpressionFieldTrait.php
ExpressionFieldTrait.fieldIdentifiers
public function fieldIdentifiers() { $identifiers = []; $tableName = $this->table(); $fieldNames = $this->fieldNames(); foreach ($fieldNames as $fieldName) { $identifiers[] = Expression::quoteIdentifier($fieldName, $tableName); } return $identifiers; }
php
public function fieldIdentifiers() { $identifiers = []; $tableName = $this->table(); $fieldNames = $this->fieldNames(); foreach ($fieldNames as $fieldName) { $identifiers[] = Expression::quoteIdentifier($fieldName, $tableName); } return $identifiers; }
[ "public", "function", "fieldIdentifiers", "(", ")", "{", "$", "identifiers", "=", "[", "]", ";", "$", "tableName", "=", "$", "this", "->", "table", "(", ")", ";", "$", "fieldNames", "=", "$", "this", "->", "fieldNames", "(", ")", ";", "foreach", "(",...
Retrieve the property's fully-qualified field names. @return string[]
[ "Retrieve", "the", "property", "s", "fully", "-", "qualified", "field", "names", "." ]
db3a7af547ccf96efe2d9be028b252bc8646f5d5
https://github.com/locomotivemtl/charcoal-core/blob/db3a7af547ccf96efe2d9be028b252bc8646f5d5/src/Charcoal/Source/ExpressionFieldTrait.php#L205-L215
train
locomotivemtl/charcoal-core
src/Charcoal/Source/ExpressionFieldTrait.php
ExpressionFieldTrait.fieldIdentifier
public function fieldIdentifier() { $tableName = $this->table(); $fieldName = $this->fieldName(); return Expression::quoteIdentifier($fieldName, $tableName); }
php
public function fieldIdentifier() { $tableName = $this->table(); $fieldName = $this->fieldName(); return Expression::quoteIdentifier($fieldName, $tableName); }
[ "public", "function", "fieldIdentifier", "(", ")", "{", "$", "tableName", "=", "$", "this", "->", "table", "(", ")", ";", "$", "fieldName", "=", "$", "this", "->", "fieldName", "(", ")", ";", "return", "Expression", "::", "quoteIdentifier", "(", "$", "...
Retrieve the fully-qualified field name. @return string
[ "Retrieve", "the", "fully", "-", "qualified", "field", "name", "." ]
db3a7af547ccf96efe2d9be028b252bc8646f5d5
https://github.com/locomotivemtl/charcoal-core/blob/db3a7af547ccf96efe2d9be028b252bc8646f5d5/src/Charcoal/Source/ExpressionFieldTrait.php#L222-L228
train
rinvex/cortex-tenants
src/Http/Controllers/Adminarea/TenantsMediaController.php
TenantsMediaController.index
public function index(Tenant $tenant, MediaDataTable $mediaDataTable) { return $mediaDataTable->with([ 'resource' => $tenant, 'tabs' => 'adminarea.tenants.tabs', 'id' => "adminarea-tenants-{$tenant->getRouteKey()}-media-table", 'url' => route('adminarea.tenants.media.store', ['tenant' => $tenant]), ])->render('cortex/foundation::adminarea.pages.datatable-dropzone'); }
php
public function index(Tenant $tenant, MediaDataTable $mediaDataTable) { return $mediaDataTable->with([ 'resource' => $tenant, 'tabs' => 'adminarea.tenants.tabs', 'id' => "adminarea-tenants-{$tenant->getRouteKey()}-media-table", 'url' => route('adminarea.tenants.media.store', ['tenant' => $tenant]), ])->render('cortex/foundation::adminarea.pages.datatable-dropzone'); }
[ "public", "function", "index", "(", "Tenant", "$", "tenant", ",", "MediaDataTable", "$", "mediaDataTable", ")", "{", "return", "$", "mediaDataTable", "->", "with", "(", "[", "'resource'", "=>", "$", "tenant", ",", "'tabs'", "=>", "'adminarea.tenants.tabs'", ",...
List tenant media. @param \Cortex\Tenants\Models\Tenant $tenant @param \Cortex\Foundation\DataTables\MediaDataTable $mediaDataTable @return \Illuminate\Http\JsonResponse|\Illuminate\Http\RedirectResponse
[ "List", "tenant", "media", "." ]
b837a3d14fd4cf6bfb35f41c61ef41ee9a05a34a
https://github.com/rinvex/cortex-tenants/blob/b837a3d14fd4cf6bfb35f41c61ef41ee9a05a34a/src/Http/Controllers/Adminarea/TenantsMediaController.php#L48-L56
train
rinvex/cortex-tenants
src/Http/Controllers/Adminarea/TenantsMediaController.php
TenantsMediaController.store
public function store(ImageFormRequest $request, Tenant $tenant): void { $tenant->addMediaFromRequest('file') ->sanitizingFileName(function ($fileName) { return md5($fileName).'.'.pathinfo($fileName, PATHINFO_EXTENSION); }) ->toMediaCollection('default', config('cortex.tenants.media.disk')); }
php
public function store(ImageFormRequest $request, Tenant $tenant): void { $tenant->addMediaFromRequest('file') ->sanitizingFileName(function ($fileName) { return md5($fileName).'.'.pathinfo($fileName, PATHINFO_EXTENSION); }) ->toMediaCollection('default', config('cortex.tenants.media.disk')); }
[ "public", "function", "store", "(", "ImageFormRequest", "$", "request", ",", "Tenant", "$", "tenant", ")", ":", "void", "{", "$", "tenant", "->", "addMediaFromRequest", "(", "'file'", ")", "->", "sanitizingFileName", "(", "function", "(", "$", "fileName", ")...
Store new tenant media. @param \Cortex\Foundation\Http\Requests\ImageFormRequest $request @param \Cortex\Tenants\Models\Tenant $tenant @return void
[ "Store", "new", "tenant", "media", "." ]
b837a3d14fd4cf6bfb35f41c61ef41ee9a05a34a
https://github.com/rinvex/cortex-tenants/blob/b837a3d14fd4cf6bfb35f41c61ef41ee9a05a34a/src/Http/Controllers/Adminarea/TenantsMediaController.php#L66-L73
train
rinvex/cortex-tenants
src/Http/Controllers/Adminarea/TenantsMediaController.php
TenantsMediaController.destroy
public function destroy(Tenant $tenant, Media $media) { $tenant->media()->where($media->getKeyName(), $media->getKey())->first()->delete(); return intend([ 'url' => route('adminarea.tenants.media.index', ['tenant' => $tenant]), 'with' => ['warning' => trans('cortex/foundation::messages.resource_deleted', ['resource' => trans('cortex/foundation::common.media'), 'identifier' => $media->getRouteKey()])], ]); }
php
public function destroy(Tenant $tenant, Media $media) { $tenant->media()->where($media->getKeyName(), $media->getKey())->first()->delete(); return intend([ 'url' => route('adminarea.tenants.media.index', ['tenant' => $tenant]), 'with' => ['warning' => trans('cortex/foundation::messages.resource_deleted', ['resource' => trans('cortex/foundation::common.media'), 'identifier' => $media->getRouteKey()])], ]); }
[ "public", "function", "destroy", "(", "Tenant", "$", "tenant", ",", "Media", "$", "media", ")", "{", "$", "tenant", "->", "media", "(", ")", "->", "where", "(", "$", "media", "->", "getKeyName", "(", ")", ",", "$", "media", "->", "getKey", "(", ")"...
Destroy given tenant media. @param \Cortex\Tenants\Models\Tenant $tenant @param \Spatie\MediaLibrary\Models\Media $media @return \Illuminate\Http\JsonResponse|\Illuminate\Http\RedirectResponse
[ "Destroy", "given", "tenant", "media", "." ]
b837a3d14fd4cf6bfb35f41c61ef41ee9a05a34a
https://github.com/rinvex/cortex-tenants/blob/b837a3d14fd4cf6bfb35f41c61ef41ee9a05a34a/src/Http/Controllers/Adminarea/TenantsMediaController.php#L83-L91
train
timble/kodekit
code/object/config/format.php
ObjectConfigFormat.toFile
public function toFile($filename) { $directory = dirname($filename); if(empty($filename)) { throw new \InvalidArgumentException('No file name specified'); } if (!is_dir($directory)) { throw new \RuntimeException(sprintf('Directory : %s does not exists!', $directory)); } if (!is_writable($directory)) { throw new \RuntimeException(sprintf("Cannot write in directory : %s", $directory)); } $result = file_put_contents($filename, $this->toString(), LOCK_EX); if($result === false) { throw new \RuntimeException(sprintf("Error writing to %s", $filename)); } }
php
public function toFile($filename) { $directory = dirname($filename); if(empty($filename)) { throw new \InvalidArgumentException('No file name specified'); } if (!is_dir($directory)) { throw new \RuntimeException(sprintf('Directory : %s does not exists!', $directory)); } if (!is_writable($directory)) { throw new \RuntimeException(sprintf("Cannot write in directory : %s", $directory)); } $result = file_put_contents($filename, $this->toString(), LOCK_EX); if($result === false) { throw new \RuntimeException(sprintf("Error writing to %s", $filename)); } }
[ "public", "function", "toFile", "(", "$", "filename", ")", "{", "$", "directory", "=", "dirname", "(", "$", "filename", ")", ";", "if", "(", "empty", "(", "$", "filename", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'No file na...
Write a config object to a file. @param string $filename @throws \InvalidArgumentException @throws \RuntimeException @return void
[ "Write", "a", "config", "object", "to", "a", "file", "." ]
4c376f8873f8d10c55e3d290616ff622605cd246
https://github.com/timble/kodekit/blob/4c376f8873f8d10c55e3d290616ff622605cd246/code/object/config/format.php#L53-L74
train
rosasurfer/ministruts
src/net/http/HttpClient.php
HttpClient.setTimeout
public function setTimeout($timeout) { if (!is_int($timeout)) throw new IllegalTypeException('Illegal type of parameter $timeout: '.gettype($timeout)); if ($timeout < 1) throw new InvalidArgumentException('Invalid argument $timeout: '.$timeout); $this->timeout = $timeout; return $this; }
php
public function setTimeout($timeout) { if (!is_int($timeout)) throw new IllegalTypeException('Illegal type of parameter $timeout: '.gettype($timeout)); if ($timeout < 1) throw new InvalidArgumentException('Invalid argument $timeout: '.$timeout); $this->timeout = $timeout; return $this; }
[ "public", "function", "setTimeout", "(", "$", "timeout", ")", "{", "if", "(", "!", "is_int", "(", "$", "timeout", ")", ")", "throw", "new", "IllegalTypeException", "(", "'Illegal type of parameter $timeout: '", ".", "gettype", "(", "$", "timeout", ")", ")", ...
Setzt den Verbindungs-Timeout. @param int $timeout - Timeout in Sekunden @return $this
[ "Setzt", "den", "Verbindungs", "-", "Timeout", "." ]
9d27f93dd53d2d626c75c92cfde9d004bab34d30
https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/net/http/HttpClient.php#L38-L44
train
rosasurfer/ministruts
src/net/http/HttpClient.php
HttpClient.setFollowRedirects
public function setFollowRedirects($follow) { if (!is_bool($follow)) throw new IllegalTypeException('Illegal type of parameter $follow: '.gettype($follow)); $this->followRedirects = $follow; return $this; }
php
public function setFollowRedirects($follow) { if (!is_bool($follow)) throw new IllegalTypeException('Illegal type of parameter $follow: '.gettype($follow)); $this->followRedirects = $follow; return $this; }
[ "public", "function", "setFollowRedirects", "(", "$", "follow", ")", "{", "if", "(", "!", "is_bool", "(", "$", "follow", ")", ")", "throw", "new", "IllegalTypeException", "(", "'Illegal type of parameter $follow: '", ".", "gettype", "(", "$", "follow", ")", ")...
Ob Redirect-Headern gefolgt werden soll oder nicht. @param bool $follow @return $this
[ "Ob", "Redirect", "-", "Headern", "gefolgt", "werden", "soll", "oder", "nicht", "." ]
9d27f93dd53d2d626c75c92cfde9d004bab34d30
https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/net/http/HttpClient.php#L64-L69
train
rosasurfer/ministruts
src/net/http/HttpClient.php
HttpClient.setMaxRedirects
public function setMaxRedirects($maxRedirects) { if (!is_int($maxRedirects)) throw new IllegalTypeException('Illegal type of parameter $maxRedirects: '.gettype($maxRedirects)); $this->maxRedirects = $maxRedirects; return $this; }
php
public function setMaxRedirects($maxRedirects) { if (!is_int($maxRedirects)) throw new IllegalTypeException('Illegal type of parameter $maxRedirects: '.gettype($maxRedirects)); $this->maxRedirects = $maxRedirects; return $this; }
[ "public", "function", "setMaxRedirects", "(", "$", "maxRedirects", ")", "{", "if", "(", "!", "is_int", "(", "$", "maxRedirects", ")", ")", "throw", "new", "IllegalTypeException", "(", "'Illegal type of parameter $maxRedirects: '", ".", "gettype", "(", "$", "maxRed...
Setzt die maximale Anzahl der Redirects, denen gefolgt werden soll. @param int $maxRedirects @return $this
[ "Setzt", "die", "maximale", "Anzahl", "der", "Redirects", "denen", "gefolgt", "werden", "soll", "." ]
9d27f93dd53d2d626c75c92cfde9d004bab34d30
https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/net/http/HttpClient.php#L89-L94
train
locomotivemtl/charcoal-core
src/Charcoal/Source/Database/DatabaseOrder.php
DatabaseOrder.sql
public function sql() { if ($this->active()) { switch ($this->mode()) { case self::MODE_RANDOM: return $this->byRandom(); case self::MODE_CUSTOM: return $this->byCondition(); case self::MODE_VALUES: return $this->byValues(); } if ($this->hasCondition()) { return $this->byCondition(); } if ($this->hasValues()) { return $this->byValues(); } if ($this->hasProperty()) { return $this->byProperty(); } } return ''; }
php
public function sql() { if ($this->active()) { switch ($this->mode()) { case self::MODE_RANDOM: return $this->byRandom(); case self::MODE_CUSTOM: return $this->byCondition(); case self::MODE_VALUES: return $this->byValues(); } if ($this->hasCondition()) { return $this->byCondition(); } if ($this->hasValues()) { return $this->byValues(); } if ($this->hasProperty()) { return $this->byProperty(); } } return ''; }
[ "public", "function", "sql", "(", ")", "{", "if", "(", "$", "this", "->", "active", "(", ")", ")", "{", "switch", "(", "$", "this", "->", "mode", "(", ")", ")", "{", "case", "self", "::", "MODE_RANDOM", ":", "return", "$", "this", "->", "byRandom...
Converts the order into a SQL expression for the ORDER BY clause. @return string A SQL string fragment.
[ "Converts", "the", "order", "into", "a", "SQL", "expression", "for", "the", "ORDER", "BY", "clause", "." ]
db3a7af547ccf96efe2d9be028b252bc8646f5d5
https://github.com/locomotivemtl/charcoal-core/blob/db3a7af547ccf96efe2d9be028b252bc8646f5d5/src/Charcoal/Source/Database/DatabaseOrder.php#L49-L77
train
locomotivemtl/charcoal-core
src/Charcoal/Source/Database/DatabaseOrder.php
DatabaseOrder.prepareValues
public function prepareValues($values) { if (empty($values)) { return []; } if (!is_array($values)) { $values = (array)$values; } $values = array_filter($values, 'is_scalar'); $values = array_map('self::quoteValue', $values); return $values; }
php
public function prepareValues($values) { if (empty($values)) { return []; } if (!is_array($values)) { $values = (array)$values; } $values = array_filter($values, 'is_scalar'); $values = array_map('self::quoteValue', $values); return $values; }
[ "public", "function", "prepareValues", "(", "$", "values", ")", "{", "if", "(", "empty", "(", "$", "values", ")", ")", "{", "return", "[", "]", ";", "}", "if", "(", "!", "is_array", "(", "$", "values", ")", ")", "{", "$", "values", "=", "(", "a...
Parse the given values for SQL. @param mixed $values The value to be normalized. @return array Returns a collection of parsed values.
[ "Parse", "the", "given", "values", "for", "SQL", "." ]
db3a7af547ccf96efe2d9be028b252bc8646f5d5
https://github.com/locomotivemtl/charcoal-core/blob/db3a7af547ccf96efe2d9be028b252bc8646f5d5/src/Charcoal/Source/Database/DatabaseOrder.php#L168-L182
train
hakito/PHP-Stuzza-EPS-BankTransfer
src/SoCommunicator.php
SoCommunicator.GetBanks
public function GetBanks($validateXml = true, $url = null) { if ($url == null) $url = 'https://routing.eps.or.at/appl/epsSO/data/haendler/v2_5'; $body = $this->GetUrl($url, 'Requesting bank list'); if ($validateXml) XmlValidator::ValidateBankList($body); return $body; }
php
public function GetBanks($validateXml = true, $url = null) { if ($url == null) $url = 'https://routing.eps.or.at/appl/epsSO/data/haendler/v2_5'; $body = $this->GetUrl($url, 'Requesting bank list'); if ($validateXml) XmlValidator::ValidateBankList($body); return $body; }
[ "public", "function", "GetBanks", "(", "$", "validateXml", "=", "true", ",", "$", "url", "=", "null", ")", "{", "if", "(", "$", "url", "==", "null", ")", "$", "url", "=", "'https://routing.eps.or.at/appl/epsSO/data/haendler/v2_5'", ";", "$", "body", "=", "...
Get XML of banks from scheme operator. Will throw an exception if data cannot be fetched, or XSD validation fails. @param bool $validateXml validate against XSD @param string $url Scheme operator URL for the banks list @throws XmlValidationException when the returned BankList does not validate against XSD and $validateXSD is set to TRUE @return string
[ "Get", "XML", "of", "banks", "from", "scheme", "operator", ".", "Will", "throw", "an", "exception", "if", "data", "cannot", "be", "fetched", "or", "XSD", "validation", "fails", "." ]
c2af496ecf4b9f095447a7b9f5c02d20924252bd
https://github.com/hakito/PHP-Stuzza-EPS-BankTransfer/blob/c2af496ecf4b9f095447a7b9f5c02d20924252bd/src/SoCommunicator.php#L87-L97
train
hakito/PHP-Stuzza-EPS-BankTransfer
src/SoCommunicator.php
SoCommunicator.SendTransferInitiatorDetails
public function SendTransferInitiatorDetails($transferInitiatorDetails, $targetUrl = null) { if ($transferInitiatorDetails->RemittanceIdentifier != null) $transferInitiatorDetails->RemittanceIdentifier = $this->AppendHash($transferInitiatorDetails->RemittanceIdentifier); if ($transferInitiatorDetails->UnstructuredRemittanceIdentifier != null) $transferInitiatorDetails->UnstructuredRemittanceIdentifier = $this->AppendHash($transferInitiatorDetails->UnstructuredRemittanceIdentifier); if ($targetUrl == null) $targetUrl = 'https://routing.eps.or.at/appl/epsSO/transinit/eps/v2_5'; $data = $transferInitiatorDetails->GetSimpleXml(); $xmlData = $data->asXML(); $response = $this->PostUrl($targetUrl, $xmlData, 'Send payment order'); XmlValidator::ValidateEpsProtocol($response); return $response; }
php
public function SendTransferInitiatorDetails($transferInitiatorDetails, $targetUrl = null) { if ($transferInitiatorDetails->RemittanceIdentifier != null) $transferInitiatorDetails->RemittanceIdentifier = $this->AppendHash($transferInitiatorDetails->RemittanceIdentifier); if ($transferInitiatorDetails->UnstructuredRemittanceIdentifier != null) $transferInitiatorDetails->UnstructuredRemittanceIdentifier = $this->AppendHash($transferInitiatorDetails->UnstructuredRemittanceIdentifier); if ($targetUrl == null) $targetUrl = 'https://routing.eps.or.at/appl/epsSO/transinit/eps/v2_5'; $data = $transferInitiatorDetails->GetSimpleXml(); $xmlData = $data->asXML(); $response = $this->PostUrl($targetUrl, $xmlData, 'Send payment order'); XmlValidator::ValidateEpsProtocol($response); return $response; }
[ "public", "function", "SendTransferInitiatorDetails", "(", "$", "transferInitiatorDetails", ",", "$", "targetUrl", "=", "null", ")", "{", "if", "(", "$", "transferInitiatorDetails", "->", "RemittanceIdentifier", "!=", "null", ")", "$", "transferInitiatorDetails", "->"...
Sends the given TransferInitiatorDetails to the Scheme Operator @param TransferInitiatorDetails $transferInitiatorDetails @param string $targetUrl url with preselected bank identifier @throws XmlValidationException when the returned BankResponseDetails does not validate against XSD @throws \UnexpectedValueException when using security suffix without security seed @return string BankResponseDetails
[ "Sends", "the", "given", "TransferInitiatorDetails", "to", "the", "Scheme", "Operator" ]
c2af496ecf4b9f095447a7b9f5c02d20924252bd
https://github.com/hakito/PHP-Stuzza-EPS-BankTransfer/blob/c2af496ecf4b9f095447a7b9f5c02d20924252bd/src/SoCommunicator.php#L107-L124
train
rosasurfer/ministruts
src/db/orm/PersistableObject.php
PersistableObject.get
protected function get($property) { $mapping = $this->dao()->getMapping(); if (isset($mapping['properties'][$property])) return $this->getNonRelationValue($property); if (isset($mapping['relations'][$property])) return $this->getRelationValue($property); throw new RuntimeException('Not a mapped property "'.$property.'"'); }
php
protected function get($property) { $mapping = $this->dao()->getMapping(); if (isset($mapping['properties'][$property])) return $this->getNonRelationValue($property); if (isset($mapping['relations'][$property])) return $this->getRelationValue($property); throw new RuntimeException('Not a mapped property "'.$property.'"'); }
[ "protected", "function", "get", "(", "$", "property", ")", "{", "$", "mapping", "=", "$", "this", "->", "dao", "(", ")", "->", "getMapping", "(", ")", ";", "if", "(", "isset", "(", "$", "mapping", "[", "'properties'", "]", "[", "$", "property", "]"...
Return the logical value of a mapped property. @param string $property - property name @return mixed - property value
[ "Return", "the", "logical", "value", "of", "a", "mapped", "property", "." ]
9d27f93dd53d2d626c75c92cfde9d004bab34d30
https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/db/orm/PersistableObject.php#L104-L114
train
rosasurfer/ministruts
src/db/orm/PersistableObject.php
PersistableObject.getPhysicalValue
private function getPhysicalValue($column, $type = null) { $mapping = $this->dao()->getMapping(); $column = strtolower($column); if (!isset($mapping['columns'][$column])) throw new RuntimeException('Not a mapped column "'.func_get_arg(0).'"'); $property = &$mapping['columns'][$column]; $propertyName = $property['name']; $propertyValue = $this->$propertyName; // the logical or physical column value if ($propertyValue === null) return null; if (isset($property['assoc'])) { if ($propertyValue === false) return null; if (!is_object($propertyValue)) { // a foreign-key value of a not-yet-fetched relation if ($type !== null) throw new RuntimeException('Unexpected parameter $type="'.$type.'" (not null) for relation [name="'.$propertyName.'", column="'.$column.'", ...] of entity "'.$mapping['class'].'"'); return $propertyValue; } /** @var PersistableObject $object */ $object = $propertyValue; // a single instance of "one-to-one"|"many-to-one" relation, no join table if (!isset($property['ref-column'])) $property['ref-column'] = $object->dao()->getMapping()['identity']['column']; $fkColumn = $property['ref-column']; return $object->getPhysicalValue($fkColumn); } $columnType = $property['column-type']; switch ($columnType) { case 'bool' : case 'boolean': return (bool)(int) $propertyValue; case 'int' : case 'integer': return (int) $propertyValue; case 'real' : case 'float' : case 'double' : case 'decimal': return (float) $propertyValue; case 'text' : case 'string' : return (string) $propertyValue; default: // TODO: convert custom types (e.g. Enum|DateTime) to physical values //if (is_class($propertyType)) { // $object->$propertyName = new $propertyType($row[$column]); // break; //} } throw new RuntimeException('Unsupported attribute "column-type"="'.$columnType.'" in property [name="'.$propertyName.'", ...] of entity "'.$mapping['class'].'"'); }
php
private function getPhysicalValue($column, $type = null) { $mapping = $this->dao()->getMapping(); $column = strtolower($column); if (!isset($mapping['columns'][$column])) throw new RuntimeException('Not a mapped column "'.func_get_arg(0).'"'); $property = &$mapping['columns'][$column]; $propertyName = $property['name']; $propertyValue = $this->$propertyName; // the logical or physical column value if ($propertyValue === null) return null; if (isset($property['assoc'])) { if ($propertyValue === false) return null; if (!is_object($propertyValue)) { // a foreign-key value of a not-yet-fetched relation if ($type !== null) throw new RuntimeException('Unexpected parameter $type="'.$type.'" (not null) for relation [name="'.$propertyName.'", column="'.$column.'", ...] of entity "'.$mapping['class'].'"'); return $propertyValue; } /** @var PersistableObject $object */ $object = $propertyValue; // a single instance of "one-to-one"|"many-to-one" relation, no join table if (!isset($property['ref-column'])) $property['ref-column'] = $object->dao()->getMapping()['identity']['column']; $fkColumn = $property['ref-column']; return $object->getPhysicalValue($fkColumn); } $columnType = $property['column-type']; switch ($columnType) { case 'bool' : case 'boolean': return (bool)(int) $propertyValue; case 'int' : case 'integer': return (int) $propertyValue; case 'real' : case 'float' : case 'double' : case 'decimal': return (float) $propertyValue; case 'text' : case 'string' : return (string) $propertyValue; default: // TODO: convert custom types (e.g. Enum|DateTime) to physical values //if (is_class($propertyType)) { // $object->$propertyName = new $propertyType($row[$column]); // break; //} } throw new RuntimeException('Unsupported attribute "column-type"="'.$columnType.'" in property [name="'.$propertyName.'", ...] of entity "'.$mapping['class'].'"'); }
[ "private", "function", "getPhysicalValue", "(", "$", "column", ",", "$", "type", "=", "null", ")", "{", "$", "mapping", "=", "$", "this", "->", "dao", "(", ")", "->", "getMapping", "(", ")", ";", "$", "column", "=", "strtolower", "(", "$", "column", ...
Return the value of a mapped column. @param string $column - column name @param string $type [optional] - column type (default: type as configured in the entity mapping) @return mixed - column value
[ "Return", "the", "value", "of", "a", "mapped", "column", "." ]
9d27f93dd53d2d626c75c92cfde9d004bab34d30
https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/db/orm/PersistableObject.php#L249-L302
train
rosasurfer/ministruts
src/db/orm/PersistableObject.php
PersistableObject.isDeleted
final public function isDeleted() { foreach ($this->dao()->getMapping()['properties'] as $name => $property) { if (isset($property['soft-delete']) && $property['soft-delete']===true) { return ($this->$name !== null); } } return false; }
php
final public function isDeleted() { foreach ($this->dao()->getMapping()['properties'] as $name => $property) { if (isset($property['soft-delete']) && $property['soft-delete']===true) { return ($this->$name !== null); } } return false; }
[ "final", "public", "function", "isDeleted", "(", ")", "{", "foreach", "(", "$", "this", "->", "dao", "(", ")", "->", "getMapping", "(", ")", "[", "'properties'", "]", "as", "$", "name", "=>", "$", "property", ")", "{", "if", "(", "isset", "(", "$",...
Whether the instance is marked as "soft deleted". @return bool
[ "Whether", "the", "instance", "is", "marked", "as", "soft", "deleted", "." ]
9d27f93dd53d2d626c75c92cfde9d004bab34d30
https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/db/orm/PersistableObject.php#L334-L341
train
rosasurfer/ministruts
src/db/orm/PersistableObject.php
PersistableObject.save
public function save() { if (!$this->isPersistent()) { $this->dao()->transaction(function() { if ($this->beforeSave() !== true) // pre-processing hook return $this; $this->insert(); $this->afterSave(); // post-processing hook }); } elseif ($this->isModified()) { $this->dao()->transaction(function() { if ($this->beforeSave() !== true) // pre-processing hook return $this; $this->update(); $this->afterSave(); // post-processing hook }); } else { // persistent but not modified } return $this; }
php
public function save() { if (!$this->isPersistent()) { $this->dao()->transaction(function() { if ($this->beforeSave() !== true) // pre-processing hook return $this; $this->insert(); $this->afterSave(); // post-processing hook }); } elseif ($this->isModified()) { $this->dao()->transaction(function() { if ($this->beforeSave() !== true) // pre-processing hook return $this; $this->update(); $this->afterSave(); // post-processing hook }); } else { // persistent but not modified } return $this; }
[ "public", "function", "save", "(", ")", "{", "if", "(", "!", "$", "this", "->", "isPersistent", "(", ")", ")", "{", "$", "this", "->", "dao", "(", ")", "->", "transaction", "(", "function", "(", ")", "{", "if", "(", "$", "this", "->", "beforeSave...
Save the instance in the storage mechanism. @return $this
[ "Save", "the", "instance", "in", "the", "storage", "mechanism", "." ]
9d27f93dd53d2d626c75c92cfde9d004bab34d30
https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/db/orm/PersistableObject.php#L370-L391
train
rosasurfer/ministruts
src/db/orm/PersistableObject.php
PersistableObject.insert
private function insert() { if ($this->isPersistent()) throw new RuntimeException('Cannot insert already persistent '.$this); // pre-processing hook if ($this->beforeInsert() !== true) return $this; $mapping = $this->dao()->getMapping(); // collect column values $values = []; foreach ($mapping['columns'] as $column => $property) { $values[$column] = $this->getPhysicalValue($column); }; // perform insertion $id = $this->doInsert($values); $this->_modified = false; // assign the returned identity value $idName = $mapping['identity']['name']; if ($this->$idName === null) $this->$idName = $id; // post-processing hook $this->afterInsert(); return $this; }
php
private function insert() { if ($this->isPersistent()) throw new RuntimeException('Cannot insert already persistent '.$this); // pre-processing hook if ($this->beforeInsert() !== true) return $this; $mapping = $this->dao()->getMapping(); // collect column values $values = []; foreach ($mapping['columns'] as $column => $property) { $values[$column] = $this->getPhysicalValue($column); }; // perform insertion $id = $this->doInsert($values); $this->_modified = false; // assign the returned identity value $idName = $mapping['identity']['name']; if ($this->$idName === null) $this->$idName = $id; // post-processing hook $this->afterInsert(); return $this; }
[ "private", "function", "insert", "(", ")", "{", "if", "(", "$", "this", "->", "isPersistent", "(", ")", ")", "throw", "new", "RuntimeException", "(", "'Cannot insert already persistent '", ".", "$", "this", ")", ";", "// pre-processing hook", "if", "(", "$", ...
Insert this instance into the storage mechanism. @return $this
[ "Insert", "this", "instance", "into", "the", "storage", "mechanism", "." ]
9d27f93dd53d2d626c75c92cfde9d004bab34d30
https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/db/orm/PersistableObject.php#L399-L426
train
rosasurfer/ministruts
src/db/orm/PersistableObject.php
PersistableObject.update
private function update() { // pre-processing hook if ($this->beforeUpdate() !== true) return $this; $mapping = $this->dao()->getMapping(); $changes = []; // collect modified properties and their values foreach ($mapping['properties'] as $property) { // TODO: Until the dirty check is implemented all $propertyName = $property['name']; // properties are assumed dirty. $changes[$propertyName] = $this->$propertyName; } // perform update if ($this->doUpdate($changes)) { $this->_modified = false; // post-processing hook $this->afterUpdate(); } return $this; }
php
private function update() { // pre-processing hook if ($this->beforeUpdate() !== true) return $this; $mapping = $this->dao()->getMapping(); $changes = []; // collect modified properties and their values foreach ($mapping['properties'] as $property) { // TODO: Until the dirty check is implemented all $propertyName = $property['name']; // properties are assumed dirty. $changes[$propertyName] = $this->$propertyName; } // perform update if ($this->doUpdate($changes)) { $this->_modified = false; // post-processing hook $this->afterUpdate(); } return $this; }
[ "private", "function", "update", "(", ")", "{", "// pre-processing hook", "if", "(", "$", "this", "->", "beforeUpdate", "(", ")", "!==", "true", ")", "return", "$", "this", ";", "$", "mapping", "=", "$", "this", "->", "dao", "(", ")", "->", "getMapping...
Update the instance. @return $this
[ "Update", "the", "instance", "." ]
9d27f93dd53d2d626c75c92cfde9d004bab34d30
https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/db/orm/PersistableObject.php#L434-L456
train
rosasurfer/ministruts
src/db/orm/PersistableObject.php
PersistableObject.delete
public function delete() { if (!$this->isPersistent()) throw new IllegalStateException('Cannot delete non-persistent '.get_class($this)); $this->dao()->transaction(function() { if ($this->beforeDelete() !== true) // pre-processing hook return $this; if ($this->doDelete()) { // perform deletion // reset identity property $idName = $this->dao()->getMapping()['identity']['name']; $this->$idName = null; $this->afterDelete(); // post-processing hook } }); return $this; }
php
public function delete() { if (!$this->isPersistent()) throw new IllegalStateException('Cannot delete non-persistent '.get_class($this)); $this->dao()->transaction(function() { if ($this->beforeDelete() !== true) // pre-processing hook return $this; if ($this->doDelete()) { // perform deletion // reset identity property $idName = $this->dao()->getMapping()['identity']['name']; $this->$idName = null; $this->afterDelete(); // post-processing hook } }); return $this; }
[ "public", "function", "delete", "(", ")", "{", "if", "(", "!", "$", "this", "->", "isPersistent", "(", ")", ")", "throw", "new", "IllegalStateException", "(", "'Cannot delete non-persistent '", ".", "get_class", "(", "$", "this", ")", ")", ";", "$", "this"...
Delete the instance from the storage mechanism. @return $this
[ "Delete", "the", "instance", "from", "the", "storage", "mechanism", "." ]
9d27f93dd53d2d626c75c92cfde9d004bab34d30
https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/db/orm/PersistableObject.php#L464-L480
train
rosasurfer/ministruts
src/db/orm/PersistableObject.php
PersistableObject.doInsert
private function doInsert(array $values) { $db = $this->db(); $mapping = $this->dao()->getMapping(); $table = $mapping['table']; $idColumn = $mapping['identity']['column']; $id = null; if (isset($values[$idColumn])) $id = $values[$idColumn]; else unset($values[$idColumn]); // translate column values foreach ($values as &$value) { $value = $db->escapeLiteral($value); }; unset($value); // create SQL statement $sql = 'insert into '.$table.' ('.join(', ', \array_keys($values)).') values ('.join(', ', $values).')'; // execute SQL statement if ($id) { $db->execute($sql); } else if ($db->supportsInsertReturn()) { $id = $db->query($sql.' returning '.$idColumn)->fetchInt(); } else { $id = $db->execute($sql)->lastInsertId(); } return $id; }
php
private function doInsert(array $values) { $db = $this->db(); $mapping = $this->dao()->getMapping(); $table = $mapping['table']; $idColumn = $mapping['identity']['column']; $id = null; if (isset($values[$idColumn])) $id = $values[$idColumn]; else unset($values[$idColumn]); // translate column values foreach ($values as &$value) { $value = $db->escapeLiteral($value); }; unset($value); // create SQL statement $sql = 'insert into '.$table.' ('.join(', ', \array_keys($values)).') values ('.join(', ', $values).')'; // execute SQL statement if ($id) { $db->execute($sql); } else if ($db->supportsInsertReturn()) { $id = $db->query($sql.' returning '.$idColumn)->fetchInt(); } else { $id = $db->execute($sql)->lastInsertId(); } return $id; }
[ "private", "function", "doInsert", "(", "array", "$", "values", ")", "{", "$", "db", "=", "$", "this", "->", "db", "(", ")", ";", "$", "mapping", "=", "$", "this", "->", "dao", "(", ")", "->", "getMapping", "(", ")", ";", "$", "table", "=", "$"...
Perform the actual insertion of a data record representing the instance. @param array $values - record values @return mixed - the inserted record's identity value
[ "Perform", "the", "actual", "insertion", "of", "a", "data", "record", "representing", "the", "instance", "." ]
9d27f93dd53d2d626c75c92cfde9d004bab34d30
https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/db/orm/PersistableObject.php#L490-L519
train
rosasurfer/ministruts
src/db/orm/PersistableObject.php
PersistableObject.doUpdate
private function doUpdate(array $changes) { $db = $this->db(); $entity = $this->dao()->getEntityMapping(); $table = $entity->getTableName(); // collect identity infos $identity = $entity->getIdentity(); $idColumn = $identity->getColumn(); $idValue = $identity->convertToDBValue($this->getObjectId(), $db); // collect version infos $versionMapping = $versionName = $versionColumn = $oldVersion = null; //if ($versionMapping = $entity->getVersion()) { // $versionName = $versionMapping->getName(); // $versionColumn = $versionMapping->getColumn(); // $oldVersion = $object->getSnapshot()->$versionName; // TODO: implement dirty check via snapshot // $oldVersion = $versionMapping->convertToDBValue($oldVersion, $db); //} // create SQL $sql = 'update '.$table.' set'; // update table foreach ($changes as $name => $value) { // set ... $mapping = $entity->getProperty($name); // ... $columnName = $mapping->getColumn(); // ... $columnValue = $mapping->convertToDBValue($value, $db); // column1 = value1, $sql .= ' '.$columnName.' = '.$columnValue.','; // column2 = value2, } // ... $sql = strLeft($sql, -1); // ... $sql .= ' where '.$idColumn.' = '.$idValue; // where id = value if ($versionMapping) { // ... $op = $oldVersion=='null' ? 'is':'='; // ... $sql .= ' and '.$versionColumn.' '.$op.' '.$oldVersion; // and version = oldVersion } // execute SQL and check for concurrent modifications if ($db->execute($sql)->lastAffectedRows() != 1) { if ($versionMapping) { $this->reload(); $msg = 'expected version: '.$oldVersion.', found version: '.$this->$versionName; } else $msg = 'record not found'; throw new ConcurrentModificationException('Error updating '.get_class($this).' (oid='.$this->getObjectId().'), '.$msg); } return true; }
php
private function doUpdate(array $changes) { $db = $this->db(); $entity = $this->dao()->getEntityMapping(); $table = $entity->getTableName(); // collect identity infos $identity = $entity->getIdentity(); $idColumn = $identity->getColumn(); $idValue = $identity->convertToDBValue($this->getObjectId(), $db); // collect version infos $versionMapping = $versionName = $versionColumn = $oldVersion = null; //if ($versionMapping = $entity->getVersion()) { // $versionName = $versionMapping->getName(); // $versionColumn = $versionMapping->getColumn(); // $oldVersion = $object->getSnapshot()->$versionName; // TODO: implement dirty check via snapshot // $oldVersion = $versionMapping->convertToDBValue($oldVersion, $db); //} // create SQL $sql = 'update '.$table.' set'; // update table foreach ($changes as $name => $value) { // set ... $mapping = $entity->getProperty($name); // ... $columnName = $mapping->getColumn(); // ... $columnValue = $mapping->convertToDBValue($value, $db); // column1 = value1, $sql .= ' '.$columnName.' = '.$columnValue.','; // column2 = value2, } // ... $sql = strLeft($sql, -1); // ... $sql .= ' where '.$idColumn.' = '.$idValue; // where id = value if ($versionMapping) { // ... $op = $oldVersion=='null' ? 'is':'='; // ... $sql .= ' and '.$versionColumn.' '.$op.' '.$oldVersion; // and version = oldVersion } // execute SQL and check for concurrent modifications if ($db->execute($sql)->lastAffectedRows() != 1) { if ($versionMapping) { $this->reload(); $msg = 'expected version: '.$oldVersion.', found version: '.$this->$versionName; } else $msg = 'record not found'; throw new ConcurrentModificationException('Error updating '.get_class($this).' (oid='.$this->getObjectId().'), '.$msg); } return true; }
[ "private", "function", "doUpdate", "(", "array", "$", "changes", ")", "{", "$", "db", "=", "$", "this", "->", "db", "(", ")", ";", "$", "entity", "=", "$", "this", "->", "dao", "(", ")", "->", "getEntityMapping", "(", ")", ";", "$", "table", "=",...
Perform the actual update and write modifications of the instance to the storage mechanism. @param array $changes - modifications @return bool - success status
[ "Perform", "the", "actual", "update", "and", "write", "modifications", "of", "the", "instance", "to", "the", "storage", "mechanism", "." ]
9d27f93dd53d2d626c75c92cfde9d004bab34d30
https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/db/orm/PersistableObject.php#L529-L573
train
rosasurfer/ministruts
src/db/orm/PersistableObject.php
PersistableObject.doDelete
private function doDelete() { $db = $this->db(); $entity = $this->dao()->getEntityMapping(); $table = $entity->getTableName(); // collect identity infos $identity = $entity->getIdentity(); $idColumn = $identity->getColumn(); $idValue = $identity->convertToDBValue($this->getObjectId(), $db); // create SQL $sql = 'delete from '.$table.' where '.$idColumn.' = '.$idValue; // execute SQL and check for concurrent modifications if ($db->execute($sql)->lastAffectedRows() != 1) throw new ConcurrentModificationException('Error deleting '.get_class($this).' (oid='.$this->getObjectId().'): record not found'); return true; }
php
private function doDelete() { $db = $this->db(); $entity = $this->dao()->getEntityMapping(); $table = $entity->getTableName(); // collect identity infos $identity = $entity->getIdentity(); $idColumn = $identity->getColumn(); $idValue = $identity->convertToDBValue($this->getObjectId(), $db); // create SQL $sql = 'delete from '.$table.' where '.$idColumn.' = '.$idValue; // execute SQL and check for concurrent modifications if ($db->execute($sql)->lastAffectedRows() != 1) throw new ConcurrentModificationException('Error deleting '.get_class($this).' (oid='.$this->getObjectId().'): record not found'); return true; }
[ "private", "function", "doDelete", "(", ")", "{", "$", "db", "=", "$", "this", "->", "db", "(", ")", ";", "$", "entity", "=", "$", "this", "->", "dao", "(", ")", "->", "getEntityMapping", "(", ")", ";", "$", "table", "=", "$", "entity", "->", "...
Perform the actual deletion of the instance. @return bool - success status
[ "Perform", "the", "actual", "deletion", "of", "the", "instance", "." ]
9d27f93dd53d2d626c75c92cfde9d004bab34d30
https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/db/orm/PersistableObject.php#L581-L599
train
rosasurfer/ministruts
src/db/orm/PersistableObject.php
PersistableObject.populateNew
public static function populateNew($class, array $row) { if (static::class != __CLASS__) throw new IllegalAccessException('Cannot access method '.__METHOD__.'() on a derived class.'); if (!is_a($class, __CLASS__, $allowString=true)) throw new InvalidArgumentException('Not a '.__CLASS__.' subclass: '.$class); /** @var self $object */ $object = new $class(); $object->populate($row); return $object; }
php
public static function populateNew($class, array $row) { if (static::class != __CLASS__) throw new IllegalAccessException('Cannot access method '.__METHOD__.'() on a derived class.'); if (!is_a($class, __CLASS__, $allowString=true)) throw new InvalidArgumentException('Not a '.__CLASS__.' subclass: '.$class); /** @var self $object */ $object = new $class(); $object->populate($row); return $object; }
[ "public", "static", "function", "populateNew", "(", "$", "class", ",", "array", "$", "row", ")", "{", "if", "(", "static", "::", "class", "!=", "__CLASS__", ")", "throw", "new", "IllegalAccessException", "(", "'Cannot access method '", ".", "__METHOD__", ".", ...
Create a new instance and populate it with the specified properties. This method is called by the ORM to transform database query result records to instances of the respective entity class. @param string $class - entity class name @param array $row - array with property values (a result row from a database query) @return self
[ "Create", "a", "new", "instance", "and", "populate", "it", "with", "the", "specified", "properties", ".", "This", "method", "is", "called", "by", "the", "ORM", "to", "transform", "database", "query", "result", "records", "to", "instances", "of", "the", "resp...
9d27f93dd53d2d626c75c92cfde9d004bab34d30
https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/db/orm/PersistableObject.php#L677-L685
train
rosasurfer/ministruts
src/db/orm/PersistableObject.php
PersistableObject.reload
public function reload($resetRelations = false) { // TODO: implement and set default=TRUE if (!$this->isPersistent()) throw new IllegalStateException('Cannot reload non-persistent '.get_class($this)); // TODO: This method cannot yet handle composite primary keys. $db = $this->db(); $dao = $this->dao(); $entity = $dao->getEntityMapping(); $table = $entity->getTableName(); // collect identity infos $identity = $entity->getIdentity(); $idColumn = $identity->getColumn(); $idName = $identity->getName(); $idValue = $identity->convertToDBValue($this->$idName, $db); // create and execute SQL $sql = 'select * from '.$table.' where '.$idColumn.' = '.$idValue; $row = $db->query($sql)->fetchRow(); if ($row === null) throw new ConcurrentModificationException('Error reloading '.get_class($this).' ('.$this->getObjectId().'), record not found'); // apply record values return $this->populate($row); }
php
public function reload($resetRelations = false) { // TODO: implement and set default=TRUE if (!$this->isPersistent()) throw new IllegalStateException('Cannot reload non-persistent '.get_class($this)); // TODO: This method cannot yet handle composite primary keys. $db = $this->db(); $dao = $this->dao(); $entity = $dao->getEntityMapping(); $table = $entity->getTableName(); // collect identity infos $identity = $entity->getIdentity(); $idColumn = $identity->getColumn(); $idName = $identity->getName(); $idValue = $identity->convertToDBValue($this->$idName, $db); // create and execute SQL $sql = 'select * from '.$table.' where '.$idColumn.' = '.$idValue; $row = $db->query($sql)->fetchRow(); if ($row === null) throw new ConcurrentModificationException('Error reloading '.get_class($this).' ('.$this->getObjectId().'), record not found'); // apply record values return $this->populate($row); }
[ "public", "function", "reload", "(", "$", "resetRelations", "=", "false", ")", "{", "// TODO: implement and set default=TRUE", "if", "(", "!", "$", "this", "->", "isPersistent", "(", ")", ")", "throw", "new", "IllegalStateException", "(", "'Cannot reload non-persist...
Reload this instance from the database and optionally reset relations. @param bool $resetRelations [optional] - NOT YET IMPLEMENTED Whether to reset relations and re-fetch on next access. (default: no) @return $this
[ "Reload", "this", "instance", "from", "the", "database", "and", "optionally", "reset", "relations", "." ]
9d27f93dd53d2d626c75c92cfde9d004bab34d30
https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/db/orm/PersistableObject.php#L696-L721
train
timble/kodekit
code/template/helper/paginator.php
TemplateHelperPaginator.limit
public function limit($config = array()) { $config = new ObjectConfigJson($config); $config->append(array( 'limit' => 0, 'attribs' => array('class' => 'k-form-control'), 'values' => array(5, 10, 15, 20, 25, 30, 50, 100) )); $html = ''; $selected = 0; $options = array(); $values = ObjectConfig::unbox($config->values); if ($config->limit && !in_array($config->limit, $values)) { $values[] = $config->limit; sort($values); } foreach($values as $value) { if($value == $config->limit) { $selected = $value; } $options[] = $this->option(array('label' => $value, 'value' => $value)); } if ($config->limit == $config->total) { $options[] = $this->option(array('label' => $this->getObject('translator')->translate('All'), 'value' => 0)); } $html .= $this->optionlist(array('options' => $options, 'name' => 'limit', 'attribs' => $config->attribs, 'selected' => $selected)); return $html; }
php
public function limit($config = array()) { $config = new ObjectConfigJson($config); $config->append(array( 'limit' => 0, 'attribs' => array('class' => 'k-form-control'), 'values' => array(5, 10, 15, 20, 25, 30, 50, 100) )); $html = ''; $selected = 0; $options = array(); $values = ObjectConfig::unbox($config->values); if ($config->limit && !in_array($config->limit, $values)) { $values[] = $config->limit; sort($values); } foreach($values as $value) { if($value == $config->limit) { $selected = $value; } $options[] = $this->option(array('label' => $value, 'value' => $value)); } if ($config->limit == $config->total) { $options[] = $this->option(array('label' => $this->getObject('translator')->translate('All'), 'value' => 0)); } $html .= $this->optionlist(array('options' => $options, 'name' => 'limit', 'attribs' => $config->attribs, 'selected' => $selected)); return $html; }
[ "public", "function", "limit", "(", "$", "config", "=", "array", "(", ")", ")", "{", "$", "config", "=", "new", "ObjectConfigJson", "(", "$", "config", ")", ";", "$", "config", "->", "append", "(", "array", "(", "'limit'", "=>", "0", ",", "'attribs'"...
Render a select box with limit values @param array|ObjectConfig $config An optional array with configuration options @return string Html select box
[ "Render", "a", "select", "box", "with", "limit", "values" ]
4c376f8873f8d10c55e3d290616ff622605cd246
https://github.com/timble/kodekit/blob/4c376f8873f8d10c55e3d290616ff622605cd246/code/template/helper/paginator.php#L77-L111
train
timble/kodekit
code/template/helper/paginator.php
TemplateHelperPaginator.pages
public function pages($config = array()) { $config = new ModelPaginator($config); $config->append(array( 'url' => null, 'total' => 0, 'display' => 2, 'offset' => 0, 'limit' => 0, 'show_limit' => true, 'show_count' => false ))->append(array( 'show_pages' => $config->count !== 1 )); $pages = $config->pages; $html = ''; $html .= $pages->previous->active ? '<li>'.$this->page($pages->previous, $config->url).'</li>' : ''; $previous = null; foreach ($pages->offsets as $page) { if ($previous && $page->page - $previous->page > 1) { $html .= '<li class="k-is-disabled"><span>&hellip;</span></li>'; } $html .= '<li class="'.($page->active && !$page->current ? '' : 'k-is-active').'">'; $html .= $this->page($page, $config->url); $html .= '</li>'; $previous = $page; } $html .= $pages->next->active ? '<li>'.$this->page($pages->next, $config->url).'</li>' : ''; return $html; }
php
public function pages($config = array()) { $config = new ModelPaginator($config); $config->append(array( 'url' => null, 'total' => 0, 'display' => 2, 'offset' => 0, 'limit' => 0, 'show_limit' => true, 'show_count' => false ))->append(array( 'show_pages' => $config->count !== 1 )); $pages = $config->pages; $html = ''; $html .= $pages->previous->active ? '<li>'.$this->page($pages->previous, $config->url).'</li>' : ''; $previous = null; foreach ($pages->offsets as $page) { if ($previous && $page->page - $previous->page > 1) { $html .= '<li class="k-is-disabled"><span>&hellip;</span></li>'; } $html .= '<li class="'.($page->active && !$page->current ? '' : 'k-is-active').'">'; $html .= $this->page($page, $config->url); $html .= '</li>'; $previous = $page; } $html .= $pages->next->active ? '<li>'.$this->page($pages->next, $config->url).'</li>' : ''; return $html; }
[ "public", "function", "pages", "(", "$", "config", "=", "array", "(", ")", ")", "{", "$", "config", "=", "new", "ModelPaginator", "(", "$", "config", ")", ";", "$", "config", "->", "append", "(", "array", "(", "'url'", "=>", "null", ",", "'total'", ...
Render a list of pages links @param array $config An optional array with configuration options @return string Html
[ "Render", "a", "list", "of", "pages", "links" ]
4c376f8873f8d10c55e3d290616ff622605cd246
https://github.com/timble/kodekit/blob/4c376f8873f8d10c55e3d290616ff622605cd246/code/template/helper/paginator.php#L119-L157
train
timble/kodekit
code/template/helper/paginator.php
TemplateHelperPaginator.page
public function page(ObjectConfigInterface $page, HttpUrlInterface $url) { $page->append(array( 'title' => '', 'current' => false, 'active' => false, 'offset' => 0, 'limit' => 0, 'rel' => '', 'attribs' => array(), )); //Set the offset and limit $url->query['limit'] = $page->limit; $url->query['offset'] = $page->offset; $link_attribs = []; if (!empty($page->rel)) { $link_attribs['rel'] = $page->rel; } if ($page->active && !$page->current) { $link_attribs['href'] = (string)$url; } $html = '<a '.$this->buildAttributes($link_attribs).'>'.$this->getObject('translator')->translate($page->title).'</a>'; return $html; }
php
public function page(ObjectConfigInterface $page, HttpUrlInterface $url) { $page->append(array( 'title' => '', 'current' => false, 'active' => false, 'offset' => 0, 'limit' => 0, 'rel' => '', 'attribs' => array(), )); //Set the offset and limit $url->query['limit'] = $page->limit; $url->query['offset'] = $page->offset; $link_attribs = []; if (!empty($page->rel)) { $link_attribs['rel'] = $page->rel; } if ($page->active && !$page->current) { $link_attribs['href'] = (string)$url; } $html = '<a '.$this->buildAttributes($link_attribs).'>'.$this->getObject('translator')->translate($page->title).'</a>'; return $html; }
[ "public", "function", "page", "(", "ObjectConfigInterface", "$", "page", ",", "HttpUrlInterface", "$", "url", ")", "{", "$", "page", "->", "append", "(", "array", "(", "'title'", "=>", "''", ",", "'current'", "=>", "false", ",", "'active'", "=>", "false", ...
Render a page link @param ObjectConfigInterface $page The page data @param HttpUrlInterface $url The base url to create the link @return string Html
[ "Render", "a", "page", "link" ]
4c376f8873f8d10c55e3d290616ff622605cd246
https://github.com/timble/kodekit/blob/4c376f8873f8d10c55e3d290616ff622605cd246/code/template/helper/paginator.php#L166-L195
train
timble/kodekit
code/database/behavior/accessible.php
DatabaseBehaviorAccessible.canAccess
public function canAccess() { //Check if the user needs to be authentic to access if($this->hasProperty('access') && !empty($this->access)) { if(!$this->getObject('user')->isAuthentic()) { return false; } } //Check if the user is in the group(s) to access if($this->hasProperty('access_group') && !empty($this->access_group)) { $groups = $this->getObject('user')->getGroups(); if(!in_array($this->access_group, $groups)) { return false; } } //Check if the user has the right role(s) to access if($this->hasProperty('access_role') && !empty($this->access_role)) { if(!$this->getObject('user')->hasRole($this->access_role)) { return false; } } return true; }
php
public function canAccess() { //Check if the user needs to be authentic to access if($this->hasProperty('access') && !empty($this->access)) { if(!$this->getObject('user')->isAuthentic()) { return false; } } //Check if the user is in the group(s) to access if($this->hasProperty('access_group') && !empty($this->access_group)) { $groups = $this->getObject('user')->getGroups(); if(!in_array($this->access_group, $groups)) { return false; } } //Check if the user has the right role(s) to access if($this->hasProperty('access_role') && !empty($this->access_role)) { if(!$this->getObject('user')->hasRole($this->access_role)) { return false; } } return true; }
[ "public", "function", "canAccess", "(", ")", "{", "//Check if the user needs to be authentic to access", "if", "(", "$", "this", "->", "hasProperty", "(", "'access'", ")", "&&", "!", "empty", "(", "$", "this", "->", "access", ")", ")", "{", "if", "(", "!", ...
Check if the row can be accessed @return boolean True on success, false otherwise
[ "Check", "if", "the", "row", "can", "be", "accessed" ]
4c376f8873f8d10c55e3d290616ff622605cd246
https://github.com/timble/kodekit/blob/4c376f8873f8d10c55e3d290616ff622605cd246/code/database/behavior/accessible.php#L29-L58
train
timble/kodekit
code/filesystem/mimetype/mimetype.php
FilesystemMimetype.registerResolver
public function registerResolver($resolver, array $config = array()) { if(!($resolver instanceof FilesystemMimetypeInterface)) { if(is_string($resolver) && strpos($resolver, '.') === false ) { $identifier = $this->getIdentifier()->toArray(); $identifier['path'][] = 'mimetype'; $identifier['name'] = $resolver; $identifier = $this->getIdentifier($identifier); } else $identifier = $this->getIdentifier($resolver); $resolver = $identifier; } else $identifier = $resolver->getIdentifier(); //Merge the config for the resolver $identifier->getConfig()->merge($config); //Store the resolver $name = $identifier->name; if(isset($this->__resolvers[$name])) { unset($this->__resolvers[$name]); } $this->__resolvers[$name] = $resolver; return $this; }
php
public function registerResolver($resolver, array $config = array()) { if(!($resolver instanceof FilesystemMimetypeInterface)) { if(is_string($resolver) && strpos($resolver, '.') === false ) { $identifier = $this->getIdentifier()->toArray(); $identifier['path'][] = 'mimetype'; $identifier['name'] = $resolver; $identifier = $this->getIdentifier($identifier); } else $identifier = $this->getIdentifier($resolver); $resolver = $identifier; } else $identifier = $resolver->getIdentifier(); //Merge the config for the resolver $identifier->getConfig()->merge($config); //Store the resolver $name = $identifier->name; if(isset($this->__resolvers[$name])) { unset($this->__resolvers[$name]); } $this->__resolvers[$name] = $resolver; return $this; }
[ "public", "function", "registerResolver", "(", "$", "resolver", ",", "array", "$", "config", "=", "array", "(", ")", ")", "{", "if", "(", "!", "(", "$", "resolver", "instanceof", "FilesystemMimetypeInterface", ")", ")", "{", "if", "(", "is_string", "(", ...
Registers a new mime type resolver. The last added mimetype resolver is preferred over previously registered ones. @param mixed $resolver An object that implements FilesystemMimetypeInterface, ObjectIdentifier object or valid identifier string @param array $config An optional associative array of configuration options @return $this
[ "Registers", "a", "new", "mime", "type", "resolver", "." ]
4c376f8873f8d10c55e3d290616ff622605cd246
https://github.com/timble/kodekit/blob/4c376f8873f8d10c55e3d290616ff622605cd246/code/filesystem/mimetype/mimetype.php#L95-L126
train
timble/kodekit
code/filesystem/mimetype/mimetype.php
FilesystemMimetype.fromPath
public function fromPath($path) { if (!is_file($path)) { throw new \RuntimeException('File not found at '.$path); } if (!is_readable($path)) { throw new \RuntimeException('File not readable at '.$path); } $mimetype = null; foreach (array_reverse($this->__resolvers) as $name => $resolver) { //Lazy create the resolver if(!($resolver instanceof FilesystemMimetypeInterface)) { $resolver = $this->getObject($resolver); if (!$resolver instanceof FilesystemMimetypeInterface) { throw new \UnexpectedValueException('Resolver does not implement FilesystemMimetypeInterface'); } $this->__resolvers[$name] = $resolver; } /* @var $resolver FilesystemMimetypeInterface */ if (null !== $mimetype = $resolver->fromPath($path)) { break; } } return $mimetype; }
php
public function fromPath($path) { if (!is_file($path)) { throw new \RuntimeException('File not found at '.$path); } if (!is_readable($path)) { throw new \RuntimeException('File not readable at '.$path); } $mimetype = null; foreach (array_reverse($this->__resolvers) as $name => $resolver) { //Lazy create the resolver if(!($resolver instanceof FilesystemMimetypeInterface)) { $resolver = $this->getObject($resolver); if (!$resolver instanceof FilesystemMimetypeInterface) { throw new \UnexpectedValueException('Resolver does not implement FilesystemMimetypeInterface'); } $this->__resolvers[$name] = $resolver; } /* @var $resolver FilesystemMimetypeInterface */ if (null !== $mimetype = $resolver->fromPath($path)) { break; } } return $mimetype; }
[ "public", "function", "fromPath", "(", "$", "path", ")", "{", "if", "(", "!", "is_file", "(", "$", "path", ")", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "'File not found at '", ".", "$", "path", ")", ";", "}", "if", "(", "!", "is_read...
Tries to find the mime type of the given file from it's file path. The file is passed to each registered mime type resolver in FILO order. Once a resolver returns a value that is not NULL, the result is returned. @param string $path The path to the file @throws \LogicException If the file cannot be found @throws \RuntimeException If the file is not readable @throws \UnexpectedValueException If the resolver doesn't implement FilesystemMimetypeInterface @return string The mime type or NULL, if none could be found
[ "Tries", "to", "find", "the", "mime", "type", "of", "the", "given", "file", "from", "it", "s", "file", "path", "." ]
4c376f8873f8d10c55e3d290616ff622605cd246
https://github.com/timble/kodekit/blob/4c376f8873f8d10c55e3d290616ff622605cd246/code/filesystem/mimetype/mimetype.php#L142-L175
train
locomotivemtl/charcoal-core
src/Charcoal/Model/AbstractMetadata.php
AbstractMetadata.property
public function property($propertyIdent = null) { if (isset($this->properties[$propertyIdent])) { return $this->properties[$propertyIdent]; } else { return null; } }
php
public function property($propertyIdent = null) { if (isset($this->properties[$propertyIdent])) { return $this->properties[$propertyIdent]; } else { return null; } }
[ "public", "function", "property", "(", "$", "propertyIdent", "=", "null", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "properties", "[", "$", "propertyIdent", "]", ")", ")", "{", "return", "$", "this", "->", "properties", "[", "$", "propertyI...
Retrieve the given property. @param string $propertyIdent The property identifier. @return array|null
[ "Retrieve", "the", "given", "property", "." ]
db3a7af547ccf96efe2d9be028b252bc8646f5d5
https://github.com/locomotivemtl/charcoal-core/blob/db3a7af547ccf96efe2d9be028b252bc8646f5d5/src/Charcoal/Model/AbstractMetadata.php#L96-L103
train
locomotivemtl/charcoal-core
src/Charcoal/Model/AbstractMetadata.php
AbstractMetadata.propertyObject
public function propertyObject($propertyIdent) { if (!isset($this->propertiesObjects[$propertyIdent])) { return null; } else { return $this->propertiesObjects[$propertyIdent]; } }
php
public function propertyObject($propertyIdent) { if (!isset($this->propertiesObjects[$propertyIdent])) { return null; } else { return $this->propertiesObjects[$propertyIdent]; } }
[ "public", "function", "propertyObject", "(", "$", "propertyIdent", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "propertiesObjects", "[", "$", "propertyIdent", "]", ")", ")", "{", "return", "null", ";", "}", "else", "{", "return", "$", "t...
Retrieve the given property as an object. @param string $propertyIdent The property (identifier) to return, as an object. @return PropertyInterface|null
[ "Retrieve", "the", "given", "property", "as", "an", "object", "." ]
db3a7af547ccf96efe2d9be028b252bc8646f5d5
https://github.com/locomotivemtl/charcoal-core/blob/db3a7af547ccf96efe2d9be028b252bc8646f5d5/src/Charcoal/Model/AbstractMetadata.php#L124-L131
train
timble/kodekit
code/template/helper/actionbar.php
TemplateHelperActionbar.render
public function render($config = array()) { $config = new ObjectConfigJson($config); $config->append(array( 'toolbar' => null, 'attribs' => array('class' => array('k-toolbar', 'k-js-toolbar')) )); $html = ''; if(isset($config->toolbar) && count($config->toolbar)) { //Force the id $config->attribs['id'] = 'toolbar-'.$config->toolbar->getType(); $html .= '<div '.$this->buildAttributes($config->attribs).'>'; foreach ($config->toolbar as $command) { $name = $command->getName(); if(method_exists($this, $name)) { $html .= $this->$name(ObjectConfig::unbox($command)); } else { $html .= $this->command(ObjectConfig::unbox($command)); } } $html .= '</div>'; } return $html; }
php
public function render($config = array()) { $config = new ObjectConfigJson($config); $config->append(array( 'toolbar' => null, 'attribs' => array('class' => array('k-toolbar', 'k-js-toolbar')) )); $html = ''; if(isset($config->toolbar) && count($config->toolbar)) { //Force the id $config->attribs['id'] = 'toolbar-'.$config->toolbar->getType(); $html .= '<div '.$this->buildAttributes($config->attribs).'>'; foreach ($config->toolbar as $command) { $name = $command->getName(); if(method_exists($this, $name)) { $html .= $this->$name(ObjectConfig::unbox($command)); } else { $html .= $this->command(ObjectConfig::unbox($command)); } } $html .= '</div>'; } return $html; }
[ "public", "function", "render", "(", "$", "config", "=", "array", "(", ")", ")", "{", "$", "config", "=", "new", "ObjectConfigJson", "(", "$", "config", ")", ";", "$", "config", "->", "append", "(", "array", "(", "'toolbar'", "=>", "null", ",", "'att...
Render the action bar @param array $config An optional array with configuration options @return string Html
[ "Render", "the", "action", "bar" ]
4c376f8873f8d10c55e3d290616ff622605cd246
https://github.com/timble/kodekit/blob/4c376f8873f8d10c55e3d290616ff622605cd246/code/template/helper/actionbar.php#L26-L57
train
timble/kodekit
code/template/helper/actionbar.php
TemplateHelperActionbar.dialog
public function dialog($config = array()) { $html = $this->createHelper('behavior')->modal(); $html .= $this->command($config); return $html; }
php
public function dialog($config = array()) { $html = $this->createHelper('behavior')->modal(); $html .= $this->command($config); return $html; }
[ "public", "function", "dialog", "(", "$", "config", "=", "array", "(", ")", ")", "{", "$", "html", "=", "$", "this", "->", "createHelper", "(", "'behavior'", ")", "->", "modal", "(", ")", ";", "$", "html", ".=", "$", "this", "->", "command", "(", ...
Render a dialog button @param array $config An optional array with configuration options @return string Html
[ "Render", "a", "dialog", "button" ]
4c376f8873f8d10c55e3d290616ff622605cd246
https://github.com/timble/kodekit/blob/4c376f8873f8d10c55e3d290616ff622605cd246/code/template/helper/actionbar.php#L144-L150
train
rosasurfer/ministruts
src/ministruts/ActionMapping.php
ActionMapping.setName
public function setName($name) { if ($this->configured) throw new IllegalStateException('Configuration is frozen'); if (!strlen($name=trim($name))) throw new StrutsConfigException('<mapping name="'.func_get_arg(0).'"'.($this->path ? ' path="'.$this->path.'"':'').': Illegal name (empty value).'); $this->name = $name; return $this; }
php
public function setName($name) { if ($this->configured) throw new IllegalStateException('Configuration is frozen'); if (!strlen($name=trim($name))) throw new StrutsConfigException('<mapping name="'.func_get_arg(0).'"'.($this->path ? ' path="'.$this->path.'"':'').': Illegal name (empty value).'); $this->name = $name; return $this; }
[ "public", "function", "setName", "(", "$", "name", ")", "{", "if", "(", "$", "this", "->", "configured", ")", "throw", "new", "IllegalStateException", "(", "'Configuration is frozen'", ")", ";", "if", "(", "!", "strlen", "(", "$", "name", "=", "trim", "(...
Set the mapping's name. @param string $name @return $this @throws StrutsConfigException on configuration errors
[ "Set", "the", "mapping", "s", "name", "." ]
9d27f93dd53d2d626c75c92cfde9d004bab34d30
https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/ministruts/ActionMapping.php#L90-L96
train
rosasurfer/ministruts
src/ministruts/ActionMapping.php
ActionMapping.setPath
public function setPath($path) { if ($this->configured) throw new IllegalStateException('Configuration is frozen'); if ($path[0] != '/') throw new StrutsConfigException('<mapping'.($this->name ? ' name="'.$this->name.'"':'').' path="'.$path.'": Illegal path (value must start with a slash "/").'); $this->path = $path; return $this; }
php
public function setPath($path) { if ($this->configured) throw new IllegalStateException('Configuration is frozen'); if ($path[0] != '/') throw new StrutsConfigException('<mapping'.($this->name ? ' name="'.$this->name.'"':'').' path="'.$path.'": Illegal path (value must start with a slash "/").'); $this->path = $path; return $this; }
[ "public", "function", "setPath", "(", "$", "path", ")", "{", "if", "(", "$", "this", "->", "configured", ")", "throw", "new", "IllegalStateException", "(", "'Configuration is frozen'", ")", ";", "if", "(", "$", "path", "[", "0", "]", "!=", "'/'", ")", ...
Set the mapping's path. @param string $path @return $this @throws StrutsConfigException on configuration errors
[ "Set", "the", "mapping", "s", "path", "." ]
9d27f93dd53d2d626c75c92cfde9d004bab34d30
https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/ministruts/ActionMapping.php#L118-L124
train
rosasurfer/ministruts
src/ministruts/ActionMapping.php
ActionMapping.isSupportedMethod
public function isSupportedMethod($method) { if (!is_string($method)) throw new IllegalTypeException('Illegal type of parameter $method: '.gettype($method)); return isset($this->methods[strtoupper($method)]); }
php
public function isSupportedMethod($method) { if (!is_string($method)) throw new IllegalTypeException('Illegal type of parameter $method: '.gettype($method)); return isset($this->methods[strtoupper($method)]); }
[ "public", "function", "isSupportedMethod", "(", "$", "method", ")", "{", "if", "(", "!", "is_string", "(", "$", "method", ")", ")", "throw", "new", "IllegalTypeException", "(", "'Illegal type of parameter $method: '", ".", "gettype", "(", "$", "method", ")", "...
Whether the mapping is configured to handle requests of the specified HTTP method. @param string $method - HTTP method verb @return bool
[ "Whether", "the", "mapping", "is", "configured", "to", "handle", "requests", "of", "the", "specified", "HTTP", "method", "." ]
9d27f93dd53d2d626c75c92cfde9d004bab34d30
https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/ministruts/ActionMapping.php#L144-L147
train
rosasurfer/ministruts
src/ministruts/ActionMapping.php
ActionMapping.setMethod
public function setMethod($method) { if ($this->configured) throw new IllegalStateException('Configuration is frozen'); $name = $this->name ? ' name="'.$this->name.'"':''; $path = $this->path ? ' path="'.$this->path.'"':''; $method = strtoupper($method); if ($method!='GET' && $method!='POST') throw new StrutsConfigException('<mapping'.$name.''.$path.' methods="'.func_get_arg(0).'": Invalid HTTP method.'); $this->methods[$method] = true; return $this; }
php
public function setMethod($method) { if ($this->configured) throw new IllegalStateException('Configuration is frozen'); $name = $this->name ? ' name="'.$this->name.'"':''; $path = $this->path ? ' path="'.$this->path.'"':''; $method = strtoupper($method); if ($method!='GET' && $method!='POST') throw new StrutsConfigException('<mapping'.$name.''.$path.' methods="'.func_get_arg(0).'": Invalid HTTP method.'); $this->methods[$method] = true; return $this; }
[ "public", "function", "setMethod", "(", "$", "method", ")", "{", "if", "(", "$", "this", "->", "configured", ")", "throw", "new", "IllegalStateException", "(", "'Configuration is frozen'", ")", ";", "$", "name", "=", "$", "this", "->", "name", "?", "' name...
Set the HTTP methods the mapping will be able to handle. @param string $method - HTTP method verb @return $this @throws StrutsConfigException on configuration errors
[ "Set", "the", "HTTP", "methods", "the", "mapping", "will", "be", "able", "to", "handle", "." ]
9d27f93dd53d2d626c75c92cfde9d004bab34d30
https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/ministruts/ActionMapping.php#L159-L169
train
rosasurfer/ministruts
src/ministruts/ActionMapping.php
ActionMapping.setRoles
public function setRoles($roles) { if ($this->configured) throw new IllegalStateException('Configuration is frozen'); $name = $this->name ? ' name="'.$this->name.'"':''; $path = $this->path ? ' path="'.$this->path.'"':''; //static $pattern = '/^!?[A-Za-z_][A-Za-z0-9_]*(,!?[A-Za-z_][A-Za-z0-9_]*)*$/'; static $pattern = '/^!?[A-Za-z_][A-Za-z0-9_]*$/'; if (!strlen($roles) || !preg_match($pattern, $roles)) throw new StrutsConfigException('<mapping'.$name.$path.' roles="'.$roles.'": Invalid roles expression.'); // check for invalid id combinations, e.g. "Member,!Member" $tokens = explode(',', $roles); $keys = \array_flip($tokens); foreach ($tokens as $role) { if (isset($keys['!'.$role])) throw new StrutsConfigException('<mapping'.$name.$path.' roles="'.$roles.'": Invalid roles expression.'); } // remove duplicates $this->roles = join(',', \array_flip($keys)); return $this; }
php
public function setRoles($roles) { if ($this->configured) throw new IllegalStateException('Configuration is frozen'); $name = $this->name ? ' name="'.$this->name.'"':''; $path = $this->path ? ' path="'.$this->path.'"':''; //static $pattern = '/^!?[A-Za-z_][A-Za-z0-9_]*(,!?[A-Za-z_][A-Za-z0-9_]*)*$/'; static $pattern = '/^!?[A-Za-z_][A-Za-z0-9_]*$/'; if (!strlen($roles) || !preg_match($pattern, $roles)) throw new StrutsConfigException('<mapping'.$name.$path.' roles="'.$roles.'": Invalid roles expression.'); // check for invalid id combinations, e.g. "Member,!Member" $tokens = explode(',', $roles); $keys = \array_flip($tokens); foreach ($tokens as $role) { if (isset($keys['!'.$role])) throw new StrutsConfigException('<mapping'.$name.$path.' roles="'.$roles.'": Invalid roles expression.'); } // remove duplicates $this->roles = join(',', \array_flip($keys)); return $this; }
[ "public", "function", "setRoles", "(", "$", "roles", ")", "{", "if", "(", "$", "this", "->", "configured", ")", "throw", "new", "IllegalStateException", "(", "'Configuration is frozen'", ")", ";", "$", "name", "=", "$", "this", "->", "name", "?", "' name=\...
Set the mapping's role restrictions. @param string $roles - role expression @return $this @throws StrutsConfigException on configuration errors
[ "Set", "the", "mapping", "s", "role", "restrictions", "." ]
9d27f93dd53d2d626c75c92cfde9d004bab34d30
https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/ministruts/ActionMapping.php#L191-L211
train
rosasurfer/ministruts
src/ministruts/ActionMapping.php
ActionMapping.freeze
public function freeze() { if ($this->configured) throw new IllegalStateException('Configuration is frozen'); $name = $this->name ? ' name="'.$this->name.'"':''; $path = $this->path ? ' path="'.$this->path.'"':''; $mapping = $name.$path; if (!$this->path) throw new StrutsConfigException('<mapping'.$mapping.': A "path" attribute must be configured for '.$this); if (!$this->formClassName && $this->formValidateFirst) throw new StrutsConfigException('<mapping'.$mapping.': A form must be configured if "form-validate-first" is set to "true".'); if (!$this->actionClassName && !$this->forward) { if (!$this->formClassName || !$this->formValidateFirst) throw new StrutsConfigException('<mapping'.$mapping.': Either an "action", "include", "forward" or "redirect" attribute must be specified.'); if (!$this->formClassName || !$this->formValidateFirst) { throw new StrutsConfigException('<mapping'.$mapping.': Either an "action", "include", "forward" or "redirect" attribute must be specified.'); } elseif ($this->formClassName && $this->formValidateFirst) { if (!isset($this->forwards[ActionForward::VALIDATION_SUCCESS_KEY]) || !isset($this->forwards[ActionForward::VALIDATION_ERROR_KEY])) throw new StrutsConfigException('<mapping'.$mapping.' form="'.$this->formClassName.'": A "success" and "error" forward must be configured to validate the form.'); } } $this->configured = true; return $this; }
php
public function freeze() { if ($this->configured) throw new IllegalStateException('Configuration is frozen'); $name = $this->name ? ' name="'.$this->name.'"':''; $path = $this->path ? ' path="'.$this->path.'"':''; $mapping = $name.$path; if (!$this->path) throw new StrutsConfigException('<mapping'.$mapping.': A "path" attribute must be configured for '.$this); if (!$this->formClassName && $this->formValidateFirst) throw new StrutsConfigException('<mapping'.$mapping.': A form must be configured if "form-validate-first" is set to "true".'); if (!$this->actionClassName && !$this->forward) { if (!$this->formClassName || !$this->formValidateFirst) throw new StrutsConfigException('<mapping'.$mapping.': Either an "action", "include", "forward" or "redirect" attribute must be specified.'); if (!$this->formClassName || !$this->formValidateFirst) { throw new StrutsConfigException('<mapping'.$mapping.': Either an "action", "include", "forward" or "redirect" attribute must be specified.'); } elseif ($this->formClassName && $this->formValidateFirst) { if (!isset($this->forwards[ActionForward::VALIDATION_SUCCESS_KEY]) || !isset($this->forwards[ActionForward::VALIDATION_ERROR_KEY])) throw new StrutsConfigException('<mapping'.$mapping.' form="'.$this->formClassName.'": A "success" and "error" forward must be configured to validate the form.'); } } $this->configured = true; return $this; }
[ "public", "function", "freeze", "(", ")", "{", "if", "(", "$", "this", "->", "configured", ")", "throw", "new", "IllegalStateException", "(", "'Configuration is frozen'", ")", ";", "$", "name", "=", "$", "this", "->", "name", "?", "' name=\"'", ".", "$", ...
Lock the mapping's configuration. Called after all properties of the mapping are set. @return $this @throws StrutsConfigException on configuration errors
[ "Lock", "the", "mapping", "s", "configuration", ".", "Called", "after", "all", "properties", "of", "the", "mapping", "are", "set", "." ]
9d27f93dd53d2d626c75c92cfde9d004bab34d30
https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/ministruts/ActionMapping.php#L443-L466
train
rosasurfer/ministruts
src/util/Validator.php
Validator.isIPAddress
public static function isIPAddress($string, $returnBytes = false) { static $pattern = '/^([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/'; $result = is_string($string) && strlen($string) && preg_match($pattern, $string, $bytes); if ($result) { \array_shift($bytes); foreach ($bytes as $i => $byte) { $b = (int) $byte; if (!is_string($byte) || $b > 255) return false; $bytes[$i] = $b; } if ($bytes[0] == 0) return false; return $returnBytes ? $bytes : true; } return false; }
php
public static function isIPAddress($string, $returnBytes = false) { static $pattern = '/^([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/'; $result = is_string($string) && strlen($string) && preg_match($pattern, $string, $bytes); if ($result) { \array_shift($bytes); foreach ($bytes as $i => $byte) { $b = (int) $byte; if (!is_string($byte) || $b > 255) return false; $bytes[$i] = $b; } if ($bytes[0] == 0) return false; return $returnBytes ? $bytes : true; } return false; }
[ "public", "static", "function", "isIPAddress", "(", "$", "string", ",", "$", "returnBytes", "=", "false", ")", "{", "static", "$", "pattern", "=", "'/^([0-9]{1,3})\\.([0-9]{1,3})\\.([0-9]{1,3})\\.([0-9]{1,3})$/'", ";", "$", "result", "=", "is_string", "(", "$", "s...
Ob der uebergebene String eine syntaktisch gueltige IP-Adresse ist. @param string $string - der zu ueberpruefende String @param bool $returnBytes [optional] - Typ des Rueckgabewertes FALSE: Boolean (default) TRUE: Array mit den Adressbytes oder FALSE, wenn der String keine gueltige IP-Adresse darstellt @return bool|array
[ "Ob", "der", "uebergebene", "String", "eine", "syntaktisch", "gueltige", "IP", "-", "Adresse", "ist", "." ]
9d27f93dd53d2d626c75c92cfde9d004bab34d30
https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/util/Validator.php#L25-L46
train
rosasurfer/ministruts
src/util/Validator.php
Validator.isIPLanAddress
public static function isIPLanAddress($string) { $bytes = self::isIPAddress($string, true); if ($bytes) { if ($bytes[0] == 10) // 10.0.0.0 - 10.255.255.255 return true; if ($bytes[0] == 172) // 172.16.0.0 - 172.31.255.255 return (15 < $bytes[1] && $bytes[1] < 32); if ($bytes[0]==192 && $bytes[1]==168) // 192.168.0.0 - 192.168.255.255 return true; } return false; }
php
public static function isIPLanAddress($string) { $bytes = self::isIPAddress($string, true); if ($bytes) { if ($bytes[0] == 10) // 10.0.0.0 - 10.255.255.255 return true; if ($bytes[0] == 172) // 172.16.0.0 - 172.31.255.255 return (15 < $bytes[1] && $bytes[1] < 32); if ($bytes[0]==192 && $bytes[1]==168) // 192.168.0.0 - 192.168.255.255 return true; } return false; }
[ "public", "static", "function", "isIPLanAddress", "(", "$", "string", ")", "{", "$", "bytes", "=", "self", "::", "isIPAddress", "(", "$", "string", ",", "true", ")", ";", "if", "(", "$", "bytes", ")", "{", "if", "(", "$", "bytes", "[", "0", "]", ...
Ob der uebergebene String eine syntaktisch gueltige IP-Adresse eines lokalen Netzwerks ist. @param string $string - der zu ueberpruefende String @return bool
[ "Ob", "der", "uebergebene", "String", "eine", "syntaktisch", "gueltige", "IP", "-", "Adresse", "eines", "lokalen", "Netzwerks", "ist", "." ]
9d27f93dd53d2d626c75c92cfde9d004bab34d30
https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/util/Validator.php#L56-L71
train
rosasurfer/ministruts
src/util/Validator.php
Validator.isIPWanAddress
public static function isIPWanAddress($string) { $bytes = self::isIPAddress($string, true); // Die Logik entspricht dem Gegenteil von self:: isIPLanAdress() + zusaetzlicher Tests. if ($bytes) { if ($bytes[0] == 10) // 10.0.0.0 - 10.255.255.255 return false; if ($bytes[0] == 127) // 127.0.0.0 - 127.255.255.255 return false; if ($bytes[0]==169) // 169.0.0.0 - 169.255.255.255 !!! wem zugewiesen? niemandem? return false; if ($bytes[0] == 172) // 172.16.0.0 - 172.31.255.255 return !(15 < $bytes[1] && $bytes[1] < 32); if ($bytes[0]==192) // 192.168.0.0 - 192.168.255.255 return ($bytes[1]!=168); } // dieses TRUE ist eher spekulativ return true; }
php
public static function isIPWanAddress($string) { $bytes = self::isIPAddress($string, true); // Die Logik entspricht dem Gegenteil von self:: isIPLanAdress() + zusaetzlicher Tests. if ($bytes) { if ($bytes[0] == 10) // 10.0.0.0 - 10.255.255.255 return false; if ($bytes[0] == 127) // 127.0.0.0 - 127.255.255.255 return false; if ($bytes[0]==169) // 169.0.0.0 - 169.255.255.255 !!! wem zugewiesen? niemandem? return false; if ($bytes[0] == 172) // 172.16.0.0 - 172.31.255.255 return !(15 < $bytes[1] && $bytes[1] < 32); if ($bytes[0]==192) // 192.168.0.0 - 192.168.255.255 return ($bytes[1]!=168); } // dieses TRUE ist eher spekulativ return true; }
[ "public", "static", "function", "isIPWanAddress", "(", "$", "string", ")", "{", "$", "bytes", "=", "self", "::", "isIPAddress", "(", "$", "string", ",", "true", ")", ";", "// Die Logik entspricht dem Gegenteil von self:: isIPLanAdress() + zusaetzlicher Tests.", "if", ...
Ob der uebergebene String eine syntaktisch gueltige IP-Adresse eines externen Netzwerks ist. @param string $string - der zu ueberpruefende String @return bool
[ "Ob", "der", "uebergebene", "String", "eine", "syntaktisch", "gueltige", "IP", "-", "Adresse", "eines", "externen", "Netzwerks", "ist", "." ]
9d27f93dd53d2d626c75c92cfde9d004bab34d30
https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/util/Validator.php#L81-L104
train