id
int32
0
241k
repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
226,200
Techworker/ssml
src/Specification/Alexa.php
Alexa.validatePhoneme
protected function validatePhoneme(Phoneme $phoneme) { $alphabet = $phoneme->alphabet; if (!in_array($alphabet, self::PHONEME_ALPHABETS, true)) { throw new InvalidAttributeValueException( $phoneme, 'alphabet', $alphabet, self::PHONEME_ALPHABETS, 'alexa' ); } }
php
protected function validatePhoneme(Phoneme $phoneme) { $alphabet = $phoneme->alphabet; if (!in_array($alphabet, self::PHONEME_ALPHABETS, true)) { throw new InvalidAttributeValueException( $phoneme, 'alphabet', $alphabet, self::PHONEME_ALPHABETS, 'alexa' ); } }
[ "protected", "function", "validatePhoneme", "(", "Phoneme", "$", "phoneme", ")", "{", "$", "alphabet", "=", "$", "phoneme", "->", "alphabet", ";", "if", "(", "!", "in_array", "(", "$", "alphabet", ",", "self", "::", "PHONEME_ALPHABETS", ",", "true", ")", ")", "{", "throw", "new", "InvalidAttributeValueException", "(", "$", "phoneme", ",", "'alphabet'", ",", "$", "alphabet", ",", "self", "::", "PHONEME_ALPHABETS", ",", "'alexa'", ")", ";", "}", "}" ]
Validates a Phoneme element. @param Phoneme $phoneme @throws InvalidAttributeValueException
[ "Validates", "a", "Phoneme", "element", "." ]
cafb979b777480baf7a01b5db2bf7c2cff837805
https://github.com/Techworker/ssml/blob/cafb979b777480baf7a01b5db2bf7c2cff837805/src/Specification/Alexa.php#L110-L118
226,201
Techworker/ssml
src/Specification/Alexa.php
Alexa.validateSayAs
protected function validateSayAs(SayAs $sayAs) { $interpretAs = $sayAs->interpretAs; if (!in_array($interpretAs, self::SAY_AS_INTERPRET_AS, true)) { throw new InvalidAttributeValueException( $sayAs, 'interpret-as', $interpretAs, self::SAY_AS_INTERPRET_AS, 'alexa' ); } $format = $sayAs->format; if ($interpretAs === 'date') { if (!in_array($format, self::SAY_AS_DATE_FORMATS, true)) { throw new InvalidAttributeValueException( $sayAs, 'format', $format, self::SAY_AS_DATE_FORMATS, 'alexa' ); } } // We will not check interjection values. }
php
protected function validateSayAs(SayAs $sayAs) { $interpretAs = $sayAs->interpretAs; if (!in_array($interpretAs, self::SAY_AS_INTERPRET_AS, true)) { throw new InvalidAttributeValueException( $sayAs, 'interpret-as', $interpretAs, self::SAY_AS_INTERPRET_AS, 'alexa' ); } $format = $sayAs->format; if ($interpretAs === 'date') { if (!in_array($format, self::SAY_AS_DATE_FORMATS, true)) { throw new InvalidAttributeValueException( $sayAs, 'format', $format, self::SAY_AS_DATE_FORMATS, 'alexa' ); } } // We will not check interjection values. }
[ "protected", "function", "validateSayAs", "(", "SayAs", "$", "sayAs", ")", "{", "$", "interpretAs", "=", "$", "sayAs", "->", "interpretAs", ";", "if", "(", "!", "in_array", "(", "$", "interpretAs", ",", "self", "::", "SAY_AS_INTERPRET_AS", ",", "true", ")", ")", "{", "throw", "new", "InvalidAttributeValueException", "(", "$", "sayAs", ",", "'interpret-as'", ",", "$", "interpretAs", ",", "self", "::", "SAY_AS_INTERPRET_AS", ",", "'alexa'", ")", ";", "}", "$", "format", "=", "$", "sayAs", "->", "format", ";", "if", "(", "$", "interpretAs", "===", "'date'", ")", "{", "if", "(", "!", "in_array", "(", "$", "format", ",", "self", "::", "SAY_AS_DATE_FORMATS", ",", "true", ")", ")", "{", "throw", "new", "InvalidAttributeValueException", "(", "$", "sayAs", ",", "'format'", ",", "$", "format", ",", "self", "::", "SAY_AS_DATE_FORMATS", ",", "'alexa'", ")", ";", "}", "}", "// We will not check interjection values.", "}" ]
Validates a SayAs element. @param SayAs $sayAs @throws SsmlException
[ "Validates", "a", "SayAs", "element", "." ]
cafb979b777480baf7a01b5db2bf7c2cff837805
https://github.com/Techworker/ssml/blob/cafb979b777480baf7a01b5db2bf7c2cff837805/src/Specification/Alexa.php#L126-L145
226,202
Techworker/ssml
src/Specification/Alexa.php
Alexa.validateWord
protected function validateWord(Word $word) { $role = $word->role; if (!in_array($role, self::WORD_ROLES, true)) { throw new InvalidAttributeValueException( $word, 'role', $role, self::WORD_ROLES, 'alexa' ); } }
php
protected function validateWord(Word $word) { $role = $word->role; if (!in_array($role, self::WORD_ROLES, true)) { throw new InvalidAttributeValueException( $word, 'role', $role, self::WORD_ROLES, 'alexa' ); } }
[ "protected", "function", "validateWord", "(", "Word", "$", "word", ")", "{", "$", "role", "=", "$", "word", "->", "role", ";", "if", "(", "!", "in_array", "(", "$", "role", ",", "self", "::", "WORD_ROLES", ",", "true", ")", ")", "{", "throw", "new", "InvalidAttributeValueException", "(", "$", "word", ",", "'role'", ",", "$", "role", ",", "self", "::", "WORD_ROLES", ",", "'alexa'", ")", ";", "}", "}" ]
Validates a Word element. @param Word $word @throws SsmlException
[ "Validates", "a", "Word", "element", "." ]
cafb979b777480baf7a01b5db2bf7c2cff837805
https://github.com/Techworker/ssml/blob/cafb979b777480baf7a01b5db2bf7c2cff837805/src/Specification/Alexa.php#L153-L161
226,203
sdboyer/gliph
src/Gliph/Traversal/DepthFirst.php
DepthFirst.traverse
public static function traverse(Digraph $graph, DepthFirstVisitorInterface $visitor, $start = NULL) { if ($start === NULL) { $queue = self::find_sources($graph, $visitor); } else if ($start instanceof \SplDoublyLinkedList) { $queue = $start; } else if (is_object($start)) { $queue = new \SplDoublyLinkedList(); $queue->push($start); } if ($queue->isEmpty()) { throw new RuntimeException('No start vertex or vertices were provided, and no source vertices could be found in the provided graph.', E_WARNING); } $visiting = new \SplObjectStorage(); $visited = new \SplObjectStorage(); $visitor->beginTraversal(); $visit = function($vertex) use ($graph, $visitor, &$visit, $visiting, $visited) { if ($visiting->contains($vertex)) { $visitor->onBackEdge($vertex, $visit); } else if (!$visited->contains($vertex)) { $visiting->attach($vertex); $visitor->onStartVertex($vertex, $visit); foreach ($graph->successorsOf($vertex) as $head) { $visitor->onExamineEdge($vertex, $head, $visit); $visit($head); } $visitor->onFinishVertex($vertex, $visit); $visiting->detach($vertex); $visited->attach($vertex); } }; // TODO experiment with adding a generator-producing visitor method that yields the queue here while (!$queue->isEmpty()) { $vertex = $queue->shift(); $visit($vertex); } $visitor->endTraversal(); }
php
public static function traverse(Digraph $graph, DepthFirstVisitorInterface $visitor, $start = NULL) { if ($start === NULL) { $queue = self::find_sources($graph, $visitor); } else if ($start instanceof \SplDoublyLinkedList) { $queue = $start; } else if (is_object($start)) { $queue = new \SplDoublyLinkedList(); $queue->push($start); } if ($queue->isEmpty()) { throw new RuntimeException('No start vertex or vertices were provided, and no source vertices could be found in the provided graph.', E_WARNING); } $visiting = new \SplObjectStorage(); $visited = new \SplObjectStorage(); $visitor->beginTraversal(); $visit = function($vertex) use ($graph, $visitor, &$visit, $visiting, $visited) { if ($visiting->contains($vertex)) { $visitor->onBackEdge($vertex, $visit); } else if (!$visited->contains($vertex)) { $visiting->attach($vertex); $visitor->onStartVertex($vertex, $visit); foreach ($graph->successorsOf($vertex) as $head) { $visitor->onExamineEdge($vertex, $head, $visit); $visit($head); } $visitor->onFinishVertex($vertex, $visit); $visiting->detach($vertex); $visited->attach($vertex); } }; // TODO experiment with adding a generator-producing visitor method that yields the queue here while (!$queue->isEmpty()) { $vertex = $queue->shift(); $visit($vertex); } $visitor->endTraversal(); }
[ "public", "static", "function", "traverse", "(", "Digraph", "$", "graph", ",", "DepthFirstVisitorInterface", "$", "visitor", ",", "$", "start", "=", "NULL", ")", "{", "if", "(", "$", "start", "===", "NULL", ")", "{", "$", "queue", "=", "self", "::", "find_sources", "(", "$", "graph", ",", "$", "visitor", ")", ";", "}", "else", "if", "(", "$", "start", "instanceof", "\\", "SplDoublyLinkedList", ")", "{", "$", "queue", "=", "$", "start", ";", "}", "else", "if", "(", "is_object", "(", "$", "start", ")", ")", "{", "$", "queue", "=", "new", "\\", "SplDoublyLinkedList", "(", ")", ";", "$", "queue", "->", "push", "(", "$", "start", ")", ";", "}", "if", "(", "$", "queue", "->", "isEmpty", "(", ")", ")", "{", "throw", "new", "RuntimeException", "(", "'No start vertex or vertices were provided, and no source vertices could be found in the provided graph.'", ",", "E_WARNING", ")", ";", "}", "$", "visiting", "=", "new", "\\", "SplObjectStorage", "(", ")", ";", "$", "visited", "=", "new", "\\", "SplObjectStorage", "(", ")", ";", "$", "visitor", "->", "beginTraversal", "(", ")", ";", "$", "visit", "=", "function", "(", "$", "vertex", ")", "use", "(", "$", "graph", ",", "$", "visitor", ",", "&", "$", "visit", ",", "$", "visiting", ",", "$", "visited", ")", "{", "if", "(", "$", "visiting", "->", "contains", "(", "$", "vertex", ")", ")", "{", "$", "visitor", "->", "onBackEdge", "(", "$", "vertex", ",", "$", "visit", ")", ";", "}", "else", "if", "(", "!", "$", "visited", "->", "contains", "(", "$", "vertex", ")", ")", "{", "$", "visiting", "->", "attach", "(", "$", "vertex", ")", ";", "$", "visitor", "->", "onStartVertex", "(", "$", "vertex", ",", "$", "visit", ")", ";", "foreach", "(", "$", "graph", "->", "successorsOf", "(", "$", "vertex", ")", "as", "$", "head", ")", "{", "$", "visitor", "->", "onExamineEdge", "(", "$", "vertex", ",", "$", "head", ",", "$", "visit", ")", ";", "$", "visit", "(", "$", "head", ")", ";", "}", "$", "visitor", "->", "onFinishVertex", "(", "$", "vertex", ",", "$", "visit", ")", ";", "$", "visiting", "->", "detach", "(", "$", "vertex", ")", ";", "$", "visited", "->", "attach", "(", "$", "vertex", ")", ";", "}", "}", ";", "// TODO experiment with adding a generator-producing visitor method that yields the queue here", "while", "(", "!", "$", "queue", "->", "isEmpty", "(", ")", ")", "{", "$", "vertex", "=", "$", "queue", "->", "shift", "(", ")", ";", "$", "visit", "(", "$", "vertex", ")", ";", "}", "$", "visitor", "->", "endTraversal", "(", ")", ";", "}" ]
Perform a depth-first traversal on the provided graph. @param Digraph $graph The graph on which to perform the depth-first search. @param DepthFirstVisitorInterface $visitor The visitor object to use during the traversal. @param object|\SplDoublyLinkedList $start A vertex, or vertices, to use as start points for the traversal. There are a few sub-behaviors here: - If an SplDoublyLinkedList, SplQueue, or SplStack is provided, the traversal will deque and visit vertices contained therein. - If a single vertex object is provided, it will be the sole originating point for the traversal. - If no value is provided, DepthFirst::find_sources() is called to search the graph for source vertices. These are place into an SplQueue in the order in which they are discovered, and traversal is then run over that queue in the same manner as if calling code had provided a queue directly. This method *guarantees* that all vertices in the graph will be visited. @throws RuntimeException Thrown if an invalid $start parameter is provided.
[ "Perform", "a", "depth", "-", "first", "traversal", "on", "the", "provided", "graph", "." ]
5ec6314b2b211053f6bae989b95446ccf6e8ded0
https://github.com/sdboyer/gliph/blob/5ec6314b2b211053f6bae989b95446ccf6e8ded0/src/Gliph/Traversal/DepthFirst.php#L36-L85
226,204
sdboyer/gliph
src/Gliph/Traversal/DepthFirst.php
DepthFirst.find_sources
public static function find_sources(Digraph $graph, DepthFirstVisitorInterface $visitor) { $incomings = new \SplObjectStorage(); $queue = new \SplQueue(); foreach ($graph->edges() as $edge) { if (!isset($incomings[$edge[1]])) { $incomings[$edge[1]] = new \SplObjectStorage(); } $incomings[$edge[1]]->attach($edge[0]); } // Prime the queue with vertices that have no incoming edges. foreach ($graph->vertices() as $vertex) { if (!$incomings->contains($vertex)) { $queue->push($vertex); $visitor->onInitializeVertex($vertex, TRUE, $queue); } else { $visitor->onInitializeVertex($vertex, FALSE, $queue); } } return $queue; }
php
public static function find_sources(Digraph $graph, DepthFirstVisitorInterface $visitor) { $incomings = new \SplObjectStorage(); $queue = new \SplQueue(); foreach ($graph->edges() as $edge) { if (!isset($incomings[$edge[1]])) { $incomings[$edge[1]] = new \SplObjectStorage(); } $incomings[$edge[1]]->attach($edge[0]); } // Prime the queue with vertices that have no incoming edges. foreach ($graph->vertices() as $vertex) { if (!$incomings->contains($vertex)) { $queue->push($vertex); $visitor->onInitializeVertex($vertex, TRUE, $queue); } else { $visitor->onInitializeVertex($vertex, FALSE, $queue); } } return $queue; }
[ "public", "static", "function", "find_sources", "(", "Digraph", "$", "graph", ",", "DepthFirstVisitorInterface", "$", "visitor", ")", "{", "$", "incomings", "=", "new", "\\", "SplObjectStorage", "(", ")", ";", "$", "queue", "=", "new", "\\", "SplQueue", "(", ")", ";", "foreach", "(", "$", "graph", "->", "edges", "(", ")", "as", "$", "edge", ")", "{", "if", "(", "!", "isset", "(", "$", "incomings", "[", "$", "edge", "[", "1", "]", "]", ")", ")", "{", "$", "incomings", "[", "$", "edge", "[", "1", "]", "]", "=", "new", "\\", "SplObjectStorage", "(", ")", ";", "}", "$", "incomings", "[", "$", "edge", "[", "1", "]", "]", "->", "attach", "(", "$", "edge", "[", "0", "]", ")", ";", "}", "// Prime the queue with vertices that have no incoming edges.", "foreach", "(", "$", "graph", "->", "vertices", "(", ")", "as", "$", "vertex", ")", "{", "if", "(", "!", "$", "incomings", "->", "contains", "(", "$", "vertex", ")", ")", "{", "$", "queue", "->", "push", "(", "$", "vertex", ")", ";", "$", "visitor", "->", "onInitializeVertex", "(", "$", "vertex", ",", "TRUE", ",", "$", "queue", ")", ";", "}", "else", "{", "$", "visitor", "->", "onInitializeVertex", "(", "$", "vertex", ",", "FALSE", ",", "$", "queue", ")", ";", "}", "}", "return", "$", "queue", ";", "}" ]
Finds source vertices in a Digraph, then enqueues them. @param Digraph $graph @param DepthFirstVisitorInterface $visitor @return \SplQueue
[ "Finds", "source", "vertices", "in", "a", "Digraph", "then", "enqueues", "them", "." ]
5ec6314b2b211053f6bae989b95446ccf6e8ded0
https://github.com/sdboyer/gliph/blob/5ec6314b2b211053f6bae989b95446ccf6e8ded0/src/Gliph/Traversal/DepthFirst.php#L95-L118
226,205
sdboyer/gliph
src/Gliph/Traversal/DepthFirst.php
DepthFirst.toposort
public static function toposort(Digraph $graph, $start = NULL) { $visitor = new DepthFirstToposortVisitor(); self::traverse($graph, $visitor, $start); return $visitor->getTsl(); }
php
public static function toposort(Digraph $graph, $start = NULL) { $visitor = new DepthFirstToposortVisitor(); self::traverse($graph, $visitor, $start); return $visitor->getTsl(); }
[ "public", "static", "function", "toposort", "(", "Digraph", "$", "graph", ",", "$", "start", "=", "NULL", ")", "{", "$", "visitor", "=", "new", "DepthFirstToposortVisitor", "(", ")", ";", "self", "::", "traverse", "(", "$", "graph", ",", "$", "visitor", ",", "$", "start", ")", ";", "return", "$", "visitor", "->", "getTsl", "(", ")", ";", "}" ]
Performs a topological sort on the provided graph. @param Digraph $graph @param object|\SplDoublyLinkedList $start The starting point(s) for the toposort. @see DepthFirst::traverse() @return array A valid topologically sorted list for the provided graph.
[ "Performs", "a", "topological", "sort", "on", "the", "provided", "graph", "." ]
5ec6314b2b211053f6bae989b95446ccf6e8ded0
https://github.com/sdboyer/gliph/blob/5ec6314b2b211053f6bae989b95446ccf6e8ded0/src/Gliph/Traversal/DepthFirst.php#L130-L135
226,206
mlanin/laravel-setup-wizard
src/Commands/Steps/CreateUser.php
CreateUser.preview
public function preview($results) { $table = $results['__table']; unset($results['__table']); $this->command->info('I will insert this values into <comment>' . $table . '</comment> table'); $this->command->table(['column', 'value'], $this->arrayToTable($results)); }
php
public function preview($results) { $table = $results['__table']; unset($results['__table']); $this->command->info('I will insert this values into <comment>' . $table . '</comment> table'); $this->command->table(['column', 'value'], $this->arrayToTable($results)); }
[ "public", "function", "preview", "(", "$", "results", ")", "{", "$", "table", "=", "$", "results", "[", "'__table'", "]", ";", "unset", "(", "$", "results", "[", "'__table'", "]", ")", ";", "$", "this", "->", "command", "->", "info", "(", "'I will insert this values into <comment>'", ".", "$", "table", ".", "'</comment> table'", ")", ";", "$", "this", "->", "command", "->", "table", "(", "[", "'column'", ",", "'value'", "]", ",", "$", "this", "->", "arrayToTable", "(", "$", "results", ")", ")", ";", "}" ]
Preview results. @param mixed $results @return void
[ "Preview", "results", "." ]
b2614612f92861af434e70b0fe070f6167a71e33
https://github.com/mlanin/laravel-setup-wizard/blob/b2614612f92861af434e70b0fe070f6167a71e33/src/Commands/Steps/CreateUser.php#L44-L51
226,207
mlanin/laravel-setup-wizard
src/Commands/Steps/CreateUser.php
CreateUser.getTable
protected function getTable($table = '') { if (empty($table)) { switch (config('auth.driver')) { case 'eloquent': $table = $this->getTableByModelClass(config('auth.model')); break; case 'database': default: $table = config('auth.table'); break; } } return $table; }
php
protected function getTable($table = '') { if (empty($table)) { switch (config('auth.driver')) { case 'eloquent': $table = $this->getTableByModelClass(config('auth.model')); break; case 'database': default: $table = config('auth.table'); break; } } return $table; }
[ "protected", "function", "getTable", "(", "$", "table", "=", "''", ")", "{", "if", "(", "empty", "(", "$", "table", ")", ")", "{", "switch", "(", "config", "(", "'auth.driver'", ")", ")", "{", "case", "'eloquent'", ":", "$", "table", "=", "$", "this", "->", "getTableByModelClass", "(", "config", "(", "'auth.model'", ")", ")", ";", "break", ";", "case", "'database'", ":", "default", ":", "$", "table", "=", "config", "(", "'auth.table'", ")", ";", "break", ";", "}", "}", "return", "$", "table", ";", "}" ]
Get users table name. @param string $table @return string
[ "Get", "users", "table", "name", "." ]
b2614612f92861af434e70b0fe070f6167a71e33
https://github.com/mlanin/laravel-setup-wizard/blob/b2614612f92861af434e70b0fe070f6167a71e33/src/Commands/Steps/CreateUser.php#L73-L90
226,208
crip-laravel/filesys
src/App/Blob.php
Blob.init
public function init(ServiceBlob $blob) { $this->bytes = $blob->metadata->getSize(); $this->dir = $blob->metadata->getDir(true); $this->fullName = $blob->metadata->getFullName(); $this->mediaType = $blob->getMediaType(); $this->name = $blob->metadata->getName(); $this->thumb = $blob->getThumbUrl(); $this->type = $blob->getType(); $this->updatedAt = $blob->metadata->getLastModified(); $this->url = $blob->getUrl(); $this->xs = $blob->getXsThumbUrl(); $this->path = $blob->metadata->getPath(true); }
php
public function init(ServiceBlob $blob) { $this->bytes = $blob->metadata->getSize(); $this->dir = $blob->metadata->getDir(true); $this->fullName = $blob->metadata->getFullName(); $this->mediaType = $blob->getMediaType(); $this->name = $blob->metadata->getName(); $this->thumb = $blob->getThumbUrl(); $this->type = $blob->getType(); $this->updatedAt = $blob->metadata->getLastModified(); $this->url = $blob->getUrl(); $this->xs = $blob->getXsThumbUrl(); $this->path = $blob->metadata->getPath(true); }
[ "public", "function", "init", "(", "ServiceBlob", "$", "blob", ")", "{", "$", "this", "->", "bytes", "=", "$", "blob", "->", "metadata", "->", "getSize", "(", ")", ";", "$", "this", "->", "dir", "=", "$", "blob", "->", "metadata", "->", "getDir", "(", "true", ")", ";", "$", "this", "->", "fullName", "=", "$", "blob", "->", "metadata", "->", "getFullName", "(", ")", ";", "$", "this", "->", "mediaType", "=", "$", "blob", "->", "getMediaType", "(", ")", ";", "$", "this", "->", "name", "=", "$", "blob", "->", "metadata", "->", "getName", "(", ")", ";", "$", "this", "->", "thumb", "=", "$", "blob", "->", "getThumbUrl", "(", ")", ";", "$", "this", "->", "type", "=", "$", "blob", "->", "getType", "(", ")", ";", "$", "this", "->", "updatedAt", "=", "$", "blob", "->", "metadata", "->", "getLastModified", "(", ")", ";", "$", "this", "->", "url", "=", "$", "blob", "->", "getUrl", "(", ")", ";", "$", "this", "->", "xs", "=", "$", "blob", "->", "getXsThumbUrl", "(", ")", ";", "$", "this", "->", "path", "=", "$", "blob", "->", "metadata", "->", "getPath", "(", "true", ")", ";", "}" ]
Initialize Blob properties from service instance. @param ServiceBlob $blob
[ "Initialize", "Blob", "properties", "from", "service", "instance", "." ]
43c66929a5a16772dbb3bae4b5188bdc10b6f9ec
https://github.com/crip-laravel/filesys/blob/43c66929a5a16772dbb3bae4b5188bdc10b6f9ec/src/App/Blob.php#L46-L59
226,209
gjerokrsteski/pimf-framework
core/Pimf/Util/Identifier.php
Identifier.slag
protected function slag() { $ident = str_replace('-', '_', implode(self::getDelimiter(), $this->args)); $ident = str_replace('_', self::getDelimiter(), $ident); $ident = trim($ident); $ident = str_replace(' ', '', $ident); return strip_tags(strtolower($ident)); }
php
protected function slag() { $ident = str_replace('-', '_', implode(self::getDelimiter(), $this->args)); $ident = str_replace('_', self::getDelimiter(), $ident); $ident = trim($ident); $ident = str_replace(' ', '', $ident); return strip_tags(strtolower($ident)); }
[ "protected", "function", "slag", "(", ")", "{", "$", "ident", "=", "str_replace", "(", "'-'", ",", "'_'", ",", "implode", "(", "self", "::", "getDelimiter", "(", ")", ",", "$", "this", "->", "args", ")", ")", ";", "$", "ident", "=", "str_replace", "(", "'_'", ",", "self", "::", "getDelimiter", "(", ")", ",", "$", "ident", ")", ";", "$", "ident", "=", "trim", "(", "$", "ident", ")", ";", "$", "ident", "=", "str_replace", "(", "' '", ",", "''", ",", "$", "ident", ")", ";", "return", "strip_tags", "(", "strtolower", "(", "$", "ident", ")", ")", ";", "}" ]
Slags the identifier. @return string
[ "Slags", "the", "identifier", "." ]
859aa7c8bb727b556c5e32224842af3cff33f18b
https://github.com/gjerokrsteski/pimf-framework/blob/859aa7c8bb727b556c5e32224842af3cff33f18b/core/Pimf/Util/Identifier.php#L79-L87
226,210
Techworker/ssml
src/Traits/SentenceTrait.php
SentenceTrait.sentence
public function sentence(string $text = null): Sentence { $sentence = Sentence::factory(); if ($text !== null) { $sentence->text($text); } /** @var ContainerElement $this */ return $this->addElement($sentence); }
php
public function sentence(string $text = null): Sentence { $sentence = Sentence::factory(); if ($text !== null) { $sentence->text($text); } /** @var ContainerElement $this */ return $this->addElement($sentence); }
[ "public", "function", "sentence", "(", "string", "$", "text", "=", "null", ")", ":", "Sentence", "{", "$", "sentence", "=", "Sentence", "::", "factory", "(", ")", ";", "if", "(", "$", "text", "!==", "null", ")", "{", "$", "sentence", "->", "text", "(", "$", "text", ")", ";", "}", "/** @var ContainerElement $this */", "return", "$", "this", "->", "addElement", "(", "$", "sentence", ")", ";", "}" ]
Adds a new sentence element. If a text is provided, it will be added. @param string|null $text @return Sentence
[ "Adds", "a", "new", "sentence", "element", ".", "If", "a", "text", "is", "provided", "it", "will", "be", "added", "." ]
cafb979b777480baf7a01b5db2bf7c2cff837805
https://github.com/Techworker/ssml/blob/cafb979b777480baf7a01b5db2bf7c2cff837805/src/Traits/SentenceTrait.php#L29-L38
226,211
gjerokrsteski/pimf-framework
core/Pimf/Util/Uploaded/Factory.php
Factory.get
public static function get(array $file, $test = false) { $file = static::heal($file); if (is_array($file) && isset($file['name']) && empty($file['name']) === false) { $keys = array_keys($file); sort($keys); if ($keys == self::$fileKeys) { if (UPLOAD_ERR_NO_FILE == $file['error']) { return null; } return new Uploaded($file['tmp_name'], $file['name'], $file['type'], $file['size'], $file['error'], $test); } } return null; }
php
public static function get(array $file, $test = false) { $file = static::heal($file); if (is_array($file) && isset($file['name']) && empty($file['name']) === false) { $keys = array_keys($file); sort($keys); if ($keys == self::$fileKeys) { if (UPLOAD_ERR_NO_FILE == $file['error']) { return null; } return new Uploaded($file['tmp_name'], $file['name'], $file['type'], $file['size'], $file['error'], $test); } } return null; }
[ "public", "static", "function", "get", "(", "array", "$", "file", ",", "$", "test", "=", "false", ")", "{", "$", "file", "=", "static", "::", "heal", "(", "$", "file", ")", ";", "if", "(", "is_array", "(", "$", "file", ")", "&&", "isset", "(", "$", "file", "[", "'name'", "]", ")", "&&", "empty", "(", "$", "file", "[", "'name'", "]", ")", "===", "false", ")", "{", "$", "keys", "=", "array_keys", "(", "$", "file", ")", ";", "sort", "(", "$", "keys", ")", ";", "if", "(", "$", "keys", "==", "self", "::", "$", "fileKeys", ")", "{", "if", "(", "UPLOAD_ERR_NO_FILE", "==", "$", "file", "[", "'error'", "]", ")", "{", "return", "null", ";", "}", "return", "new", "Uploaded", "(", "$", "file", "[", "'tmp_name'", "]", ",", "$", "file", "[", "'name'", "]", ",", "$", "file", "[", "'type'", "]", ",", "$", "file", "[", "'size'", "]", ",", "$", "file", "[", "'error'", "]", ",", "$", "test", ")", ";", "}", "}", "return", "null", ";", "}" ]
Factory for save instance creation. <code> // Create an instance using the factory method. $file = \Pimf\Util\Uploaded\Factory::get($_FILES); </code> @param mixed $file A $_FILES multi-dimensional array of uploaded file information. @param bool $test Whether the test mode is active for essayer unit-testing. @return null|Uploaded
[ "Factory", "for", "save", "instance", "creation", "." ]
859aa7c8bb727b556c5e32224842af3cff33f18b
https://github.com/gjerokrsteski/pimf-framework/blob/859aa7c8bb727b556c5e32224842af3cff33f18b/core/Pimf/Util/Uploaded/Factory.php#L49-L70
226,212
Techworker/ssml
src/Traits/ParagraphTrait.php
ParagraphTrait.paragraph
public function paragraph(string $text = null): Paragraph { $paragraph = Paragraph::factory(); if ($text !== null) { $paragraph->text($text); } /** @var ContainerElement $this */ return $this->addElement($paragraph); }
php
public function paragraph(string $text = null): Paragraph { $paragraph = Paragraph::factory(); if ($text !== null) { $paragraph->text($text); } /** @var ContainerElement $this */ return $this->addElement($paragraph); }
[ "public", "function", "paragraph", "(", "string", "$", "text", "=", "null", ")", ":", "Paragraph", "{", "$", "paragraph", "=", "Paragraph", "::", "factory", "(", ")", ";", "if", "(", "$", "text", "!==", "null", ")", "{", "$", "paragraph", "->", "text", "(", "$", "text", ")", ";", "}", "/** @var ContainerElement $this */", "return", "$", "this", "->", "addElement", "(", "$", "paragraph", ")", ";", "}" ]
Adds a new paragraph element. If text is provided, this will also be added. @param string|null $text @return Paragraph
[ "Adds", "a", "new", "paragraph", "element", ".", "If", "text", "is", "provided", "this", "will", "also", "be", "added", "." ]
cafb979b777480baf7a01b5db2bf7c2cff837805
https://github.com/Techworker/ssml/blob/cafb979b777480baf7a01b5db2bf7c2cff837805/src/Traits/ParagraphTrait.php#L40-L49
226,213
LUSHDigital/microservice-crud
src/Http/Controllers/CrudController.php
CrudController.show
public function show($id) { // Check the cache for item data. Otherwise get from the db. $item = Cache::rememberForever($this->modelTableName . ':' . $id, function () use ($id) { return call_user_func([$this->getModelClass(), 'findOrFail'], $id)->toArray(); }); return $this->generateResponse($this->modelTableName, $item); }
php
public function show($id) { // Check the cache for item data. Otherwise get from the db. $item = Cache::rememberForever($this->modelTableName . ':' . $id, function () use ($id) { return call_user_func([$this->getModelClass(), 'findOrFail'], $id)->toArray(); }); return $this->generateResponse($this->modelTableName, $item); }
[ "public", "function", "show", "(", "$", "id", ")", "{", "// Check the cache for item data. Otherwise get from the db.", "$", "item", "=", "Cache", "::", "rememberForever", "(", "$", "this", "->", "modelTableName", ".", "':'", ".", "$", "id", ",", "function", "(", ")", "use", "(", "$", "id", ")", "{", "return", "call_user_func", "(", "[", "$", "this", "->", "getModelClass", "(", ")", ",", "'findOrFail'", "]", ",", "$", "id", ")", "->", "toArray", "(", ")", ";", "}", ")", ";", "return", "$", "this", "->", "generateResponse", "(", "$", "this", "->", "modelTableName", ",", "$", "item", ")", ";", "}" ]
Get a single item by it's ID. @param int $id @return Response
[ "Get", "a", "single", "item", "by", "it", "s", "ID", "." ]
df429279af36688462de78877650efdc04494c4a
https://github.com/LUSHDigital/microservice-crud/blob/df429279af36688462de78877650efdc04494c4a/src/Http/Controllers/CrudController.php#L125-L133
226,214
LUSHDigital/microservice-crud
src/Http/Controllers/CrudController.php
CrudController.destroy
public function destroy($id) { // Get the item. $item = call_user_func([$this->getModelClass(), 'findOrFail'], $id); // Delete the item. $item->delete(); return $this->generateResponse($this->modelTableName, null, Response::HTTP_OK, Status::OK, 'Item was deleted successfully.'); }
php
public function destroy($id) { // Get the item. $item = call_user_func([$this->getModelClass(), 'findOrFail'], $id); // Delete the item. $item->delete(); return $this->generateResponse($this->modelTableName, null, Response::HTTP_OK, Status::OK, 'Item was deleted successfully.'); }
[ "public", "function", "destroy", "(", "$", "id", ")", "{", "// Get the item.", "$", "item", "=", "call_user_func", "(", "[", "$", "this", "->", "getModelClass", "(", ")", ",", "'findOrFail'", "]", ",", "$", "id", ")", ";", "// Delete the item.", "$", "item", "->", "delete", "(", ")", ";", "return", "$", "this", "->", "generateResponse", "(", "$", "this", "->", "modelTableName", ",", "null", ",", "Response", "::", "HTTP_OK", ",", "Status", "::", "OK", ",", "'Item was deleted successfully.'", ")", ";", "}" ]
Delete a single item. @param int $id @return Response
[ "Delete", "a", "single", "item", "." ]
df429279af36688462de78877650efdc04494c4a
https://github.com/LUSHDigital/microservice-crud/blob/df429279af36688462de78877650efdc04494c4a/src/Http/Controllers/CrudController.php#L164-L173
226,215
LUSHDigital/microservice-crud
src/Http/Controllers/CrudController.php
CrudController.getModelClass
public function getModelClass() { $model = $this->getModelNamespace() . '\\' . $this->getModelBaseClass(); // Validate the model class. $this->validateModelClass($model); return $model; }
php
public function getModelClass() { $model = $this->getModelNamespace() . '\\' . $this->getModelBaseClass(); // Validate the model class. $this->validateModelClass($model); return $model; }
[ "public", "function", "getModelClass", "(", ")", "{", "$", "model", "=", "$", "this", "->", "getModelNamespace", "(", ")", ".", "'\\\\'", ".", "$", "this", "->", "getModelBaseClass", "(", ")", ";", "// Validate the model class.", "$", "this", "->", "validateModelClass", "(", "$", "model", ")", ";", "return", "$", "model", ";", "}" ]
Get the fully qualified class of the model related to this controller. @return string @throws CrudModelException
[ "Get", "the", "fully", "qualified", "class", "of", "the", "model", "related", "to", "this", "controller", "." ]
df429279af36688462de78877650efdc04494c4a
https://github.com/LUSHDigital/microservice-crud/blob/df429279af36688462de78877650efdc04494c4a/src/Http/Controllers/CrudController.php#L181-L189
226,216
LUSHDigital/microservice-crud
src/Http/Controllers/CrudController.php
CrudController.getModelBaseClass
public function getModelBaseClass() { // Use the non-plural version of the controller name if no model // is already specified. if (empty($this->modelBaseClass)) { $this->modelBaseClass = Str::singular(str_replace('Controller', '', class_basename($this))); } return $this->modelBaseClass; }
php
public function getModelBaseClass() { // Use the non-plural version of the controller name if no model // is already specified. if (empty($this->modelBaseClass)) { $this->modelBaseClass = Str::singular(str_replace('Controller', '', class_basename($this))); } return $this->modelBaseClass; }
[ "public", "function", "getModelBaseClass", "(", ")", "{", "// Use the non-plural version of the controller name if no model", "// is already specified.", "if", "(", "empty", "(", "$", "this", "->", "modelBaseClass", ")", ")", "{", "$", "this", "->", "modelBaseClass", "=", "Str", "::", "singular", "(", "str_replace", "(", "'Controller'", ",", "''", ",", "class_basename", "(", "$", "this", ")", ")", ")", ";", "}", "return", "$", "this", "->", "modelBaseClass", ";", "}" ]
Get the name of the model related to this CRUD controller. @return string
[ "Get", "the", "name", "of", "the", "model", "related", "to", "this", "CRUD", "controller", "." ]
df429279af36688462de78877650efdc04494c4a
https://github.com/LUSHDigital/microservice-crud/blob/df429279af36688462de78877650efdc04494c4a/src/Http/Controllers/CrudController.php#L196-L205
226,217
LUSHDigital/microservice-crud
src/Http/Controllers/CrudController.php
CrudController.validateModelClass
protected function validateModelClass($modelClass) { // Validate the expected model exists. if (!class_exists($modelClass)) { throw new CrudModelException('The related model does not exist.'); } // Validate the model extends the correct base model. if (!is_subclass_of($modelClass, self::MICROSERVICE_BASE_MODEL_CLASS)) { throw new CrudModelException('The related model must extend the MicroServiceBaseModel abstract class.'); } // Validate the model implements the correct interface. if (!in_array(self::MICROSERVICE_CRUD_MODEL_INTERFACE, class_implements($modelClass))) { throw new CrudModelException('The related model must implement CrudModelInterface.'); } }
php
protected function validateModelClass($modelClass) { // Validate the expected model exists. if (!class_exists($modelClass)) { throw new CrudModelException('The related model does not exist.'); } // Validate the model extends the correct base model. if (!is_subclass_of($modelClass, self::MICROSERVICE_BASE_MODEL_CLASS)) { throw new CrudModelException('The related model must extend the MicroServiceBaseModel abstract class.'); } // Validate the model implements the correct interface. if (!in_array(self::MICROSERVICE_CRUD_MODEL_INTERFACE, class_implements($modelClass))) { throw new CrudModelException('The related model must implement CrudModelInterface.'); } }
[ "protected", "function", "validateModelClass", "(", "$", "modelClass", ")", "{", "// Validate the expected model exists.", "if", "(", "!", "class_exists", "(", "$", "modelClass", ")", ")", "{", "throw", "new", "CrudModelException", "(", "'The related model does not exist.'", ")", ";", "}", "// Validate the model extends the correct base model.", "if", "(", "!", "is_subclass_of", "(", "$", "modelClass", ",", "self", "::", "MICROSERVICE_BASE_MODEL_CLASS", ")", ")", "{", "throw", "new", "CrudModelException", "(", "'The related model must extend the MicroServiceBaseModel abstract class.'", ")", ";", "}", "// Validate the model implements the correct interface.", "if", "(", "!", "in_array", "(", "self", "::", "MICROSERVICE_CRUD_MODEL_INTERFACE", ",", "class_implements", "(", "$", "modelClass", ")", ")", ")", "{", "throw", "new", "CrudModelException", "(", "'The related model must implement CrudModelInterface.'", ")", ";", "}", "}" ]
Validate a model class name. @param $modelClass @return void @throws CrudModelException
[ "Validate", "a", "model", "class", "name", "." ]
df429279af36688462de78877650efdc04494c4a
https://github.com/LUSHDigital/microservice-crud/blob/df429279af36688462de78877650efdc04494c4a/src/Http/Controllers/CrudController.php#L229-L245
226,218
CallFire/CallFire-PHP-SDK
src/CallFire/Api/Rest/Client/Number.php
Number.QueryRegions
public function QueryRegions(Request\QueryRegions $QueryRegions = null) { $uri = $this->getUri('/number/regions', array()); return $this->get($uri, $QueryRegions); }
php
public function QueryRegions(Request\QueryRegions $QueryRegions = null) { $uri = $this->getUri('/number/regions', array()); return $this->get($uri, $QueryRegions); }
[ "public", "function", "QueryRegions", "(", "Request", "\\", "QueryRegions", "$", "QueryRegions", "=", "null", ")", "{", "$", "uri", "=", "$", "this", "->", "getUri", "(", "'/number/regions'", ",", "array", "(", ")", ")", ";", "return", "$", "this", "->", "get", "(", "$", "uri", ",", "$", "QueryRegions", ")", ";", "}" ]
Queries regions for use in subsequent searches and purchase requests Use a know subset of info on a region to query for the full set of info on a region. Example, if you know the city you can query for phone number prefixes, rate-centers, etc... associated with that city. @api @param Request\QueryRegions $QueryRegions = null
[ "Queries", "regions", "for", "use", "in", "subsequent", "searches", "and", "purchase", "requests" ]
7d6d3e1c59d4116e4fadaf57851a2fa127a13f65
https://github.com/CallFire/CallFire-PHP-SDK/blob/7d6d3e1c59d4116e4fadaf57851a2fa127a13f65/src/CallFire/Api/Rest/Client/Number.php#L24-L29
226,219
CallFire/CallFire-PHP-SDK
src/CallFire/Api/Rest/Client/Number.php
Number.QueryNumbers
public function QueryNumbers(Request\QueryNumbers $QueryNumbers = null) { $uri = $this->getUri('/number', array()); return $this->get($uri, $QueryNumbers); }
php
public function QueryNumbers(Request\QueryNumbers $QueryNumbers = null) { $uri = $this->getUri('/number', array()); return $this->get($uri, $QueryNumbers); }
[ "public", "function", "QueryNumbers", "(", "Request", "\\", "QueryNumbers", "$", "QueryNumbers", "=", "null", ")", "{", "$", "uri", "=", "$", "this", "->", "getUri", "(", "'/number'", ",", "array", "(", ")", ")", ";", "return", "$", "this", "->", "get", "(", "$", "uri", ",", "$", "QueryNumbers", ")", ";", "}" ]
Lists numbers owned by your account Search for numbers already purchased and in your account by region info such as prefix, city, state, zipcode, rate center, etc... Returns info on the numbers in your account such as status, lease info, configuration, etc... @api @param Request\QueryNumbers $QueryNumbers = null
[ "Lists", "numbers", "owned", "by", "your", "account" ]
7d6d3e1c59d4116e4fadaf57851a2fa127a13f65
https://github.com/CallFire/CallFire-PHP-SDK/blob/7d6d3e1c59d4116e4fadaf57851a2fa127a13f65/src/CallFire/Api/Rest/Client/Number.php#L41-L46
226,220
CallFire/CallFire-PHP-SDK
src/CallFire/Api/Rest/Client/Number.php
Number.ConfigureNumber
public function ConfigureNumber($Number, Request\ConfigureNumber $ConfigureNumber) { $uri = $this->getUri('/number/%s', array($Number)); return $this->put($uri, $ConfigureNumber); }
php
public function ConfigureNumber($Number, Request\ConfigureNumber $ConfigureNumber) { $uri = $this->getUri('/number/%s', array($Number)); return $this->put($uri, $ConfigureNumber); }
[ "public", "function", "ConfigureNumber", "(", "$", "Number", ",", "Request", "\\", "ConfigureNumber", "$", "ConfigureNumber", ")", "{", "$", "uri", "=", "$", "this", "->", "getUri", "(", "'/number/%s'", ",", "array", "(", "$", "Number", ")", ")", ";", "return", "$", "this", "->", "put", "(", "$", "uri", ",", "$", "ConfigureNumber", ")", ";", "}" ]
Configure a number owned by your account Update number configuration, such as ENABLE / DISABLE or turn call recording on, using 11 diget E.164 format to select number. No response is returned. @api @param string $Number @param Request\ConfigureNumber $ConfigureNumber
[ "Configure", "a", "number", "owned", "by", "your", "account" ]
7d6d3e1c59d4116e4fadaf57851a2fa127a13f65
https://github.com/CallFire/CallFire-PHP-SDK/blob/7d6d3e1c59d4116e4fadaf57851a2fa127a13f65/src/CallFire/Api/Rest/Client/Number.php#L75-L80
226,221
CallFire/CallFire-PHP-SDK
src/CallFire/Api/Rest/Client/Number.php
Number.SearchAvailableNumbers
public function SearchAvailableNumbers(Request\SearchAvailableNumbers $SearchAvailableNumbers = null) { $uri = $this->getUri('/number/search', array()); return $this->get($uri, $SearchAvailableNumbers); }
php
public function SearchAvailableNumbers(Request\SearchAvailableNumbers $SearchAvailableNumbers = null) { $uri = $this->getUri('/number/search', array()); return $this->get($uri, $SearchAvailableNumbers); }
[ "public", "function", "SearchAvailableNumbers", "(", "Request", "\\", "SearchAvailableNumbers", "$", "SearchAvailableNumbers", "=", "null", ")", "{", "$", "uri", "=", "$", "this", "->", "getUri", "(", "'/number/search'", ",", "array", "(", ")", ")", ";", "return", "$", "this", "->", "get", "(", "$", "uri", ",", "$", "SearchAvailableNumbers", ")", ";", "}" ]
Search for new numbers that are available for purchase Find numbers available for purchase using either TollFree = true or by region info, such as prefix, city, zipcode, etc... The max count of numbers to return must also be specified. @api @param Request\SearchAvailableNumbers $SearchAvailableNumbers = null
[ "Search", "for", "new", "numbers", "that", "are", "available", "for", "purchase" ]
7d6d3e1c59d4116e4fadaf57851a2fa127a13f65
https://github.com/CallFire/CallFire-PHP-SDK/blob/7d6d3e1c59d4116e4fadaf57851a2fa127a13f65/src/CallFire/Api/Rest/Client/Number.php#L92-L97
226,222
CallFire/CallFire-PHP-SDK
src/CallFire/Api/Rest/Client/Number.php
Number.QueryKeywords
public function QueryKeywords(Request\QueryKeywords $QueryKeywords = null) { $uri = $this->getUri('/number/keyword', array()); return $this->get($uri, $QueryKeywords); }
php
public function QueryKeywords(Request\QueryKeywords $QueryKeywords = null) { $uri = $this->getUri('/number/keyword', array()); return $this->get($uri, $QueryKeywords); }
[ "public", "function", "QueryKeywords", "(", "Request", "\\", "QueryKeywords", "$", "QueryKeywords", "=", "null", ")", "{", "$", "uri", "=", "$", "this", "->", "getUri", "(", "'/number/keyword'", ",", "array", "(", ")", ")", ";", "return", "$", "this", "->", "get", "(", "$", "uri", ",", "$", "QueryKeywords", ")", ";", "}" ]
Lists keywords owned by your account Get info such as status, lease dates, etc... on keywords owned by your account. @api @param Request\QueryKeywords $QueryKeywords = null
[ "Lists", "keywords", "owned", "by", "your", "account" ]
7d6d3e1c59d4116e4fadaf57851a2fa127a13f65
https://github.com/CallFire/CallFire-PHP-SDK/blob/7d6d3e1c59d4116e4fadaf57851a2fa127a13f65/src/CallFire/Api/Rest/Client/Number.php#L107-L112
226,223
CallFire/CallFire-PHP-SDK
src/CallFire/Api/Rest/Client/Number.php
Number.SearchAvailableKeywords
public function SearchAvailableKeywords(Request\SearchAvailableKeywords $SearchAvailableKeywords = null) { $uri = $this->getUri('/number/keyword/search', array()); return $this->get($uri, $SearchAvailableKeywords); }
php
public function SearchAvailableKeywords(Request\SearchAvailableKeywords $SearchAvailableKeywords = null) { $uri = $this->getUri('/number/keyword/search', array()); return $this->get($uri, $SearchAvailableKeywords); }
[ "public", "function", "SearchAvailableKeywords", "(", "Request", "\\", "SearchAvailableKeywords", "$", "SearchAvailableKeywords", "=", "null", ")", "{", "$", "uri", "=", "$", "this", "->", "getUri", "(", "'/number/keyword/search'", ",", "array", "(", ")", ")", ";", "return", "$", "this", "->", "get", "(", "$", "uri", ",", "$", "SearchAvailableKeywords", ")", ";", "}" ]
Search for keywords available for purchase Supply list of keywords to see if they are available for purchase. If keyword is available for purchase it will be returned in result. If not available then it will not be returned in result. Once available keywords are found they can be purchase using CreateNumberOrder @api @param Request\SearchAvailableKeywords $SearchAvailableKeywords = null
[ "Search", "for", "keywords", "available", "for", "purchase" ]
7d6d3e1c59d4116e4fadaf57851a2fa127a13f65
https://github.com/CallFire/CallFire-PHP-SDK/blob/7d6d3e1c59d4116e4fadaf57851a2fa127a13f65/src/CallFire/Api/Rest/Client/Number.php#L125-L130
226,224
CallFire/CallFire-PHP-SDK
src/CallFire/Api/Rest/Client/Number.php
Number.Release
public function Release(Request\Release $Release = null) { $uri = $this->getUri('/number/release', array()); return $this->put($uri, $Release); }
php
public function Release(Request\Release $Release = null) { $uri = $this->getUri('/number/release', array()); return $this->put($uri, $Release); }
[ "public", "function", "Release", "(", "Request", "\\", "Release", "$", "Release", "=", "null", ")", "{", "$", "uri", "=", "$", "this", "->", "getUri", "(", "'/number/release'", ",", "array", "(", ")", ")", ";", "return", "$", "this", "->", "put", "(", "$", "uri", ",", "$", "Release", ")", ";", "}" ]
Disable auto-renew for a number or keyword CallFire's system automatically "renews" your numbers and keywords each month and bills you accordingly. When you no longer need a number or keyword, you can easily 'Release' it and stop your recurring monthly charge. Once you release a keyword, you will not be able to repurchase it for a month after the release becomes effective. For example, if your keyword is slated to auto-renew for another month on April 29th, and you release it on April 15th, you will still be able to use it until April 29th. However, you will not be able to repurchase it until May 29th. Therefore, please be sure of your decision before releasing. @api @param Request\Release $Release = null
[ "Disable", "auto", "-", "renew", "for", "a", "number", "or", "keyword" ]
7d6d3e1c59d4116e4fadaf57851a2fa127a13f65
https://github.com/CallFire/CallFire-PHP-SDK/blob/7d6d3e1c59d4116e4fadaf57851a2fa127a13f65/src/CallFire/Api/Rest/Client/Number.php#L190-L195
226,225
gjerokrsteski/pimf-framework
core/Pimf/Application.php
Application.bootstrap
public static function bootstrap(array $conf, array $server = array()) { $problems = array(); try { Config::load($conf); $environment = Config::get('environment'); date_default_timezone_set(Config::get('timezone')); self::setupUtils($server, Config::get('bootstrap.local_temp_directory'), Config::get('logging.storage', 'file')); self::loadListeners(BASE_PATH . 'app/' . Config::get('app.name') . '/events.php'); self::setupErrorHandling($environment); self::loadPdoDriver($environment, Config::get($environment . '.db'), Config::get('app.name')); self::loadRoutes( Config::get('app.routeable'), BASE_PATH . 'app/' . Config::get('app.name') . '/routes.php' ); } catch (\Throwable $throwable) { $problems[] = $throwable->getMessage(); } catch (\Exception $exception) { $problems[] = $exception->getMessage(); } self::reportIf($problems, PHP_VERSION); }
php
public static function bootstrap(array $conf, array $server = array()) { $problems = array(); try { Config::load($conf); $environment = Config::get('environment'); date_default_timezone_set(Config::get('timezone')); self::setupUtils($server, Config::get('bootstrap.local_temp_directory'), Config::get('logging.storage', 'file')); self::loadListeners(BASE_PATH . 'app/' . Config::get('app.name') . '/events.php'); self::setupErrorHandling($environment); self::loadPdoDriver($environment, Config::get($environment . '.db'), Config::get('app.name')); self::loadRoutes( Config::get('app.routeable'), BASE_PATH . 'app/' . Config::get('app.name') . '/routes.php' ); } catch (\Throwable $throwable) { $problems[] = $throwable->getMessage(); } catch (\Exception $exception) { $problems[] = $exception->getMessage(); } self::reportIf($problems, PHP_VERSION); }
[ "public", "static", "function", "bootstrap", "(", "array", "$", "conf", ",", "array", "$", "server", "=", "array", "(", ")", ")", "{", "$", "problems", "=", "array", "(", ")", ";", "try", "{", "Config", "::", "load", "(", "$", "conf", ")", ";", "$", "environment", "=", "Config", "::", "get", "(", "'environment'", ")", ";", "date_default_timezone_set", "(", "Config", "::", "get", "(", "'timezone'", ")", ")", ";", "self", "::", "setupUtils", "(", "$", "server", ",", "Config", "::", "get", "(", "'bootstrap.local_temp_directory'", ")", ",", "Config", "::", "get", "(", "'logging.storage'", ",", "'file'", ")", ")", ";", "self", "::", "loadListeners", "(", "BASE_PATH", ".", "'app/'", ".", "Config", "::", "get", "(", "'app.name'", ")", ".", "'/events.php'", ")", ";", "self", "::", "setupErrorHandling", "(", "$", "environment", ")", ";", "self", "::", "loadPdoDriver", "(", "$", "environment", ",", "Config", "::", "get", "(", "$", "environment", ".", "'.db'", ")", ",", "Config", "::", "get", "(", "'app.name'", ")", ")", ";", "self", "::", "loadRoutes", "(", "Config", "::", "get", "(", "'app.routeable'", ")", ",", "BASE_PATH", ".", "'app/'", ".", "Config", "::", "get", "(", "'app.name'", ")", ".", "'/routes.php'", ")", ";", "}", "catch", "(", "\\", "Throwable", "$", "throwable", ")", "{", "$", "problems", "[", "]", "=", "$", "throwable", "->", "getMessage", "(", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "exception", ")", "{", "$", "problems", "[", "]", "=", "$", "exception", "->", "getMessage", "(", ")", ";", "}", "self", "::", "reportIf", "(", "$", "problems", ",", "PHP_VERSION", ")", ";", "}" ]
Mechanism used to do initial setup and edging before a application runs. @param array $conf The array of configuration options. @param array $server Array of information such as headers, paths, and script locations. @return boolean|null
[ "Mechanism", "used", "to", "do", "initial", "setup", "and", "edging", "before", "a", "application", "runs", "." ]
859aa7c8bb727b556c5e32224842af3cff33f18b
https://github.com/gjerokrsteski/pimf-framework/blob/859aa7c8bb727b556c5e32224842af3cff33f18b/core/Pimf/Application.php#L53-L81
226,226
vinkla/laravel-backup
src/ProfileRegistryFactory.php
ProfileRegistryFactory.make
public function make(array $config): ProfileRegistry { $config = $this->getConfig($config); return $this->getProfileRegistry($config); }
php
public function make(array $config): ProfileRegistry { $config = $this->getConfig($config); return $this->getProfileRegistry($config); }
[ "public", "function", "make", "(", "array", "$", "config", ")", ":", "ProfileRegistry", "{", "$", "config", "=", "$", "this", "->", "getConfig", "(", "$", "config", ")", ";", "return", "$", "this", "->", "getProfileRegistry", "(", "$", "config", ")", ";", "}" ]
Make the profile registry. @param array $config @return \Zenstruck\Backup\ProfileRegistry
[ "Make", "the", "profile", "registry", "." ]
d3662b6509a39bce9cd75cc3e65b4ea01be46b26
https://github.com/vinkla/laravel-backup/blob/d3662b6509a39bce9cd75cc3e65b4ea01be46b26/src/ProfileRegistryFactory.php#L53-L58
226,227
vinkla/laravel-backup
src/ProfileRegistryFactory.php
ProfileRegistryFactory.getProfileRegistry
protected function getProfileRegistry(array $config): ProfileRegistry { $registry = new ProfileRegistry(); foreach (array_get($config, 'profiles') as $name => $profile) { $profile = $this->builder->create( $name, array_get($profile, 'scratch_dir', storage_path('backups')), array_get($profile, 'processor'), array_get($profile, 'namer'), array_get($profile, 'sources'), array_get($profile, 'destinations') ); $registry->add($profile); } return $registry; }
php
protected function getProfileRegistry(array $config): ProfileRegistry { $registry = new ProfileRegistry(); foreach (array_get($config, 'profiles') as $name => $profile) { $profile = $this->builder->create( $name, array_get($profile, 'scratch_dir', storage_path('backups')), array_get($profile, 'processor'), array_get($profile, 'namer'), array_get($profile, 'sources'), array_get($profile, 'destinations') ); $registry->add($profile); } return $registry; }
[ "protected", "function", "getProfileRegistry", "(", "array", "$", "config", ")", ":", "ProfileRegistry", "{", "$", "registry", "=", "new", "ProfileRegistry", "(", ")", ";", "foreach", "(", "array_get", "(", "$", "config", ",", "'profiles'", ")", "as", "$", "name", "=>", "$", "profile", ")", "{", "$", "profile", "=", "$", "this", "->", "builder", "->", "create", "(", "$", "name", ",", "array_get", "(", "$", "profile", ",", "'scratch_dir'", ",", "storage_path", "(", "'backups'", ")", ")", ",", "array_get", "(", "$", "profile", ",", "'processor'", ")", ",", "array_get", "(", "$", "profile", ",", "'namer'", ")", ",", "array_get", "(", "$", "profile", ",", "'sources'", ")", ",", "array_get", "(", "$", "profile", ",", "'destinations'", ")", ")", ";", "$", "registry", "->", "add", "(", "$", "profile", ")", ";", "}", "return", "$", "registry", ";", "}" ]
Get the profile registry. @param array $config @return \Zenstruck\Backup\ProfileRegistry
[ "Get", "the", "profile", "registry", "." ]
d3662b6509a39bce9cd75cc3e65b4ea01be46b26
https://github.com/vinkla/laravel-backup/blob/d3662b6509a39bce9cd75cc3e65b4ea01be46b26/src/ProfileRegistryFactory.php#L95-L113
226,228
gjerokrsteski/pimf-framework
core/Pimf/Session/Storages/Pdo.php
Pdo.load
public function load($key) { try { $sth = $this->pdo->prepare( 'SELECT * FROM sessions WHERE id = :id' ); $sth->bindValue(':id', $key, \PDO::PARAM_INT); $sth->execute(); $session = $sth->fetchObject(); if ($session instanceof \stdClass) { return array( 'id' => $session->id, 'last_activity' => $session->last_activity, 'data' => unserialize($session->data) ); } return null; } catch (\PDOException $pdoe) { return null; } }
php
public function load($key) { try { $sth = $this->pdo->prepare( 'SELECT * FROM sessions WHERE id = :id' ); $sth->bindValue(':id', $key, \PDO::PARAM_INT); $sth->execute(); $session = $sth->fetchObject(); if ($session instanceof \stdClass) { return array( 'id' => $session->id, 'last_activity' => $session->last_activity, 'data' => unserialize($session->data) ); } return null; } catch (\PDOException $pdoe) { return null; } }
[ "public", "function", "load", "(", "$", "key", ")", "{", "try", "{", "$", "sth", "=", "$", "this", "->", "pdo", "->", "prepare", "(", "'SELECT * FROM sessions WHERE id = :id'", ")", ";", "$", "sth", "->", "bindValue", "(", "':id'", ",", "$", "key", ",", "\\", "PDO", "::", "PARAM_INT", ")", ";", "$", "sth", "->", "execute", "(", ")", ";", "$", "session", "=", "$", "sth", "->", "fetchObject", "(", ")", ";", "if", "(", "$", "session", "instanceof", "\\", "stdClass", ")", "{", "return", "array", "(", "'id'", "=>", "$", "session", "->", "id", ",", "'last_activity'", "=>", "$", "session", "->", "last_activity", ",", "'data'", "=>", "unserialize", "(", "$", "session", "->", "data", ")", ")", ";", "}", "return", "null", ";", "}", "catch", "(", "\\", "PDOException", "$", "pdoe", ")", "{", "return", "null", ";", "}", "}" ]
Load a session from storage by a given ID. If no session is found for the ID, null will be returned. @param string $key @return array|null
[ "Load", "a", "session", "from", "storage", "by", "a", "given", "ID", ".", "If", "no", "session", "is", "found", "for", "the", "ID", "null", "will", "be", "returned", "." ]
859aa7c8bb727b556c5e32224842af3cff33f18b
https://github.com/gjerokrsteski/pimf-framework/blob/859aa7c8bb727b556c5e32224842af3cff33f18b/core/Pimf/Session/Storages/Pdo.php#L40-L64
226,229
gjerokrsteski/pimf-framework
core/Pimf/Session/Storages/Pdo.php
Pdo.delete
public function delete($key) { $sth = $this->pdo->prepare( "DELETE FROM sessions WHERE id = :id" ); $sth->bindValue(':id', $key, \PDO::PARAM_INT); $sth->execute(); }
php
public function delete($key) { $sth = $this->pdo->prepare( "DELETE FROM sessions WHERE id = :id" ); $sth->bindValue(':id', $key, \PDO::PARAM_INT); $sth->execute(); }
[ "public", "function", "delete", "(", "$", "key", ")", "{", "$", "sth", "=", "$", "this", "->", "pdo", "->", "prepare", "(", "\"DELETE FROM sessions WHERE id = :id\"", ")", ";", "$", "sth", "->", "bindValue", "(", "':id'", ",", "$", "key", ",", "\\", "PDO", "::", "PARAM_INT", ")", ";", "$", "sth", "->", "execute", "(", ")", ";", "}" ]
Delete a session from storage by a given ID. @param string $key
[ "Delete", "a", "session", "from", "storage", "by", "a", "given", "ID", "." ]
859aa7c8bb727b556c5e32224842af3cff33f18b
https://github.com/gjerokrsteski/pimf-framework/blob/859aa7c8bb727b556c5e32224842af3cff33f18b/core/Pimf/Session/Storages/Pdo.php#L96-L104
226,230
frictionlessdata/datapackage-php
src/Factory.php
Factory.resource
public static function resource($descriptor, $basePath = null, $skipValidations = false) { $resourceClass = static::getResourceClass($descriptor); $resource = new $resourceClass($descriptor, $basePath, $skipValidations); return $resource; }
php
public static function resource($descriptor, $basePath = null, $skipValidations = false) { $resourceClass = static::getResourceClass($descriptor); $resource = new $resourceClass($descriptor, $basePath, $skipValidations); return $resource; }
[ "public", "static", "function", "resource", "(", "$", "descriptor", ",", "$", "basePath", "=", "null", ",", "$", "skipValidations", "=", "false", ")", "{", "$", "resourceClass", "=", "static", "::", "getResourceClass", "(", "$", "descriptor", ")", ";", "$", "resource", "=", "new", "$", "resourceClass", "(", "$", "descriptor", ",", "$", "basePath", ",", "$", "skipValidations", ")", ";", "return", "$", "resource", ";", "}" ]
create a resource object. @param object $descriptor @param null|string $basePath @param bool $skipValidations @return Resources\BaseResource @throws Exceptions\ResourceValidationFailedException
[ "create", "a", "resource", "object", "." ]
e745c21c1e9b11734964909275cfb4688004f07a
https://github.com/frictionlessdata/datapackage-php/blob/e745c21c1e9b11734964909275cfb4688004f07a/src/Factory.php#L59-L65
226,231
frictionlessdata/datapackage-php
src/Factory.php
Factory.validate
public static function validate($source, $basePath = null) { $curResource = 1; $curLine = null; try { $datapackage = static::datapackage($source, $basePath); foreach ($datapackage as $resource) { $curLine = 1; foreach ($resource as $line) { if ($curLine == self::VALIDATE_PEEK_LINES) { break; } ++$curLine; } ++$curResource; } // no validation errors return []; } catch (Exceptions\DatapackageInvalidSourceException $e) { // failed to load the datapackage descriptor // return a list containing a single LOAD_FAILED validation error return [ new Validators\DatapackageValidationError( Validators\DatapackageValidationError::LOAD_FAILED, $e->getMessage() ), ]; } catch (Exceptions\DatapackageValidationFailedException $e) { // datapackage descriptor failed validation - return the validation errors return $e->validationErrors; } catch (Exceptions\ResourceValidationFailedException $e) { // resource descriptor failed validation - return the validation errors return [ new Validators\DatapackageValidationError( Validators\DatapackageValidationError::RESOURCE_FAILED_VALIDATION, [ 'resource' => $curResource, 'validationErrors' => $e->validationErrors, ] ), ]; } catch (Exceptions\DataStreamOpenException $e) { // failed to open data stream return [ new Validators\DatapackageValidationError( Validators\DatapackageValidationError::DATA_STREAM_FAILURE, [ 'resource' => $curResource, 'line' => 0, 'error' => $e->getMessage(), ] ), ]; } catch (Exceptions\DataStreamValidationException $e) { // failed to validate the data stream return [ new Validators\DatapackageValidationError( Validators\DatapackageValidationError::DATA_STREAM_FAILURE, [ 'resource' => $curResource, 'line' => $curLine, 'error' => $e->getMessage(), ] ), ]; } }
php
public static function validate($source, $basePath = null) { $curResource = 1; $curLine = null; try { $datapackage = static::datapackage($source, $basePath); foreach ($datapackage as $resource) { $curLine = 1; foreach ($resource as $line) { if ($curLine == self::VALIDATE_PEEK_LINES) { break; } ++$curLine; } ++$curResource; } // no validation errors return []; } catch (Exceptions\DatapackageInvalidSourceException $e) { // failed to load the datapackage descriptor // return a list containing a single LOAD_FAILED validation error return [ new Validators\DatapackageValidationError( Validators\DatapackageValidationError::LOAD_FAILED, $e->getMessage() ), ]; } catch (Exceptions\DatapackageValidationFailedException $e) { // datapackage descriptor failed validation - return the validation errors return $e->validationErrors; } catch (Exceptions\ResourceValidationFailedException $e) { // resource descriptor failed validation - return the validation errors return [ new Validators\DatapackageValidationError( Validators\DatapackageValidationError::RESOURCE_FAILED_VALIDATION, [ 'resource' => $curResource, 'validationErrors' => $e->validationErrors, ] ), ]; } catch (Exceptions\DataStreamOpenException $e) { // failed to open data stream return [ new Validators\DatapackageValidationError( Validators\DatapackageValidationError::DATA_STREAM_FAILURE, [ 'resource' => $curResource, 'line' => 0, 'error' => $e->getMessage(), ] ), ]; } catch (Exceptions\DataStreamValidationException $e) { // failed to validate the data stream return [ new Validators\DatapackageValidationError( Validators\DatapackageValidationError::DATA_STREAM_FAILURE, [ 'resource' => $curResource, 'line' => $curLine, 'error' => $e->getMessage(), ] ), ]; } }
[ "public", "static", "function", "validate", "(", "$", "source", ",", "$", "basePath", "=", "null", ")", "{", "$", "curResource", "=", "1", ";", "$", "curLine", "=", "null", ";", "try", "{", "$", "datapackage", "=", "static", "::", "datapackage", "(", "$", "source", ",", "$", "basePath", ")", ";", "foreach", "(", "$", "datapackage", "as", "$", "resource", ")", "{", "$", "curLine", "=", "1", ";", "foreach", "(", "$", "resource", "as", "$", "line", ")", "{", "if", "(", "$", "curLine", "==", "self", "::", "VALIDATE_PEEK_LINES", ")", "{", "break", ";", "}", "++", "$", "curLine", ";", "}", "++", "$", "curResource", ";", "}", "// no validation errors", "return", "[", "]", ";", "}", "catch", "(", "Exceptions", "\\", "DatapackageInvalidSourceException", "$", "e", ")", "{", "// failed to load the datapackage descriptor", "// return a list containing a single LOAD_FAILED validation error", "return", "[", "new", "Validators", "\\", "DatapackageValidationError", "(", "Validators", "\\", "DatapackageValidationError", "::", "LOAD_FAILED", ",", "$", "e", "->", "getMessage", "(", ")", ")", ",", "]", ";", "}", "catch", "(", "Exceptions", "\\", "DatapackageValidationFailedException", "$", "e", ")", "{", "// datapackage descriptor failed validation - return the validation errors", "return", "$", "e", "->", "validationErrors", ";", "}", "catch", "(", "Exceptions", "\\", "ResourceValidationFailedException", "$", "e", ")", "{", "// resource descriptor failed validation - return the validation errors", "return", "[", "new", "Validators", "\\", "DatapackageValidationError", "(", "Validators", "\\", "DatapackageValidationError", "::", "RESOURCE_FAILED_VALIDATION", ",", "[", "'resource'", "=>", "$", "curResource", ",", "'validationErrors'", "=>", "$", "e", "->", "validationErrors", ",", "]", ")", ",", "]", ";", "}", "catch", "(", "Exceptions", "\\", "DataStreamOpenException", "$", "e", ")", "{", "// failed to open data stream", "return", "[", "new", "Validators", "\\", "DatapackageValidationError", "(", "Validators", "\\", "DatapackageValidationError", "::", "DATA_STREAM_FAILURE", ",", "[", "'resource'", "=>", "$", "curResource", ",", "'line'", "=>", "0", ",", "'error'", "=>", "$", "e", "->", "getMessage", "(", ")", ",", "]", ")", ",", "]", ";", "}", "catch", "(", "Exceptions", "\\", "DataStreamValidationException", "$", "e", ")", "{", "// failed to validate the data stream", "return", "[", "new", "Validators", "\\", "DatapackageValidationError", "(", "Validators", "\\", "DatapackageValidationError", "::", "DATA_STREAM_FAILURE", ",", "[", "'resource'", "=>", "$", "curResource", ",", "'line'", "=>", "$", "curLine", ",", "'error'", "=>", "$", "e", "->", "getMessage", "(", ")", ",", "]", ")", ",", "]", ";", "}", "}" ]
validates a given datapackage descriptor will load all resources, and sample 10 lines of data from each data source. @param mixed $source datapackage source - same as in datapackage function @param null|string $basePath same as in datapackage function @return Validators\DatapackageValidationError[]
[ "validates", "a", "given", "datapackage", "descriptor", "will", "load", "all", "resources", "and", "sample", "10", "lines", "of", "data", "from", "each", "data", "source", "." ]
e745c21c1e9b11734964909275cfb4688004f07a
https://github.com/frictionlessdata/datapackage-php/blob/e745c21c1e9b11734964909275cfb4688004f07a/src/Factory.php#L76-L141
226,232
gjerokrsteski/pimf-framework
core/Pimf/Error.php
Error.exception
public static function exception(\Exception $exception, Logger $logger, $exit = true) { static::log($exception, $logger); ob_get_length() > 0 && ob_get_level() && ob_end_clean(); if (Config::get('error.debug_info') === true) { echo static::format($exception, Sapi::isCli()); if ($exit) { exit; } } if ($exception instanceof \Pimf\Controller\Exception || $exception instanceof \Pimf\Resolver\Exception ) { Event::first('404', array($exception)); Header::sendNotFound(null, $exit); } else { Event::first('500', array($exception)); Header::sendInternalServerError(null, $exit); } }
php
public static function exception(\Exception $exception, Logger $logger, $exit = true) { static::log($exception, $logger); ob_get_length() > 0 && ob_get_level() && ob_end_clean(); if (Config::get('error.debug_info') === true) { echo static::format($exception, Sapi::isCli()); if ($exit) { exit; } } if ($exception instanceof \Pimf\Controller\Exception || $exception instanceof \Pimf\Resolver\Exception ) { Event::first('404', array($exception)); Header::sendNotFound(null, $exit); } else { Event::first('500', array($exception)); Header::sendInternalServerError(null, $exit); } }
[ "public", "static", "function", "exception", "(", "\\", "Exception", "$", "exception", ",", "Logger", "$", "logger", ",", "$", "exit", "=", "true", ")", "{", "static", "::", "log", "(", "$", "exception", ",", "$", "logger", ")", ";", "ob_get_length", "(", ")", ">", "0", "&&", "ob_get_level", "(", ")", "&&", "ob_end_clean", "(", ")", ";", "if", "(", "Config", "::", "get", "(", "'error.debug_info'", ")", "===", "true", ")", "{", "echo", "static", "::", "format", "(", "$", "exception", ",", "Sapi", "::", "isCli", "(", ")", ")", ";", "if", "(", "$", "exit", ")", "{", "exit", ";", "}", "}", "if", "(", "$", "exception", "instanceof", "\\", "Pimf", "\\", "Controller", "\\", "Exception", "||", "$", "exception", "instanceof", "\\", "Pimf", "\\", "Resolver", "\\", "Exception", ")", "{", "Event", "::", "first", "(", "'404'", ",", "array", "(", "$", "exception", ")", ")", ";", "Header", "::", "sendNotFound", "(", "null", ",", "$", "exit", ")", ";", "}", "else", "{", "Event", "::", "first", "(", "'500'", ",", "array", "(", "$", "exception", ")", ")", ";", "Header", "::", "sendInternalServerError", "(", "null", ",", "$", "exit", ")", ";", "}", "}" ]
Handle an exception and display the exception report. @param \Exception $exception @param Logger $logger @param boolean $exit
[ "Handle", "an", "exception", "and", "display", "the", "exception", "report", "." ]
859aa7c8bb727b556c5e32224842af3cff33f18b
https://github.com/gjerokrsteski/pimf-framework/blob/859aa7c8bb727b556c5e32224842af3cff33f18b/core/Pimf/Error.php#L29-L51
226,233
gjerokrsteski/pimf-framework
core/Pimf/Error.php
Error.format
public static function format(\Exception $exception, $isCli = false) { if ($isCli === true) { return "+++ Untreated Exception +++" . PHP_EOL . "Message: " . $exception->getMessage() . PHP_EOL . "Location: " . $exception->getFile() . " on line " . $exception->getLine() . PHP_EOL . "Stack Trace: " . PHP_EOL . $exception->getTraceAsString() . PHP_EOL; } return "<html> <head> <style> pre { display: block; padding: 8.5px; margin: 0 0 9px; line-height: 18px; word-break: break-all; word-wrap: break-word; white-space: pre; white-space: pre-wrap; border: 1px solid #ccc; border: 1px solid rgba(0, 0, 0, 0.15); -webkit-border-radius: 4px; -moz-border-radius: 4px; border-radius: 6px; color: chartreuse; background-color: black; } </style> </head> <h2>Untreated Exception</h2> <h3>Message:</h3> <pre>" . $exception->getMessage() . "</pre> <h3>Location:</h3> <pre>" . $exception->getFile() . " on line " . $exception->getLine() . "</pre> <h3>Stack Trace:</h3> <pre>" . $exception->getTraceAsString() . "</pre></html>"; }
php
public static function format(\Exception $exception, $isCli = false) { if ($isCli === true) { return "+++ Untreated Exception +++" . PHP_EOL . "Message: " . $exception->getMessage() . PHP_EOL . "Location: " . $exception->getFile() . " on line " . $exception->getLine() . PHP_EOL . "Stack Trace: " . PHP_EOL . $exception->getTraceAsString() . PHP_EOL; } return "<html> <head> <style> pre { display: block; padding: 8.5px; margin: 0 0 9px; line-height: 18px; word-break: break-all; word-wrap: break-word; white-space: pre; white-space: pre-wrap; border: 1px solid #ccc; border: 1px solid rgba(0, 0, 0, 0.15); -webkit-border-radius: 4px; -moz-border-radius: 4px; border-radius: 6px; color: chartreuse; background-color: black; } </style> </head> <h2>Untreated Exception</h2> <h3>Message:</h3> <pre>" . $exception->getMessage() . "</pre> <h3>Location:</h3> <pre>" . $exception->getFile() . " on line " . $exception->getLine() . "</pre> <h3>Stack Trace:</h3> <pre>" . $exception->getTraceAsString() . "</pre></html>"; }
[ "public", "static", "function", "format", "(", "\\", "Exception", "$", "exception", ",", "$", "isCli", "=", "false", ")", "{", "if", "(", "$", "isCli", "===", "true", ")", "{", "return", "\"+++ Untreated Exception +++\"", ".", "PHP_EOL", ".", "\"Message: \"", ".", "$", "exception", "->", "getMessage", "(", ")", ".", "PHP_EOL", ".", "\"Location: \"", ".", "$", "exception", "->", "getFile", "(", ")", ".", "\" on line \"", ".", "$", "exception", "->", "getLine", "(", ")", ".", "PHP_EOL", ".", "\"Stack Trace: \"", ".", "PHP_EOL", ".", "$", "exception", "->", "getTraceAsString", "(", ")", ".", "PHP_EOL", ";", "}", "return", "\"<html>\n <head>\n <style>\n pre { display: block;\n padding: 8.5px;\n margin: 0 0 9px;\n line-height: 18px;\n word-break: break-all;\n word-wrap: break-word;\n white-space: pre;\n white-space: pre-wrap;\n border: 1px solid #ccc;\n border: 1px solid rgba(0, 0, 0, 0.15);\n -webkit-border-radius: 4px;\n -moz-border-radius: 4px;\n border-radius: 6px;\n color: chartreuse;\n background-color: black;\n }\n </style>\n </head>\n <h2>Untreated Exception</h2>\n <h3>Message:</h3>\n <pre>\"", ".", "$", "exception", "->", "getMessage", "(", ")", ".", "\"</pre>\n <h3>Location:</h3>\n <pre>\"", ".", "$", "exception", "->", "getFile", "(", ")", ".", "\" on line \"", ".", "$", "exception", "->", "getLine", "(", ")", ".", "\"</pre>\n <h3>Stack Trace:</h3>\n <pre>\"", ".", "$", "exception", "->", "getTraceAsString", "(", ")", ".", "\"</pre></html>\"", ";", "}" ]
If detailed errors are enabled, just format the exception into a simple error message and display it. @param \Exception $exception @param boolean $isCli @return string
[ "If", "detailed", "errors", "are", "enabled", "just", "format", "the", "exception", "into", "a", "simple", "error", "message", "and", "display", "it", "." ]
859aa7c8bb727b556c5e32224842af3cff33f18b
https://github.com/gjerokrsteski/pimf-framework/blob/859aa7c8bb727b556c5e32224842af3cff33f18b/core/Pimf/Error.php#L62-L98
226,234
gjerokrsteski/pimf-framework
core/Pimf/Error.php
Error.native
public static function native($code, $error, $file, $line, Logger $logger, $reporting, $exit = true) { if ($reporting === 0) { return; } // create an ErrorException for the PHP error $exception = new \ErrorException($error, $code, 0, $file, $line); if (in_array($code, (array)Config::get('error.ignore_levels'))) { return static::log($exception, $logger); } // display the ErrorException static::exception($exception, $logger, $exit); }
php
public static function native($code, $error, $file, $line, Logger $logger, $reporting, $exit = true) { if ($reporting === 0) { return; } // create an ErrorException for the PHP error $exception = new \ErrorException($error, $code, 0, $file, $line); if (in_array($code, (array)Config::get('error.ignore_levels'))) { return static::log($exception, $logger); } // display the ErrorException static::exception($exception, $logger, $exit); }
[ "public", "static", "function", "native", "(", "$", "code", ",", "$", "error", ",", "$", "file", ",", "$", "line", ",", "Logger", "$", "logger", ",", "$", "reporting", ",", "$", "exit", "=", "true", ")", "{", "if", "(", "$", "reporting", "===", "0", ")", "{", "return", ";", "}", "// create an ErrorException for the PHP error", "$", "exception", "=", "new", "\\", "ErrorException", "(", "$", "error", ",", "$", "code", ",", "0", ",", "$", "file", ",", "$", "line", ")", ";", "if", "(", "in_array", "(", "$", "code", ",", "(", "array", ")", "Config", "::", "get", "(", "'error.ignore_levels'", ")", ")", ")", "{", "return", "static", "::", "log", "(", "$", "exception", ",", "$", "logger", ")", ";", "}", "// display the ErrorException", "static", "::", "exception", "(", "$", "exception", ",", "$", "logger", ",", "$", "exit", ")", ";", "}" ]
Handle a native PHP error as an ErrorException. @param int $code @param string $error @param string $file @param int $line @param Logger $logger @param array|int $reporting which PHP errors are reported @param boolean $exit
[ "Handle", "a", "native", "PHP", "error", "as", "an", "ErrorException", "." ]
859aa7c8bb727b556c5e32224842af3cff33f18b
https://github.com/gjerokrsteski/pimf-framework/blob/859aa7c8bb727b556c5e32224842af3cff33f18b/core/Pimf/Error.php#L111-L126
226,235
crip-laravel/filesys
src/App/Controllers/FolderController.php
FolderController.store
public function store(Request $request) { $this->manager->resetPath($request->folder); if (empty($request->name)) { return $this->json('Name property is required.', 422); } if (!$this->manager->blobExists()) { return $this->json('Folder not found.', 404); } $result = $this->manager->makeDirectory($request->name)->fullDetails(); return $this->json($result); }
php
public function store(Request $request) { $this->manager->resetPath($request->folder); if (empty($request->name)) { return $this->json('Name property is required.', 422); } if (!$this->manager->blobExists()) { return $this->json('Folder not found.', 404); } $result = $this->manager->makeDirectory($request->name)->fullDetails(); return $this->json($result); }
[ "public", "function", "store", "(", "Request", "$", "request", ")", "{", "$", "this", "->", "manager", "->", "resetPath", "(", "$", "request", "->", "folder", ")", ";", "if", "(", "empty", "(", "$", "request", "->", "name", ")", ")", "{", "return", "$", "this", "->", "json", "(", "'Name property is required.'", ",", "422", ")", ";", "}", "if", "(", "!", "$", "this", "->", "manager", "->", "blobExists", "(", ")", ")", "{", "return", "$", "this", "->", "json", "(", "'Folder not found.'", ",", "404", ")", ";", "}", "$", "result", "=", "$", "this", "->", "manager", "->", "makeDirectory", "(", "$", "request", "->", "name", ")", "->", "fullDetails", "(", ")", ";", "return", "$", "this", "->", "json", "(", "$", "result", ")", ";", "}" ]
Create new sub folder @param Request $request @return JsonResponse
[ "Create", "new", "sub", "folder" ]
43c66929a5a16772dbb3bae4b5188bdc10b6f9ec
https://github.com/crip-laravel/filesys/blob/43c66929a5a16772dbb3bae4b5188bdc10b6f9ec/src/App/Controllers/FolderController.php#L26-L41
226,236
crip-laravel/filesys
src/App/Controllers/FolderController.php
FolderController.show
public function show($folder) { $this->manager->resetPath($folder); if (!$this->manager->blobExists()) { return $this->json('File not found.', 404); } $list = $this->manager->folderContent(); return $this->json($list); }
php
public function show($folder) { $this->manager->resetPath($folder); if (!$this->manager->blobExists()) { return $this->json('File not found.', 404); } $list = $this->manager->folderContent(); return $this->json($list); }
[ "public", "function", "show", "(", "$", "folder", ")", "{", "$", "this", "->", "manager", "->", "resetPath", "(", "$", "folder", ")", ";", "if", "(", "!", "$", "this", "->", "manager", "->", "blobExists", "(", ")", ")", "{", "return", "$", "this", "->", "json", "(", "'File not found.'", ",", "404", ")", ";", "}", "$", "list", "=", "$", "this", "->", "manager", "->", "folderContent", "(", ")", ";", "return", "$", "this", "->", "json", "(", "$", "list", ")", ";", "}" ]
List folder content @param string $folder @return JsonResponse
[ "List", "folder", "content" ]
43c66929a5a16772dbb3bae4b5188bdc10b6f9ec
https://github.com/crip-laravel/filesys/blob/43c66929a5a16772dbb3bae4b5188bdc10b6f9ec/src/App/Controllers/FolderController.php#L48-L59
226,237
crip-laravel/filesys
src/App/Controllers/FolderController.php
FolderController.update
public function update(Request $request, string $folder = '') { if (empty($request->name)) { return $this->json('Name property is required.', 422); } $this->manager->resetPath($folder); if (!$this->manager->blobExists()) { return $this->json('Folder not found.', 404); } $details = $this->manager->rename($request->name); return $this->json($details); }
php
public function update(Request $request, string $folder = '') { if (empty($request->name)) { return $this->json('Name property is required.', 422); } $this->manager->resetPath($folder); if (!$this->manager->blobExists()) { return $this->json('Folder not found.', 404); } $details = $this->manager->rename($request->name); return $this->json($details); }
[ "public", "function", "update", "(", "Request", "$", "request", ",", "string", "$", "folder", "=", "''", ")", "{", "if", "(", "empty", "(", "$", "request", "->", "name", ")", ")", "{", "return", "$", "this", "->", "json", "(", "'Name property is required.'", ",", "422", ")", ";", "}", "$", "this", "->", "manager", "->", "resetPath", "(", "$", "folder", ")", ";", "if", "(", "!", "$", "this", "->", "manager", "->", "blobExists", "(", ")", ")", "{", "return", "$", "this", "->", "json", "(", "'Folder not found.'", ",", "404", ")", ";", "}", "$", "details", "=", "$", "this", "->", "manager", "->", "rename", "(", "$", "request", "->", "name", ")", ";", "return", "$", "this", "->", "json", "(", "$", "details", ")", ";", "}" ]
Rename folder name @param Request $request @param string $folder @return JsonResponse
[ "Rename", "folder", "name" ]
43c66929a5a16772dbb3bae4b5188bdc10b6f9ec
https://github.com/crip-laravel/filesys/blob/43c66929a5a16772dbb3bae4b5188bdc10b6f9ec/src/App/Controllers/FolderController.php#L67-L82
226,238
gjerokrsteski/pimf-framework
core/Pimf/Memcached.php
Memcached.connect
protected static function connect(array $servers, $memcache = null) { if (!$memcache) { $memcache = new \Memcached(); } foreach ($servers as $server) { $memcache->addServer($server['host'], $server['port'], $server['weight']); } if ($memcache->getVersion() === false) { throw new \RuntimeException('could not establish memcached connection!'); } return $memcache; }
php
protected static function connect(array $servers, $memcache = null) { if (!$memcache) { $memcache = new \Memcached(); } foreach ($servers as $server) { $memcache->addServer($server['host'], $server['port'], $server['weight']); } if ($memcache->getVersion() === false) { throw new \RuntimeException('could not establish memcached connection!'); } return $memcache; }
[ "protected", "static", "function", "connect", "(", "array", "$", "servers", ",", "$", "memcache", "=", "null", ")", "{", "if", "(", "!", "$", "memcache", ")", "{", "$", "memcache", "=", "new", "\\", "Memcached", "(", ")", ";", "}", "foreach", "(", "$", "servers", "as", "$", "server", ")", "{", "$", "memcache", "->", "addServer", "(", "$", "server", "[", "'host'", "]", ",", "$", "server", "[", "'port'", "]", ",", "$", "server", "[", "'weight'", "]", ")", ";", "}", "if", "(", "$", "memcache", "->", "getVersion", "(", ")", "===", "false", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "'could not establish memcached connection!'", ")", ";", "}", "return", "$", "memcache", ";", "}" ]
Create a new Memcached connection instance. @param array $servers @param null $memcache @return \Memcached|null @throws \RuntimeException
[ "Create", "a", "new", "Memcached", "connection", "instance", "." ]
859aa7c8bb727b556c5e32224842af3cff33f18b
https://github.com/gjerokrsteski/pimf-framework/blob/859aa7c8bb727b556c5e32224842af3cff33f18b/core/Pimf/Memcached.php#L80-L95
226,239
mlanin/laravel-setup-wizard
src/Commands/Steps/AbstractStep.php
AbstractStep.run
public function run($pretend = false) { $results = $this->prepare(); $this->preview($results); if ($this->command->confirm('Everything is right?')) { $return = $pretend ? true : $this->finish($results); if ($return === false) { $return = $this->repeat(); } } else { $return = $this->repeat(); } return $return; }
php
public function run($pretend = false) { $results = $this->prepare(); $this->preview($results); if ($this->command->confirm('Everything is right?')) { $return = $pretend ? true : $this->finish($results); if ($return === false) { $return = $this->repeat(); } } else { $return = $this->repeat(); } return $return; }
[ "public", "function", "run", "(", "$", "pretend", "=", "false", ")", "{", "$", "results", "=", "$", "this", "->", "prepare", "(", ")", ";", "$", "this", "->", "preview", "(", "$", "results", ")", ";", "if", "(", "$", "this", "->", "command", "->", "confirm", "(", "'Everything is right?'", ")", ")", "{", "$", "return", "=", "$", "pretend", "?", "true", ":", "$", "this", "->", "finish", "(", "$", "results", ")", ";", "if", "(", "$", "return", "===", "false", ")", "{", "$", "return", "=", "$", "this", "->", "repeat", "(", ")", ";", "}", "}", "else", "{", "$", "return", "=", "$", "this", "->", "repeat", "(", ")", ";", "}", "return", "$", "return", ";", "}" ]
Run step. @param bool $pretend @return mixed
[ "Run", "step", "." ]
b2614612f92861af434e70b0fe070f6167a71e33
https://github.com/mlanin/laravel-setup-wizard/blob/b2614612f92861af434e70b0fe070f6167a71e33/src/Commands/Steps/AbstractStep.php#L35-L56
226,240
mlanin/laravel-setup-wizard
src/Commands/Steps/AbstractStep.php
AbstractStep.repeat
public function repeat() { if ($this->repeats > self::REPEATS) { return false; } if ($this->command->confirm('Do you want to repeat step?')) { $this->repeats++; return $this->run(); } return false; }
php
public function repeat() { if ($this->repeats > self::REPEATS) { return false; } if ($this->command->confirm('Do you want to repeat step?')) { $this->repeats++; return $this->run(); } return false; }
[ "public", "function", "repeat", "(", ")", "{", "if", "(", "$", "this", "->", "repeats", ">", "self", "::", "REPEATS", ")", "{", "return", "false", ";", "}", "if", "(", "$", "this", "->", "command", "->", "confirm", "(", "'Do you want to repeat step?'", ")", ")", "{", "$", "this", "->", "repeats", "++", ";", "return", "$", "this", "->", "run", "(", ")", ";", "}", "return", "false", ";", "}" ]
Repeat step. @return bool
[ "Repeat", "step", "." ]
b2614612f92861af434e70b0fe070f6167a71e33
https://github.com/mlanin/laravel-setup-wizard/blob/b2614612f92861af434e70b0fe070f6167a71e33/src/Commands/Steps/AbstractStep.php#L63-L78
226,241
Techworker/ssml
src/SsmlBuilder.php
SsmlBuilder.toDOM
public static function toDOM(BaseElement $element): \DOMDocument { $doc = new \DOMDocument('1.0', 'utf-8'); $doc->appendChild($element->toDOM($doc)); return $doc; }
php
public static function toDOM(BaseElement $element): \DOMDocument { $doc = new \DOMDocument('1.0', 'utf-8'); $doc->appendChild($element->toDOM($doc)); return $doc; }
[ "public", "static", "function", "toDOM", "(", "BaseElement", "$", "element", ")", ":", "\\", "DOMDocument", "{", "$", "doc", "=", "new", "\\", "DOMDocument", "(", "'1.0'", ",", "'utf-8'", ")", ";", "$", "doc", "->", "appendChild", "(", "$", "element", "->", "toDOM", "(", "$", "doc", ")", ")", ";", "return", "$", "doc", ";", "}" ]
Gets the xml representation of a tree. @param BaseElement $element @return \DOMDocument
[ "Gets", "the", "xml", "representation", "of", "a", "tree", "." ]
cafb979b777480baf7a01b5db2bf7c2cff837805
https://github.com/Techworker/ssml/blob/cafb979b777480baf7a01b5db2bf7c2cff837805/src/SsmlBuilder.php#L38-L43
226,242
CallFire/CallFire-PHP-SDK
src/CallFire/Api/Rest/Client/Subscription.php
Subscription.CreateSubscription
public function CreateSubscription(Request\CreateSubscription $CreateSubscription = null) { $uri = $this->getUri('/subscription', array()); return $this->post($uri, $CreateSubscription); }
php
public function CreateSubscription(Request\CreateSubscription $CreateSubscription = null) { $uri = $this->getUri('/subscription', array()); return $this->post($uri, $CreateSubscription); }
[ "public", "function", "CreateSubscription", "(", "Request", "\\", "CreateSubscription", "$", "CreateSubscription", "=", "null", ")", "{", "$", "uri", "=", "$", "this", "->", "getUri", "(", "'/subscription'", ",", "array", "(", ")", ")", ";", "return", "$", "this", "->", "post", "(", "$", "uri", ",", "$", "CreateSubscription", ")", ";", "}" ]
Creates a new subscription for CallFire event notifications CreateSubscription registers a URI endpoint to start receiving CallFire notification events on. Returned is the subscriptionId that can be used later to query, update, or delete the subscription. The subscriptionId is also returned as part of all notification events as 'subscriptionId'. A URI endpoint will need to be provided that can handle the HTTP notification events coming from CallFire.com. @api @param Request\CreateSubscription $CreateSubscription = null
[ "Creates", "a", "new", "subscription", "for", "CallFire", "event", "notifications" ]
7d6d3e1c59d4116e4fadaf57851a2fa127a13f65
https://github.com/CallFire/CallFire-PHP-SDK/blob/7d6d3e1c59d4116e4fadaf57851a2fa127a13f65/src/CallFire/Api/Rest/Client/Subscription.php#L27-L32
226,243
CallFire/CallFire-PHP-SDK
src/CallFire/Api/Rest/Client/Subscription.php
Subscription.QuerySubscriptions
public function QuerySubscriptions(Request\QuerySubscriptions $QuerySubscriptions = null) { $uri = $this->getUri('/subscription', array()); return $this->get($uri, $QuerySubscriptions); }
php
public function QuerySubscriptions(Request\QuerySubscriptions $QuerySubscriptions = null) { $uri = $this->getUri('/subscription', array()); return $this->get($uri, $QuerySubscriptions); }
[ "public", "function", "QuerySubscriptions", "(", "Request", "\\", "QuerySubscriptions", "$", "QuerySubscriptions", "=", "null", ")", "{", "$", "uri", "=", "$", "this", "->", "getUri", "(", "'/subscription'", ",", "array", "(", ")", ")", ";", "return", "$", "this", "->", "get", "(", "$", "uri", ",", "$", "QuerySubscriptions", ")", ";", "}" ]
Get a list of registered subscriptions Return a list of all subscriptions registered to an account. Subscriptions returned contain info like id, enabled, endpoint, filter, etc... @api @param Request\QuerySubscriptions $QuerySubscriptions = null
[ "Get", "a", "list", "of", "registered", "subscriptions" ]
7d6d3e1c59d4116e4fadaf57851a2fa127a13f65
https://github.com/CallFire/CallFire-PHP-SDK/blob/7d6d3e1c59d4116e4fadaf57851a2fa127a13f65/src/CallFire/Api/Rest/Client/Subscription.php#L43-L48
226,244
CallFire/CallFire-PHP-SDK
src/CallFire/Api/Rest/Client/Subscription.php
Subscription.UpdateSubscription
public function UpdateSubscription($Id, Request\UpdateSubscription $UpdateSubscription = null) { $uri = $this->getUri('/subscription/%s', array($Id)); return $this->put($uri, $UpdateSubscription); }
php
public function UpdateSubscription($Id, Request\UpdateSubscription $UpdateSubscription = null) { $uri = $this->getUri('/subscription/%s', array($Id)); return $this->put($uri, $UpdateSubscription); }
[ "public", "function", "UpdateSubscription", "(", "$", "Id", ",", "Request", "\\", "UpdateSubscription", "$", "UpdateSubscription", "=", "null", ")", "{", "$", "uri", "=", "$", "this", "->", "getUri", "(", "'/subscription/%s'", ",", "array", "(", "$", "Id", ")", ")", ";", "return", "$", "this", "->", "put", "(", "$", "uri", ",", "$", "UpdateSubscription", ")", ";", "}" ]
Updates an existing subscription Update existing subscription by ID Use this to enable or disable notification events, change the notification endpoint URI, or change the filtering so only receive notification for a subset of events. UpdateSubscription service call returns no response. Testing this method using swagger doc REST interface (Try Me! button) does not work correctly. Please use curl or other rest client to test api call. @api @param Request\UpdateSubscription $UpdateSubscription = null @param int $Id
[ "Updates", "an", "existing", "subscription" ]
7d6d3e1c59d4116e4fadaf57851a2fa127a13f65
https://github.com/CallFire/CallFire-PHP-SDK/blob/7d6d3e1c59d4116e4fadaf57851a2fa127a13f65/src/CallFire/Api/Rest/Client/Subscription.php#L97-L102
226,245
sdboyer/gliph
src/Gliph/Visitor/DepthFirstBasicVisitor.php
DepthFirstBasicVisitor.getReachable
public function getReachable($vertex) { if ($this->getState() !== self::COMPLETE) { throw new WrongVisitorStateException('Correct reachability data cannot be retrieved until traversal is complete.'); } if (!isset($this->paths[$vertex])) { return FALSE; } return $this->paths[$vertex]; }
php
public function getReachable($vertex) { if ($this->getState() !== self::COMPLETE) { throw new WrongVisitorStateException('Correct reachability data cannot be retrieved until traversal is complete.'); } if (!isset($this->paths[$vertex])) { return FALSE; } return $this->paths[$vertex]; }
[ "public", "function", "getReachable", "(", "$", "vertex", ")", "{", "if", "(", "$", "this", "->", "getState", "(", ")", "!==", "self", "::", "COMPLETE", ")", "{", "throw", "new", "WrongVisitorStateException", "(", "'Correct reachability data cannot be retrieved until traversal is complete.'", ")", ";", "}", "if", "(", "!", "isset", "(", "$", "this", "->", "paths", "[", "$", "vertex", "]", ")", ")", "{", "return", "FALSE", ";", "}", "return", "$", "this", "->", "paths", "[", "$", "vertex", "]", ";", "}" ]
Returns an array of all vertices reachable from the given vertex. @param object $vertex The vertex for which reachability data is desired. @return array|bool An array of reachable vertices, or FALSE if the vertex could not be found in the reachability data. Note that an empty array will be returned for vertices that zero reachable vertices. This is a different from FALSE, so the identity operator (===) should be used to verify returns. @throws WrongVisitorStateException Thrown if reachability data is requested before the traversal algorithm completes.
[ "Returns", "an", "array", "of", "all", "vertices", "reachable", "from", "the", "given", "vertex", "." ]
5ec6314b2b211053f6bae989b95446ccf6e8ded0
https://github.com/sdboyer/gliph/blob/5ec6314b2b211053f6bae989b95446ccf6e8ded0/src/Gliph/Visitor/DepthFirstBasicVisitor.php#L81-L91
226,246
bazo/wamp-client
src/WAMP/WAMPClient.php
WAMPClient.prefix
public function prefix($prefix, $uri) { $type = WAMPProtocol::MSG_PREFIX; $data = [$type, $prefix, $uri]; $this->send($data); }
php
public function prefix($prefix, $uri) { $type = WAMPProtocol::MSG_PREFIX; $data = [$type, $prefix, $uri]; $this->send($data); }
[ "public", "function", "prefix", "(", "$", "prefix", ",", "$", "uri", ")", "{", "$", "type", "=", "WAMPProtocol", "::", "MSG_PREFIX", ";", "$", "data", "=", "[", "$", "type", ",", "$", "prefix", ",", "$", "uri", "]", ";", "$", "this", "->", "send", "(", "$", "data", ")", ";", "}" ]
Establish a prefix on server @see http://wamp.ws/spec#prefix_message @param type $prefix @param type $uri
[ "Establish", "a", "prefix", "on", "server" ]
f93efeeb7a891b7fc4130d32071b43f4902b86cd
https://github.com/bazo/wamp-client/blob/f93efeeb7a891b7fc4130d32071b43f4902b86cd/src/WAMP/WAMPClient.php#L177-L182
226,247
bazo/wamp-client
src/WAMP/WAMPClient.php
WAMPClient.call
public function call($procUri, $arguments = []) { $args = func_get_args(); array_shift($args); $type = WAMPProtocol::MSG_CALL; $callId = uniqid("", $moreEntropy = TRUE); $data = array_merge(array($type, $callId, $procUri), $args); $this->send($data); }
php
public function call($procUri, $arguments = []) { $args = func_get_args(); array_shift($args); $type = WAMPProtocol::MSG_CALL; $callId = uniqid("", $moreEntropy = TRUE); $data = array_merge(array($type, $callId, $procUri), $args); $this->send($data); }
[ "public", "function", "call", "(", "$", "procUri", ",", "$", "arguments", "=", "[", "]", ")", "{", "$", "args", "=", "func_get_args", "(", ")", ";", "array_shift", "(", "$", "args", ")", ";", "$", "type", "=", "WAMPProtocol", "::", "MSG_CALL", ";", "$", "callId", "=", "uniqid", "(", "\"\"", ",", "$", "moreEntropy", "=", "TRUE", ")", ";", "$", "data", "=", "array_merge", "(", "array", "(", "$", "type", ",", "$", "callId", ",", "$", "procUri", ")", ",", "$", "args", ")", ";", "$", "this", "->", "send", "(", "$", "data", ")", ";", "}" ]
Call a procedure on server @see http://wamp.ws/spec#call_message @param string $procURI @param mixed $arguments
[ "Call", "a", "procedure", "on", "server" ]
f93efeeb7a891b7fc4130d32071b43f4902b86cd
https://github.com/bazo/wamp-client/blob/f93efeeb7a891b7fc4130d32071b43f4902b86cd/src/WAMP/WAMPClient.php#L191-L200
226,248
bazo/wamp-client
src/WAMP/WAMPClient.php
WAMPClient.publish
public function publish($topicUri, $payload, $exclude = [], $eligible = []) { $type = WAMPProtocol::MSG_PUBLISH; $data = array($type, $topicUri, $payload, $exclude, $eligible); $this->send($data); }
php
public function publish($topicUri, $payload, $exclude = [], $eligible = []) { $type = WAMPProtocol::MSG_PUBLISH; $data = array($type, $topicUri, $payload, $exclude, $eligible); $this->send($data); }
[ "public", "function", "publish", "(", "$", "topicUri", ",", "$", "payload", ",", "$", "exclude", "=", "[", "]", ",", "$", "eligible", "=", "[", "]", ")", "{", "$", "type", "=", "WAMPProtocol", "::", "MSG_PUBLISH", ";", "$", "data", "=", "array", "(", "$", "type", ",", "$", "topicUri", ",", "$", "payload", ",", "$", "exclude", ",", "$", "eligible", ")", ";", "$", "this", "->", "send", "(", "$", "data", ")", ";", "}" ]
The client will send an event to all clients connected to the server who have subscribed to the topicURI @see http://wamp.ws/spec#publish_message @param string $topicUri @param string $payload @param string $exclude @param string $eligible
[ "The", "client", "will", "send", "an", "event", "to", "all", "clients", "connected", "to", "the", "server", "who", "have", "subscribed", "to", "the", "topicURI" ]
f93efeeb7a891b7fc4130d32071b43f4902b86cd
https://github.com/bazo/wamp-client/blob/f93efeeb7a891b7fc4130d32071b43f4902b86cd/src/WAMP/WAMPClient.php#L211-L216
226,249
jagilpe/encryption-bundle
Doctrine/ORM/EncryptionEntityRepositoryDecorator.php
EncryptionEntityRepositoryDecorator.filterHasEncryptedField
private function filterHasEncryptedField(array $criteria) { $result = false; if (!empty($criteria)) { $encryptedFields = array_keys($this->getEncryptedFields()); $criteriaFields = array_keys($criteria); $commonFields = array_intersect($encryptedFields, $criteriaFields); $result = !empty($commonFields); } return $result; }
php
private function filterHasEncryptedField(array $criteria) { $result = false; if (!empty($criteria)) { $encryptedFields = array_keys($this->getEncryptedFields()); $criteriaFields = array_keys($criteria); $commonFields = array_intersect($encryptedFields, $criteriaFields); $result = !empty($commonFields); } return $result; }
[ "private", "function", "filterHasEncryptedField", "(", "array", "$", "criteria", ")", "{", "$", "result", "=", "false", ";", "if", "(", "!", "empty", "(", "$", "criteria", ")", ")", "{", "$", "encryptedFields", "=", "array_keys", "(", "$", "this", "->", "getEncryptedFields", "(", ")", ")", ";", "$", "criteriaFields", "=", "array_keys", "(", "$", "criteria", ")", ";", "$", "commonFields", "=", "array_intersect", "(", "$", "encryptedFields", ",", "$", "criteriaFields", ")", ";", "$", "result", "=", "!", "empty", "(", "$", "commonFields", ")", ";", "}", "return", "$", "result", ";", "}" ]
Checks if any of the fields in the filter criteria is encrypted @param array $criteria @return boolean
[ "Checks", "if", "any", "of", "the", "fields", "in", "the", "filter", "criteria", "is", "encrypted" ]
1e1ba13a3cc646b36e3407822f2e8339c5671f47
https://github.com/jagilpe/encryption-bundle/blob/1e1ba13a3cc646b36e3407822f2e8339c5671f47/Doctrine/ORM/EncryptionEntityRepositoryDecorator.php#L127-L140
226,250
jagilpe/encryption-bundle
Doctrine/ORM/EncryptionEntityRepositoryDecorator.php
EncryptionEntityRepositoryDecorator.orderByHasEncryptedField
private function orderByHasEncryptedField(array $orderBy = null) { $result = false; if ($orderBy && !empty($orderBy)) { $encryptedFields = array_keys($this->getEncryptedFields()); $orderByFields = array_keys($orderBy); $commonFields = array_intersect($encryptedFields, $orderByFields); $result = !empty($commonFields); } return $result; }
php
private function orderByHasEncryptedField(array $orderBy = null) { $result = false; if ($orderBy && !empty($orderBy)) { $encryptedFields = array_keys($this->getEncryptedFields()); $orderByFields = array_keys($orderBy); $commonFields = array_intersect($encryptedFields, $orderByFields); $result = !empty($commonFields); } return $result; }
[ "private", "function", "orderByHasEncryptedField", "(", "array", "$", "orderBy", "=", "null", ")", "{", "$", "result", "=", "false", ";", "if", "(", "$", "orderBy", "&&", "!", "empty", "(", "$", "orderBy", ")", ")", "{", "$", "encryptedFields", "=", "array_keys", "(", "$", "this", "->", "getEncryptedFields", "(", ")", ")", ";", "$", "orderByFields", "=", "array_keys", "(", "$", "orderBy", ")", ";", "$", "commonFields", "=", "array_intersect", "(", "$", "encryptedFields", ",", "$", "orderByFields", ")", ";", "$", "result", "=", "!", "empty", "(", "$", "commonFields", ")", ";", "}", "return", "$", "result", ";", "}" ]
Checks if any of the fields in the order by clause is encrypted @param array $orderBy @return boolean
[ "Checks", "if", "any", "of", "the", "fields", "in", "the", "order", "by", "clause", "is", "encrypted" ]
1e1ba13a3cc646b36e3407822f2e8339c5671f47
https://github.com/jagilpe/encryption-bundle/blob/1e1ba13a3cc646b36e3407822f2e8339c5671f47/Doctrine/ORM/EncryptionEntityRepositoryDecorator.php#L149-L162
226,251
jagilpe/encryption-bundle
Doctrine/ORM/EncryptionEntityRepositoryDecorator.php
EncryptionEntityRepositoryDecorator.filterWithEncryptedCriteria
private function filterWithEncryptedCriteria($values, array $encryptedCriteria) { $result = array_filter($values, function($value) use ($encryptedCriteria) { foreach ($encryptedCriteria as $fieldName => $fieldValue) { if (!$this->fieldValueMatches($value, $fieldName, $fieldValue)) { return false; } } return true; }); return $result; }
php
private function filterWithEncryptedCriteria($values, array $encryptedCriteria) { $result = array_filter($values, function($value) use ($encryptedCriteria) { foreach ($encryptedCriteria as $fieldName => $fieldValue) { if (!$this->fieldValueMatches($value, $fieldName, $fieldValue)) { return false; } } return true; }); return $result; }
[ "private", "function", "filterWithEncryptedCriteria", "(", "$", "values", ",", "array", "$", "encryptedCriteria", ")", "{", "$", "result", "=", "array_filter", "(", "$", "values", ",", "function", "(", "$", "value", ")", "use", "(", "$", "encryptedCriteria", ")", "{", "foreach", "(", "$", "encryptedCriteria", "as", "$", "fieldName", "=>", "$", "fieldValue", ")", "{", "if", "(", "!", "$", "this", "->", "fieldValueMatches", "(", "$", "value", ",", "$", "fieldName", ",", "$", "fieldValue", ")", ")", "{", "return", "false", ";", "}", "}", "return", "true", ";", "}", ")", ";", "return", "$", "result", ";", "}" ]
Filters the values using by one or more encrypted fields @param array $values @param array $orderBy @return array
[ "Filters", "the", "values", "using", "by", "one", "or", "more", "encrypted", "fields" ]
1e1ba13a3cc646b36e3407822f2e8339c5671f47
https://github.com/jagilpe/encryption-bundle/blob/1e1ba13a3cc646b36e3407822f2e8339c5671f47/Doctrine/ORM/EncryptionEntityRepositoryDecorator.php#L219-L231
226,252
jagilpe/encryption-bundle
Doctrine/ORM/EncryptionEntityRepositoryDecorator.php
EncryptionEntityRepositoryDecorator.fieldValueMatches
private function fieldValueMatches($entity, $fieldName, $fieldValue) { $value = $this->getFieldValue($entity, $fieldName); if (is_array($fieldValue)) { $matches = in_array($value, $fieldValue); } else { $matches = ($value == $fieldValue); } return $matches; }
php
private function fieldValueMatches($entity, $fieldName, $fieldValue) { $value = $this->getFieldValue($entity, $fieldName); if (is_array($fieldValue)) { $matches = in_array($value, $fieldValue); } else { $matches = ($value == $fieldValue); } return $matches; }
[ "private", "function", "fieldValueMatches", "(", "$", "entity", ",", "$", "fieldName", ",", "$", "fieldValue", ")", "{", "$", "value", "=", "$", "this", "->", "getFieldValue", "(", "$", "entity", ",", "$", "fieldName", ")", ";", "if", "(", "is_array", "(", "$", "fieldValue", ")", ")", "{", "$", "matches", "=", "in_array", "(", "$", "value", ",", "$", "fieldValue", ")", ";", "}", "else", "{", "$", "matches", "=", "(", "$", "value", "==", "$", "fieldValue", ")", ";", "}", "return", "$", "matches", ";", "}" ]
Check if the value of the field matches the given value @param mixed $entity @param string $fieldName @return mixed
[ "Check", "if", "the", "value", "of", "the", "field", "matches", "the", "given", "value" ]
1e1ba13a3cc646b36e3407822f2e8339c5671f47
https://github.com/jagilpe/encryption-bundle/blob/1e1ba13a3cc646b36e3407822f2e8339c5671f47/Doctrine/ORM/EncryptionEntityRepositoryDecorator.php#L241-L252
226,253
jagilpe/encryption-bundle
Doctrine/ORM/EncryptionEntityRepositoryDecorator.php
EncryptionEntityRepositoryDecorator.sortWithEncryptedOrderBy
private function sortWithEncryptedOrderBy($values, array $orderBy) { usort($values, function($entity1, $entity2) use ($orderBy) { foreach ($orderBy as $fieldName => $order) { $value1 = $this->getFieldValue($entity1, $fieldName); $value2 = $this->getFieldValue($entity2, $fieldName); if ($value1 < $value2) { return (strtoupper($order) === 'ASC') ? -1 : 1; } elseif ($value1 > $value2) { return (strtoupper($order) === 'ASC') ? 1 : -1; } } // If we are here is because all the values were equal return 0; }); return $values; }
php
private function sortWithEncryptedOrderBy($values, array $orderBy) { usort($values, function($entity1, $entity2) use ($orderBy) { foreach ($orderBy as $fieldName => $order) { $value1 = $this->getFieldValue($entity1, $fieldName); $value2 = $this->getFieldValue($entity2, $fieldName); if ($value1 < $value2) { return (strtoupper($order) === 'ASC') ? -1 : 1; } elseif ($value1 > $value2) { return (strtoupper($order) === 'ASC') ? 1 : -1; } } // If we are here is because all the values were equal return 0; }); return $values; }
[ "private", "function", "sortWithEncryptedOrderBy", "(", "$", "values", ",", "array", "$", "orderBy", ")", "{", "usort", "(", "$", "values", ",", "function", "(", "$", "entity1", ",", "$", "entity2", ")", "use", "(", "$", "orderBy", ")", "{", "foreach", "(", "$", "orderBy", "as", "$", "fieldName", "=>", "$", "order", ")", "{", "$", "value1", "=", "$", "this", "->", "getFieldValue", "(", "$", "entity1", ",", "$", "fieldName", ")", ";", "$", "value2", "=", "$", "this", "->", "getFieldValue", "(", "$", "entity2", ",", "$", "fieldName", ")", ";", "if", "(", "$", "value1", "<", "$", "value2", ")", "{", "return", "(", "strtoupper", "(", "$", "order", ")", "===", "'ASC'", ")", "?", "-", "1", ":", "1", ";", "}", "elseif", "(", "$", "value1", ">", "$", "value2", ")", "{", "return", "(", "strtoupper", "(", "$", "order", ")", "===", "'ASC'", ")", "?", "1", ":", "-", "1", ";", "}", "}", "// If we are here is because all the values were equal", "return", "0", ";", "}", ")", ";", "return", "$", "values", ";", "}" ]
Sorts the values using by one or more encrypted fields @param array $values @param array $orderBy @return array
[ "Sorts", "the", "values", "using", "by", "one", "or", "more", "encrypted", "fields" ]
1e1ba13a3cc646b36e3407822f2e8339c5671f47
https://github.com/jagilpe/encryption-bundle/blob/1e1ba13a3cc646b36e3407822f2e8339c5671f47/Doctrine/ORM/EncryptionEntityRepositoryDecorator.php#L262-L282
226,254
jagilpe/encryption-bundle
Crypt/KeyStore.php
KeyStore.getUserKey
private function getUserKey(PKEncryptionEnabledUserInterface $user) { $pkiKey = $this->findKeyByUser($user); if (!$pkiKey) { $userId = $user->getId(); $userClass = $this->getUserClass($user); $pkiKey = new PKIPrivateKey(); $pkiKey->setUserClass($userClass); $pkiKey->setUserId($userId); } return $pkiKey; }
php
private function getUserKey(PKEncryptionEnabledUserInterface $user) { $pkiKey = $this->findKeyByUser($user); if (!$pkiKey) { $userId = $user->getId(); $userClass = $this->getUserClass($user); $pkiKey = new PKIPrivateKey(); $pkiKey->setUserClass($userClass); $pkiKey->setUserId($userId); } return $pkiKey; }
[ "private", "function", "getUserKey", "(", "PKEncryptionEnabledUserInterface", "$", "user", ")", "{", "$", "pkiKey", "=", "$", "this", "->", "findKeyByUser", "(", "$", "user", ")", ";", "if", "(", "!", "$", "pkiKey", ")", "{", "$", "userId", "=", "$", "user", "->", "getId", "(", ")", ";", "$", "userClass", "=", "$", "this", "->", "getUserClass", "(", "$", "user", ")", ";", "$", "pkiKey", "=", "new", "PKIPrivateKey", "(", ")", ";", "$", "pkiKey", "->", "setUserClass", "(", "$", "userClass", ")", ";", "$", "pkiKey", "->", "setUserId", "(", "$", "userId", ")", ";", "}", "return", "$", "pkiKey", ";", "}" ]
Returns the Key pair of the user or a new one if it has not already been persisted @param \Jagilpe\EncryptionBundle\Entity\PKEncryptionEnabledUserInterface $user @return \Jagilpe\EncryptionBundle\Entity\PKIPrivateKey
[ "Returns", "the", "Key", "pair", "of", "the", "user", "or", "a", "new", "one", "if", "it", "has", "not", "already", "been", "persisted" ]
1e1ba13a3cc646b36e3407822f2e8339c5671f47
https://github.com/jagilpe/encryption-bundle/blob/1e1ba13a3cc646b36e3407822f2e8339c5671f47/Crypt/KeyStore.php#L134-L148
226,255
jagilpe/encryption-bundle
Crypt/KeyStore.php
KeyStore.findKeyByUser
private function findKeyByUser(PKEncryptionEnabledUserInterface $user) { $userClass = $this->getUserClass($user); $userId = $user->getId(); $key = $this->getKeyRepository()->findOneBy(array('userClass' => $userClass, 'userId' => $userId)); return $key; }
php
private function findKeyByUser(PKEncryptionEnabledUserInterface $user) { $userClass = $this->getUserClass($user); $userId = $user->getId(); $key = $this->getKeyRepository()->findOneBy(array('userClass' => $userClass, 'userId' => $userId)); return $key; }
[ "private", "function", "findKeyByUser", "(", "PKEncryptionEnabledUserInterface", "$", "user", ")", "{", "$", "userClass", "=", "$", "this", "->", "getUserClass", "(", "$", "user", ")", ";", "$", "userId", "=", "$", "user", "->", "getId", "(", ")", ";", "$", "key", "=", "$", "this", "->", "getKeyRepository", "(", ")", "->", "findOneBy", "(", "array", "(", "'userClass'", "=>", "$", "userClass", ",", "'userId'", "=>", "$", "userId", ")", ")", ";", "return", "$", "key", ";", "}" ]
Returns the previously persisted key pair of a user @param \Jagilpe\EncryptionBundle\Entity\PKEncryptionEnabledUserInterface $user @return \Jagilpe\EncryptionBundle\Entity\PKIPrivateKey
[ "Returns", "the", "previously", "persisted", "key", "pair", "of", "a", "user" ]
1e1ba13a3cc646b36e3407822f2e8339c5671f47
https://github.com/jagilpe/encryption-bundle/blob/1e1ba13a3cc646b36e3407822f2e8339c5671f47/Crypt/KeyStore.php#L156-L163
226,256
jagilpe/encryption-bundle
Crypt/KeyStore.php
KeyStore.deleteUserKey
private function deleteUserKey(PKEncryptionEnabledUserInterface$user, $flush = false) { $key = $this->findKeyByUser($user); if ($key) { $this->getEntityManager()->remove($key); if ($flush) { $this->getEntityManager()->flush(); } } }
php
private function deleteUserKey(PKEncryptionEnabledUserInterface$user, $flush = false) { $key = $this->findKeyByUser($user); if ($key) { $this->getEntityManager()->remove($key); if ($flush) { $this->getEntityManager()->flush(); } } }
[ "private", "function", "deleteUserKey", "(", "PKEncryptionEnabledUserInterface", "$", "user", ",", "$", "flush", "=", "false", ")", "{", "$", "key", "=", "$", "this", "->", "findKeyByUser", "(", "$", "user", ")", ";", "if", "(", "$", "key", ")", "{", "$", "this", "->", "getEntityManager", "(", ")", "->", "remove", "(", "$", "key", ")", ";", "if", "(", "$", "flush", ")", "{", "$", "this", "->", "getEntityManager", "(", ")", "->", "flush", "(", ")", ";", "}", "}", "}" ]
Deletes the key pair of a user @param \Jagilpe\EncryptionBundle\Entity\PKEncryptionEnabledUserInterface $user
[ "Deletes", "the", "key", "pair", "of", "a", "user" ]
1e1ba13a3cc646b36e3407822f2e8339c5671f47
https://github.com/jagilpe/encryption-bundle/blob/1e1ba13a3cc646b36e3407822f2e8339c5671f47/Crypt/KeyStore.php#L175-L184
226,257
jagilpe/encryption-bundle
Crypt/KeyStore.php
KeyStore.encryptPrivateKey
private function encryptPrivateKey(PKIPrivateKey $pkiKey) { // Generate the symmetric key and iv to encrypt the users' key $iv = $this->cryptographyProvider->generateIV(CryptographyProviderInterface::PRIVATE_KEY_ENCRYPTION); $symmetricKey = $this->cryptographyProvider->generateSecureKey(); $keyData = new KeyData($symmetricKey, $iv); // The private key of the user that we want to encrypt $userPrivateKey = $pkiKey->getPrivateKey(); $encryptedUserPrivateKey = $this->cryptographyProvider->encrypt($userPrivateKey, $keyData); if ($encryptedUserPrivateKey) { $pkiKey->setPrivateKey($encryptedUserPrivateKey); $pkiKey->setEncrypted(true); // Now we have to encrypt the symmetric key with the public master key $publicMasterKey = $this->getPublicMasterKey(); $encryptedKey = base64_encode($this->cryptographyProvider->encryptWithPublicKey($symmetricKey, $publicMasterKey)); $pkiKey->setKey($encryptedKey); $pkiKey->setIv($iv); } else { $pkiKey->setKey(null); $pkiKey->setIv(null); $pkiKey->setEncrypted(false); } }
php
private function encryptPrivateKey(PKIPrivateKey $pkiKey) { // Generate the symmetric key and iv to encrypt the users' key $iv = $this->cryptographyProvider->generateIV(CryptographyProviderInterface::PRIVATE_KEY_ENCRYPTION); $symmetricKey = $this->cryptographyProvider->generateSecureKey(); $keyData = new KeyData($symmetricKey, $iv); // The private key of the user that we want to encrypt $userPrivateKey = $pkiKey->getPrivateKey(); $encryptedUserPrivateKey = $this->cryptographyProvider->encrypt($userPrivateKey, $keyData); if ($encryptedUserPrivateKey) { $pkiKey->setPrivateKey($encryptedUserPrivateKey); $pkiKey->setEncrypted(true); // Now we have to encrypt the symmetric key with the public master key $publicMasterKey = $this->getPublicMasterKey(); $encryptedKey = base64_encode($this->cryptographyProvider->encryptWithPublicKey($symmetricKey, $publicMasterKey)); $pkiKey->setKey($encryptedKey); $pkiKey->setIv($iv); } else { $pkiKey->setKey(null); $pkiKey->setIv(null); $pkiKey->setEncrypted(false); } }
[ "private", "function", "encryptPrivateKey", "(", "PKIPrivateKey", "$", "pkiKey", ")", "{", "// Generate the symmetric key and iv to encrypt the users' key", "$", "iv", "=", "$", "this", "->", "cryptographyProvider", "->", "generateIV", "(", "CryptographyProviderInterface", "::", "PRIVATE_KEY_ENCRYPTION", ")", ";", "$", "symmetricKey", "=", "$", "this", "->", "cryptographyProvider", "->", "generateSecureKey", "(", ")", ";", "$", "keyData", "=", "new", "KeyData", "(", "$", "symmetricKey", ",", "$", "iv", ")", ";", "// The private key of the user that we want to encrypt", "$", "userPrivateKey", "=", "$", "pkiKey", "->", "getPrivateKey", "(", ")", ";", "$", "encryptedUserPrivateKey", "=", "$", "this", "->", "cryptographyProvider", "->", "encrypt", "(", "$", "userPrivateKey", ",", "$", "keyData", ")", ";", "if", "(", "$", "encryptedUserPrivateKey", ")", "{", "$", "pkiKey", "->", "setPrivateKey", "(", "$", "encryptedUserPrivateKey", ")", ";", "$", "pkiKey", "->", "setEncrypted", "(", "true", ")", ";", "// Now we have to encrypt the symmetric key with the public master key", "$", "publicMasterKey", "=", "$", "this", "->", "getPublicMasterKey", "(", ")", ";", "$", "encryptedKey", "=", "base64_encode", "(", "$", "this", "->", "cryptographyProvider", "->", "encryptWithPublicKey", "(", "$", "symmetricKey", ",", "$", "publicMasterKey", ")", ")", ";", "$", "pkiKey", "->", "setKey", "(", "$", "encryptedKey", ")", ";", "$", "pkiKey", "->", "setIv", "(", "$", "iv", ")", ";", "}", "else", "{", "$", "pkiKey", "->", "setKey", "(", "null", ")", ";", "$", "pkiKey", "->", "setIv", "(", "null", ")", ";", "$", "pkiKey", "->", "setEncrypted", "(", "false", ")", ";", "}", "}" ]
Encrypts the private key of the user using the app master public key @param \Jagilpe\EncryptionBundle\Entity\PKIPrivateKey $pkiKey
[ "Encrypts", "the", "private", "key", "of", "the", "user", "using", "the", "app", "master", "public", "key" ]
1e1ba13a3cc646b36e3407822f2e8339c5671f47
https://github.com/jagilpe/encryption-bundle/blob/1e1ba13a3cc646b36e3407822f2e8339c5671f47/Crypt/KeyStore.php#L207-L233
226,258
jagilpe/encryption-bundle
Crypt/KeyStore.php
KeyStore.decryptPrivateKey
private function decryptPrivateKey(PKIPrivateKey $pkiKey) { // Get the symmetric key used to encrypt the private key of the user $encryptedKey = base64_decode($pkiKey->getKey()); $privateMasterKey = $this->getPrivateMasterKey(); $symmetricKey = $this->cryptographyProvider->decryptWithPrivateKey($encryptedKey, $privateMasterKey); if ($symmetricKey) { // Decrypt the private key of the user $iv = $pkiKey->getIv(); $keyData = new KeyData($symmetricKey, $iv); $encryptedUserPrivateKey = $pkiKey->getPrivateKey(); $userPrivateKey = $this->cryptographyProvider->decrypt($encryptedUserPrivateKey, $keyData); return $userPrivateKey; } else { throw new EncryptionException('Could not retrieve the encryption keys of the user'); } }
php
private function decryptPrivateKey(PKIPrivateKey $pkiKey) { // Get the symmetric key used to encrypt the private key of the user $encryptedKey = base64_decode($pkiKey->getKey()); $privateMasterKey = $this->getPrivateMasterKey(); $symmetricKey = $this->cryptographyProvider->decryptWithPrivateKey($encryptedKey, $privateMasterKey); if ($symmetricKey) { // Decrypt the private key of the user $iv = $pkiKey->getIv(); $keyData = new KeyData($symmetricKey, $iv); $encryptedUserPrivateKey = $pkiKey->getPrivateKey(); $userPrivateKey = $this->cryptographyProvider->decrypt($encryptedUserPrivateKey, $keyData); return $userPrivateKey; } else { throw new EncryptionException('Could not retrieve the encryption keys of the user'); } }
[ "private", "function", "decryptPrivateKey", "(", "PKIPrivateKey", "$", "pkiKey", ")", "{", "// Get the symmetric key used to encrypt the private key of the user", "$", "encryptedKey", "=", "base64_decode", "(", "$", "pkiKey", "->", "getKey", "(", ")", ")", ";", "$", "privateMasterKey", "=", "$", "this", "->", "getPrivateMasterKey", "(", ")", ";", "$", "symmetricKey", "=", "$", "this", "->", "cryptographyProvider", "->", "decryptWithPrivateKey", "(", "$", "encryptedKey", ",", "$", "privateMasterKey", ")", ";", "if", "(", "$", "symmetricKey", ")", "{", "// Decrypt the private key of the user", "$", "iv", "=", "$", "pkiKey", "->", "getIv", "(", ")", ";", "$", "keyData", "=", "new", "KeyData", "(", "$", "symmetricKey", ",", "$", "iv", ")", ";", "$", "encryptedUserPrivateKey", "=", "$", "pkiKey", "->", "getPrivateKey", "(", ")", ";", "$", "userPrivateKey", "=", "$", "this", "->", "cryptographyProvider", "->", "decrypt", "(", "$", "encryptedUserPrivateKey", ",", "$", "keyData", ")", ";", "return", "$", "userPrivateKey", ";", "}", "else", "{", "throw", "new", "EncryptionException", "(", "'Could not retrieve the encryption keys of the user'", ")", ";", "}", "}" ]
Descrypts the private key of the user using the app master private key and returns it @param \Jagilpe\EncryptionBundle\Entity\PKIPrivateKey $pkiKey @return string
[ "Descrypts", "the", "private", "key", "of", "the", "user", "using", "the", "app", "master", "private", "key", "and", "returns", "it" ]
1e1ba13a3cc646b36e3407822f2e8339c5671f47
https://github.com/jagilpe/encryption-bundle/blob/1e1ba13a3cc646b36e3407822f2e8339c5671f47/Crypt/KeyStore.php#L242-L263
226,259
jagilpe/encryption-bundle
Crypt/KeyStore.php
KeyStore.getPublicMasterKey
public function getPublicMasterKey() { if (!$this->publicMasterKey) { $masterKey = $this->getMasterKey(); $publicKeyDetails = openssl_pkey_get_details($masterKey); $this->publicMasterKey = $publicKeyDetails['key']; } return $this->publicMasterKey; }
php
public function getPublicMasterKey() { if (!$this->publicMasterKey) { $masterKey = $this->getMasterKey(); $publicKeyDetails = openssl_pkey_get_details($masterKey); $this->publicMasterKey = $publicKeyDetails['key']; } return $this->publicMasterKey; }
[ "public", "function", "getPublicMasterKey", "(", ")", "{", "if", "(", "!", "$", "this", "->", "publicMasterKey", ")", "{", "$", "masterKey", "=", "$", "this", "->", "getMasterKey", "(", ")", ";", "$", "publicKeyDetails", "=", "openssl_pkey_get_details", "(", "$", "masterKey", ")", ";", "$", "this", "->", "publicMasterKey", "=", "$", "publicKeyDetails", "[", "'key'", "]", ";", "}", "return", "$", "this", "->", "publicMasterKey", ";", "}" ]
Returns the public master key @return string
[ "Returns", "the", "public", "master", "key" ]
1e1ba13a3cc646b36e3407822f2e8339c5671f47
https://github.com/jagilpe/encryption-bundle/blob/1e1ba13a3cc646b36e3407822f2e8339c5671f47/Crypt/KeyStore.php#L270-L278
226,260
jagilpe/encryption-bundle
Crypt/KeyStore.php
KeyStore.getPrivateMasterKey
public function getPrivateMasterKey() { if (!$this->privateMasterKey) { $masterKey = $this->getMasterKey(); openssl_pkey_export($masterKey, $this->privateMasterKey); } return $this->privateMasterKey; }
php
public function getPrivateMasterKey() { if (!$this->privateMasterKey) { $masterKey = $this->getMasterKey(); openssl_pkey_export($masterKey, $this->privateMasterKey); } return $this->privateMasterKey; }
[ "public", "function", "getPrivateMasterKey", "(", ")", "{", "if", "(", "!", "$", "this", "->", "privateMasterKey", ")", "{", "$", "masterKey", "=", "$", "this", "->", "getMasterKey", "(", ")", ";", "openssl_pkey_export", "(", "$", "masterKey", ",", "$", "this", "->", "privateMasterKey", ")", ";", "}", "return", "$", "this", "->", "privateMasterKey", ";", "}" ]
Returns the private master key @return string
[ "Returns", "the", "private", "master", "key" ]
1e1ba13a3cc646b36e3407822f2e8339c5671f47
https://github.com/jagilpe/encryption-bundle/blob/1e1ba13a3cc646b36e3407822f2e8339c5671f47/Crypt/KeyStore.php#L285-L292
226,261
jagilpe/encryption-bundle
Crypt/KeyStore.php
KeyStore.getMasterKey
private function getMasterKey() { if (!$this->masterKey) { $certificatePath = 'file://'.$this->masterKeyData['cert_file']; $passPhrase = $this->masterKeyData['passphrase']; $this->masterKey = openssl_pkey_get_private($certificatePath, $passPhrase); if (!$this->masterKey) { throw new EncryptionException('Could not open master encryption key'); } } return $this->masterKey; }
php
private function getMasterKey() { if (!$this->masterKey) { $certificatePath = 'file://'.$this->masterKeyData['cert_file']; $passPhrase = $this->masterKeyData['passphrase']; $this->masterKey = openssl_pkey_get_private($certificatePath, $passPhrase); if (!$this->masterKey) { throw new EncryptionException('Could not open master encryption key'); } } return $this->masterKey; }
[ "private", "function", "getMasterKey", "(", ")", "{", "if", "(", "!", "$", "this", "->", "masterKey", ")", "{", "$", "certificatePath", "=", "'file://'", ".", "$", "this", "->", "masterKeyData", "[", "'cert_file'", "]", ";", "$", "passPhrase", "=", "$", "this", "->", "masterKeyData", "[", "'passphrase'", "]", ";", "$", "this", "->", "masterKey", "=", "openssl_pkey_get_private", "(", "$", "certificatePath", ",", "$", "passPhrase", ")", ";", "if", "(", "!", "$", "this", "->", "masterKey", ")", "{", "throw", "new", "EncryptionException", "(", "'Could not open master encryption key'", ")", ";", "}", "}", "return", "$", "this", "->", "masterKey", ";", "}" ]
Returns the master key resource identifier @return resource
[ "Returns", "the", "master", "key", "resource", "identifier" ]
1e1ba13a3cc646b36e3407822f2e8339c5671f47
https://github.com/jagilpe/encryption-bundle/blob/1e1ba13a3cc646b36e3407822f2e8339c5671f47/Crypt/KeyStore.php#L299-L311
226,262
jagilpe/encryption-bundle
Crypt/KeyManager.php
KeyManager.encryptSymmetricKeyWithUserKey
private function encryptSymmetricKeyWithUserKey($clearKey, $entity) { $users = $this->accessChecker->getAllowedUsers($entity); $symmetricKey = new SymmetricKey(); foreach ($users as $user) { $publicKey = $this->getPublicKey($user); $encryptedKey = base64_encode($this->cryptographyProvider->encryptWithPublicKey($clearKey, $publicKey)); $symmetricKey->addKey($user, $encryptedKey); } return $symmetricKey; }
php
private function encryptSymmetricKeyWithUserKey($clearKey, $entity) { $users = $this->accessChecker->getAllowedUsers($entity); $symmetricKey = new SymmetricKey(); foreach ($users as $user) { $publicKey = $this->getPublicKey($user); $encryptedKey = base64_encode($this->cryptographyProvider->encryptWithPublicKey($clearKey, $publicKey)); $symmetricKey->addKey($user, $encryptedKey); } return $symmetricKey; }
[ "private", "function", "encryptSymmetricKeyWithUserKey", "(", "$", "clearKey", ",", "$", "entity", ")", "{", "$", "users", "=", "$", "this", "->", "accessChecker", "->", "getAllowedUsers", "(", "$", "entity", ")", ";", "$", "symmetricKey", "=", "new", "SymmetricKey", "(", ")", ";", "foreach", "(", "$", "users", "as", "$", "user", ")", "{", "$", "publicKey", "=", "$", "this", "->", "getPublicKey", "(", "$", "user", ")", ";", "$", "encryptedKey", "=", "base64_encode", "(", "$", "this", "->", "cryptographyProvider", "->", "encryptWithPublicKey", "(", "$", "clearKey", ",", "$", "publicKey", ")", ")", ";", "$", "symmetricKey", "->", "addKey", "(", "$", "user", ",", "$", "encryptedKey", ")", ";", "}", "return", "$", "symmetricKey", ";", "}" ]
Encrypts the Symmetric Key of the entity using Per User Encryption @param string $clearKey @param mixed $entity @return SymmetricKey
[ "Encrypts", "the", "Symmetric", "Key", "of", "the", "entity", "using", "Per", "User", "Encryption" ]
1e1ba13a3cc646b36e3407822f2e8339c5671f47
https://github.com/jagilpe/encryption-bundle/blob/1e1ba13a3cc646b36e3407822f2e8339c5671f47/Crypt/KeyManager.php#L310-L322
226,263
jagilpe/encryption-bundle
Crypt/KeyManager.php
KeyManager.encryptSymmetricKeyWithSystemKey
private function encryptSymmetricKeyWithSystemKey($clearKey, $entity) { $publicMasterKey = $this->keyStore->getPublicMasterKey(); $symmetricKey = new SymmetricKey(); $encryptedKey = base64_encode($this->cryptographyProvider->encryptWithPublicKey($clearKey, $publicMasterKey)); $symmetricKey->addSystemKey($encryptedKey); return $symmetricKey; }
php
private function encryptSymmetricKeyWithSystemKey($clearKey, $entity) { $publicMasterKey = $this->keyStore->getPublicMasterKey(); $symmetricKey = new SymmetricKey(); $encryptedKey = base64_encode($this->cryptographyProvider->encryptWithPublicKey($clearKey, $publicMasterKey)); $symmetricKey->addSystemKey($encryptedKey); return $symmetricKey; }
[ "private", "function", "encryptSymmetricKeyWithSystemKey", "(", "$", "clearKey", ",", "$", "entity", ")", "{", "$", "publicMasterKey", "=", "$", "this", "->", "keyStore", "->", "getPublicMasterKey", "(", ")", ";", "$", "symmetricKey", "=", "new", "SymmetricKey", "(", ")", ";", "$", "encryptedKey", "=", "base64_encode", "(", "$", "this", "->", "cryptographyProvider", "->", "encryptWithPublicKey", "(", "$", "clearKey", ",", "$", "publicMasterKey", ")", ")", ";", "$", "symmetricKey", "->", "addSystemKey", "(", "$", "encryptedKey", ")", ";", "return", "$", "symmetricKey", ";", "}" ]
Encrypts the Symmetric Key of the entity using System Encryption @param string $clearKey @param mixed $entity @return SymmetricKey
[ "Encrypts", "the", "Symmetric", "Key", "of", "the", "entity", "using", "System", "Encryption" ]
1e1ba13a3cc646b36e3407822f2e8339c5671f47
https://github.com/jagilpe/encryption-bundle/blob/1e1ba13a3cc646b36e3407822f2e8339c5671f47/Crypt/KeyManager.php#L332-L340
226,264
jagilpe/encryption-bundle
Crypt/KeyManager.php
KeyManager.decryptSymmetricKey
private function decryptSymmetricKey($entity) { $decryptedKey = null; $encryptionMode = $this->getEncryptionMode($entity); switch ($encryptionMode) { case EncryptionService::MODE_PER_USER_SHAREABLE: $decryptedKey = $this->decryptSymmetricKeyWithUserKey($entity); break; case EncryptionService::MODE_SYSTEM_ENCRYPTION: $decryptedKey = $this->decryptSymmetricKeyWithSystemKey($entity); break; default: throw new EncryptionException(sprintf('Encryption mode %s not supported.', $encryptionMode)); } return $decryptedKey; }
php
private function decryptSymmetricKey($entity) { $decryptedKey = null; $encryptionMode = $this->getEncryptionMode($entity); switch ($encryptionMode) { case EncryptionService::MODE_PER_USER_SHAREABLE: $decryptedKey = $this->decryptSymmetricKeyWithUserKey($entity); break; case EncryptionService::MODE_SYSTEM_ENCRYPTION: $decryptedKey = $this->decryptSymmetricKeyWithSystemKey($entity); break; default: throw new EncryptionException(sprintf('Encryption mode %s not supported.', $encryptionMode)); } return $decryptedKey; }
[ "private", "function", "decryptSymmetricKey", "(", "$", "entity", ")", "{", "$", "decryptedKey", "=", "null", ";", "$", "encryptionMode", "=", "$", "this", "->", "getEncryptionMode", "(", "$", "entity", ")", ";", "switch", "(", "$", "encryptionMode", ")", "{", "case", "EncryptionService", "::", "MODE_PER_USER_SHAREABLE", ":", "$", "decryptedKey", "=", "$", "this", "->", "decryptSymmetricKeyWithUserKey", "(", "$", "entity", ")", ";", "break", ";", "case", "EncryptionService", "::", "MODE_SYSTEM_ENCRYPTION", ":", "$", "decryptedKey", "=", "$", "this", "->", "decryptSymmetricKeyWithSystemKey", "(", "$", "entity", ")", ";", "break", ";", "default", ":", "throw", "new", "EncryptionException", "(", "sprintf", "(", "'Encryption mode %s not supported.'", ",", "$", "encryptionMode", ")", ")", ";", "}", "return", "$", "decryptedKey", ";", "}" ]
Decrypts the Symmetric Key used to encrypt the fields of the entity @param mixed $entity @throws EncryptionException @return string
[ "Decrypts", "the", "Symmetric", "Key", "used", "to", "encrypt", "the", "fields", "of", "the", "entity" ]
1e1ba13a3cc646b36e3407822f2e8339c5671f47
https://github.com/jagilpe/encryption-bundle/blob/1e1ba13a3cc646b36e3407822f2e8339c5671f47/Crypt/KeyManager.php#L351-L368
226,265
jagilpe/encryption-bundle
Crypt/KeyManager.php
KeyManager.decryptSymmetricKeyWithUserKey
private function decryptSymmetricKeyWithUserKey($entity) { $encryptedKey = $entity->getKey(); $decryptedKey = null; $user = $this->getUser(); if ($user instanceof PKEncryptionEnabledUserInterface && $userKey = $encryptedKey->getKey($user)) { $userKey = base64_decode($userKey); $privateKey = $this->getPrivateKey(); } elseif ($this->accessChecker->canUseOwnerPrivateKey($entity, $user)) { // Check if the logged in user can decrpyt the data without private key $vivaUser = $entity->getUserProfile()->getUser(); $userKey = base64_decode($encryptedKey->getKey($vivaUser)); $privateKey = $this->keyStore->getPrivateKey($vivaUser); } else { return null; } $decryptedKey = $this->cryptographyProvider->decryptWithPrivateKey($userKey, $privateKey); return $decryptedKey; }
php
private function decryptSymmetricKeyWithUserKey($entity) { $encryptedKey = $entity->getKey(); $decryptedKey = null; $user = $this->getUser(); if ($user instanceof PKEncryptionEnabledUserInterface && $userKey = $encryptedKey->getKey($user)) { $userKey = base64_decode($userKey); $privateKey = $this->getPrivateKey(); } elseif ($this->accessChecker->canUseOwnerPrivateKey($entity, $user)) { // Check if the logged in user can decrpyt the data without private key $vivaUser = $entity->getUserProfile()->getUser(); $userKey = base64_decode($encryptedKey->getKey($vivaUser)); $privateKey = $this->keyStore->getPrivateKey($vivaUser); } else { return null; } $decryptedKey = $this->cryptographyProvider->decryptWithPrivateKey($userKey, $privateKey); return $decryptedKey; }
[ "private", "function", "decryptSymmetricKeyWithUserKey", "(", "$", "entity", ")", "{", "$", "encryptedKey", "=", "$", "entity", "->", "getKey", "(", ")", ";", "$", "decryptedKey", "=", "null", ";", "$", "user", "=", "$", "this", "->", "getUser", "(", ")", ";", "if", "(", "$", "user", "instanceof", "PKEncryptionEnabledUserInterface", "&&", "$", "userKey", "=", "$", "encryptedKey", "->", "getKey", "(", "$", "user", ")", ")", "{", "$", "userKey", "=", "base64_decode", "(", "$", "userKey", ")", ";", "$", "privateKey", "=", "$", "this", "->", "getPrivateKey", "(", ")", ";", "}", "elseif", "(", "$", "this", "->", "accessChecker", "->", "canUseOwnerPrivateKey", "(", "$", "entity", ",", "$", "user", ")", ")", "{", "// Check if the logged in user can decrpyt the data without private key", "$", "vivaUser", "=", "$", "entity", "->", "getUserProfile", "(", ")", "->", "getUser", "(", ")", ";", "$", "userKey", "=", "base64_decode", "(", "$", "encryptedKey", "->", "getKey", "(", "$", "vivaUser", ")", ")", ";", "$", "privateKey", "=", "$", "this", "->", "keyStore", "->", "getPrivateKey", "(", "$", "vivaUser", ")", ";", "}", "else", "{", "return", "null", ";", "}", "$", "decryptedKey", "=", "$", "this", "->", "cryptographyProvider", "->", "decryptWithPrivateKey", "(", "$", "userKey", ",", "$", "privateKey", ")", ";", "return", "$", "decryptedKey", ";", "}" ]
Decrypts the Symmetric Key of the entity using Per User Encryption @param $entity @return string
[ "Decrypts", "the", "Symmetric", "Key", "of", "the", "entity", "using", "Per", "User", "Encryption" ]
1e1ba13a3cc646b36e3407822f2e8339c5671f47
https://github.com/jagilpe/encryption-bundle/blob/1e1ba13a3cc646b36e3407822f2e8339c5671f47/Crypt/KeyManager.php#L377-L400
226,266
jagilpe/encryption-bundle
Crypt/KeyManager.php
KeyManager.decryptSymmetricKeyWithSystemKey
private function decryptSymmetricKeyWithSystemKey($entity) { /** @var SymmetricKey $encryptedKey */ $encryptedKey = $entity->getKey(); $decryptedKey = null; $systemKey = $encryptedKey->getSystemKey(); $privateKey = $this->keyStore->getPrivateMasterKey(); if ($systemKey) { $systemKey = base64_decode($systemKey); $decryptedKey = $this->cryptographyProvider->decryptWithPrivateKey($systemKey, $privateKey); } return $decryptedKey; }
php
private function decryptSymmetricKeyWithSystemKey($entity) { /** @var SymmetricKey $encryptedKey */ $encryptedKey = $entity->getKey(); $decryptedKey = null; $systemKey = $encryptedKey->getSystemKey(); $privateKey = $this->keyStore->getPrivateMasterKey(); if ($systemKey) { $systemKey = base64_decode($systemKey); $decryptedKey = $this->cryptographyProvider->decryptWithPrivateKey($systemKey, $privateKey); } return $decryptedKey; }
[ "private", "function", "decryptSymmetricKeyWithSystemKey", "(", "$", "entity", ")", "{", "/** @var SymmetricKey $encryptedKey */", "$", "encryptedKey", "=", "$", "entity", "->", "getKey", "(", ")", ";", "$", "decryptedKey", "=", "null", ";", "$", "systemKey", "=", "$", "encryptedKey", "->", "getSystemKey", "(", ")", ";", "$", "privateKey", "=", "$", "this", "->", "keyStore", "->", "getPrivateMasterKey", "(", ")", ";", "if", "(", "$", "systemKey", ")", "{", "$", "systemKey", "=", "base64_decode", "(", "$", "systemKey", ")", ";", "$", "decryptedKey", "=", "$", "this", "->", "cryptographyProvider", "->", "decryptWithPrivateKey", "(", "$", "systemKey", ",", "$", "privateKey", ")", ";", "}", "return", "$", "decryptedKey", ";", "}" ]
Decrypts the Symmetric Key of the entity using System Encryption @param $entity @return string
[ "Decrypts", "the", "Symmetric", "Key", "of", "the", "entity", "using", "System", "Encryption" ]
1e1ba13a3cc646b36e3407822f2e8339c5671f47
https://github.com/jagilpe/encryption-bundle/blob/1e1ba13a3cc646b36e3407822f2e8339c5671f47/Crypt/KeyManager.php#L409-L424
226,267
jagilpe/encryption-bundle
Crypt/KeyManager.php
KeyManager.generatePKIKeys
private function generatePKIKeys() { // OPENSSL config $config = array( 'digest_alg' => $this->settings['private_key']['digest_method'], 'private_key_bits' => $this->settings['private_key']['bits'], 'private_key_type' => $this->settings['private_key']['type'], ); $privateKey = null; $resource = openssl_pkey_new($config); openssl_pkey_export($resource, $privateKey); if(!$privateKey) { throw new EncryptionException('Private key could not be generated'); } $publicKeyDetails = openssl_pkey_get_details($resource); $publicKey = $publicKeyDetails['key']; return array($publicKey, $privateKey); }
php
private function generatePKIKeys() { // OPENSSL config $config = array( 'digest_alg' => $this->settings['private_key']['digest_method'], 'private_key_bits' => $this->settings['private_key']['bits'], 'private_key_type' => $this->settings['private_key']['type'], ); $privateKey = null; $resource = openssl_pkey_new($config); openssl_pkey_export($resource, $privateKey); if(!$privateKey) { throw new EncryptionException('Private key could not be generated'); } $publicKeyDetails = openssl_pkey_get_details($resource); $publicKey = $publicKeyDetails['key']; return array($publicKey, $privateKey); }
[ "private", "function", "generatePKIKeys", "(", ")", "{", "// OPENSSL config", "$", "config", "=", "array", "(", "'digest_alg'", "=>", "$", "this", "->", "settings", "[", "'private_key'", "]", "[", "'digest_method'", "]", ",", "'private_key_bits'", "=>", "$", "this", "->", "settings", "[", "'private_key'", "]", "[", "'bits'", "]", ",", "'private_key_type'", "=>", "$", "this", "->", "settings", "[", "'private_key'", "]", "[", "'type'", "]", ",", ")", ";", "$", "privateKey", "=", "null", ";", "$", "resource", "=", "openssl_pkey_new", "(", "$", "config", ")", ";", "openssl_pkey_export", "(", "$", "resource", ",", "$", "privateKey", ")", ";", "if", "(", "!", "$", "privateKey", ")", "{", "throw", "new", "EncryptionException", "(", "'Private key could not be generated'", ")", ";", "}", "$", "publicKeyDetails", "=", "openssl_pkey_get_details", "(", "$", "resource", ")", ";", "$", "publicKey", "=", "$", "publicKeyDetails", "[", "'key'", "]", ";", "return", "array", "(", "$", "publicKey", ",", "$", "privateKey", ")", ";", "}" ]
Generates a pki keys pair @return array @throws EncryptionException
[ "Generates", "a", "pki", "keys", "pair" ]
1e1ba13a3cc646b36e3407822f2e8339c5671f47
https://github.com/jagilpe/encryption-bundle/blob/1e1ba13a3cc646b36e3407822f2e8339c5671f47/Crypt/KeyManager.php#L441-L463
226,268
jagilpe/encryption-bundle
Crypt/KeyManager.php
KeyManager.encryptPrivateKey
private function encryptPrivateKey(PKEncryptionEnabledUserInterface $user) { if (!$user->isPrivateKeyEncrypted()) { $privateKey = $user->getPrivateKey(); $passwordDigest = $this->getUserPasswordDigest($user); if ($passwordDigest) { $iv = $this->cryptographyProvider->generateIV(CryptographyProviderInterface::PRIVATE_KEY_ENCRYPTION); $keyData = new KeyData($passwordDigest, $iv); try { $encryptedPrivateKey = $this->cryptographyProvider->encrypt( $privateKey, $keyData, CryptographyProviderInterface::PRIVATE_KEY_ENCRYPTION); $encrypted = true; } catch (\Exception $ex) { $encryptedPrivateKey = $privateKey; $iv = null; $encrypted = false; } } else { $encryptedPrivateKey = $privateKey; $iv = null; $encrypted = false; } $user->setPrivateKey($encryptedPrivateKey); if ($encrypted) { $user->setPrivateKeyIv($iv); $user->setPrivateKeyEncrypted(true); } } }
php
private function encryptPrivateKey(PKEncryptionEnabledUserInterface $user) { if (!$user->isPrivateKeyEncrypted()) { $privateKey = $user->getPrivateKey(); $passwordDigest = $this->getUserPasswordDigest($user); if ($passwordDigest) { $iv = $this->cryptographyProvider->generateIV(CryptographyProviderInterface::PRIVATE_KEY_ENCRYPTION); $keyData = new KeyData($passwordDigest, $iv); try { $encryptedPrivateKey = $this->cryptographyProvider->encrypt( $privateKey, $keyData, CryptographyProviderInterface::PRIVATE_KEY_ENCRYPTION); $encrypted = true; } catch (\Exception $ex) { $encryptedPrivateKey = $privateKey; $iv = null; $encrypted = false; } } else { $encryptedPrivateKey = $privateKey; $iv = null; $encrypted = false; } $user->setPrivateKey($encryptedPrivateKey); if ($encrypted) { $user->setPrivateKeyIv($iv); $user->setPrivateKeyEncrypted(true); } } }
[ "private", "function", "encryptPrivateKey", "(", "PKEncryptionEnabledUserInterface", "$", "user", ")", "{", "if", "(", "!", "$", "user", "->", "isPrivateKeyEncrypted", "(", ")", ")", "{", "$", "privateKey", "=", "$", "user", "->", "getPrivateKey", "(", ")", ";", "$", "passwordDigest", "=", "$", "this", "->", "getUserPasswordDigest", "(", "$", "user", ")", ";", "if", "(", "$", "passwordDigest", ")", "{", "$", "iv", "=", "$", "this", "->", "cryptographyProvider", "->", "generateIV", "(", "CryptographyProviderInterface", "::", "PRIVATE_KEY_ENCRYPTION", ")", ";", "$", "keyData", "=", "new", "KeyData", "(", "$", "passwordDigest", ",", "$", "iv", ")", ";", "try", "{", "$", "encryptedPrivateKey", "=", "$", "this", "->", "cryptographyProvider", "->", "encrypt", "(", "$", "privateKey", ",", "$", "keyData", ",", "CryptographyProviderInterface", "::", "PRIVATE_KEY_ENCRYPTION", ")", ";", "$", "encrypted", "=", "true", ";", "}", "catch", "(", "\\", "Exception", "$", "ex", ")", "{", "$", "encryptedPrivateKey", "=", "$", "privateKey", ";", "$", "iv", "=", "null", ";", "$", "encrypted", "=", "false", ";", "}", "}", "else", "{", "$", "encryptedPrivateKey", "=", "$", "privateKey", ";", "$", "iv", "=", "null", ";", "$", "encrypted", "=", "false", ";", "}", "$", "user", "->", "setPrivateKey", "(", "$", "encryptedPrivateKey", ")", ";", "if", "(", "$", "encrypted", ")", "{", "$", "user", "->", "setPrivateKeyIv", "(", "$", "iv", ")", ";", "$", "user", "->", "setPrivateKeyEncrypted", "(", "true", ")", ";", "}", "}", "}" ]
Encrypts the Private key of the user using his password @param \Jagilpe\EncryptionBundle\Entity\PKEncryptionEnabledUserInterface $user @return array
[ "Encrypts", "the", "Private", "key", "of", "the", "user", "using", "his", "password" ]
1e1ba13a3cc646b36e3407822f2e8339c5671f47
https://github.com/jagilpe/encryption-bundle/blob/1e1ba13a3cc646b36e3407822f2e8339c5671f47/Crypt/KeyManager.php#L472-L508
226,269
jagilpe/encryption-bundle
Crypt/KeyManager.php
KeyManager.getUserPasswordDigest
private function getUserPasswordDigest(PKEncryptionEnabledUserInterface $user) { $passwordDigest = $user->getPasswordDigest(); if (!$passwordDigest) { $password = $user->getPlainPassword(); if ($password) { $salt = $user->getSalt(); $passwordDigest = $this->cryptographyProvider->getPasswordDigest($password, $salt); } } return $passwordDigest; }
php
private function getUserPasswordDigest(PKEncryptionEnabledUserInterface $user) { $passwordDigest = $user->getPasswordDigest(); if (!$passwordDigest) { $password = $user->getPlainPassword(); if ($password) { $salt = $user->getSalt(); $passwordDigest = $this->cryptographyProvider->getPasswordDigest($password, $salt); } } return $passwordDigest; }
[ "private", "function", "getUserPasswordDigest", "(", "PKEncryptionEnabledUserInterface", "$", "user", ")", "{", "$", "passwordDigest", "=", "$", "user", "->", "getPasswordDigest", "(", ")", ";", "if", "(", "!", "$", "passwordDigest", ")", "{", "$", "password", "=", "$", "user", "->", "getPlainPassword", "(", ")", ";", "if", "(", "$", "password", ")", "{", "$", "salt", "=", "$", "user", "->", "getSalt", "(", ")", ";", "$", "passwordDigest", "=", "$", "this", "->", "cryptographyProvider", "->", "getPasswordDigest", "(", "$", "password", ",", "$", "salt", ")", ";", "}", "}", "return", "$", "passwordDigest", ";", "}" ]
Returns the password digest of the password of the user @param \Jagilpe\EncryptionBundle\Entity\PKEncryptionEnabledUserInterface $user @return string
[ "Returns", "the", "password", "digest", "of", "the", "password", "of", "the", "user" ]
1e1ba13a3cc646b36e3407822f2e8339c5671f47
https://github.com/jagilpe/encryption-bundle/blob/1e1ba13a3cc646b36e3407822f2e8339c5671f47/Crypt/KeyManager.php#L517-L531
226,270
jagilpe/encryption-bundle
Crypt/KeyManager.php
KeyManager.decryptPrivateKey
private function decryptPrivateKey(PKEncryptionEnabledUserInterface $user, array $params = array()) { if (isset($params['password_digest'])) { $passwordDigest = base64_decode($params['password_digest']); } else { if (isset($params['password'])) { $salt = $user->getSalt(); $passwordDigest = $this->cryptographyProvider->getPasswordDigest($params['password'], $salt); } else { throw new EncryptionException('Could not retrieve the user\'s key'); } } $iv = $user->getPrivateKeyIv(); $keyData = new KeyData($passwordDigest, $iv); $encryptedPrivateKey = $user->getPrivateKey(); $privateKey = $this->cryptographyProvider->decrypt( $encryptedPrivateKey, $keyData, CryptographyProviderInterface::PRIVATE_KEY_ENCRYPTION); return $privateKey; }
php
private function decryptPrivateKey(PKEncryptionEnabledUserInterface $user, array $params = array()) { if (isset($params['password_digest'])) { $passwordDigest = base64_decode($params['password_digest']); } else { if (isset($params['password'])) { $salt = $user->getSalt(); $passwordDigest = $this->cryptographyProvider->getPasswordDigest($params['password'], $salt); } else { throw new EncryptionException('Could not retrieve the user\'s key'); } } $iv = $user->getPrivateKeyIv(); $keyData = new KeyData($passwordDigest, $iv); $encryptedPrivateKey = $user->getPrivateKey(); $privateKey = $this->cryptographyProvider->decrypt( $encryptedPrivateKey, $keyData, CryptographyProviderInterface::PRIVATE_KEY_ENCRYPTION); return $privateKey; }
[ "private", "function", "decryptPrivateKey", "(", "PKEncryptionEnabledUserInterface", "$", "user", ",", "array", "$", "params", "=", "array", "(", ")", ")", "{", "if", "(", "isset", "(", "$", "params", "[", "'password_digest'", "]", ")", ")", "{", "$", "passwordDigest", "=", "base64_decode", "(", "$", "params", "[", "'password_digest'", "]", ")", ";", "}", "else", "{", "if", "(", "isset", "(", "$", "params", "[", "'password'", "]", ")", ")", "{", "$", "salt", "=", "$", "user", "->", "getSalt", "(", ")", ";", "$", "passwordDigest", "=", "$", "this", "->", "cryptographyProvider", "->", "getPasswordDigest", "(", "$", "params", "[", "'password'", "]", ",", "$", "salt", ")", ";", "}", "else", "{", "throw", "new", "EncryptionException", "(", "'Could not retrieve the user\\'s key'", ")", ";", "}", "}", "$", "iv", "=", "$", "user", "->", "getPrivateKeyIv", "(", ")", ";", "$", "keyData", "=", "new", "KeyData", "(", "$", "passwordDigest", ",", "$", "iv", ")", ";", "$", "encryptedPrivateKey", "=", "$", "user", "->", "getPrivateKey", "(", ")", ";", "$", "privateKey", "=", "$", "this", "->", "cryptographyProvider", "->", "decrypt", "(", "$", "encryptedPrivateKey", ",", "$", "keyData", ",", "CryptographyProviderInterface", "::", "PRIVATE_KEY_ENCRYPTION", ")", ";", "return", "$", "privateKey", ";", "}" ]
Encrypts the Private key of the user using his password or a digest of it @param \Jagilpe\EncryptionBundle\Entity\PKEncryptionEnabledUserInterface $user @param array $params @return string|boolean @throws EncryptionException
[ "Encrypts", "the", "Private", "key", "of", "the", "user", "using", "his", "password", "or", "a", "digest", "of", "it" ]
1e1ba13a3cc646b36e3407822f2e8339c5671f47
https://github.com/jagilpe/encryption-bundle/blob/1e1ba13a3cc646b36e3407822f2e8339c5671f47/Crypt/KeyManager.php#L543-L568
226,271
jagilpe/encryption-bundle
Crypt/KeyManager.php
KeyManager.getEncryptionMode
private function getEncryptionMode($entity) { $className = ClassUtils::getClass($entity); $classMetadata = $this->metadataFactory->getMetadataFor($className); return $classMetadata->encryptionMode; }
php
private function getEncryptionMode($entity) { $className = ClassUtils::getClass($entity); $classMetadata = $this->metadataFactory->getMetadataFor($className); return $classMetadata->encryptionMode; }
[ "private", "function", "getEncryptionMode", "(", "$", "entity", ")", "{", "$", "className", "=", "ClassUtils", "::", "getClass", "(", "$", "entity", ")", ";", "$", "classMetadata", "=", "$", "this", "->", "metadataFactory", "->", "getMetadataFor", "(", "$", "className", ")", ";", "return", "$", "classMetadata", "->", "encryptionMode", ";", "}" ]
Returns the encryption mode for the given entity @param $entity @return ClassMetadata
[ "Returns", "the", "encryption", "mode", "for", "the", "given", "entity" ]
1e1ba13a3cc646b36e3407822f2e8339c5671f47
https://github.com/jagilpe/encryption-bundle/blob/1e1ba13a3cc646b36e3407822f2e8339c5671f47/Crypt/KeyManager.php#L577-L583
226,272
gjerokrsteski/pimf-framework
core/Pimf/Util/Validator.php
Validator.email
public function email($field) { return (filter_var(trim($this->get($field)), FILTER_VALIDATE_EMAIL) !== false) ?: $this->error($field, __FUNCTION__); }
php
public function email($field) { return (filter_var(trim($this->get($field)), FILTER_VALIDATE_EMAIL) !== false) ?: $this->error($field, __FUNCTION__); }
[ "public", "function", "email", "(", "$", "field", ")", "{", "return", "(", "filter_var", "(", "trim", "(", "$", "this", "->", "get", "(", "$", "field", ")", ")", ",", "FILTER_VALIDATE_EMAIL", ")", "!==", "false", ")", "?", ":", "$", "this", "->", "error", "(", "$", "field", ",", "__FUNCTION__", ")", ";", "}" ]
check to see if valid email address @param string $field @return bool
[ "check", "to", "see", "if", "valid", "email", "address" ]
859aa7c8bb727b556c5e32224842af3cff33f18b
https://github.com/gjerokrsteski/pimf-framework/blob/859aa7c8bb727b556c5e32224842af3cff33f18b/core/Pimf/Util/Validator.php#L60-L64
226,273
gjerokrsteski/pimf-framework
core/Pimf/Util/Validator.php
Validator.ip
public function ip($field) { return (filter_var(trim($this->get($field)), FILTER_VALIDATE_IP) !== false) ?: $this->error($field, __FUNCTION__); }
php
public function ip($field) { return (filter_var(trim($this->get($field)), FILTER_VALIDATE_IP) !== false) ?: $this->error($field, __FUNCTION__); }
[ "public", "function", "ip", "(", "$", "field", ")", "{", "return", "(", "filter_var", "(", "trim", "(", "$", "this", "->", "get", "(", "$", "field", ")", ")", ",", "FILTER_VALIDATE_IP", ")", "!==", "false", ")", "?", ":", "$", "this", "->", "error", "(", "$", "field", ",", "__FUNCTION__", ")", ";", "}" ]
Check is a valid IP. @param $field @return bool
[ "Check", "is", "a", "valid", "IP", "." ]
859aa7c8bb727b556c5e32224842af3cff33f18b
https://github.com/gjerokrsteski/pimf-framework/blob/859aa7c8bb727b556c5e32224842af3cff33f18b/core/Pimf/Util/Validator.php#L73-L77
226,274
gjerokrsteski/pimf-framework
core/Pimf/Util/Validator.php
Validator.url
public function url($field) { return (filter_var(trim($this->get($field)), FILTER_VALIDATE_URL) !== false) ?: $this->error($field, __FUNCTION__); }
php
public function url($field) { return (filter_var(trim($this->get($field)), FILTER_VALIDATE_URL) !== false) ?: $this->error($field, __FUNCTION__); }
[ "public", "function", "url", "(", "$", "field", ")", "{", "return", "(", "filter_var", "(", "trim", "(", "$", "this", "->", "get", "(", "$", "field", ")", ")", ",", "FILTER_VALIDATE_URL", ")", "!==", "false", ")", "?", ":", "$", "this", "->", "error", "(", "$", "field", ",", "__FUNCTION__", ")", ";", "}" ]
Check is a valid URL. @param $field @return bool
[ "Check", "is", "a", "valid", "URL", "." ]
859aa7c8bb727b556c5e32224842af3cff33f18b
https://github.com/gjerokrsteski/pimf-framework/blob/859aa7c8bb727b556c5e32224842af3cff33f18b/core/Pimf/Util/Validator.php#L86-L90
226,275
gjerokrsteski/pimf-framework
core/Pimf/Util/Validator.php
Validator.compare
public function compare($field1, $field2, $caseInsensitive = false) { $field1value = $this->get($field1); $field2value = $this->get($field2); $valid = (strcmp($field1value, $field2value) == 0); if ($caseInsensitive) { $valid = (strcmp(strtolower($field1value), strtolower($field2value)) == 0); } return ($valid === true) ?: $this->error($field1 . "|" . $field2, __FUNCTION__); }
php
public function compare($field1, $field2, $caseInsensitive = false) { $field1value = $this->get($field1); $field2value = $this->get($field2); $valid = (strcmp($field1value, $field2value) == 0); if ($caseInsensitive) { $valid = (strcmp(strtolower($field1value), strtolower($field2value)) == 0); } return ($valid === true) ?: $this->error($field1 . "|" . $field2, __FUNCTION__); }
[ "public", "function", "compare", "(", "$", "field1", ",", "$", "field2", ",", "$", "caseInsensitive", "=", "false", ")", "{", "$", "field1value", "=", "$", "this", "->", "get", "(", "$", "field1", ")", ";", "$", "field2value", "=", "$", "this", "->", "get", "(", "$", "field2", ")", ";", "$", "valid", "=", "(", "strcmp", "(", "$", "field1value", ",", "$", "field2value", ")", "==", "0", ")", ";", "if", "(", "$", "caseInsensitive", ")", "{", "$", "valid", "=", "(", "strcmp", "(", "strtolower", "(", "$", "field1value", ")", ",", "strtolower", "(", "$", "field2value", ")", ")", "==", "0", ")", ";", "}", "return", "(", "$", "valid", "===", "true", ")", "?", ":", "$", "this", "->", "error", "(", "$", "field1", ".", "\"|\"", ".", "$", "field2", ",", "__FUNCTION__", ")", ";", "}" ]
Check to see if two fields are equal. @param string $field1 @param string $field2 @param bool $caseInsensitive @return bool
[ "Check", "to", "see", "if", "two", "fields", "are", "equal", "." ]
859aa7c8bb727b556c5e32224842af3cff33f18b
https://github.com/gjerokrsteski/pimf-framework/blob/859aa7c8bb727b556c5e32224842af3cff33f18b/core/Pimf/Util/Validator.php#L101-L113
226,276
gjerokrsteski/pimf-framework
core/Pimf/Util/Validator.php
Validator.lengthBetween
public function lengthBetween($field, $min, $max, $inclusive = false) { $fieldValue = strlen(trim($this->get($field))); $valid = ($fieldValue <= $max && $fieldValue >= $min); if (!$inclusive) { $valid = ($fieldValue < $max && $fieldValue > $min); } return ($valid === true) ?: $this->error($field, __FUNCTION__); }
php
public function lengthBetween($field, $min, $max, $inclusive = false) { $fieldValue = strlen(trim($this->get($field))); $valid = ($fieldValue <= $max && $fieldValue >= $min); if (!$inclusive) { $valid = ($fieldValue < $max && $fieldValue > $min); } return ($valid === true) ?: $this->error($field, __FUNCTION__); }
[ "public", "function", "lengthBetween", "(", "$", "field", ",", "$", "min", ",", "$", "max", ",", "$", "inclusive", "=", "false", ")", "{", "$", "fieldValue", "=", "strlen", "(", "trim", "(", "$", "this", "->", "get", "(", "$", "field", ")", ")", ")", ";", "$", "valid", "=", "(", "$", "fieldValue", "<=", "$", "max", "&&", "$", "fieldValue", ">=", "$", "min", ")", ";", "if", "(", "!", "$", "inclusive", ")", "{", "$", "valid", "=", "(", "$", "fieldValue", "<", "$", "max", "&&", "$", "fieldValue", ">", "$", "min", ")", ";", "}", "return", "(", "$", "valid", "===", "true", ")", "?", ":", "$", "this", "->", "error", "(", "$", "field", ",", "__FUNCTION__", ")", ";", "}" ]
Check to see if the length of a field is between two numbers @param string $field @param int $min @param int $max @param bool $inclusive @return bool
[ "Check", "to", "see", "if", "the", "length", "of", "a", "field", "is", "between", "two", "numbers" ]
859aa7c8bb727b556c5e32224842af3cff33f18b
https://github.com/gjerokrsteski/pimf-framework/blob/859aa7c8bb727b556c5e32224842af3cff33f18b/core/Pimf/Util/Validator.php#L125-L136
226,277
gjerokrsteski/pimf-framework
core/Pimf/Util/Validator.php
Validator.punctuation
public function punctuation($field) { return (preg_match("/[^\w\s\p{P}]/", '' . $this->get($field)) > 0) ? $this->error($field, __FUNCTION__) : true; }
php
public function punctuation($field) { return (preg_match("/[^\w\s\p{P}]/", '' . $this->get($field)) > 0) ? $this->error($field, __FUNCTION__) : true; }
[ "public", "function", "punctuation", "(", "$", "field", ")", "{", "return", "(", "preg_match", "(", "\"/[^\\w\\s\\p{P}]/\"", ",", "''", ".", "$", "this", "->", "get", "(", "$", "field", ")", ")", ">", "0", ")", "?", "$", "this", "->", "error", "(", "$", "field", ",", "__FUNCTION__", ")", ":", "true", ";", "}" ]
Check to see if there is punctuation @param string $field @return bool
[ "Check", "to", "see", "if", "there", "is", "punctuation" ]
859aa7c8bb727b556c5e32224842af3cff33f18b
https://github.com/gjerokrsteski/pimf-framework/blob/859aa7c8bb727b556c5e32224842af3cff33f18b/core/Pimf/Util/Validator.php#L145-L148
226,278
gjerokrsteski/pimf-framework
core/Pimf/Util/Validator.php
Validator.digit
public function digit($field) { return (ctype_digit((string)$this->get($field)) === true) ?: $this->error($field, __FUNCTION__); }
php
public function digit($field) { return (ctype_digit((string)$this->get($field)) === true) ?: $this->error($field, __FUNCTION__); }
[ "public", "function", "digit", "(", "$", "field", ")", "{", "return", "(", "ctype_digit", "(", "(", "string", ")", "$", "this", "->", "get", "(", "$", "field", ")", ")", "===", "true", ")", "?", ":", "$", "this", "->", "error", "(", "$", "field", ",", "__FUNCTION__", ")", ";", "}" ]
Check if a field contains only decimal digit @param string $field @return bool
[ "Check", "if", "a", "field", "contains", "only", "decimal", "digit" ]
859aa7c8bb727b556c5e32224842af3cff33f18b
https://github.com/gjerokrsteski/pimf-framework/blob/859aa7c8bb727b556c5e32224842af3cff33f18b/core/Pimf/Util/Validator.php#L208-L211
226,279
gjerokrsteski/pimf-framework
core/Pimf/Util/Validator.php
Validator.alpha
public function alpha($field) { return (ctype_alpha((string)$this->get($field)) === true) ?: $this->error($field, __FUNCTION__); }
php
public function alpha($field) { return (ctype_alpha((string)$this->get($field)) === true) ?: $this->error($field, __FUNCTION__); }
[ "public", "function", "alpha", "(", "$", "field", ")", "{", "return", "(", "ctype_alpha", "(", "(", "string", ")", "$", "this", "->", "get", "(", "$", "field", ")", ")", "===", "true", ")", "?", ":", "$", "this", "->", "error", "(", "$", "field", ",", "__FUNCTION__", ")", ";", "}" ]
Check if a field contains only alphabetic characters @param string $field @return bool
[ "Check", "if", "a", "field", "contains", "only", "alphabetic", "characters" ]
859aa7c8bb727b556c5e32224842af3cff33f18b
https://github.com/gjerokrsteski/pimf-framework/blob/859aa7c8bb727b556c5e32224842af3cff33f18b/core/Pimf/Util/Validator.php#L220-L223
226,280
gjerokrsteski/pimf-framework
core/Pimf/Util/Validator.php
Validator.alphaNumeric
public function alphaNumeric($field) { return (ctype_alnum((string)$this->get($field)) === true) ?: $this->error($field, __FUNCTION__); }
php
public function alphaNumeric($field) { return (ctype_alnum((string)$this->get($field)) === true) ?: $this->error($field, __FUNCTION__); }
[ "public", "function", "alphaNumeric", "(", "$", "field", ")", "{", "return", "(", "ctype_alnum", "(", "(", "string", ")", "$", "this", "->", "get", "(", "$", "field", ")", ")", "===", "true", ")", "?", ":", "$", "this", "->", "error", "(", "$", "field", ",", "__FUNCTION__", ")", ";", "}" ]
Check if a field contains only alphanumeric characters @param string $field @return bool
[ "Check", "if", "a", "field", "contains", "only", "alphanumeric", "characters" ]
859aa7c8bb727b556c5e32224842af3cff33f18b
https://github.com/gjerokrsteski/pimf-framework/blob/859aa7c8bb727b556c5e32224842af3cff33f18b/core/Pimf/Util/Validator.php#L232-L235
226,281
gjerokrsteski/pimf-framework
core/Pimf/Util/Validator.php
Validator.date
public function date($field, $format) { $fieldValue = $this->get($field); try { $date = new \DateTime($fieldValue); return $fieldValue === $date->format($format); } catch (\Exception $exception) { return $this->error($field, __FUNCTION__); } }
php
public function date($field, $format) { $fieldValue = $this->get($field); try { $date = new \DateTime($fieldValue); return $fieldValue === $date->format($format); } catch (\Exception $exception) { return $this->error($field, __FUNCTION__); } }
[ "public", "function", "date", "(", "$", "field", ",", "$", "format", ")", "{", "$", "fieldValue", "=", "$", "this", "->", "get", "(", "$", "field", ")", ";", "try", "{", "$", "date", "=", "new", "\\", "DateTime", "(", "$", "fieldValue", ")", ";", "return", "$", "fieldValue", "===", "$", "date", "->", "format", "(", "$", "format", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "exception", ")", "{", "return", "$", "this", "->", "error", "(", "$", "field", ",", "__FUNCTION__", ")", ";", "}", "}" ]
Check if field is a date by specified format. @param string $field @param string $format Find formats here http://www.php.net/manual/en/function.date.php @return boolean
[ "Check", "if", "field", "is", "a", "date", "by", "specified", "format", "." ]
859aa7c8bb727b556c5e32224842af3cff33f18b
https://github.com/gjerokrsteski/pimf-framework/blob/859aa7c8bb727b556c5e32224842af3cff33f18b/core/Pimf/Util/Validator.php#L245-L257
226,282
vinkla/laravel-backup
src/Sources/MysqlDumpSource.php
MysqlDumpSource.bootstrap
public function bootstrap(): Source { $connection = $this->getDatabaseConnection(); $config = $this->config->get("database.connections.$connection"); if (array_get($config, 'driver') !== 'mysql') { throw new InvalidArgumentException("Unsupported database driver [{$config['driver']}]."); } return new Source( $this->getName(), array_get($config, 'database'), array_get($config, 'host'), array_get($config, 'username'), array_get($config, 'password') ); }
php
public function bootstrap(): Source { $connection = $this->getDatabaseConnection(); $config = $this->config->get("database.connections.$connection"); if (array_get($config, 'driver') !== 'mysql') { throw new InvalidArgumentException("Unsupported database driver [{$config['driver']}]."); } return new Source( $this->getName(), array_get($config, 'database'), array_get($config, 'host'), array_get($config, 'username'), array_get($config, 'password') ); }
[ "public", "function", "bootstrap", "(", ")", ":", "Source", "{", "$", "connection", "=", "$", "this", "->", "getDatabaseConnection", "(", ")", ";", "$", "config", "=", "$", "this", "->", "config", "->", "get", "(", "\"database.connections.$connection\"", ")", ";", "if", "(", "array_get", "(", "$", "config", ",", "'driver'", ")", "!==", "'mysql'", ")", "{", "throw", "new", "InvalidArgumentException", "(", "\"Unsupported database driver [{$config['driver']}].\"", ")", ";", "}", "return", "new", "Source", "(", "$", "this", "->", "getName", "(", ")", ",", "array_get", "(", "$", "config", ",", "'database'", ")", ",", "array_get", "(", "$", "config", ",", "'host'", ")", ",", "array_get", "(", "$", "config", ",", "'username'", ")", ",", "array_get", "(", "$", "config", ",", "'password'", ")", ")", ";", "}" ]
Bootstrap the source. @throws \InvalidArgumentException @return \Zenstruck\Backup\Source\MySqlDumpSource
[ "Bootstrap", "the", "source", "." ]
d3662b6509a39bce9cd75cc3e65b4ea01be46b26
https://github.com/vinkla/laravel-backup/blob/d3662b6509a39bce9cd75cc3e65b4ea01be46b26/src/Sources/MysqlDumpSource.php#L53-L70
226,283
Techworker/ssml
src/Traits/PhonemeTrait.php
PhonemeTrait.phoneme
public function phoneme(string $alphabet, string $ph, string $text): ContainerElement { /** @var ContainerElement $this */ return $this->addElement(Phoneme::factory($alphabet, $ph, $text)); }
php
public function phoneme(string $alphabet, string $ph, string $text): ContainerElement { /** @var ContainerElement $this */ return $this->addElement(Phoneme::factory($alphabet, $ph, $text)); }
[ "public", "function", "phoneme", "(", "string", "$", "alphabet", ",", "string", "$", "ph", ",", "string", "$", "text", ")", ":", "ContainerElement", "{", "/** @var ContainerElement $this */", "return", "$", "this", "->", "addElement", "(", "Phoneme", "::", "factory", "(", "$", "alphabet", ",", "$", "ph", ",", "$", "text", ")", ")", ";", "}" ]
Adds a phoneme element. @param string $alphabet @param string $ph @param string $text @return ContainerElement
[ "Adds", "a", "phoneme", "element", "." ]
cafb979b777480baf7a01b5db2bf7c2cff837805
https://github.com/Techworker/ssml/blob/cafb979b777480baf7a01b5db2bf7c2cff837805/src/Traits/PhonemeTrait.php#L32-L36
226,284
phergie/phergie-irc-client-react
src/Client.php
Client.getLoop
public function getLoop() { if (!$this->loop) { $this->loop = \React\EventLoop\Factory::create(); } return $this->loop; }
php
public function getLoop() { if (!$this->loop) { $this->loop = \React\EventLoop\Factory::create(); } return $this->loop; }
[ "public", "function", "getLoop", "(", ")", "{", "if", "(", "!", "$", "this", "->", "loop", ")", "{", "$", "this", "->", "loop", "=", "\\", "React", "\\", "EventLoop", "\\", "Factory", "::", "create", "(", ")", ";", "}", "return", "$", "this", "->", "loop", ";", "}" ]
Returns the event loop dependency, initializing it if needed. @return \React\EventLoop\LoopInterface
[ "Returns", "the", "event", "loop", "dependency", "initializing", "it", "if", "needed", "." ]
b0d03f1e1ff34a2868f1f7d677786fdd1786b320
https://github.com/phergie/phergie-irc-client-react/blob/b0d03f1e1ff34a2868f1f7d677786fdd1786b320/src/Client.php#L100-L106
226,285
phergie/phergie-irc-client-react
src/Client.php
Client.getResolver
public function getResolver() { if ($this->resolver instanceof Resolver) { return $this->resolver; } $factory = new Factory(); $this->resolver = $factory->createCached($this->getDnsServer(), $this->getLoop()); return $this->resolver; }
php
public function getResolver() { if ($this->resolver instanceof Resolver) { return $this->resolver; } $factory = new Factory(); $this->resolver = $factory->createCached($this->getDnsServer(), $this->getLoop()); return $this->resolver; }
[ "public", "function", "getResolver", "(", ")", "{", "if", "(", "$", "this", "->", "resolver", "instanceof", "Resolver", ")", "{", "return", "$", "this", "->", "resolver", ";", "}", "$", "factory", "=", "new", "Factory", "(", ")", ";", "$", "this", "->", "resolver", "=", "$", "factory", "->", "createCached", "(", "$", "this", "->", "getDnsServer", "(", ")", ",", "$", "this", "->", "getLoop", "(", ")", ")", ";", "return", "$", "this", "->", "resolver", ";", "}" ]
Get the DNS Resolver, if one isn't set in instance will be created. @return Resolver
[ "Get", "the", "DNS", "Resolver", "if", "one", "isn", "t", "set", "in", "instance", "will", "be", "created", "." ]
b0d03f1e1ff34a2868f1f7d677786fdd1786b320
https://github.com/phergie/phergie-irc-client-react/blob/b0d03f1e1ff34a2868f1f7d677786fdd1786b320/src/Client.php#L123-L133
226,286
phergie/phergie-irc-client-react
src/Client.php
Client.addActiveConnection
protected function addActiveConnection(ConnectionInterface $connection) { if (!$this->activeConnections) { $this->activeConnections = new \SplObjectStorage; } $this->activeConnections->attach($connection); }
php
protected function addActiveConnection(ConnectionInterface $connection) { if (!$this->activeConnections) { $this->activeConnections = new \SplObjectStorage; } $this->activeConnections->attach($connection); }
[ "protected", "function", "addActiveConnection", "(", "ConnectionInterface", "$", "connection", ")", "{", "if", "(", "!", "$", "this", "->", "activeConnections", ")", "{", "$", "this", "->", "activeConnections", "=", "new", "\\", "SplObjectStorage", ";", "}", "$", "this", "->", "activeConnections", "->", "attach", "(", "$", "connection", ")", ";", "}" ]
Add a connection instance to the active connection store @param \Phergie\Irc\ConnectionInterface
[ "Add", "a", "connection", "instance", "to", "the", "active", "connection", "store" ]
b0d03f1e1ff34a2868f1f7d677786fdd1786b320
https://github.com/phergie/phergie-irc-client-react/blob/b0d03f1e1ff34a2868f1f7d677786fdd1786b320/src/Client.php#L180-L186
226,287
phergie/phergie-irc-client-react
src/Client.php
Client.getSocket
protected function getSocket($remote, array $context) { $socket = stream_socket_client( $remote, $errno, $errstr, ini_get('default_socket_timeout'), STREAM_CLIENT_CONNECT, stream_context_create($context) ); if (!$socket) { throw new Exception( 'Unable to connect to remote ' . $remote . ': socket error ' . $errno . ' ' . $errstr, Exception::ERR_CONNECTION_ATTEMPT_FAILED ); } stream_set_blocking($socket, 0); return $socket; }
php
protected function getSocket($remote, array $context) { $socket = stream_socket_client( $remote, $errno, $errstr, ini_get('default_socket_timeout'), STREAM_CLIENT_CONNECT, stream_context_create($context) ); if (!$socket) { throw new Exception( 'Unable to connect to remote ' . $remote . ': socket error ' . $errno . ' ' . $errstr, Exception::ERR_CONNECTION_ATTEMPT_FAILED ); } stream_set_blocking($socket, 0); return $socket; }
[ "protected", "function", "getSocket", "(", "$", "remote", ",", "array", "$", "context", ")", "{", "$", "socket", "=", "stream_socket_client", "(", "$", "remote", ",", "$", "errno", ",", "$", "errstr", ",", "ini_get", "(", "'default_socket_timeout'", ")", ",", "STREAM_CLIENT_CONNECT", ",", "stream_context_create", "(", "$", "context", ")", ")", ";", "if", "(", "!", "$", "socket", ")", "{", "throw", "new", "Exception", "(", "'Unable to connect to remote '", ".", "$", "remote", ".", "': socket error '", ".", "$", "errno", ".", "' '", ".", "$", "errstr", ",", "Exception", "::", "ERR_CONNECTION_ATTEMPT_FAILED", ")", ";", "}", "stream_set_blocking", "(", "$", "socket", ",", "0", ")", ";", "return", "$", "socket", ";", "}" ]
Returns a socket configured for a specified remote. @param string $remote Address to connect the socket to (e.g. tcp://irc.freenode.net:6667) @param array $context Context options for the socket @return resource @throws \Phergie\Irc\Client\React\Exception if unable to connect to the specified remote
[ "Returns", "a", "socket", "configured", "for", "a", "specified", "remote", "." ]
b0d03f1e1ff34a2868f1f7d677786fdd1786b320
https://github.com/phergie/phergie-irc-client-react/blob/b0d03f1e1ff34a2868f1f7d677786fdd1786b320/src/Client.php#L218-L239
226,288
phergie/phergie-irc-client-react
src/Client.php
Client.getRemote
protected function getRemote(ConnectionInterface $connection) { $hostname = $connection->getServerHostname(); $port = $connection->getServerPort(); $deferred = new Deferred(); $this->resolveHostname($hostname) ->then( function($ip) use($deferred, $port) { $deferred->resolve('tcp://' . $ip . ':' . $port); }, function($error) use ($deferred) { $deferred->reject($error); } ); return $deferred->promise(); }
php
protected function getRemote(ConnectionInterface $connection) { $hostname = $connection->getServerHostname(); $port = $connection->getServerPort(); $deferred = new Deferred(); $this->resolveHostname($hostname) ->then( function($ip) use($deferred, $port) { $deferred->resolve('tcp://' . $ip . ':' . $port); }, function($error) use ($deferred) { $deferred->reject($error); } ); return $deferred->promise(); }
[ "protected", "function", "getRemote", "(", "ConnectionInterface", "$", "connection", ")", "{", "$", "hostname", "=", "$", "connection", "->", "getServerHostname", "(", ")", ";", "$", "port", "=", "$", "connection", "->", "getServerPort", "(", ")", ";", "$", "deferred", "=", "new", "Deferred", "(", ")", ";", "$", "this", "->", "resolveHostname", "(", "$", "hostname", ")", "->", "then", "(", "function", "(", "$", "ip", ")", "use", "(", "$", "deferred", ",", "$", "port", ")", "{", "$", "deferred", "->", "resolve", "(", "'tcp://'", ".", "$", "ip", ".", "':'", ".", "$", "port", ")", ";", "}", ",", "function", "(", "$", "error", ")", "use", "(", "$", "deferred", ")", "{", "$", "deferred", "->", "reject", "(", "$", "error", ")", ";", "}", ")", ";", "return", "$", "deferred", "->", "promise", "(", ")", ";", "}" ]
Derives a remote for a given connection. @param \Phergie\Irc\ConnectionInterface $connection @return string Remote usable to establish a socket connection
[ "Derives", "a", "remote", "for", "a", "given", "connection", "." ]
b0d03f1e1ff34a2868f1f7d677786fdd1786b320
https://github.com/phergie/phergie-irc-client-react/blob/b0d03f1e1ff34a2868f1f7d677786fdd1786b320/src/Client.php#L280-L297
226,289
phergie/phergie-irc-client-react
src/Client.php
Client.resolveHostname
protected function resolveHostname($hostname) { if (false !== filter_var($hostname, FILTER_VALIDATE_IP)) { return \React\Promise\resolve($hostname); } return $this->getResolver()->resolve($hostname); }
php
protected function resolveHostname($hostname) { if (false !== filter_var($hostname, FILTER_VALIDATE_IP)) { return \React\Promise\resolve($hostname); } return $this->getResolver()->resolve($hostname); }
[ "protected", "function", "resolveHostname", "(", "$", "hostname", ")", "{", "if", "(", "false", "!==", "filter_var", "(", "$", "hostname", ",", "FILTER_VALIDATE_IP", ")", ")", "{", "return", "\\", "React", "\\", "Promise", "\\", "resolve", "(", "$", "hostname", ")", ";", "}", "return", "$", "this", "->", "getResolver", "(", ")", "->", "resolve", "(", "$", "hostname", ")", ";", "}" ]
Resolve an IP address from a hostname @param string $hostname @return PromiseInterface promise resolving to the hostname's IP
[ "Resolve", "an", "IP", "address", "from", "a", "hostname" ]
b0d03f1e1ff34a2868f1f7d677786fdd1786b320
https://github.com/phergie/phergie-irc-client-react/blob/b0d03f1e1ff34a2868f1f7d677786fdd1786b320/src/Client.php#L305-L312
226,290
phergie/phergie-irc-client-react
src/Client.php
Client.getContext
protected function getContext(ConnectionInterface $connection) { $context = array(); if ($this->getForceIpv4Flag($connection)) { $context['bindto'] = '0.0.0.0:0'; } $context = array('socket' => $context); return $context; }
php
protected function getContext(ConnectionInterface $connection) { $context = array(); if ($this->getForceIpv4Flag($connection)) { $context['bindto'] = '0.0.0.0:0'; } $context = array('socket' => $context); return $context; }
[ "protected", "function", "getContext", "(", "ConnectionInterface", "$", "connection", ")", "{", "$", "context", "=", "array", "(", ")", ";", "if", "(", "$", "this", "->", "getForceIpv4Flag", "(", "$", "connection", ")", ")", "{", "$", "context", "[", "'bindto'", "]", "=", "'0.0.0.0:0'", ";", "}", "$", "context", "=", "array", "(", "'socket'", "=>", "$", "context", ")", ";", "return", "$", "context", ";", "}" ]
Derives a set of socket context options for a given connection. @param \Phergie\Irc\ConnectionInterface $connection @return array Associative array of context option key-value pairs
[ "Derives", "a", "set", "of", "socket", "context", "options", "for", "a", "given", "connection", "." ]
b0d03f1e1ff34a2868f1f7d677786fdd1786b320
https://github.com/phergie/phergie-irc-client-react/blob/b0d03f1e1ff34a2868f1f7d677786fdd1786b320/src/Client.php#L320-L328
226,291
phergie/phergie-irc-client-react
src/Client.php
Client.getSecureContext
protected function getSecureContext(ConnectionInterface $connection) { $context = array(); if ($this->getForceIpv4Flag($connection)) { $context['bindto'] = '0.0.0.0:0'; } if ($this->getAllowSelfSignedFlag($connection)) { $context['allow_self_signed'] = true; } return $context; }
php
protected function getSecureContext(ConnectionInterface $connection) { $context = array(); if ($this->getForceIpv4Flag($connection)) { $context['bindto'] = '0.0.0.0:0'; } if ($this->getAllowSelfSignedFlag($connection)) { $context['allow_self_signed'] = true; } return $context; }
[ "protected", "function", "getSecureContext", "(", "ConnectionInterface", "$", "connection", ")", "{", "$", "context", "=", "array", "(", ")", ";", "if", "(", "$", "this", "->", "getForceIpv4Flag", "(", "$", "connection", ")", ")", "{", "$", "context", "[", "'bindto'", "]", "=", "'0.0.0.0:0'", ";", "}", "if", "(", "$", "this", "->", "getAllowSelfSignedFlag", "(", "$", "connection", ")", ")", "{", "$", "context", "[", "'allow_self_signed'", "]", "=", "true", ";", "}", "return", "$", "context", ";", "}" ]
Derives a set of socket context options for a given secure connection. @param \Phergie\Irc\ConnectionInterface $connection @return array Associative array of context option key-value pairs
[ "Derives", "a", "set", "of", "socket", "context", "options", "for", "a", "given", "secure", "connection", "." ]
b0d03f1e1ff34a2868f1f7d677786fdd1786b320
https://github.com/phergie/phergie-irc-client-react/blob/b0d03f1e1ff34a2868f1f7d677786fdd1786b320/src/Client.php#L336-L346
226,292
phergie/phergie-irc-client-react
src/Client.php
Client.getStream
protected function getStream($socket) { if (class_exists(DuplexResourceStream::class)) { return new DuplexResourceStream($socket, $this->getLoop()); } return new Stream($socket, $this->getLoop()); }
php
protected function getStream($socket) { if (class_exists(DuplexResourceStream::class)) { return new DuplexResourceStream($socket, $this->getLoop()); } return new Stream($socket, $this->getLoop()); }
[ "protected", "function", "getStream", "(", "$", "socket", ")", "{", "if", "(", "class_exists", "(", "DuplexResourceStream", "::", "class", ")", ")", "{", "return", "new", "DuplexResourceStream", "(", "$", "socket", ",", "$", "this", "->", "getLoop", "(", ")", ")", ";", "}", "return", "new", "Stream", "(", "$", "socket", ",", "$", "this", "->", "getLoop", "(", ")", ")", ";", "}" ]
Returns a stream for a socket connection. @param resource $socket Socket for the connection to the server @param \React\EventLoop\LoopInterface $loop Event loop @return \React\Stream\DuplexStreamInterface
[ "Returns", "a", "stream", "for", "a", "socket", "connection", "." ]
b0d03f1e1ff34a2868f1f7d677786fdd1786b320
https://github.com/phergie/phergie-irc-client-react/blob/b0d03f1e1ff34a2868f1f7d677786fdd1786b320/src/Client.php#L355-L362
226,293
phergie/phergie-irc-client-react
src/Client.php
Client.getOutputLogCallback
protected function getOutputLogCallback(ConnectionInterface $connection, $level, $prefix = null) { $logger = $this->getLogger(); if (!method_exists($logger, $level)) { throw new \DomainException("Invalid log level '$level'"); } return function($message) use ($connection, $level, $prefix, $logger) { $output = sprintf('%s %s%s', $connection->getMask(), $prefix, trim($message)); call_user_func(array($logger, $level), $output); }; }
php
protected function getOutputLogCallback(ConnectionInterface $connection, $level, $prefix = null) { $logger = $this->getLogger(); if (!method_exists($logger, $level)) { throw new \DomainException("Invalid log level '$level'"); } return function($message) use ($connection, $level, $prefix, $logger) { $output = sprintf('%s %s%s', $connection->getMask(), $prefix, trim($message)); call_user_func(array($logger, $level), $output); }; }
[ "protected", "function", "getOutputLogCallback", "(", "ConnectionInterface", "$", "connection", ",", "$", "level", ",", "$", "prefix", "=", "null", ")", "{", "$", "logger", "=", "$", "this", "->", "getLogger", "(", ")", ";", "if", "(", "!", "method_exists", "(", "$", "logger", ",", "$", "level", ")", ")", "{", "throw", "new", "\\", "DomainException", "(", "\"Invalid log level '$level'\"", ")", ";", "}", "return", "function", "(", "$", "message", ")", "use", "(", "$", "connection", ",", "$", "level", ",", "$", "prefix", ",", "$", "logger", ")", "{", "$", "output", "=", "sprintf", "(", "'%s %s%s'", ",", "$", "connection", "->", "getMask", "(", ")", ",", "$", "prefix", ",", "trim", "(", "$", "message", ")", ")", ";", "call_user_func", "(", "array", "(", "$", "logger", ",", "$", "level", ")", ",", "$", "output", ")", ";", "}", ";", "}" ]
Generates a closure for stream output logging. @param \Phergie\Irc\ConnectionInterface $connection @param string $level Evenement logging level to use @param string $prefix Prefix string for log lines (optional) @return callable @throws \DomainException if $level is not a valid logging level
[ "Generates", "a", "closure", "for", "stream", "output", "logging", "." ]
b0d03f1e1ff34a2868f1f7d677786fdd1786b320
https://github.com/phergie/phergie-irc-client-react/blob/b0d03f1e1ff34a2868f1f7d677786fdd1786b320/src/Client.php#L373-L383
226,294
phergie/phergie-irc-client-react
src/Client.php
Client.addLogging
protected function addLogging(EventEmitter $emitter, ConnectionInterface $connection) { $emitter->on('data', $this->getOutputLogCallback($connection, 'debug')); $emitter->on('error', $this->getOutputLogCallback($connection, 'notice')); }
php
protected function addLogging(EventEmitter $emitter, ConnectionInterface $connection) { $emitter->on('data', $this->getOutputLogCallback($connection, 'debug')); $emitter->on('error', $this->getOutputLogCallback($connection, 'notice')); }
[ "protected", "function", "addLogging", "(", "EventEmitter", "$", "emitter", ",", "ConnectionInterface", "$", "connection", ")", "{", "$", "emitter", "->", "on", "(", "'data'", ",", "$", "this", "->", "getOutputLogCallback", "(", "$", "connection", ",", "'debug'", ")", ")", ";", "$", "emitter", "->", "on", "(", "'error'", ",", "$", "this", "->", "getOutputLogCallback", "(", "$", "connection", ",", "'notice'", ")", ")", ";", "}" ]
Adds an event listener to log data emitted by a stream. @param \Evenement\EventEmitter $emitter @param \Phergie\Irc\ConnectionInterface $connection Connection corresponding to the stream
[ "Adds", "an", "event", "listener", "to", "log", "data", "emitted", "by", "a", "stream", "." ]
b0d03f1e1ff34a2868f1f7d677786fdd1786b320
https://github.com/phergie/phergie-irc-client-react/blob/b0d03f1e1ff34a2868f1f7d677786fdd1786b320/src/Client.php#L392-L396
226,295
phergie/phergie-irc-client-react
src/Client.php
Client.getReadStream
protected function getReadStream(ConnectionInterface $connection) { $read = new ReadStream(); $this->addLogging($read, $connection); $read->on('invalid', $this->getOutputLogCallback($connection, 'notice', 'Parser unable to parse line: ')); return $read; }
php
protected function getReadStream(ConnectionInterface $connection) { $read = new ReadStream(); $this->addLogging($read, $connection); $read->on('invalid', $this->getOutputLogCallback($connection, 'notice', 'Parser unable to parse line: ')); return $read; }
[ "protected", "function", "getReadStream", "(", "ConnectionInterface", "$", "connection", ")", "{", "$", "read", "=", "new", "ReadStream", "(", ")", ";", "$", "this", "->", "addLogging", "(", "$", "read", ",", "$", "connection", ")", ";", "$", "read", "->", "on", "(", "'invalid'", ",", "$", "this", "->", "getOutputLogCallback", "(", "$", "connection", ",", "'notice'", ",", "'Parser unable to parse line: '", ")", ")", ";", "return", "$", "read", ";", "}" ]
Returns a stream instance for parsing messages from the server and emitting them as events. @param \Phergie\Irc\ConnectionInterface $connection Connection corresponding to the read stream @return \Phergie\Irc\Client\React\ReadStream
[ "Returns", "a", "stream", "instance", "for", "parsing", "messages", "from", "the", "server", "and", "emitting", "them", "as", "events", "." ]
b0d03f1e1ff34a2868f1f7d677786fdd1786b320
https://github.com/phergie/phergie-irc-client-react/blob/b0d03f1e1ff34a2868f1f7d677786fdd1786b320/src/Client.php#L406-L412
226,296
phergie/phergie-irc-client-react
src/Client.php
Client.getWriteStream
protected function getWriteStream(ConnectionInterface $connection) { $write = new WriteStream(); $this->addLogging($write, $connection); return $write; }
php
protected function getWriteStream(ConnectionInterface $connection) { $write = new WriteStream(); $this->addLogging($write, $connection); return $write; }
[ "protected", "function", "getWriteStream", "(", "ConnectionInterface", "$", "connection", ")", "{", "$", "write", "=", "new", "WriteStream", "(", ")", ";", "$", "this", "->", "addLogging", "(", "$", "write", ",", "$", "connection", ")", ";", "return", "$", "write", ";", "}" ]
Returns a stream instance for sending events to the server. @param \Phergie\Irc\ConnectionInterface $connection Connection corresponding to the read stream @return \Phergie\Irc\Client\React\WriteStream
[ "Returns", "a", "stream", "instance", "for", "sending", "events", "to", "the", "server", "." ]
b0d03f1e1ff34a2868f1f7d677786fdd1786b320
https://github.com/phergie/phergie-irc-client-react/blob/b0d03f1e1ff34a2868f1f7d677786fdd1786b320/src/Client.php#L421-L426
226,297
phergie/phergie-irc-client-react
src/Client.php
Client.getLogger
public function getLogger() { if (!$this->logger) { if (!defined('STDERR')) { // See testGetLoggerRunFromStdin // @codeCoverageIgnoreStart define('STDERR', fopen('php://stderr', 'w')); } // @codeCoverageIgnoreEnd $handler = new StreamHandler(STDERR, Logger::DEBUG); $handler->setFormatter(new LineFormatter("%datetime% %level_name% %message% %context%\n")); $this->logger = new Logger(get_class($this)); $this->logger->pushHandler($handler); } return $this->logger; }
php
public function getLogger() { if (!$this->logger) { if (!defined('STDERR')) { // See testGetLoggerRunFromStdin // @codeCoverageIgnoreStart define('STDERR', fopen('php://stderr', 'w')); } // @codeCoverageIgnoreEnd $handler = new StreamHandler(STDERR, Logger::DEBUG); $handler->setFormatter(new LineFormatter("%datetime% %level_name% %message% %context%\n")); $this->logger = new Logger(get_class($this)); $this->logger->pushHandler($handler); } return $this->logger; }
[ "public", "function", "getLogger", "(", ")", "{", "if", "(", "!", "$", "this", "->", "logger", ")", "{", "if", "(", "!", "defined", "(", "'STDERR'", ")", ")", "{", "// See testGetLoggerRunFromStdin", "// @codeCoverageIgnoreStart", "define", "(", "'STDERR'", ",", "fopen", "(", "'php://stderr'", ",", "'w'", ")", ")", ";", "}", "// @codeCoverageIgnoreEnd", "$", "handler", "=", "new", "StreamHandler", "(", "STDERR", ",", "Logger", "::", "DEBUG", ")", ";", "$", "handler", "->", "setFormatter", "(", "new", "LineFormatter", "(", "\"%datetime% %level_name% %message% %context%\\n\"", ")", ")", ";", "$", "this", "->", "logger", "=", "new", "Logger", "(", "get_class", "(", "$", "this", ")", ")", ";", "$", "this", "->", "logger", "->", "pushHandler", "(", "$", "handler", ")", ";", "}", "return", "$", "this", "->", "logger", ";", "}" ]
Returns a stream instance for logging data on the socket connection. @return \Psr\Log\LoggerInterface
[ "Returns", "a", "stream", "instance", "for", "logging", "data", "on", "the", "socket", "connection", "." ]
b0d03f1e1ff34a2868f1f7d677786fdd1786b320
https://github.com/phergie/phergie-irc-client-react/blob/b0d03f1e1ff34a2868f1f7d677786fdd1786b320/src/Client.php#L433-L448
226,298
phergie/phergie-irc-client-react
src/Client.php
Client.getReadCallback
protected function getReadCallback(WriteStream $write, ConnectionInterface $connection) { $logger = $this->getLogger(); return function($message) use ($write, $connection, $logger) { $this->processInput($message, $write, $connection); $this->emit('irc.received', array($message, $write, $connection, $logger)); }; }
php
protected function getReadCallback(WriteStream $write, ConnectionInterface $connection) { $logger = $this->getLogger(); return function($message) use ($write, $connection, $logger) { $this->processInput($message, $write, $connection); $this->emit('irc.received', array($message, $write, $connection, $logger)); }; }
[ "protected", "function", "getReadCallback", "(", "WriteStream", "$", "write", ",", "ConnectionInterface", "$", "connection", ")", "{", "$", "logger", "=", "$", "this", "->", "getLogger", "(", ")", ";", "return", "function", "(", "$", "message", ")", "use", "(", "$", "write", ",", "$", "connection", ",", "$", "logger", ")", "{", "$", "this", "->", "processInput", "(", "$", "message", ",", "$", "write", ",", "$", "connection", ")", ";", "$", "this", "->", "emit", "(", "'irc.received'", ",", "array", "(", "$", "message", ",", "$", "write", ",", "$", "connection", ",", "$", "logger", ")", ")", ";", "}", ";", "}" ]
Returns a callback for proxying IRC events from the read stream to IRC listeners of the client. @param \Phergie\Irc\Client\React\WriteStream $write Write stream corresponding to the read stream on which the event occurred @param \Phergie\Irc\ConnectionInterface $connection Connection on which the event occurred @return callable
[ "Returns", "a", "callback", "for", "proxying", "IRC", "events", "from", "the", "read", "stream", "to", "IRC", "listeners", "of", "the", "client", "." ]
b0d03f1e1ff34a2868f1f7d677786fdd1786b320
https://github.com/phergie/phergie-irc-client-react/blob/b0d03f1e1ff34a2868f1f7d677786fdd1786b320/src/Client.php#L470-L477
226,299
phergie/phergie-irc-client-react
src/Client.php
Client.getWriteCallback
protected function getWriteCallback(WriteStream $write, ConnectionInterface $connection) { $logger = $this->getLogger(); return function($message) use ($write, $connection, $logger) { $this->emit('irc.sent', array($message, $write, $connection, $logger)); }; }
php
protected function getWriteCallback(WriteStream $write, ConnectionInterface $connection) { $logger = $this->getLogger(); return function($message) use ($write, $connection, $logger) { $this->emit('irc.sent', array($message, $write, $connection, $logger)); }; }
[ "protected", "function", "getWriteCallback", "(", "WriteStream", "$", "write", ",", "ConnectionInterface", "$", "connection", ")", "{", "$", "logger", "=", "$", "this", "->", "getLogger", "(", ")", ";", "return", "function", "(", "$", "message", ")", "use", "(", "$", "write", ",", "$", "connection", ",", "$", "logger", ")", "{", "$", "this", "->", "emit", "(", "'irc.sent'", ",", "array", "(", "$", "message", ",", "$", "write", ",", "$", "connection", ",", "$", "logger", ")", ")", ";", "}", ";", "}" ]
Returns a callback for proxying events from the write stream to IRC listeners of the client. @param \Phergie\Irc\Client\React\WriteStream $write Write stream corresponding to the read stream on which the event occurred @param \Phergie\Irc\ConnectionInterface $connection Connection on which the event occurred @return callable
[ "Returns", "a", "callback", "for", "proxying", "events", "from", "the", "write", "stream", "to", "IRC", "listeners", "of", "the", "client", "." ]
b0d03f1e1ff34a2868f1f7d677786fdd1786b320
https://github.com/phergie/phergie-irc-client-react/blob/b0d03f1e1ff34a2868f1f7d677786fdd1786b320/src/Client.php#L489-L495