id
int32
0
241k
repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
sequence
docstring
stringlengths
3
47.2k
docstring_tokens
sequence
sha
stringlengths
40
40
url
stringlengths
91
247
4,900
phlexible/phlexible
src/Phlexible/Bundle/ElementtypeBundle/Controller/ViabilityController.php
ViabilityController.fortypeAction
public function fortypeAction(Request $request) { $elementtypeService = $this->get('phlexible_elementtype.elementtype_service'); $for = $request->get('type', Elementtype::TYPE_FULL); $elementtypes = $elementtypeService->findAllElementtypes(); $allowedForFull = $allowedForStructure = $allowedForArea = [ Elementtype::TYPE_FULL, Elementtype::TYPE_STRUCTURE, ]; $allowedForContainer = $allowedForPart = [ Elementtype::TYPE_LAYOUTAREA, Elementtype::TYPE_LAYOUTCONTAINER, ]; $list = []; foreach ($elementtypes as $elementtype) { $type = $elementtype->getType(); if ($for === Elementtype::TYPE_FULL && !in_array($type, $allowedForFull)) { continue; } elseif ($for === Elementtype::TYPE_STRUCTURE && !in_array($type, $allowedForStructure)) { continue; } elseif ($for === Elementtype::TYPE_REFERENCE) { continue; } elseif ($for === Elementtype::TYPE_LAYOUTAREA && !in_array($type, $allowedForArea)) { continue; } elseif ($for === Elementtype::TYPE_LAYOUTCONTAINER && !in_array($type, $allowedForContainer)) { continue; } elseif ($for === Elementtype::TYPE_PART && !in_array($type, $allowedForPart)) { continue; } $list[] = [ 'id' => $elementtype->getId(), 'type' => $elementtype->getType(), 'title' => $elementtype->getTitle(), 'icon' => $elementtype->getIcon(), 'version' => $elementtype->getRevision(), ]; } return new JsonResponse(['elementtypes' => $list, 'total' => count($list)]); }
php
public function fortypeAction(Request $request) { $elementtypeService = $this->get('phlexible_elementtype.elementtype_service'); $for = $request->get('type', Elementtype::TYPE_FULL); $elementtypes = $elementtypeService->findAllElementtypes(); $allowedForFull = $allowedForStructure = $allowedForArea = [ Elementtype::TYPE_FULL, Elementtype::TYPE_STRUCTURE, ]; $allowedForContainer = $allowedForPart = [ Elementtype::TYPE_LAYOUTAREA, Elementtype::TYPE_LAYOUTCONTAINER, ]; $list = []; foreach ($elementtypes as $elementtype) { $type = $elementtype->getType(); if ($for === Elementtype::TYPE_FULL && !in_array($type, $allowedForFull)) { continue; } elseif ($for === Elementtype::TYPE_STRUCTURE && !in_array($type, $allowedForStructure)) { continue; } elseif ($for === Elementtype::TYPE_REFERENCE) { continue; } elseif ($for === Elementtype::TYPE_LAYOUTAREA && !in_array($type, $allowedForArea)) { continue; } elseif ($for === Elementtype::TYPE_LAYOUTCONTAINER && !in_array($type, $allowedForContainer)) { continue; } elseif ($for === Elementtype::TYPE_PART && !in_array($type, $allowedForPart)) { continue; } $list[] = [ 'id' => $elementtype->getId(), 'type' => $elementtype->getType(), 'title' => $elementtype->getTitle(), 'icon' => $elementtype->getIcon(), 'version' => $elementtype->getRevision(), ]; } return new JsonResponse(['elementtypes' => $list, 'total' => count($list)]); }
[ "public", "function", "fortypeAction", "(", "Request", "$", "request", ")", "{", "$", "elementtypeService", "=", "$", "this", "->", "get", "(", "'phlexible_elementtype.elementtype_service'", ")", ";", "$", "for", "=", "$", "request", "->", "get", "(", "'type'", ",", "Elementtype", "::", "TYPE_FULL", ")", ";", "$", "elementtypes", "=", "$", "elementtypeService", "->", "findAllElementtypes", "(", ")", ";", "$", "allowedForFull", "=", "$", "allowedForStructure", "=", "$", "allowedForArea", "=", "[", "Elementtype", "::", "TYPE_FULL", ",", "Elementtype", "::", "TYPE_STRUCTURE", ",", "]", ";", "$", "allowedForContainer", "=", "$", "allowedForPart", "=", "[", "Elementtype", "::", "TYPE_LAYOUTAREA", ",", "Elementtype", "::", "TYPE_LAYOUTCONTAINER", ",", "]", ";", "$", "list", "=", "[", "]", ";", "foreach", "(", "$", "elementtypes", "as", "$", "elementtype", ")", "{", "$", "type", "=", "$", "elementtype", "->", "getType", "(", ")", ";", "if", "(", "$", "for", "===", "Elementtype", "::", "TYPE_FULL", "&&", "!", "in_array", "(", "$", "type", ",", "$", "allowedForFull", ")", ")", "{", "continue", ";", "}", "elseif", "(", "$", "for", "===", "Elementtype", "::", "TYPE_STRUCTURE", "&&", "!", "in_array", "(", "$", "type", ",", "$", "allowedForStructure", ")", ")", "{", "continue", ";", "}", "elseif", "(", "$", "for", "===", "Elementtype", "::", "TYPE_REFERENCE", ")", "{", "continue", ";", "}", "elseif", "(", "$", "for", "===", "Elementtype", "::", "TYPE_LAYOUTAREA", "&&", "!", "in_array", "(", "$", "type", ",", "$", "allowedForArea", ")", ")", "{", "continue", ";", "}", "elseif", "(", "$", "for", "===", "Elementtype", "::", "TYPE_LAYOUTCONTAINER", "&&", "!", "in_array", "(", "$", "type", ",", "$", "allowedForContainer", ")", ")", "{", "continue", ";", "}", "elseif", "(", "$", "for", "===", "Elementtype", "::", "TYPE_PART", "&&", "!", "in_array", "(", "$", "type", ",", "$", "allowedForPart", ")", ")", "{", "continue", ";", "}", "$", "list", "[", "]", "=", "[", "'id'", "=>", "$", "elementtype", "->", "getId", "(", ")", ",", "'type'", "=>", "$", "elementtype", "->", "getType", "(", ")", ",", "'title'", "=>", "$", "elementtype", "->", "getTitle", "(", ")", ",", "'icon'", "=>", "$", "elementtype", "->", "getIcon", "(", ")", ",", "'version'", "=>", "$", "elementtype", "->", "getRevision", "(", ")", ",", "]", ";", "}", "return", "new", "JsonResponse", "(", "[", "'elementtypes'", "=>", "$", "list", ",", "'total'", "=>", "count", "(", "$", "list", ")", "]", ")", ";", "}" ]
List Element Types. @param Request $request @return JsonResponse @Route("/fortype", name="elementtypes_viability_for_type")
[ "List", "Element", "Types", "." ]
132f24924c9bb0dbb6c1ea84db0a463f97fa3893
https://github.com/phlexible/phlexible/blob/132f24924c9bb0dbb6c1ea84db0a463f97fa3893/src/Phlexible/Bundle/ElementtypeBundle/Controller/ViabilityController.php#L39-L84
4,901
axypro/creator
helpers/Args.php
Args.createArgs
public static function createArgs(array $pointer, array $context) { if (array_key_exists('args', $pointer)) { $args = $pointer['args']; if (!is_array($args)) { throw new InvalidPointer('args must be an array'); } } elseif (array_key_exists('options', $pointer)) { $args = [$pointer['options']]; } else { $args = []; } if (!empty($pointer['reset_args'])) { return $args; } if (!empty($context['args'])) { $args = array_merge($context['args'], $args); } if (!empty($context['append_args'])) { $args = array_merge($args, $context['append_args']); } return $args; }
php
public static function createArgs(array $pointer, array $context) { if (array_key_exists('args', $pointer)) { $args = $pointer['args']; if (!is_array($args)) { throw new InvalidPointer('args must be an array'); } } elseif (array_key_exists('options', $pointer)) { $args = [$pointer['options']]; } else { $args = []; } if (!empty($pointer['reset_args'])) { return $args; } if (!empty($context['args'])) { $args = array_merge($context['args'], $args); } if (!empty($context['append_args'])) { $args = array_merge($args, $context['append_args']); } return $args; }
[ "public", "static", "function", "createArgs", "(", "array", "$", "pointer", ",", "array", "$", "context", ")", "{", "if", "(", "array_key_exists", "(", "'args'", ",", "$", "pointer", ")", ")", "{", "$", "args", "=", "$", "pointer", "[", "'args'", "]", ";", "if", "(", "!", "is_array", "(", "$", "args", ")", ")", "{", "throw", "new", "InvalidPointer", "(", "'args must be an array'", ")", ";", "}", "}", "elseif", "(", "array_key_exists", "(", "'options'", ",", "$", "pointer", ")", ")", "{", "$", "args", "=", "[", "$", "pointer", "[", "'options'", "]", "]", ";", "}", "else", "{", "$", "args", "=", "[", "]", ";", "}", "if", "(", "!", "empty", "(", "$", "pointer", "[", "'reset_args'", "]", ")", ")", "{", "return", "$", "args", ";", "}", "if", "(", "!", "empty", "(", "$", "context", "[", "'args'", "]", ")", ")", "{", "$", "args", "=", "array_merge", "(", "$", "context", "[", "'args'", "]", ",", "$", "args", ")", ";", "}", "if", "(", "!", "empty", "(", "$", "context", "[", "'append_args'", "]", ")", ")", "{", "$", "args", "=", "array_merge", "(", "$", "args", ",", "$", "context", "[", "'append_args'", "]", ")", ";", "}", "return", "$", "args", ";", "}" ]
Creates a arguments list @param array $pointer the normalized pointer @param array $context the normalized context @return array the arguments list @throws \axy\creator\errors\InvalidPointer
[ "Creates", "a", "arguments", "list" ]
3d74e2201cdb93912d32b1d80d1fdc44018f132a
https://github.com/axypro/creator/blob/3d74e2201cdb93912d32b1d80d1fdc44018f132a/helpers/Args.php#L27-L49
4,902
atelierspierrot/library
src/Library/Helper/Filesystem.php
Filesystem.resolveRelatedPath
public static function resolveRelatedPath($from, $to) { $from_parts = array_filter( explode('/', $from) ); $to_parts = array_filter( explode('/', $to) ); foreach($from_parts as $i=>$path) { if (in_array($path, $to_parts)) { $from_parts[$i] = null; $to_parts[$i] = null; } } $from_parts = array_filter($from_parts); $to_parts = array_filter($to_parts); for($i=0; $i<count($from_parts); $i++) { array_unshift($to_parts, '..'); } /* foreach($from_parts as $path) { array_unshift($to_parts, $path); } */ return join('/', $to_parts); }
php
public static function resolveRelatedPath($from, $to) { $from_parts = array_filter( explode('/', $from) ); $to_parts = array_filter( explode('/', $to) ); foreach($from_parts as $i=>$path) { if (in_array($path, $to_parts)) { $from_parts[$i] = null; $to_parts[$i] = null; } } $from_parts = array_filter($from_parts); $to_parts = array_filter($to_parts); for($i=0; $i<count($from_parts); $i++) { array_unshift($to_parts, '..'); } /* foreach($from_parts as $path) { array_unshift($to_parts, $path); } */ return join('/', $to_parts); }
[ "public", "static", "function", "resolveRelatedPath", "(", "$", "from", ",", "$", "to", ")", "{", "$", "from_parts", "=", "array_filter", "(", "explode", "(", "'/'", ",", "$", "from", ")", ")", ";", "$", "to_parts", "=", "array_filter", "(", "explode", "(", "'/'", ",", "$", "to", ")", ")", ";", "foreach", "(", "$", "from_parts", "as", "$", "i", "=>", "$", "path", ")", "{", "if", "(", "in_array", "(", "$", "path", ",", "$", "to_parts", ")", ")", "{", "$", "from_parts", "[", "$", "i", "]", "=", "null", ";", "$", "to_parts", "[", "$", "i", "]", "=", "null", ";", "}", "}", "$", "from_parts", "=", "array_filter", "(", "$", "from_parts", ")", ";", "$", "to_parts", "=", "array_filter", "(", "$", "to_parts", ")", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "count", "(", "$", "from_parts", ")", ";", "$", "i", "++", ")", "{", "array_unshift", "(", "$", "to_parts", ",", "'..'", ")", ";", "}", "/*\n foreach($from_parts as $path) {\n array_unshift($to_parts, $path);\n }\n*/", "return", "join", "(", "'/'", ",", "$", "to_parts", ")", ";", "}" ]
Returns a relative path between two filesystem realpaths @param string $from The absolute path to work from @param string $to The absolute path to resolve from `$from` @return string The relative path from `$from` to `$to`
[ "Returns", "a", "relative", "path", "between", "two", "filesystem", "realpaths" ]
a2988a11370d13c7e0dc47f9d2d81c664c30b8dd
https://github.com/atelierspierrot/library/blob/a2988a11370d13c7e0dc47f9d2d81c664c30b8dd/src/Library/Helper/Filesystem.php#L47-L68
4,903
Zeeml/Dataset
src/Core/Mapper.php
Mapper.map
public function map(array &$row) { $inputs = $this->parse($this->inputsParams, $row); $outputs = $this->parse($this->outputParams, $row); return $inputs && $outputs ? [$inputs, $outputs] : null; }
php
public function map(array &$row) { $inputs = $this->parse($this->inputsParams, $row); $outputs = $this->parse($this->outputParams, $row); return $inputs && $outputs ? [$inputs, $outputs] : null; }
[ "public", "function", "map", "(", "array", "&", "$", "row", ")", "{", "$", "inputs", "=", "$", "this", "->", "parse", "(", "$", "this", "->", "inputsParams", ",", "$", "row", ")", ";", "$", "outputs", "=", "$", "this", "->", "parse", "(", "$", "this", "->", "outputParams", ",", "$", "row", ")", ";", "return", "$", "inputs", "&&", "$", "outputs", "?", "[", "$", "inputs", ",", "$", "outputs", "]", ":", "null", ";", "}" ]
Creates an Instance class from an array using the inputKeys and outputKeys specified in the construct @param array $row @return null|array @throws DataSetPreparationException
[ "Creates", "an", "Instance", "class", "from", "an", "array", "using", "the", "inputKeys", "and", "outputKeys", "specified", "in", "the", "construct" ]
8809ba48c99bce1e9fe7e6431be7022e02ff027a
https://github.com/Zeeml/Dataset/blob/8809ba48c99bce1e9fe7e6431be7022e02ff027a/src/Core/Mapper.php#L34-L41
4,904
marando/phpSOFA
src/Marando/IAU/iauTrxpv.php
iauTrxpv.Trxpv
public static function Trxpv(array $r, array $pv, array &$trpv) { $tr = []; /* Transpose of matrix r. */ IAU::Tr($r, $tr); /* Matrix tr * vector pv -> vector trpv. */ IAU::Rxpv($tr, $pv, $trpv); return; }
php
public static function Trxpv(array $r, array $pv, array &$trpv) { $tr = []; /* Transpose of matrix r. */ IAU::Tr($r, $tr); /* Matrix tr * vector pv -> vector trpv. */ IAU::Rxpv($tr, $pv, $trpv); return; }
[ "public", "static", "function", "Trxpv", "(", "array", "$", "r", ",", "array", "$", "pv", ",", "array", "&", "$", "trpv", ")", "{", "$", "tr", "=", "[", "]", ";", "/* Transpose of matrix r. */", "IAU", "::", "Tr", "(", "$", "r", ",", "$", "tr", ")", ";", "/* Matrix tr * vector pv -> vector trpv. */", "IAU", "::", "Rxpv", "(", "$", "tr", ",", "$", "pv", ",", "$", "trpv", ")", ";", "return", ";", "}" ]
- - - - - - - - - i a u T r x p v - - - - - - - - - Multiply a pv-vector by the transpose of an r-matrix. This function is part of the International Astronomical Union's SOFA (Standards Of Fundamental Astronomy) software collection. Status: vector/matrix support function. Given: r double[3][3] r-matrix pv double[2][3] pv-vector Returned: trpv double[2][3] r * pv Note: It is permissible for pv and trpv to be the same array. Called: iauTr transpose r-matrix iauRxpv product of r-matrix and pv-vector This revision: 2013 June 18 SOFA release 2015-02-09 Copyright (C) 2015 IAU SOFA Board. See notes at end.
[ "-", "-", "-", "-", "-", "-", "-", "-", "-", "i", "a", "u", "T", "r", "x", "p", "v", "-", "-", "-", "-", "-", "-", "-", "-", "-" ]
757fa49fe335ae1210eaa7735473fd4388b13f07
https://github.com/marando/phpSOFA/blob/757fa49fe335ae1210eaa7735473fd4388b13f07/src/Marando/IAU/iauTrxpv.php#L39-L49
4,905
rinvex/obsolete-attributable
src/Support/ValueCollection.php
ValueCollection.trashCurrentItems
protected function trashCurrentItems() { $trash = $this->entity->getEntityAttributeValueTrash(); foreach ($this->items as $value) { $trash->push($value); } }
php
protected function trashCurrentItems() { $trash = $this->entity->getEntityAttributeValueTrash(); foreach ($this->items as $value) { $trash->push($value); } }
[ "protected", "function", "trashCurrentItems", "(", ")", "{", "$", "trash", "=", "$", "this", "->", "entity", "->", "getEntityAttributeValueTrash", "(", ")", ";", "foreach", "(", "$", "this", "->", "items", "as", "$", "value", ")", "{", "$", "trash", "->", "push", "(", "$", "value", ")", ";", "}", "}" ]
Trash the current values by queuing into entity object, these trashed values will physically deleted on entity save. @return void
[ "Trash", "the", "current", "values", "by", "queuing", "into", "entity", "object", "these", "trashed", "values", "will", "physically", "deleted", "on", "entity", "save", "." ]
23fa78efda9c24e2e1579917967537a3b3b9e4ce
https://github.com/rinvex/obsolete-attributable/blob/23fa78efda9c24e2e1579917967537a3b3b9e4ce/src/Support/ValueCollection.php#L94-L101
4,906
novuso/common
src/Domain/Model/EventCollection.php
EventCollection.record
public function record(EventMessage $message): void { $eventRecord = new EventRecord( $message, $this->aggregateId, $this->aggregateType, $this->nextSequence() ); $this->lastSequence = $eventRecord->sequenceNumber(); $this->eventRecords->add($eventRecord); }
php
public function record(EventMessage $message): void { $eventRecord = new EventRecord( $message, $this->aggregateId, $this->aggregateType, $this->nextSequence() ); $this->lastSequence = $eventRecord->sequenceNumber(); $this->eventRecords->add($eventRecord); }
[ "public", "function", "record", "(", "EventMessage", "$", "message", ")", ":", "void", "{", "$", "eventRecord", "=", "new", "EventRecord", "(", "$", "message", ",", "$", "this", "->", "aggregateId", ",", "$", "this", "->", "aggregateType", ",", "$", "this", "->", "nextSequence", "(", ")", ")", ";", "$", "this", "->", "lastSequence", "=", "$", "eventRecord", "->", "sequenceNumber", "(", ")", ";", "$", "this", "->", "eventRecords", "->", "add", "(", "$", "eventRecord", ")", ";", "}" ]
Records an event message @param EventMessage $message The event message @return void
[ "Records", "an", "event", "message" ]
7d0e5a4f4c79c9622e068efc8b7c70815c460863
https://github.com/novuso/common/blob/7d0e5a4f4c79c9622e068efc8b7c70815c460863/src/Domain/Model/EventCollection.php#L97-L107
4,907
novuso/common
src/Domain/Model/EventCollection.php
EventCollection.initializeSequence
public function initializeSequence(int $committedSequence): void { assert($this->isEmpty(), 'Cannot initialize sequence after adding events'); $this->committedSequence = $committedSequence; }
php
public function initializeSequence(int $committedSequence): void { assert($this->isEmpty(), 'Cannot initialize sequence after adding events'); $this->committedSequence = $committedSequence; }
[ "public", "function", "initializeSequence", "(", "int", "$", "committedSequence", ")", ":", "void", "{", "assert", "(", "$", "this", "->", "isEmpty", "(", ")", ",", "'Cannot initialize sequence after adding events'", ")", ";", "$", "this", "->", "committedSequence", "=", "$", "committedSequence", ";", "}" ]
Initializes the committed sequence @param int $committedSequence The committed sequence number @return void
[ "Initializes", "the", "committed", "sequence" ]
7d0e5a4f4c79c9622e068efc8b7c70815c460863
https://github.com/novuso/common/blob/7d0e5a4f4c79c9622e068efc8b7c70815c460863/src/Domain/Model/EventCollection.php#L126-L130
4,908
novuso/common
src/Domain/Model/EventCollection.php
EventCollection.commit
public function commit(): void { $this->committedSequence = $this->lastSequence(); $this->eventRecords = SortedSet::comparable(EventRecord::class); }
php
public function commit(): void { $this->committedSequence = $this->lastSequence(); $this->eventRecords = SortedSet::comparable(EventRecord::class); }
[ "public", "function", "commit", "(", ")", ":", "void", "{", "$", "this", "->", "committedSequence", "=", "$", "this", "->", "lastSequence", "(", ")", ";", "$", "this", "->", "eventRecords", "=", "SortedSet", "::", "comparable", "(", "EventRecord", "::", "class", ")", ";", "}" ]
Clears events and updates committed sequence number @return void
[ "Clears", "events", "and", "updates", "committed", "sequence", "number" ]
7d0e5a4f4c79c9622e068efc8b7c70815c460863
https://github.com/novuso/common/blob/7d0e5a4f4c79c9622e068efc8b7c70815c460863/src/Domain/Model/EventCollection.php#L161-L165
4,909
thesalegroup/restorm
src/PaginatedCollection.php
PaginatedCollection.count
public function count(): int { // If the count is already set, return it if(!is_null($this->count)) { return $this->count; } // Maually create a count by looping through the entities. This will // trigger the pagination calls to get the correct count of entities $count = 0; foreach($this as $entity) { $count++; } $this->count = $count; return $count; }
php
public function count(): int { // If the count is already set, return it if(!is_null($this->count)) { return $this->count; } // Maually create a count by looping through the entities. This will // trigger the pagination calls to get the correct count of entities $count = 0; foreach($this as $entity) { $count++; } $this->count = $count; return $count; }
[ "public", "function", "count", "(", ")", ":", "int", "{", "// If the count is already set, return it", "if", "(", "!", "is_null", "(", "$", "this", "->", "count", ")", ")", "{", "return", "$", "this", "->", "count", ";", "}", "// Maually create a count by looping through the entities. This will", "// trigger the pagination calls to get the correct count of entities", "$", "count", "=", "0", ";", "foreach", "(", "$", "this", "as", "$", "entity", ")", "{", "$", "count", "++", ";", "}", "$", "this", "->", "count", "=", "$", "count", ";", "return", "$", "count", ";", "}" ]
Get the count of entities. Calling this method will force initialisation of this object and call each page of content. @return integer the count of entities. @author Rob Treacy <[email protected]>
[ "Get", "the", "count", "of", "entities", "." ]
e8b9c3c0282b624450c9c6e508f2e086d4b2155d
https://github.com/thesalegroup/restorm/blob/e8b9c3c0282b624450c9c6e508f2e086d4b2155d/src/PaginatedCollection.php#L109-L125
4,910
phn-io/template
spec/Phn/Template/Fragment/SetSpec.php
SetSpec.it_can_be_compared_to_other_template_fragments
function it_can_be_compared_to_other_template_fragments($sameValue, $differentValue, $differentType) { $sameValue->getValueMask()->willReturn(['1', '2']); $sameValue->getTypeMask()->willReturn('[..]'); $this->equals($sameValue)->shouldReturn(true); $differentValue->getValueMask()->willReturn(['3', '4']); $differentValue->getTypeMask()->willReturn('[..]'); $this->equals($differentValue)->shouldReturn(false); $differentType->getValueMask()->willReturn(['1', '2']); $differentType->getTypeMask()->willReturn('[##]'); $this->equals($differentType)->shouldReturn(false); }
php
function it_can_be_compared_to_other_template_fragments($sameValue, $differentValue, $differentType) { $sameValue->getValueMask()->willReturn(['1', '2']); $sameValue->getTypeMask()->willReturn('[..]'); $this->equals($sameValue)->shouldReturn(true); $differentValue->getValueMask()->willReturn(['3', '4']); $differentValue->getTypeMask()->willReturn('[..]'); $this->equals($differentValue)->shouldReturn(false); $differentType->getValueMask()->willReturn(['1', '2']); $differentType->getTypeMask()->willReturn('[##]'); $this->equals($differentType)->shouldReturn(false); }
[ "function", "it_can_be_compared_to_other_template_fragments", "(", "$", "sameValue", ",", "$", "differentValue", ",", "$", "differentType", ")", "{", "$", "sameValue", "->", "getValueMask", "(", ")", "->", "willReturn", "(", "[", "'1'", ",", "'2'", "]", ")", ";", "$", "sameValue", "->", "getTypeMask", "(", ")", "->", "willReturn", "(", "'[..]'", ")", ";", "$", "this", "->", "equals", "(", "$", "sameValue", ")", "->", "shouldReturn", "(", "true", ")", ";", "$", "differentValue", "->", "getValueMask", "(", ")", "->", "willReturn", "(", "[", "'3'", ",", "'4'", "]", ")", ";", "$", "differentValue", "->", "getTypeMask", "(", ")", "->", "willReturn", "(", "'[..]'", ")", ";", "$", "this", "->", "equals", "(", "$", "differentValue", ")", "->", "shouldReturn", "(", "false", ")", ";", "$", "differentType", "->", "getValueMask", "(", ")", "->", "willReturn", "(", "[", "'1'", ",", "'2'", "]", ")", ";", "$", "differentType", "->", "getTypeMask", "(", ")", "->", "willReturn", "(", "'[##]'", ")", ";", "$", "this", "->", "equals", "(", "$", "differentType", ")", "->", "shouldReturn", "(", "false", ")", ";", "}" ]
It can be compared to other template fragments. @param \Phn\Template\Fragment\Set $sameValue @param \Phn\Template\Fragment\Set $differentValue @param \Phn\Template\Fragment\Set $differentType
[ "It", "can", "be", "compared", "to", "other", "template", "fragments", "." ]
7d89c2a54347069340ff9b545b4c64b5512da1c3
https://github.com/phn-io/template/blob/7d89c2a54347069340ff9b545b4c64b5512da1c3/spec/Phn/Template/Fragment/SetSpec.php#L86-L102
4,911
snje1987/minifw
src/Controler.php
Controler.dispatch
public function dispatch($function, $args) { $class_name = get_class($this); $class = new \ReflectionClass($class_name); if ($function == '') { $function = $class->getConstant('DEFAULT_FUNCTION'); } $function = str_replace('.', '', $function); if ($function == '') { return $this->show_404(); } $function = 'c_' . $function; if (!$class->hasMethod($function)) { return $this->show_404(); } $func = $class->getMethod($function); $func->setAccessible(true); try { $func->invoke($this, $args); } catch (\Exception $ex) { if (DEBUG === 1) { return $this->show_msg($ex->getMessage(), 'Error'); } else { return $this->show_404(); } } }
php
public function dispatch($function, $args) { $class_name = get_class($this); $class = new \ReflectionClass($class_name); if ($function == '') { $function = $class->getConstant('DEFAULT_FUNCTION'); } $function = str_replace('.', '', $function); if ($function == '') { return $this->show_404(); } $function = 'c_' . $function; if (!$class->hasMethod($function)) { return $this->show_404(); } $func = $class->getMethod($function); $func->setAccessible(true); try { $func->invoke($this, $args); } catch (\Exception $ex) { if (DEBUG === 1) { return $this->show_msg($ex->getMessage(), 'Error'); } else { return $this->show_404(); } } }
[ "public", "function", "dispatch", "(", "$", "function", ",", "$", "args", ")", "{", "$", "class_name", "=", "get_class", "(", "$", "this", ")", ";", "$", "class", "=", "new", "\\", "ReflectionClass", "(", "$", "class_name", ")", ";", "if", "(", "$", "function", "==", "''", ")", "{", "$", "function", "=", "$", "class", "->", "getConstant", "(", "'DEFAULT_FUNCTION'", ")", ";", "}", "$", "function", "=", "str_replace", "(", "'.'", ",", "''", ",", "$", "function", ")", ";", "if", "(", "$", "function", "==", "''", ")", "{", "return", "$", "this", "->", "show_404", "(", ")", ";", "}", "$", "function", "=", "'c_'", ".", "$", "function", ";", "if", "(", "!", "$", "class", "->", "hasMethod", "(", "$", "function", ")", ")", "{", "return", "$", "this", "->", "show_404", "(", ")", ";", "}", "$", "func", "=", "$", "class", "->", "getMethod", "(", "$", "function", ")", ";", "$", "func", "->", "setAccessible", "(", "true", ")", ";", "try", "{", "$", "func", "->", "invoke", "(", "$", "this", ",", "$", "args", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "ex", ")", "{", "if", "(", "DEBUG", "===", "1", ")", "{", "return", "$", "this", "->", "show_msg", "(", "$", "ex", "->", "getMessage", "(", ")", ",", "'Error'", ")", ";", "}", "else", "{", "return", "$", "this", "->", "show_404", "(", ")", ";", "}", "}", "}" ]
Call controler function according to the given name. @param type $func function name @param type $args args.
[ "Call", "controler", "function", "according", "to", "the", "given", "name", "." ]
57bd2c92fd97d219487216beba8dc6c91a41aab5
https://github.com/snje1987/minifw/blob/57bd2c92fd97d219487216beba8dc6c91a41aab5/src/Controler.php#L220-L248
4,912
marando/phpSOFA
src/Marando/IAU/iauEra00.php
iauEra00.Era00
public static function Era00($dj1, $dj2) { $d1; $d2; $t; $f; $theta; /* Days since fundamental epoch. */ if ($dj1 < $dj2) { $d1 = $dj1; $d2 = $dj2; } else { $d1 = $dj2; $d2 = $dj1; } $t = $d1 + ($d2 - DJ00); /* Fractional part of T (days). */ $f = fmod($d1, 1.0) + fmod($d2, 1.0); /* Earth rotation angle at this UT1. */ $theta = IAU::Anp(D2PI * ($f + 0.7790572732640 + 0.00273781191135448 * $t)); return $theta; }
php
public static function Era00($dj1, $dj2) { $d1; $d2; $t; $f; $theta; /* Days since fundamental epoch. */ if ($dj1 < $dj2) { $d1 = $dj1; $d2 = $dj2; } else { $d1 = $dj2; $d2 = $dj1; } $t = $d1 + ($d2 - DJ00); /* Fractional part of T (days). */ $f = fmod($d1, 1.0) + fmod($d2, 1.0); /* Earth rotation angle at this UT1. */ $theta = IAU::Anp(D2PI * ($f + 0.7790572732640 + 0.00273781191135448 * $t)); return $theta; }
[ "public", "static", "function", "Era00", "(", "$", "dj1", ",", "$", "dj2", ")", "{", "$", "d1", ";", "$", "d2", ";", "$", "t", ";", "$", "f", ";", "$", "theta", ";", "/* Days since fundamental epoch. */", "if", "(", "$", "dj1", "<", "$", "dj2", ")", "{", "$", "d1", "=", "$", "dj1", ";", "$", "d2", "=", "$", "dj2", ";", "}", "else", "{", "$", "d1", "=", "$", "dj2", ";", "$", "d2", "=", "$", "dj1", ";", "}", "$", "t", "=", "$", "d1", "+", "(", "$", "d2", "-", "DJ00", ")", ";", "/* Fractional part of T (days). */", "$", "f", "=", "fmod", "(", "$", "d1", ",", "1.0", ")", "+", "fmod", "(", "$", "d2", ",", "1.0", ")", ";", "/* Earth rotation angle at this UT1. */", "$", "theta", "=", "IAU", "::", "Anp", "(", "D2PI", "*", "(", "$", "f", "+", "0.7790572732640", "+", "0.00273781191135448", "*", "$", "t", ")", ")", ";", "return", "$", "theta", ";", "}" ]
- - - - - - - - - i a u E r a 0 0 - - - - - - - - - Earth rotation angle (IAU 2000 model). This function is part of the International Astronomical Union's SOFA (Standards Of Fundamental Astronomy) software collection. Status: canonical model. Given: dj1,dj2 double UT1 as a 2-part Julian Date (see note) Returned (function value): double Earth rotation angle (radians), range 0-2pi Notes: 1) The UT1 date dj1+dj2 is a Julian Date, apportioned in any convenient way between the arguments dj1 and dj2. For example, JD(UT1)=2450123.7 could be expressed in any of these ways, among others: dj1 dj2 2450123.7 0.0 (JD method) 2451545.0 -1421.3 (J2000 method) 2400000.5 50123.2 (MJD method) 2450123.5 0.2 (date & time method) The JD method is the most natural and convenient to use in cases where the loss of several decimal digits of resolution is acceptable. The J2000 and MJD methods are good compromises between resolution and convenience. The date & time method is best matched to the algorithm used: maximum precision is delivered when the dj1 argument is for 0hrs UT1 on the day in question and the dj2 argument lies in the range 0 to 1, or vice versa. 2) The algorithm is adapted from Expression 22 of Capitaine et al. 2000. The time argument has been expressed in days directly, and, to retain precision, integer contributions have been eliminated. The same formulation is given in IERS Conventions (2003), Chap. 5, Eq. 14. Called: iauAnp normalize angle into range 0 to 2pi References: Capitaine N., Guinot B. and McCarthy D.D, 2000, Astron. Astrophys., 355, 398-405. McCarthy, D. D., Petit, G. (eds.), IERS Conventions (2003), IERS Technical Note No. 32, BKG (2004) This revision: 2013 June 18 SOFA release 2015-02-09 Copyright (C) 2015 IAU SOFA Board. See notes at end.
[ "-", "-", "-", "-", "-", "-", "-", "-", "-", "i", "a", "u", "E", "r", "a", "0", "0", "-", "-", "-", "-", "-", "-", "-", "-", "-" ]
757fa49fe335ae1210eaa7735473fd4388b13f07
https://github.com/marando/phpSOFA/blob/757fa49fe335ae1210eaa7735473fd4388b13f07/src/Marando/IAU/iauEra00.php#L71-L96
4,913
romeOz/rock-events
src/Event.php
Event.on
public static function on($class, $name, callable $handler) { $class = ObjectHelper::getClass($class); if (!isset(static::$events[$class][$name])) { static::$events[$class][$name] = []; } static::$events[$class][$name][] = $handler; }
php
public static function on($class, $name, callable $handler) { $class = ObjectHelper::getClass($class); if (!isset(static::$events[$class][$name])) { static::$events[$class][$name] = []; } static::$events[$class][$name][] = $handler; }
[ "public", "static", "function", "on", "(", "$", "class", ",", "$", "name", ",", "callable", "$", "handler", ")", "{", "$", "class", "=", "ObjectHelper", "::", "getClass", "(", "$", "class", ")", ";", "if", "(", "!", "isset", "(", "static", "::", "$", "events", "[", "$", "class", "]", "[", "$", "name", "]", ")", ")", "{", "static", "::", "$", "events", "[", "$", "class", "]", "[", "$", "name", "]", "=", "[", "]", ";", "}", "static", "::", "$", "events", "[", "$", "class", "]", "[", "$", "name", "]", "[", "]", "=", "$", "handler", ";", "}" ]
Subscribing in event. @param string|object $class the fully qualified class name to which the event handler needs to attach. @param string $name name of event @param callable $handler handler - `function (Event $event) { ... }` - `[new Foo, 'method']` - `['Foo', 'static_method']`
[ "Subscribing", "in", "event", "." ]
7aacfee29afcc29145c4452782df11e248759acc
https://github.com/romeOz/rock-events/blob/7aacfee29afcc29145c4452782df11e248759acc/src/Event.php#L50-L57
4,914
romeOz/rock-events
src/Event.php
Event.trigger
public static function trigger($class, $name, Event $event = null) { if (empty(static::$events)) { return; } if ($event === null) { $event = new static; } $event->handled = false; $event->name = $name; if (is_object($class)) { if ($event->owner === null) { $event->owner = $class; } $class = get_class($class); } else{ $class = ltrim($class, '\\'); } do { if (!empty(static::$events[$class][$name])) { foreach (static::$events[$class][$name] as $handler) { call_user_func($handler, $event); if ($event->handled) { return; } } //static::off($class, $name); } } while (($class = get_parent_class($class)) !== false); }
php
public static function trigger($class, $name, Event $event = null) { if (empty(static::$events)) { return; } if ($event === null) { $event = new static; } $event->handled = false; $event->name = $name; if (is_object($class)) { if ($event->owner === null) { $event->owner = $class; } $class = get_class($class); } else{ $class = ltrim($class, '\\'); } do { if (!empty(static::$events[$class][$name])) { foreach (static::$events[$class][$name] as $handler) { call_user_func($handler, $event); if ($event->handled) { return; } } //static::off($class, $name); } } while (($class = get_parent_class($class)) !== false); }
[ "public", "static", "function", "trigger", "(", "$", "class", ",", "$", "name", ",", "Event", "$", "event", "=", "null", ")", "{", "if", "(", "empty", "(", "static", "::", "$", "events", ")", ")", "{", "return", ";", "}", "if", "(", "$", "event", "===", "null", ")", "{", "$", "event", "=", "new", "static", ";", "}", "$", "event", "->", "handled", "=", "false", ";", "$", "event", "->", "name", "=", "$", "name", ";", "if", "(", "is_object", "(", "$", "class", ")", ")", "{", "if", "(", "$", "event", "->", "owner", "===", "null", ")", "{", "$", "event", "->", "owner", "=", "$", "class", ";", "}", "$", "class", "=", "get_class", "(", "$", "class", ")", ";", "}", "else", "{", "$", "class", "=", "ltrim", "(", "$", "class", ",", "'\\\\'", ")", ";", "}", "do", "{", "if", "(", "!", "empty", "(", "static", "::", "$", "events", "[", "$", "class", "]", "[", "$", "name", "]", ")", ")", "{", "foreach", "(", "static", "::", "$", "events", "[", "$", "class", "]", "[", "$", "name", "]", "as", "$", "handler", ")", "{", "call_user_func", "(", "$", "handler", ",", "$", "event", ")", ";", "if", "(", "$", "event", "->", "handled", ")", "{", "return", ";", "}", "}", "//static::off($class, $name);", "}", "}", "while", "(", "(", "$", "class", "=", "get_parent_class", "(", "$", "class", ")", ")", "!==", "false", ")", ";", "}" ]
Publishing event. @param string|object $class the object or the fully qualified class name specifying the class-level event. @param string $name the event name. @param Event $event the event parameter. If not set, a default [[Event]] object will be created.
[ "Publishing", "event", "." ]
7aacfee29afcc29145c4452782df11e248759acc
https://github.com/romeOz/rock-events/blob/7aacfee29afcc29145c4452782df11e248759acc/src/Event.php#L66-L97
4,915
romeOz/rock-events
src/Event.php
Event.off
public static function off($class, $name, callable $handler = null) { $class = ObjectHelper::getClass($class); if ($handler === null) { unset(static::$events[$class][$name]); if (empty(static::$events[$class])) { unset(static::$events[$class]); } return true; } $removed = false; foreach (self::$events[$class][$name] as $i => $event) { if ($event === $handler) { unset(self::$events[$class][$name][$i]); $removed = true; } } if ($removed) { self::$events[$class][$name] = array_values(self::$events[$class][$name]); } return $removed; }
php
public static function off($class, $name, callable $handler = null) { $class = ObjectHelper::getClass($class); if ($handler === null) { unset(static::$events[$class][$name]); if (empty(static::$events[$class])) { unset(static::$events[$class]); } return true; } $removed = false; foreach (self::$events[$class][$name] as $i => $event) { if ($event === $handler) { unset(self::$events[$class][$name][$i]); $removed = true; } } if ($removed) { self::$events[$class][$name] = array_values(self::$events[$class][$name]); } return $removed; }
[ "public", "static", "function", "off", "(", "$", "class", ",", "$", "name", ",", "callable", "$", "handler", "=", "null", ")", "{", "$", "class", "=", "ObjectHelper", "::", "getClass", "(", "$", "class", ")", ";", "if", "(", "$", "handler", "===", "null", ")", "{", "unset", "(", "static", "::", "$", "events", "[", "$", "class", "]", "[", "$", "name", "]", ")", ";", "if", "(", "empty", "(", "static", "::", "$", "events", "[", "$", "class", "]", ")", ")", "{", "unset", "(", "static", "::", "$", "events", "[", "$", "class", "]", ")", ";", "}", "return", "true", ";", "}", "$", "removed", "=", "false", ";", "foreach", "(", "self", "::", "$", "events", "[", "$", "class", "]", "[", "$", "name", "]", "as", "$", "i", "=>", "$", "event", ")", "{", "if", "(", "$", "event", "===", "$", "handler", ")", "{", "unset", "(", "self", "::", "$", "events", "[", "$", "class", "]", "[", "$", "name", "]", "[", "$", "i", "]", ")", ";", "$", "removed", "=", "true", ";", "}", "}", "if", "(", "$", "removed", ")", "{", "self", "::", "$", "events", "[", "$", "class", "]", "[", "$", "name", "]", "=", "array_values", "(", "self", "::", "$", "events", "[", "$", "class", "]", "[", "$", "name", "]", ")", ";", "}", "return", "$", "removed", ";", "}" ]
Detach event. @param string|object $class the fully qualified class name from which the event handler needs to be detached. @param string $name name of event @param callable $handler the event handler to be removed. If it is null, all handlers attached to the named event will be removed. @return bool @see on()
[ "Detach", "event", "." ]
7aacfee29afcc29145c4452782df11e248759acc
https://github.com/romeOz/rock-events/blob/7aacfee29afcc29145c4452782df11e248759acc/src/Event.php#L109-L132
4,916
romeOz/rock-events
src/Event.php
Event.offMulti
public static function offMulti(array $names) { foreach ($names as $value) { list($class, $name) = $value; static::off($class, $name); } }
php
public static function offMulti(array $names) { foreach ($names as $value) { list($class, $name) = $value; static::off($class, $name); } }
[ "public", "static", "function", "offMulti", "(", "array", "$", "names", ")", "{", "foreach", "(", "$", "names", "as", "$", "value", ")", "{", "list", "(", "$", "class", ",", "$", "name", ")", "=", "$", "value", ";", "static", "::", "off", "(", "$", "class", ",", "$", "name", ")", ";", "}", "}" ]
Detach events. ```php $events = [ ['foo\\Foo', 'onAfter'] ]; Event::offMulti($events); ``` @param array $names - names of event
[ "Detach", "events", "." ]
7aacfee29afcc29145c4452782df11e248759acc
https://github.com/romeOz/rock-events/blob/7aacfee29afcc29145c4452782df11e248759acc/src/Event.php#L146-L152
4,917
romeOz/rock-events
src/Event.php
Event.get
public static function get($class, $name) { $class = ObjectHelper::getClass($class); return !empty(static::$events[$class][$name]) ? static::$events[$class][$name] : null; }
php
public static function get($class, $name) { $class = ObjectHelper::getClass($class); return !empty(static::$events[$class][$name]) ? static::$events[$class][$name] : null; }
[ "public", "static", "function", "get", "(", "$", "class", ",", "$", "name", ")", "{", "$", "class", "=", "ObjectHelper", "::", "getClass", "(", "$", "class", ")", ";", "return", "!", "empty", "(", "static", "::", "$", "events", "[", "$", "class", "]", "[", "$", "name", "]", ")", "?", "static", "::", "$", "events", "[", "$", "class", "]", "[", "$", "name", "]", ":", "null", ";", "}" ]
Get event. @param string|object $class the object or the fully qualified class name specifying the class-level event. @param string $name name of event @return array|null
[ "Get", "event", "." ]
7aacfee29afcc29145c4452782df11e248759acc
https://github.com/romeOz/rock-events/blob/7aacfee29afcc29145c4452782df11e248759acc/src/Event.php#L180-L184
4,918
romeOz/rock-events
src/Event.php
Event.exists
public static function exists($class, $name) { $class = ObjectHelper::getClass($class); do { if (!empty(self::$events[$class][$name])) { return true; } } while (($class = get_parent_class($class)) !== false); return false; }
php
public static function exists($class, $name) { $class = ObjectHelper::getClass($class); do { if (!empty(self::$events[$class][$name])) { return true; } } while (($class = get_parent_class($class)) !== false); return false; }
[ "public", "static", "function", "exists", "(", "$", "class", ",", "$", "name", ")", "{", "$", "class", "=", "ObjectHelper", "::", "getClass", "(", "$", "class", ")", ";", "do", "{", "if", "(", "!", "empty", "(", "self", "::", "$", "events", "[", "$", "class", "]", "[", "$", "name", "]", ")", ")", "{", "return", "true", ";", "}", "}", "while", "(", "(", "$", "class", "=", "get_parent_class", "(", "$", "class", ")", ")", "!==", "false", ")", ";", "return", "false", ";", "}" ]
Exists event. @param string|object $class the object or the fully qualified class name specifying the class-level event. @param string $name name of event @return bool
[ "Exists", "event", "." ]
7aacfee29afcc29145c4452782df11e248759acc
https://github.com/romeOz/rock-events/blob/7aacfee29afcc29145c4452782df11e248759acc/src/Event.php#L205-L215
4,919
romeOz/rock-events
src/Event.php
Event.countHandlers
public static function countHandlers($class, $name) { $class = ObjectHelper::getClass($class); $count = 0; do { if (!empty(self::$events[$class][$name])) { $count += count(static::$events[$class][$name]); } } while (($class = get_parent_class($class)) !== false); return $count; }
php
public static function countHandlers($class, $name) { $class = ObjectHelper::getClass($class); $count = 0; do { if (!empty(self::$events[$class][$name])) { $count += count(static::$events[$class][$name]); } } while (($class = get_parent_class($class)) !== false); return $count; }
[ "public", "static", "function", "countHandlers", "(", "$", "class", ",", "$", "name", ")", "{", "$", "class", "=", "ObjectHelper", "::", "getClass", "(", "$", "class", ")", ";", "$", "count", "=", "0", ";", "do", "{", "if", "(", "!", "empty", "(", "self", "::", "$", "events", "[", "$", "class", "]", "[", "$", "name", "]", ")", ")", "{", "$", "count", "+=", "count", "(", "static", "::", "$", "events", "[", "$", "class", "]", "[", "$", "name", "]", ")", ";", "}", "}", "while", "(", "(", "$", "class", "=", "get_parent_class", "(", "$", "class", ")", ")", "!==", "false", ")", ";", "return", "$", "count", ";", "}" ]
Count handlers of events. @param string|object $class @param string $name name of event @return int
[ "Count", "handlers", "of", "events", "." ]
7aacfee29afcc29145c4452782df11e248759acc
https://github.com/romeOz/rock-events/blob/7aacfee29afcc29145c4452782df11e248759acc/src/Event.php#L233-L245
4,920
carbontwelve/tools
src/Carbontwelve/Tools/Formatters/Time.php
Time.toHuman
public function toHuman() { $units = array( "week" => 7*24*3600, "day" => 24*3600, "hour" => 3600, "minute" => 60, "second" => 1, ); // specifically handle zero if ( $this->seconds == 0 ) return "0 seconds"; $s = ""; foreach ( $units as $name => $divisor ) { if ( $quot = intval($this->seconds / $divisor) ) { $s .= "$quot $name"; $s .= (abs($quot) > 1 ? "s" : "") . ", "; $this->seconds -= $quot * $divisor; } } return substr($s, 0, -2); }
php
public function toHuman() { $units = array( "week" => 7*24*3600, "day" => 24*3600, "hour" => 3600, "minute" => 60, "second" => 1, ); // specifically handle zero if ( $this->seconds == 0 ) return "0 seconds"; $s = ""; foreach ( $units as $name => $divisor ) { if ( $quot = intval($this->seconds / $divisor) ) { $s .= "$quot $name"; $s .= (abs($quot) > 1 ? "s" : "") . ", "; $this->seconds -= $quot * $divisor; } } return substr($s, 0, -2); }
[ "public", "function", "toHuman", "(", ")", "{", "$", "units", "=", "array", "(", "\"week\"", "=>", "7", "*", "24", "*", "3600", ",", "\"day\"", "=>", "24", "*", "3600", ",", "\"hour\"", "=>", "3600", ",", "\"minute\"", "=>", "60", ",", "\"second\"", "=>", "1", ",", ")", ";", "// specifically handle zero", "if", "(", "$", "this", "->", "seconds", "==", "0", ")", "return", "\"0 seconds\"", ";", "$", "s", "=", "\"\"", ";", "foreach", "(", "$", "units", "as", "$", "name", "=>", "$", "divisor", ")", "{", "if", "(", "$", "quot", "=", "intval", "(", "$", "this", "->", "seconds", "/", "$", "divisor", ")", ")", "{", "$", "s", ".=", "\"$quot $name\"", ";", "$", "s", ".=", "(", "abs", "(", "$", "quot", ")", ">", "1", "?", "\"s\"", ":", "\"\"", ")", ".", "\", \"", ";", "$", "this", "->", "seconds", "-=", "$", "quot", "*", "$", "divisor", ";", "}", "}", "return", "substr", "(", "$", "s", ",", "0", ",", "-", "2", ")", ";", "}" ]
Convert seconds to human readable text. @source http://csl.name/php-secs-to-human-text/ @return string
[ "Convert", "seconds", "to", "human", "readable", "text", "." ]
bad49a7791612c18c3ca5b935a47d2955ae8dc67
https://github.com/carbontwelve/tools/blob/bad49a7791612c18c3ca5b935a47d2955ae8dc67/src/Carbontwelve/Tools/Formatters/Time.php#L37-L61
4,921
mikebarlow/advanced-assets
src/Assets.php
Assets.findAsset
public function findAsset($url) { if (empty($url)) { return false; } $this->asset = $this->processUrl($url); if ($this->asset === false) { return false; } // check main assets dir $mainAsset = $this->findMainAsset( $this->docRoot . DS . $this->assetDir . DS . $this->asset['asset'] ); if ($mainAsset !== false) { return $mainAsset; } // check the set theme $themeAsset = $this->findThemeAsset( $this->asset['folder'], $this->assetDir . DS . $this->asset['asset'] ); if ($themeAsset !== false) { return $themeAsset; } // get the last "fallback" directory return $this->findFallbackAsset( $this->assetDir . DS . $this->asset['asset'], $this->Folder ); }
php
public function findAsset($url) { if (empty($url)) { return false; } $this->asset = $this->processUrl($url); if ($this->asset === false) { return false; } // check main assets dir $mainAsset = $this->findMainAsset( $this->docRoot . DS . $this->assetDir . DS . $this->asset['asset'] ); if ($mainAsset !== false) { return $mainAsset; } // check the set theme $themeAsset = $this->findThemeAsset( $this->asset['folder'], $this->assetDir . DS . $this->asset['asset'] ); if ($themeAsset !== false) { return $themeAsset; } // get the last "fallback" directory return $this->findFallbackAsset( $this->assetDir . DS . $this->asset['asset'], $this->Folder ); }
[ "public", "function", "findAsset", "(", "$", "url", ")", "{", "if", "(", "empty", "(", "$", "url", ")", ")", "{", "return", "false", ";", "}", "$", "this", "->", "asset", "=", "$", "this", "->", "processUrl", "(", "$", "url", ")", ";", "if", "(", "$", "this", "->", "asset", "===", "false", ")", "{", "return", "false", ";", "}", "// check main assets dir", "$", "mainAsset", "=", "$", "this", "->", "findMainAsset", "(", "$", "this", "->", "docRoot", ".", "DS", ".", "$", "this", "->", "assetDir", ".", "DS", ".", "$", "this", "->", "asset", "[", "'asset'", "]", ")", ";", "if", "(", "$", "mainAsset", "!==", "false", ")", "{", "return", "$", "mainAsset", ";", "}", "// check the set theme", "$", "themeAsset", "=", "$", "this", "->", "findThemeAsset", "(", "$", "this", "->", "asset", "[", "'folder'", "]", ",", "$", "this", "->", "assetDir", ".", "DS", ".", "$", "this", "->", "asset", "[", "'asset'", "]", ")", ";", "if", "(", "$", "themeAsset", "!==", "false", ")", "{", "return", "$", "themeAsset", ";", "}", "// get the last \"fallback\" directory", "return", "$", "this", "->", "findFallbackAsset", "(", "$", "this", "->", "assetDir", ".", "DS", ".", "$", "this", "->", "asset", "[", "'asset'", "]", ",", "$", "this", "->", "Folder", ")", ";", "}" ]
find the asset and create symlink @param string $url Asset URL to find @return string|bool
[ "find", "the", "asset", "and", "create", "symlink" ]
88824f58408beea06703684df0c7f8024ce8478a
https://github.com/mikebarlow/advanced-assets/blob/88824f58408beea06703684df0c7f8024ce8478a/src/Assets.php#L94-L128
4,922
mikebarlow/advanced-assets
src/Assets.php
Assets.findMainAsset
public function findMainAsset($asset) { if (file_exists($asset) && $this->checkLink($asset)) { return '/' . $this->assetDir . '/' . $this->asset['asset']; } return false; }
php
public function findMainAsset($asset) { if (file_exists($asset) && $this->checkLink($asset)) { return '/' . $this->assetDir . '/' . $this->asset['asset']; } return false; }
[ "public", "function", "findMainAsset", "(", "$", "asset", ")", "{", "if", "(", "file_exists", "(", "$", "asset", ")", "&&", "$", "this", "->", "checkLink", "(", "$", "asset", ")", ")", "{", "return", "'/'", ".", "$", "this", "->", "assetDir", ".", "'/'", ".", "$", "this", "->", "asset", "[", "'asset'", "]", ";", "}", "return", "false", ";", "}" ]
check for a main asset @param string Full Absolute path to the main asset @return string|bool url path to asset or bool false
[ "check", "for", "a", "main", "asset" ]
88824f58408beea06703684df0c7f8024ce8478a
https://github.com/mikebarlow/advanced-assets/blob/88824f58408beea06703684df0c7f8024ce8478a/src/Assets.php#L161-L168
4,923
mikebarlow/advanced-assets
src/Assets.php
Assets.findThemeAsset
public function findThemeAsset($theme, $asset) { if (! empty($theme)) { $Folders = $this->engine->getFolders(); if ($Folders->exists($theme)) { $this->Folder = $Folders->get($theme); $folderPath = rtrim($this->Folder->getPath(), '/'); $folderPath = $this->removeViewFromPath($folderPath); if (file_exists($folderPath . DS . $asset)) { $this->createSymlink($folderPath); return '/' . $this->assetDir . '/' . $this->asset['asset']; } } } return false; }
php
public function findThemeAsset($theme, $asset) { if (! empty($theme)) { $Folders = $this->engine->getFolders(); if ($Folders->exists($theme)) { $this->Folder = $Folders->get($theme); $folderPath = rtrim($this->Folder->getPath(), '/'); $folderPath = $this->removeViewFromPath($folderPath); if (file_exists($folderPath . DS . $asset)) { $this->createSymlink($folderPath); return '/' . $this->assetDir . '/' . $this->asset['asset']; } } } return false; }
[ "public", "function", "findThemeAsset", "(", "$", "theme", ",", "$", "asset", ")", "{", "if", "(", "!", "empty", "(", "$", "theme", ")", ")", "{", "$", "Folders", "=", "$", "this", "->", "engine", "->", "getFolders", "(", ")", ";", "if", "(", "$", "Folders", "->", "exists", "(", "$", "theme", ")", ")", "{", "$", "this", "->", "Folder", "=", "$", "Folders", "->", "get", "(", "$", "theme", ")", ";", "$", "folderPath", "=", "rtrim", "(", "$", "this", "->", "Folder", "->", "getPath", "(", ")", ",", "'/'", ")", ";", "$", "folderPath", "=", "$", "this", "->", "removeViewFromPath", "(", "$", "folderPath", ")", ";", "if", "(", "file_exists", "(", "$", "folderPath", ".", "DS", ".", "$", "asset", ")", ")", "{", "$", "this", "->", "createSymlink", "(", "$", "folderPath", ")", ";", "return", "'/'", ".", "$", "this", "->", "assetDir", ".", "'/'", ".", "$", "this", "->", "asset", "[", "'asset'", "]", ";", "}", "}", "}", "return", "false", ";", "}" ]
check for a theme asset @param string Theme to load @param string Path to the asset @return string|bool url path to asset or bool false
[ "check", "for", "a", "theme", "asset" ]
88824f58408beea06703684df0c7f8024ce8478a
https://github.com/mikebarlow/advanced-assets/blob/88824f58408beea06703684df0c7f8024ce8478a/src/Assets.php#L177-L196
4,924
mikebarlow/advanced-assets
src/Assets.php
Assets.findFallbackAsset
public function findFallbackAsset($asset, $Folder = null) { $folderEmpty = empty($Folder); $folderAllowFallback = ! empty($Folder) && $Folder->getFallback(); if ($folderEmpty || $folderAllowFallback) { $fallbackPath = $this->engine->getDirectory(); $fallbackPath = $this->removeViewFromPath($fallbackPath); if (file_exists($fallbackPath . DS . $asset)) { $this->createSymlink($fallbackPath); return '/' . $this->assetDir . '/' . $this->asset['asset']; } } return false; }
php
public function findFallbackAsset($asset, $Folder = null) { $folderEmpty = empty($Folder); $folderAllowFallback = ! empty($Folder) && $Folder->getFallback(); if ($folderEmpty || $folderAllowFallback) { $fallbackPath = $this->engine->getDirectory(); $fallbackPath = $this->removeViewFromPath($fallbackPath); if (file_exists($fallbackPath . DS . $asset)) { $this->createSymlink($fallbackPath); return '/' . $this->assetDir . '/' . $this->asset['asset']; } } return false; }
[ "public", "function", "findFallbackAsset", "(", "$", "asset", ",", "$", "Folder", "=", "null", ")", "{", "$", "folderEmpty", "=", "empty", "(", "$", "Folder", ")", ";", "$", "folderAllowFallback", "=", "!", "empty", "(", "$", "Folder", ")", "&&", "$", "Folder", "->", "getFallback", "(", ")", ";", "if", "(", "$", "folderEmpty", "||", "$", "folderAllowFallback", ")", "{", "$", "fallbackPath", "=", "$", "this", "->", "engine", "->", "getDirectory", "(", ")", ";", "$", "fallbackPath", "=", "$", "this", "->", "removeViewFromPath", "(", "$", "fallbackPath", ")", ";", "if", "(", "file_exists", "(", "$", "fallbackPath", ".", "DS", ".", "$", "asset", ")", ")", "{", "$", "this", "->", "createSymlink", "(", "$", "fallbackPath", ")", ";", "return", "'/'", ".", "$", "this", "->", "assetDir", ".", "'/'", ".", "$", "this", "->", "asset", "[", "'asset'", "]", ";", "}", "}", "return", "false", ";", "}" ]
find the fallback asset @param string Full path to the main asset @param Object Plates\Folder Object, so we can check for fallback => true @return string|bool url path to asset or bool false
[ "find", "the", "fallback", "asset" ]
88824f58408beea06703684df0c7f8024ce8478a
https://github.com/mikebarlow/advanced-assets/blob/88824f58408beea06703684df0c7f8024ce8478a/src/Assets.php#L205-L222
4,925
mikebarlow/advanced-assets
src/Assets.php
Assets.removeViewFromPath
public function removeViewFromPath($path) { $folderBits = explode('/', $path); if (strtolower(end($folderBits)) === 'views') { array_pop($folderBits); $path = implode('/', $folderBits); } return $path; }
php
public function removeViewFromPath($path) { $folderBits = explode('/', $path); if (strtolower(end($folderBits)) === 'views') { array_pop($folderBits); $path = implode('/', $folderBits); } return $path; }
[ "public", "function", "removeViewFromPath", "(", "$", "path", ")", "{", "$", "folderBits", "=", "explode", "(", "'/'", ",", "$", "path", ")", ";", "if", "(", "strtolower", "(", "end", "(", "$", "folderBits", ")", ")", "===", "'views'", ")", "{", "array_pop", "(", "$", "folderBits", ")", ";", "$", "path", "=", "implode", "(", "'/'", ",", "$", "folderBits", ")", ";", "}", "return", "$", "path", ";", "}" ]
remove 'views' from any folder path @param string $path View path @return string $path Path with view folder remove
[ "remove", "views", "from", "any", "folder", "path" ]
88824f58408beea06703684df0c7f8024ce8478a
https://github.com/mikebarlow/advanced-assets/blob/88824f58408beea06703684df0c7f8024ce8478a/src/Assets.php#L266-L275
4,926
mikebarlow/advanced-assets
src/Assets.php
Assets.setDocRoot
public function setDocRoot($docRoot) { if (empty($docRoot) || ! file_exists($docRoot) || ! is_dir($docRoot)) { throw new \InvalidArgumentException( 'The document root set is not a valid directory.' ); } $this->docRoot = rtrim($docRoot, '/'); }
php
public function setDocRoot($docRoot) { if (empty($docRoot) || ! file_exists($docRoot) || ! is_dir($docRoot)) { throw new \InvalidArgumentException( 'The document root set is not a valid directory.' ); } $this->docRoot = rtrim($docRoot, '/'); }
[ "public", "function", "setDocRoot", "(", "$", "docRoot", ")", "{", "if", "(", "empty", "(", "$", "docRoot", ")", "||", "!", "file_exists", "(", "$", "docRoot", ")", "||", "!", "is_dir", "(", "$", "docRoot", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'The document root set is not a valid directory.'", ")", ";", "}", "$", "this", "->", "docRoot", "=", "rtrim", "(", "$", "docRoot", ",", "'/'", ")", ";", "}" ]
set the document root @param string Document Root @throws \InvalidArgumentException
[ "set", "the", "document", "root" ]
88824f58408beea06703684df0c7f8024ce8478a
https://github.com/mikebarlow/advanced-assets/blob/88824f58408beea06703684df0c7f8024ce8478a/src/Assets.php#L283-L291
4,927
mikebarlow/advanced-assets
src/Assets.php
Assets.setFileSystem
public function setFileSystem($fileSystem) { if (! is_object($fileSystem) || ! is_a($fileSystem, 'Symfony\Component\Filesystem\Filesystem')) { throw new \InvalidArgumentException( 'The File System was not a valid object.' ); } $this->fileSystem = $fileSystem; }
php
public function setFileSystem($fileSystem) { if (! is_object($fileSystem) || ! is_a($fileSystem, 'Symfony\Component\Filesystem\Filesystem')) { throw new \InvalidArgumentException( 'The File System was not a valid object.' ); } $this->fileSystem = $fileSystem; }
[ "public", "function", "setFileSystem", "(", "$", "fileSystem", ")", "{", "if", "(", "!", "is_object", "(", "$", "fileSystem", ")", "||", "!", "is_a", "(", "$", "fileSystem", ",", "'Symfony\\Component\\Filesystem\\Filesystem'", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'The File System was not a valid object.'", ")", ";", "}", "$", "this", "->", "fileSystem", "=", "$", "fileSystem", ";", "}" ]
set the file system @param object Instance of Symfony filesystem @throws \InvalidArgumentException
[ "set", "the", "file", "system" ]
88824f58408beea06703684df0c7f8024ce8478a
https://github.com/mikebarlow/advanced-assets/blob/88824f58408beea06703684df0c7f8024ce8478a/src/Assets.php#L299-L307
4,928
mikebarlow/advanced-assets
src/Assets.php
Assets.setAssetDir
public function setAssetDir($assetDir) { $emptyAssetDir = empty($assetDir); $folderNotExists = ! file_exists($this->docRoot . DS . $assetDir); $folderNotDir = ! is_dir($this->docRoot . DS . $assetDir); if ($emptyAssetDir || $folderNotExists || $folderNotDir) { throw new \InvalidArgumentException( 'The asset directory set is not a valid directory.' ); } if (! is_writable($this->docRoot . DS . $assetDir)) { throw new \LogicException( 'The folder "' . $this->docRoot . DS . $assetDir . '" must be writable.' ); } $this->assetDir = $assetDir; }
php
public function setAssetDir($assetDir) { $emptyAssetDir = empty($assetDir); $folderNotExists = ! file_exists($this->docRoot . DS . $assetDir); $folderNotDir = ! is_dir($this->docRoot . DS . $assetDir); if ($emptyAssetDir || $folderNotExists || $folderNotDir) { throw new \InvalidArgumentException( 'The asset directory set is not a valid directory.' ); } if (! is_writable($this->docRoot . DS . $assetDir)) { throw new \LogicException( 'The folder "' . $this->docRoot . DS . $assetDir . '" must be writable.' ); } $this->assetDir = $assetDir; }
[ "public", "function", "setAssetDir", "(", "$", "assetDir", ")", "{", "$", "emptyAssetDir", "=", "empty", "(", "$", "assetDir", ")", ";", "$", "folderNotExists", "=", "!", "file_exists", "(", "$", "this", "->", "docRoot", ".", "DS", ".", "$", "assetDir", ")", ";", "$", "folderNotDir", "=", "!", "is_dir", "(", "$", "this", "->", "docRoot", ".", "DS", ".", "$", "assetDir", ")", ";", "if", "(", "$", "emptyAssetDir", "||", "$", "folderNotExists", "||", "$", "folderNotDir", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'The asset directory set is not a valid directory.'", ")", ";", "}", "if", "(", "!", "is_writable", "(", "$", "this", "->", "docRoot", ".", "DS", ".", "$", "assetDir", ")", ")", "{", "throw", "new", "\\", "LogicException", "(", "'The folder \"'", ".", "$", "this", "->", "docRoot", ".", "DS", ".", "$", "assetDir", ".", "'\" must be writable.'", ")", ";", "}", "$", "this", "->", "assetDir", "=", "$", "assetDir", ";", "}" ]
set the asset container folder @param string set the asset directory @throws \InvalidArgumentException @throws \LogicException
[ "set", "the", "asset", "container", "folder" ]
88824f58408beea06703684df0c7f8024ce8478a
https://github.com/mikebarlow/advanced-assets/blob/88824f58408beea06703684df0c7f8024ce8478a/src/Assets.php#L332-L350
4,929
FlorianWolters/PHP-Component-Core-Comparable
src/php/FlorianWolters/Component/Core/ComparableUtils.php
ComparableUtils.compare
public static function compare( ComparableInterface $first = null, ComparableInterface $second = null, $nullGreater = false ) { if ($first === $second) { return self::EQUAL; } elseif (null === $first) { return $nullGreater ? self::FIRST_GT_SECOND : self::FIRST_LT_SECOND; } elseif (null === $second) { return $nullGreater ? self::FIRST_LT_SECOND : self::FIRST_GT_SECOND; } return $first->compareTo($second); }
php
public static function compare( ComparableInterface $first = null, ComparableInterface $second = null, $nullGreater = false ) { if ($first === $second) { return self::EQUAL; } elseif (null === $first) { return $nullGreater ? self::FIRST_GT_SECOND : self::FIRST_LT_SECOND; } elseif (null === $second) { return $nullGreater ? self::FIRST_LT_SECOND : self::FIRST_GT_SECOND; } return $first->compareTo($second); }
[ "public", "static", "function", "compare", "(", "ComparableInterface", "$", "first", "=", "null", ",", "ComparableInterface", "$", "second", "=", "null", ",", "$", "nullGreater", "=", "false", ")", "{", "if", "(", "$", "first", "===", "$", "second", ")", "{", "return", "self", "::", "EQUAL", ";", "}", "elseif", "(", "null", "===", "$", "first", ")", "{", "return", "$", "nullGreater", "?", "self", "::", "FIRST_GT_SECOND", ":", "self", "::", "FIRST_LT_SECOND", ";", "}", "elseif", "(", "null", "===", "$", "second", ")", "{", "return", "$", "nullGreater", "?", "self", "::", "FIRST_LT_SECOND", ":", "self", "::", "FIRST_GT_SECOND", ";", "}", "return", "$", "first", "->", "compareTo", "(", "$", "second", ")", ";", "}" ]
Compares an object with another object for order. Returns a negative integer, zero, or a positive integer as the first object is less than, equal to, or greater than the second object. The comparison of the objects is `null`-safe. @param ComparableInterface|null $first The first object to compare. May be `null`. @param ComparableInterface|null $second The second object to compare. May be `null`. @param boolean $nullGreater If `true` `null` is considered greater than a non-`null` value or if `false` `null` is considered less than a non-`null` value. @return integer A negative integer, zero, or a positive integer as the first object is less than, equal to, or greater than the second object. @throws ClassCastException If the arguments' types prevent them from being compared. @see ComparableInterface::compareTo
[ "Compares", "an", "object", "with", "another", "object", "for", "order", "." ]
f6d9c11a7c672c704dd02420d881da9d91d34b21
https://github.com/FlorianWolters/PHP-Component-Core-Comparable/blob/f6d9c11a7c672c704dd02420d881da9d91d34b21/src/php/FlorianWolters/Component/Core/ComparableUtils.php#L80-L98
4,930
NotQuiteZen/cakephp-plugin-material
src/View/Helper/FormHelper.php
FormHelper.setTemplates
public function setTemplates(array $templates) { if ($templates !== null && is_array($templates)) { $this->_userChangedTemplates = array_merge(array_keys($templates), $this->_userChangedTemplates); } $this->_setTemplatesWrapper($templates); }
php
public function setTemplates(array $templates) { if ($templates !== null && is_array($templates)) { $this->_userChangedTemplates = array_merge(array_keys($templates), $this->_userChangedTemplates); } $this->_setTemplatesWrapper($templates); }
[ "public", "function", "setTemplates", "(", "array", "$", "templates", ")", "{", "if", "(", "$", "templates", "!==", "null", "&&", "is_array", "(", "$", "templates", ")", ")", "{", "$", "this", "->", "_userChangedTemplates", "=", "array_merge", "(", "array_keys", "(", "$", "templates", ")", ",", "$", "this", "->", "_userChangedTemplates", ")", ";", "}", "$", "this", "->", "_setTemplatesWrapper", "(", "$", "templates", ")", ";", "}" ]
Sets templates to use. @param array $templates Templates to be added. @return void
[ "Sets", "templates", "to", "use", "." ]
ba77755139707a1c83ef30d6ae2db2908a941145
https://github.com/NotQuiteZen/cakephp-plugin-material/blob/ba77755139707a1c83ef30d6ae2db2908a941145/src/View/Helper/FormHelper.php#L815-L822
4,931
NotQuiteZen/cakephp-plugin-material
src/View/Helper/FormHelper.php
FormHelper._setTemplatesInternal
protected function _setTemplatesInternal(array $templates) { if (is_array($templates)) { foreach ($this->_userChangedTemplates as $key) { if (array_key_exists($key, $templates)) { unset($templates[$key]); } } } $this->_setTemplatesWrapper($templates); }
php
protected function _setTemplatesInternal(array $templates) { if (is_array($templates)) { foreach ($this->_userChangedTemplates as $key) { if (array_key_exists($key, $templates)) { unset($templates[$key]); } } } $this->_setTemplatesWrapper($templates); }
[ "protected", "function", "_setTemplatesInternal", "(", "array", "$", "templates", ")", "{", "if", "(", "is_array", "(", "$", "templates", ")", ")", "{", "foreach", "(", "$", "this", "->", "_userChangedTemplates", "as", "$", "key", ")", "{", "if", "(", "array_key_exists", "(", "$", "key", ",", "$", "templates", ")", ")", "{", "unset", "(", "$", "templates", "[", "$", "key", "]", ")", ";", "}", "}", "}", "$", "this", "->", "_setTemplatesWrapper", "(", "$", "templates", ")", ";", "}" ]
Set templates after removing the ones previously set by the user, this is to protect against overriding the users wishes @param array $templates Templates to set @return void
[ "Set", "templates", "after", "removing", "the", "ones", "previously", "set", "by", "the", "user", "this", "is", "to", "protect", "against", "overriding", "the", "users", "wishes" ]
ba77755139707a1c83ef30d6ae2db2908a941145
https://github.com/NotQuiteZen/cakephp-plugin-material/blob/ba77755139707a1c83ef30d6ae2db2908a941145/src/View/Helper/FormHelper.php#L841-L854
4,932
NotQuiteZen/cakephp-plugin-material
src/View/Helper/FormHelper.php
FormHelper.submit
public function submit($caption = null, array $options = []) { if ( ! preg_match('/\.(jpg|jpe|jpeg|gif|png|ico)$/', $caption)) { $options = $this->parseButtonClass($options); } if ( ! empty($this->getConfig('layout.classes.submitContainer'))) { $this->_setTemplatesInternal([ 'submitContainer' => '<div{{attrs}}>{{content}}</div>', ]); // Add the attributes for the submitContainer $options['templateVars']['attrs'] = $this->templater()->formatAttributes([ 'class' => $this->getConfig('layout.classes.submitContainer'), ]); } $options = $this->cleanArray($options); return parent::submit($caption, $options); }
php
public function submit($caption = null, array $options = []) { if ( ! preg_match('/\.(jpg|jpe|jpeg|gif|png|ico)$/', $caption)) { $options = $this->parseButtonClass($options); } if ( ! empty($this->getConfig('layout.classes.submitContainer'))) { $this->_setTemplatesInternal([ 'submitContainer' => '<div{{attrs}}>{{content}}</div>', ]); // Add the attributes for the submitContainer $options['templateVars']['attrs'] = $this->templater()->formatAttributes([ 'class' => $this->getConfig('layout.classes.submitContainer'), ]); } $options = $this->cleanArray($options); return parent::submit($caption, $options); }
[ "public", "function", "submit", "(", "$", "caption", "=", "null", ",", "array", "$", "options", "=", "[", "]", ")", "{", "if", "(", "!", "preg_match", "(", "'/\\.(jpg|jpe|jpeg|gif|png|ico)$/'", ",", "$", "caption", ")", ")", "{", "$", "options", "=", "$", "this", "->", "parseButtonClass", "(", "$", "options", ")", ";", "}", "if", "(", "!", "empty", "(", "$", "this", "->", "getConfig", "(", "'layout.classes.submitContainer'", ")", ")", ")", "{", "$", "this", "->", "_setTemplatesInternal", "(", "[", "'submitContainer'", "=>", "'<div{{attrs}}>{{content}}</div>'", ",", "]", ")", ";", "// Add the attributes for the submitContainer", "$", "options", "[", "'templateVars'", "]", "[", "'attrs'", "]", "=", "$", "this", "->", "templater", "(", ")", "->", "formatAttributes", "(", "[", "'class'", "=>", "$", "this", "->", "getConfig", "(", "'layout.classes.submitContainer'", ")", ",", "]", ")", ";", "}", "$", "options", "=", "$", "this", "->", "cleanArray", "(", "$", "options", ")", ";", "return", "parent", "::", "submit", "(", "$", "caption", ",", "$", "options", ")", ";", "}" ]
Creates submit button but adds bootstrap styling @param string|null $caption The label appearing on the button OR if string contains :// or the extension .jpg, .jpe, .jpeg, .gif, .png use an image if the extension exists, AND the first character is /, image is relative to webroot, OR if the first character is not /, image is relative to webroot/img. @param array $options Array of options. See above. @return string A HTML submit button
[ "Creates", "submit", "button", "but", "adds", "bootstrap", "styling" ]
ba77755139707a1c83ef30d6ae2db2908a941145
https://github.com/NotQuiteZen/cakephp-plugin-material/blob/ba77755139707a1c83ef30d6ae2db2908a941145/src/View/Helper/FormHelper.php#L1108-L1128
4,933
NotQuiteZen/cakephp-plugin-material
src/View/Helper/FormHelper.php
FormHelper._bootstrapTypeMap
protected function _bootstrapTypeMap($type) { $map = $this->_bootstrapTypeMap; return isset($map[$type]) ? $map[$type] : 'text'; }
php
protected function _bootstrapTypeMap($type) { $map = $this->_bootstrapTypeMap; return isset($map[$type]) ? $map[$type] : 'text'; }
[ "protected", "function", "_bootstrapTypeMap", "(", "$", "type", ")", "{", "$", "map", "=", "$", "this", "->", "_bootstrapTypeMap", ";", "return", "isset", "(", "$", "map", "[", "$", "type", "]", ")", "?", "$", "map", "[", "$", "type", "]", ":", "'text'", ";", "}" ]
Maps the type to bootstrap else text @param $type @return mixed|string
[ "Maps", "the", "type", "to", "bootstrap", "else", "text" ]
ba77755139707a1c83ef30d6ae2db2908a941145
https://github.com/NotQuiteZen/cakephp-plugin-material/blob/ba77755139707a1c83ef30d6ae2db2908a941145/src/View/Helper/FormHelper.php#L1292-L1296
4,934
NotQuiteZen/cakephp-plugin-material
src/View/Helper/FormHelper.php
FormHelper._parseOptions
protected function _parseOptions($fieldName, $options) { $needsMagicType = false; if (empty($options['type'])) { $needsMagicType = true; $context = $this->_getContext(); $internalType = $context->type($fieldName); if ($this->isHtml5Render($options) && in_array($internalType, ['date', 'datetime', 'time'])) { $options['type'] = $this->_bootstrapTypeMap($internalType); } else { $options['type'] = $this->_inputType($fieldName, $options); } } else { if ($this->isHtml5Render($options) && in_array($options['type'], ['date', 'datetime', 'time'])) { $options['type'] = $this->_bootstrapTypeMap($options['type']); } } $options = $this->_magicOptions($fieldName, $options, $needsMagicType); return $options; }
php
protected function _parseOptions($fieldName, $options) { $needsMagicType = false; if (empty($options['type'])) { $needsMagicType = true; $context = $this->_getContext(); $internalType = $context->type($fieldName); if ($this->isHtml5Render($options) && in_array($internalType, ['date', 'datetime', 'time'])) { $options['type'] = $this->_bootstrapTypeMap($internalType); } else { $options['type'] = $this->_inputType($fieldName, $options); } } else { if ($this->isHtml5Render($options) && in_array($options['type'], ['date', 'datetime', 'time'])) { $options['type'] = $this->_bootstrapTypeMap($options['type']); } } $options = $this->_magicOptions($fieldName, $options, $needsMagicType); return $options; }
[ "protected", "function", "_parseOptions", "(", "$", "fieldName", ",", "$", "options", ")", "{", "$", "needsMagicType", "=", "false", ";", "if", "(", "empty", "(", "$", "options", "[", "'type'", "]", ")", ")", "{", "$", "needsMagicType", "=", "true", ";", "$", "context", "=", "$", "this", "->", "_getContext", "(", ")", ";", "$", "internalType", "=", "$", "context", "->", "type", "(", "$", "fieldName", ")", ";", "if", "(", "$", "this", "->", "isHtml5Render", "(", "$", "options", ")", "&&", "in_array", "(", "$", "internalType", ",", "[", "'date'", ",", "'datetime'", ",", "'time'", "]", ")", ")", "{", "$", "options", "[", "'type'", "]", "=", "$", "this", "->", "_bootstrapTypeMap", "(", "$", "internalType", ")", ";", "}", "else", "{", "$", "options", "[", "'type'", "]", "=", "$", "this", "->", "_inputType", "(", "$", "fieldName", ",", "$", "options", ")", ";", "}", "}", "else", "{", "if", "(", "$", "this", "->", "isHtml5Render", "(", "$", "options", ")", "&&", "in_array", "(", "$", "options", "[", "'type'", "]", ",", "[", "'date'", ",", "'datetime'", ",", "'time'", "]", ")", ")", "{", "$", "options", "[", "'type'", "]", "=", "$", "this", "->", "_bootstrapTypeMap", "(", "$", "options", "[", "'type'", "]", ")", ";", "}", "}", "$", "options", "=", "$", "this", "->", "_magicOptions", "(", "$", "fieldName", ",", "$", "options", ",", "$", "needsMagicType", ")", ";", "return", "$", "options", ";", "}" ]
In case the type is defined manually by the user we need to map it @param string $fieldName @param array $options @return array
[ "In", "case", "the", "type", "is", "defined", "manually", "by", "the", "user", "we", "need", "to", "map", "it" ]
ba77755139707a1c83ef30d6ae2db2908a941145
https://github.com/NotQuiteZen/cakephp-plugin-material/blob/ba77755139707a1c83ef30d6ae2db2908a941145/src/View/Helper/FormHelper.php#L1306-L1328
4,935
PHPPlatform/session
src/Session/Factory.php
Factory.getSession
static function getSession(){ if(self::$session == null){ $sessionImplClassName = Settings::getSettings('php-platform/session',"session.class"); try{ $sessionImplReflectionClass = new \ReflectionClass($sessionImplClassName); }catch (\ReflectionException $re){ throw new ProgrammingError("session implementation class is not configured or invalid"); } $sessionInterfaceName = 'PhpPlatform\Session\Session'; if(!$sessionImplReflectionClass->implementsInterface($sessionInterfaceName)){ throw new ProgrammingError("$sessionImplClassName does not implement $sessionInterfaceName"); } $sessionGetInstanceReflectionMethod = $sessionImplReflectionClass->getMethod('getInstance'); self::$session = $sessionGetInstanceReflectionMethod->invokeArgs(null,array()); } return self::$session; }
php
static function getSession(){ if(self::$session == null){ $sessionImplClassName = Settings::getSettings('php-platform/session',"session.class"); try{ $sessionImplReflectionClass = new \ReflectionClass($sessionImplClassName); }catch (\ReflectionException $re){ throw new ProgrammingError("session implementation class is not configured or invalid"); } $sessionInterfaceName = 'PhpPlatform\Session\Session'; if(!$sessionImplReflectionClass->implementsInterface($sessionInterfaceName)){ throw new ProgrammingError("$sessionImplClassName does not implement $sessionInterfaceName"); } $sessionGetInstanceReflectionMethod = $sessionImplReflectionClass->getMethod('getInstance'); self::$session = $sessionGetInstanceReflectionMethod->invokeArgs(null,array()); } return self::$session; }
[ "static", "function", "getSession", "(", ")", "{", "if", "(", "self", "::", "$", "session", "==", "null", ")", "{", "$", "sessionImplClassName", "=", "Settings", "::", "getSettings", "(", "'php-platform/session'", ",", "\"session.class\"", ")", ";", "try", "{", "$", "sessionImplReflectionClass", "=", "new", "\\", "ReflectionClass", "(", "$", "sessionImplClassName", ")", ";", "}", "catch", "(", "\\", "ReflectionException", "$", "re", ")", "{", "throw", "new", "ProgrammingError", "(", "\"session implementation class is not configured or invalid\"", ")", ";", "}", "$", "sessionInterfaceName", "=", "'PhpPlatform\\Session\\Session'", ";", "if", "(", "!", "$", "sessionImplReflectionClass", "->", "implementsInterface", "(", "$", "sessionInterfaceName", ")", ")", "{", "throw", "new", "ProgrammingError", "(", "\"$sessionImplClassName does not implement $sessionInterfaceName\"", ")", ";", "}", "$", "sessionGetInstanceReflectionMethod", "=", "$", "sessionImplReflectionClass", "->", "getMethod", "(", "'getInstance'", ")", ";", "self", "::", "$", "session", "=", "$", "sessionGetInstanceReflectionMethod", "->", "invokeArgs", "(", "null", ",", "array", "(", ")", ")", ";", "}", "return", "self", "::", "$", "session", ";", "}" ]
This method returns Session singleton object @throws ProgrammingError @return Session
[ "This", "method", "returns", "Session", "singleton", "object" ]
9614f7718cda2003f2cf67d572a4a60a81d0d78e
https://github.com/PHPPlatform/session/blob/9614f7718cda2003f2cf67d572a4a60a81d0d78e/src/Session/Factory.php#L16-L34
4,936
zachgarwood/datatable
library/Table.php
Table.findColumn
public function findColumn($label) { $column = false; foreach ($this->getColumns() as $col) { if ($col->getLabel() == $label) { $column = $col; break; } } return $column; }
php
public function findColumn($label) { $column = false; foreach ($this->getColumns() as $col) { if ($col->getLabel() == $label) { $column = $col; break; } } return $column; }
[ "public", "function", "findColumn", "(", "$", "label", ")", "{", "$", "column", "=", "false", ";", "foreach", "(", "$", "this", "->", "getColumns", "(", ")", "as", "$", "col", ")", "{", "if", "(", "$", "col", "->", "getLabel", "(", ")", "==", "$", "label", ")", "{", "$", "column", "=", "$", "col", ";", "break", ";", "}", "}", "return", "$", "column", ";", "}" ]
Finds the column with the specified label @api @since 1.0.0 @param string $label @return Column|false Returns false if no column is found
[ "Finds", "the", "column", "with", "the", "specified", "label" ]
01d2f12e69742b721663d47a66b469397f115b34
https://github.com/zachgarwood/datatable/blob/01d2f12e69742b721663d47a66b469397f115b34/library/Table.php#L69-L80
4,937
northern/PHP-Common
src/Northern/Common/Util/ArrayUtil.php
ArrayUtil.insert
public static function insert(&$arr, $path, $value, $delimiter = '.') { if (! static::exists($arr, $path, $delimiter)) { static::set($arr, $path, $value, $delimiter); } }
php
public static function insert(&$arr, $path, $value, $delimiter = '.') { if (! static::exists($arr, $path, $delimiter)) { static::set($arr, $path, $value, $delimiter); } }
[ "public", "static", "function", "insert", "(", "&", "$", "arr", ",", "$", "path", ",", "$", "value", ",", "$", "delimiter", "=", "'.'", ")", "{", "if", "(", "!", "static", "::", "exists", "(", "$", "arr", ",", "$", "path", ",", "$", "delimiter", ")", ")", "{", "static", "::", "set", "(", "$", "arr", ",", "$", "path", ",", "$", "value", ",", "$", "delimiter", ")", ";", "}", "}" ]
Inserts a new value into a key or path only if the key or path does not yet exists. @param array $arr @param string $path @param mixed $value @param string $delimiter
[ "Inserts", "a", "new", "value", "into", "a", "key", "or", "path", "only", "if", "the", "key", "or", "path", "does", "not", "yet", "exists", "." ]
7c63ef19252fd540fb412a18af956b8563afaa55
https://github.com/northern/PHP-Common/blob/7c63ef19252fd540fb412a18af956b8563afaa55/src/Northern/Common/Util/ArrayUtil.php#L144-L149
4,938
northern/PHP-Common
src/Northern/Common/Util/ArrayUtil.php
ArrayUtil.exists
public static function exists(array &$arr, $path, $delimiter = '.') { if (array_key_exists($path, $arr)) { return true; } $segments = explode($delimiter, $path); $cur = $arr; foreach ($segments as $segment) { if (! is_array($cur) or ! array_key_exists($segment, $cur)) { return false; } $cur = $cur[$segment]; } return true; }
php
public static function exists(array &$arr, $path, $delimiter = '.') { if (array_key_exists($path, $arr)) { return true; } $segments = explode($delimiter, $path); $cur = $arr; foreach ($segments as $segment) { if (! is_array($cur) or ! array_key_exists($segment, $cur)) { return false; } $cur = $cur[$segment]; } return true; }
[ "public", "static", "function", "exists", "(", "array", "&", "$", "arr", ",", "$", "path", ",", "$", "delimiter", "=", "'.'", ")", "{", "if", "(", "array_key_exists", "(", "$", "path", ",", "$", "arr", ")", ")", "{", "return", "true", ";", "}", "$", "segments", "=", "explode", "(", "$", "delimiter", ",", "$", "path", ")", ";", "$", "cur", "=", "$", "arr", ";", "foreach", "(", "$", "segments", "as", "$", "segment", ")", "{", "if", "(", "!", "is_array", "(", "$", "cur", ")", "or", "!", "array_key_exists", "(", "$", "segment", ",", "$", "cur", ")", ")", "{", "return", "false", ";", "}", "$", "cur", "=", "$", "cur", "[", "$", "segment", "]", ";", "}", "return", "true", ";", "}" ]
Tests if a key or path exists in a specified array. If the specified key or path exists this method will return TRUE otherwise FALSE. @param array $arr @param string $path @param string $delimiter @return boolean
[ "Tests", "if", "a", "key", "or", "path", "exists", "in", "a", "specified", "array", ".", "If", "the", "specified", "key", "or", "path", "exists", "this", "method", "will", "return", "TRUE", "otherwise", "FALSE", "." ]
7c63ef19252fd540fb412a18af956b8563afaa55
https://github.com/northern/PHP-Common/blob/7c63ef19252fd540fb412a18af956b8563afaa55/src/Northern/Common/Util/ArrayUtil.php#L202-L221
4,939
northern/PHP-Common
src/Northern/Common/Util/ArrayUtil.php
ArrayUtil.keys
public static function keys($array, $prefix = null) { $keys = array_keys($array); if (! empty($prefix)) { $keys = static::prefix($keys, $prefix); } return $keys; }
php
public static function keys($array, $prefix = null) { $keys = array_keys($array); if (! empty($prefix)) { $keys = static::prefix($keys, $prefix); } return $keys; }
[ "public", "static", "function", "keys", "(", "$", "array", ",", "$", "prefix", "=", "null", ")", "{", "$", "keys", "=", "array_keys", "(", "$", "array", ")", ";", "if", "(", "!", "empty", "(", "$", "prefix", ")", ")", "{", "$", "keys", "=", "static", "::", "prefix", "(", "$", "keys", ",", "$", "prefix", ")", ";", "}", "return", "$", "keys", ";", "}" ]
This method will return all the keys of a given array and optionally prefix each key with a specified prefix. @param array $array @param string $prefix @return array
[ "This", "method", "will", "return", "all", "the", "keys", "of", "a", "given", "array", "and", "optionally", "prefix", "each", "key", "with", "a", "specified", "prefix", "." ]
7c63ef19252fd540fb412a18af956b8563afaa55
https://github.com/northern/PHP-Common/blob/7c63ef19252fd540fb412a18af956b8563afaa55/src/Northern/Common/Util/ArrayUtil.php#L280-L289
4,940
northern/PHP-Common
src/Northern/Common/Util/ArrayUtil.php
ArrayUtil.values
public static function values($array, $prefix = null) { $values = array_values($array); if (! empty($prefix)) { $values = static::prefix($values, $prefix); } return $values; }
php
public static function values($array, $prefix = null) { $values = array_values($array); if (! empty($prefix)) { $values = static::prefix($values, $prefix); } return $values; }
[ "public", "static", "function", "values", "(", "$", "array", ",", "$", "prefix", "=", "null", ")", "{", "$", "values", "=", "array_values", "(", "$", "array", ")", ";", "if", "(", "!", "empty", "(", "$", "prefix", ")", ")", "{", "$", "values", "=", "static", "::", "prefix", "(", "$", "values", ",", "$", "prefix", ")", ";", "}", "return", "$", "values", ";", "}" ]
This method will return all values of a given array and optionally prefix each value with a specified prefix. @param array $array @param string $prefix @return array
[ "This", "method", "will", "return", "all", "values", "of", "a", "given", "array", "and", "optionally", "prefix", "each", "value", "with", "a", "specified", "prefix", "." ]
7c63ef19252fd540fb412a18af956b8563afaa55
https://github.com/northern/PHP-Common/blob/7c63ef19252fd540fb412a18af956b8563afaa55/src/Northern/Common/Util/ArrayUtil.php#L299-L308
4,941
northern/PHP-Common
src/Northern/Common/Util/ArrayUtil.php
ArrayUtil.map
public static function map($callbacks, $arr, $keys = null) { foreach ($arr as $key => $val) { if (is_array($val)) { $arr[ $key ] = static::map($callbacks, $arr[ $key ]); } elseif (! is_array($keys) or in_array($key, $keys)) { if (is_array($callbacks)) { foreach ($callbacks as $callback) { $arr[ $key ] = call_user_func($callback, $arr[ $key ]); } } else { $arr[ $key ] = call_user_func($callbacks, $arr[ $key ]); } } } return $arr; }
php
public static function map($callbacks, $arr, $keys = null) { foreach ($arr as $key => $val) { if (is_array($val)) { $arr[ $key ] = static::map($callbacks, $arr[ $key ]); } elseif (! is_array($keys) or in_array($key, $keys)) { if (is_array($callbacks)) { foreach ($callbacks as $callback) { $arr[ $key ] = call_user_func($callback, $arr[ $key ]); } } else { $arr[ $key ] = call_user_func($callbacks, $arr[ $key ]); } } } return $arr; }
[ "public", "static", "function", "map", "(", "$", "callbacks", ",", "$", "arr", ",", "$", "keys", "=", "null", ")", "{", "foreach", "(", "$", "arr", "as", "$", "key", "=>", "$", "val", ")", "{", "if", "(", "is_array", "(", "$", "val", ")", ")", "{", "$", "arr", "[", "$", "key", "]", "=", "static", "::", "map", "(", "$", "callbacks", ",", "$", "arr", "[", "$", "key", "]", ")", ";", "}", "elseif", "(", "!", "is_array", "(", "$", "keys", ")", "or", "in_array", "(", "$", "key", ",", "$", "keys", ")", ")", "{", "if", "(", "is_array", "(", "$", "callbacks", ")", ")", "{", "foreach", "(", "$", "callbacks", "as", "$", "callback", ")", "{", "$", "arr", "[", "$", "key", "]", "=", "call_user_func", "(", "$", "callback", ",", "$", "arr", "[", "$", "key", "]", ")", ";", "}", "}", "else", "{", "$", "arr", "[", "$", "key", "]", "=", "call_user_func", "(", "$", "callbacks", ",", "$", "arr", "[", "$", "key", "]", ")", ";", "}", "}", "}", "return", "$", "arr", ";", "}" ]
Recursive version of array_map, applies one or more callbacks to all elements in an array, including sub-arrays. Apply "strip_tags" to every element in the array $array = ArrayHelper::map('strip_tags', $array); Apply $this->filter to every element in the array $array = ArrayHelper::map(array(array($this,'filter')), $array); Apply strip_tags and $this->filter to every element $array = ArrayHelper::map(array('strip_tags',array($this,'filter')), $array); @param mixed $callbacks @param array $array @param mixed $keys @return array
[ "Recursive", "version", "of", "array_map", "applies", "one", "or", "more", "callbacks", "to", "all", "elements", "in", "an", "array", "including", "sub", "-", "arrays", "." ]
7c63ef19252fd540fb412a18af956b8563afaa55
https://github.com/northern/PHP-Common/blob/7c63ef19252fd540fb412a18af956b8563afaa55/src/Northern/Common/Util/ArrayUtil.php#L328-L345
4,942
northern/PHP-Common
src/Northern/Common/Util/ArrayUtil.php
ArrayUtil.remapCollection
public static function remapCollection(array $collection, array $map, $createMode = true) { $results = array(); foreach ($collection as $item) { $results[] = self::remap($item, $map, $createMode); } return $results; }
php
public static function remapCollection(array $collection, array $map, $createMode = true) { $results = array(); foreach ($collection as $item) { $results[] = self::remap($item, $map, $createMode); } return $results; }
[ "public", "static", "function", "remapCollection", "(", "array", "$", "collection", ",", "array", "$", "map", ",", "$", "createMode", "=", "true", ")", "{", "$", "results", "=", "array", "(", ")", ";", "foreach", "(", "$", "collection", "as", "$", "item", ")", "{", "$", "results", "[", "]", "=", "self", "::", "remap", "(", "$", "item", ",", "$", "map", ",", "$", "createMode", ")", ";", "}", "return", "$", "results", ";", "}" ]
Remaps a collection. @param array $collection @param array $map @return array
[ "Remaps", "a", "collection", "." ]
7c63ef19252fd540fb412a18af956b8563afaa55
https://github.com/northern/PHP-Common/blob/7c63ef19252fd540fb412a18af956b8563afaa55/src/Northern/Common/Util/ArrayUtil.php#L377-L386
4,943
northern/PHP-Common
src/Northern/Common/Util/ArrayUtil.php
ArrayUtil.extract
public static function extract(array &$arr, $path, $default = null, $delimiter = '.') { $value = static::get($arr, $path, $default, $delimiter); static::delete($arr, $path, $delimiter); return $value; }
php
public static function extract(array &$arr, $path, $default = null, $delimiter = '.') { $value = static::get($arr, $path, $default, $delimiter); static::delete($arr, $path, $delimiter); return $value; }
[ "public", "static", "function", "extract", "(", "array", "&", "$", "arr", ",", "$", "path", ",", "$", "default", "=", "null", ",", "$", "delimiter", "=", "'.'", ")", "{", "$", "value", "=", "static", "::", "get", "(", "$", "arr", ",", "$", "path", ",", "$", "default", ",", "$", "delimiter", ")", ";", "static", "::", "delete", "(", "$", "arr", ",", "$", "path", ",", "$", "delimiter", ")", ";", "return", "$", "value", ";", "}" ]
Returns a value for a specified array key and deletes the key. @param array $arr @param string $path @param mixed $default @param string $delimiter @return mixed
[ "Returns", "a", "value", "for", "a", "specified", "array", "key", "and", "deletes", "the", "key", "." ]
7c63ef19252fd540fb412a18af956b8563afaa55
https://github.com/northern/PHP-Common/blob/7c63ef19252fd540fb412a18af956b8563afaa55/src/Northern/Common/Util/ArrayUtil.php#L449-L456
4,944
ouranoshong/phdescriptors
libs/CookieDescriptor.php
CookieDescriptor.getFromHeaderLine
public static function getFromHeaderLine($header_line, $source_url) { $parts = explode(';', trim($header_line)); $name = ''; $value = ''; $expires = null; $path = null; $domain = ''; // Name and value preg_match('#([^=]*)=(.*)#', $parts[0], $match); $name = trim($match[1]); $value = trim($match[2]); // Path and Expires for ($x = 1; $x < count($parts); ++$x) { $parts[$x] = trim($parts[$x]); if (preg_match("#^expires\s*=(.*)# i", $parts[$x], $match)) { $expires = trim($match[1]); } if (preg_match("#^path\s*=(.*)# i", $parts[$x], $match)) { $path = trim($match[1]); } if (preg_match("#^domain\s*=(.*)# i", $parts[$x], $match)) { $domain = trim($match[1]); } } $expires = str_replace('"', '', $expires); $path = str_replace('"', '', $path); $domain = str_replace('"', '', $domain); return new self($source_url, $name, $value, $expires, $path, $domain); }
php
public static function getFromHeaderLine($header_line, $source_url) { $parts = explode(';', trim($header_line)); $name = ''; $value = ''; $expires = null; $path = null; $domain = ''; // Name and value preg_match('#([^=]*)=(.*)#', $parts[0], $match); $name = trim($match[1]); $value = trim($match[2]); // Path and Expires for ($x = 1; $x < count($parts); ++$x) { $parts[$x] = trim($parts[$x]); if (preg_match("#^expires\s*=(.*)# i", $parts[$x], $match)) { $expires = trim($match[1]); } if (preg_match("#^path\s*=(.*)# i", $parts[$x], $match)) { $path = trim($match[1]); } if (preg_match("#^domain\s*=(.*)# i", $parts[$x], $match)) { $domain = trim($match[1]); } } $expires = str_replace('"', '', $expires); $path = str_replace('"', '', $path); $domain = str_replace('"', '', $domain); return new self($source_url, $name, $value, $expires, $path, $domain); }
[ "public", "static", "function", "getFromHeaderLine", "(", "$", "header_line", ",", "$", "source_url", ")", "{", "$", "parts", "=", "explode", "(", "';'", ",", "trim", "(", "$", "header_line", ")", ")", ";", "$", "name", "=", "''", ";", "$", "value", "=", "''", ";", "$", "expires", "=", "null", ";", "$", "path", "=", "null", ";", "$", "domain", "=", "''", ";", "// Name and value", "preg_match", "(", "'#([^=]*)=(.*)#'", ",", "$", "parts", "[", "0", "]", ",", "$", "match", ")", ";", "$", "name", "=", "trim", "(", "$", "match", "[", "1", "]", ")", ";", "$", "value", "=", "trim", "(", "$", "match", "[", "2", "]", ")", ";", "// Path and Expires", "for", "(", "$", "x", "=", "1", ";", "$", "x", "<", "count", "(", "$", "parts", ")", ";", "++", "$", "x", ")", "{", "$", "parts", "[", "$", "x", "]", "=", "trim", "(", "$", "parts", "[", "$", "x", "]", ")", ";", "if", "(", "preg_match", "(", "\"#^expires\\s*=(.*)# i\"", ",", "$", "parts", "[", "$", "x", "]", ",", "$", "match", ")", ")", "{", "$", "expires", "=", "trim", "(", "$", "match", "[", "1", "]", ")", ";", "}", "if", "(", "preg_match", "(", "\"#^path\\s*=(.*)# i\"", ",", "$", "parts", "[", "$", "x", "]", ",", "$", "match", ")", ")", "{", "$", "path", "=", "trim", "(", "$", "match", "[", "1", "]", ")", ";", "}", "if", "(", "preg_match", "(", "\"#^domain\\s*=(.*)# i\"", ",", "$", "parts", "[", "$", "x", "]", ",", "$", "match", ")", ")", "{", "$", "domain", "=", "trim", "(", "$", "match", "[", "1", "]", ")", ";", "}", "}", "$", "expires", "=", "str_replace", "(", "'\"'", ",", "''", ",", "$", "expires", ")", ";", "$", "path", "=", "str_replace", "(", "'\"'", ",", "''", ",", "$", "path", ")", ";", "$", "domain", "=", "str_replace", "(", "'\"'", ",", "''", ",", "$", "domain", ")", ";", "return", "new", "self", "(", "$", "source_url", ",", "$", "name", ",", "$", "value", ",", "$", "expires", ",", "$", "path", ",", "$", "domain", ")", ";", "}" ]
Returns a CookieDescriptor-object initiated by the given cookie-header-line. @param string $header_line The line from an header defining the cookie, e.g. "VISITOR=4c63394c2d82e31552001a58; expires="Sat, 08-Aug-2020 23:59:08 GMT"; Path=/" @param string $source_url URL the cookie was send from. @return CookieDescriptor The appropriate CookieDescriptor-object.
[ "Returns", "a", "CookieDescriptor", "-", "object", "initiated", "by", "the", "given", "cookie", "-", "header", "-", "line", "." ]
1d2277d3d6547de443d14ef70cc297cab49e0c50
https://github.com/ouranoshong/phdescriptors/blob/1d2277d3d6547de443d14ef70cc297cab49e0c50/libs/CookieDescriptor.php#L155-L190
4,945
CampusUnion/Sked
src/ValidatesDates.php
ValidatesDates.validateDate
protected function validateDate(string &$strDate) { if (!preg_match("/\d{4}\-\d{2}-\d{2}/", $strDate)) { if ($iTime = strtotime($strDate)) { $strDate = date('Y-m-d', $iTime); } else { throw new \Exception( 'Invalid date string given to ' . debug_backtrace()[1]['function'] . '. Use format YYYY-MM-DD.' ); } } }
php
protected function validateDate(string &$strDate) { if (!preg_match("/\d{4}\-\d{2}-\d{2}/", $strDate)) { if ($iTime = strtotime($strDate)) { $strDate = date('Y-m-d', $iTime); } else { throw new \Exception( 'Invalid date string given to ' . debug_backtrace()[1]['function'] . '. Use format YYYY-MM-DD.' ); } } }
[ "protected", "function", "validateDate", "(", "string", "&", "$", "strDate", ")", "{", "if", "(", "!", "preg_match", "(", "\"/\\d{4}\\-\\d{2}-\\d{2}/\"", ",", "$", "strDate", ")", ")", "{", "if", "(", "$", "iTime", "=", "strtotime", "(", "$", "strDate", ")", ")", "{", "$", "strDate", "=", "date", "(", "'Y-m-d'", ",", "$", "iTime", ")", ";", "}", "else", "{", "throw", "new", "\\", "Exception", "(", "'Invalid date string given to '", ".", "debug_backtrace", "(", ")", "[", "1", "]", "[", "'function'", "]", ".", "'. Use format YYYY-MM-DD.'", ")", ";", "}", "}", "}" ]
Verifies that the given date string is in format YYYY-MM-DD. Converts the date string to the desired format if possible. @param string $strDate YYYY-MM-DD @return bool
[ "Verifies", "that", "the", "given", "date", "string", "is", "in", "format", "YYYY", "-", "MM", "-", "DD", "." ]
5b51afdb56c0f607e54364635c4725627b19ecc6
https://github.com/CampusUnion/Sked/blob/5b51afdb56c0f607e54364635c4725627b19ecc6/src/ValidatesDates.php#L15-L27
4,946
webforge-labs/webforge-project-stack
lib/Webforge/ProjectStack/Symfony/Form/Transformer/DoctrineEntityTransformer.php
DoctrineEntityTransformer.transform
public function transform($entity) { if ($entity === NULL) { return NULL; } $getter = 'get'.ucfirst($this->identifierName); return array( '__class' => $this->entityClass, // just for verbose $this->identifierName => $entity->$getter() ); }
php
public function transform($entity) { if ($entity === NULL) { return NULL; } $getter = 'get'.ucfirst($this->identifierName); return array( '__class' => $this->entityClass, // just for verbose $this->identifierName => $entity->$getter() ); }
[ "public", "function", "transform", "(", "$", "entity", ")", "{", "if", "(", "$", "entity", "===", "NULL", ")", "{", "return", "NULL", ";", "}", "$", "getter", "=", "'get'", ".", "ucfirst", "(", "$", "this", "->", "identifierName", ")", ";", "return", "array", "(", "'__class'", "=>", "$", "this", "->", "entityClass", ",", "// just for verbose", "$", "this", "->", "identifierName", "=>", "$", "entity", "->", "$", "getter", "(", ")", ")", ";", "}" ]
Transforms an entity to its json object
[ "Transforms", "an", "entity", "to", "its", "json", "object" ]
753929c0957c660fdc62f7f358591fcb56e6d284
https://github.com/webforge-labs/webforge-project-stack/blob/753929c0957c660fdc62f7f358591fcb56e6d284/lib/Webforge/ProjectStack/Symfony/Form/Transformer/DoctrineEntityTransformer.php#L34-L45
4,947
webforge-labs/webforge-project-stack
lib/Webforge/ProjectStack/Symfony/Form/Transformer/DoctrineEntityTransformer.php
DoctrineEntityTransformer.reverseTransform
public function reverseTransform($properties) { if (!is_array($properties)) { return NULL; } if (!isset($properties[$this->identifierName])) { throw new TransformationFailedException(sprintf( 'Identifier (%s) for entity %s is not set in properties %s', $this->identifierName, $this->entityClass, json_encode($properties, JSON_PRETTY_PRINT) )); } $identifier = $properties[$this->identifierName]; $entity = $this->om ->getRepository($this->entityClass) ->findOneBy(array($this->identifierName => $identifier)) ; if (!($entity instanceof $this->entityClass)) { throw new TransformationFailedException(sprintf( 'Entity %s with identifier (%s) "%s" cannot be found', $this->entityClass, $this->identifierName, $identifier )); } return $entity; }
php
public function reverseTransform($properties) { if (!is_array($properties)) { return NULL; } if (!isset($properties[$this->identifierName])) { throw new TransformationFailedException(sprintf( 'Identifier (%s) for entity %s is not set in properties %s', $this->identifierName, $this->entityClass, json_encode($properties, JSON_PRETTY_PRINT) )); } $identifier = $properties[$this->identifierName]; $entity = $this->om ->getRepository($this->entityClass) ->findOneBy(array($this->identifierName => $identifier)) ; if (!($entity instanceof $this->entityClass)) { throw new TransformationFailedException(sprintf( 'Entity %s with identifier (%s) "%s" cannot be found', $this->entityClass, $this->identifierName, $identifier )); } return $entity; }
[ "public", "function", "reverseTransform", "(", "$", "properties", ")", "{", "if", "(", "!", "is_array", "(", "$", "properties", ")", ")", "{", "return", "NULL", ";", "}", "if", "(", "!", "isset", "(", "$", "properties", "[", "$", "this", "->", "identifierName", "]", ")", ")", "{", "throw", "new", "TransformationFailedException", "(", "sprintf", "(", "'Identifier (%s) for entity %s is not set in properties %s'", ",", "$", "this", "->", "identifierName", ",", "$", "this", "->", "entityClass", ",", "json_encode", "(", "$", "properties", ",", "JSON_PRETTY_PRINT", ")", ")", ")", ";", "}", "$", "identifier", "=", "$", "properties", "[", "$", "this", "->", "identifierName", "]", ";", "$", "entity", "=", "$", "this", "->", "om", "->", "getRepository", "(", "$", "this", "->", "entityClass", ")", "->", "findOneBy", "(", "array", "(", "$", "this", "->", "identifierName", "=>", "$", "identifier", ")", ")", ";", "if", "(", "!", "(", "$", "entity", "instanceof", "$", "this", "->", "entityClass", ")", ")", "{", "throw", "new", "TransformationFailedException", "(", "sprintf", "(", "'Entity %s with identifier (%s) \"%s\" cannot be found'", ",", "$", "this", "->", "entityClass", ",", "$", "this", "->", "identifierName", ",", "$", "identifier", ")", ")", ";", "}", "return", "$", "entity", ";", "}" ]
Transforms an json object to an entity
[ "Transforms", "an", "json", "object", "to", "an", "entity" ]
753929c0957c660fdc62f7f358591fcb56e6d284
https://github.com/webforge-labs/webforge-project-stack/blob/753929c0957c660fdc62f7f358591fcb56e6d284/lib/Webforge/ProjectStack/Symfony/Form/Transformer/DoctrineEntityTransformer.php#L51-L82
4,948
ntentan/utils
src/filesystem/UploadedFile.php
UploadedFile.moveTo
public function moveTo(string $destination): void { $destination = is_dir($destination) ? ("$destination/{$this->clientName}") : $destination; Filesystem::checkWritable(dirname($destination)); if (!move_uploaded_file($this->path, $destination)) { throw new FilesystemException("Failed to move file {$this->path} to {$destination}"); } }
php
public function moveTo(string $destination): void { $destination = is_dir($destination) ? ("$destination/{$this->clientName}") : $destination; Filesystem::checkWritable(dirname($destination)); if (!move_uploaded_file($this->path, $destination)) { throw new FilesystemException("Failed to move file {$this->path} to {$destination}"); } }
[ "public", "function", "moveTo", "(", "string", "$", "destination", ")", ":", "void", "{", "$", "destination", "=", "is_dir", "(", "$", "destination", ")", "?", "(", "\"$destination/{$this->clientName}\"", ")", ":", "$", "destination", ";", "Filesystem", "::", "checkWritable", "(", "dirname", "(", "$", "destination", ")", ")", ";", "if", "(", "!", "move_uploaded_file", "(", "$", "this", "->", "path", ",", "$", "destination", ")", ")", "{", "throw", "new", "FilesystemException", "(", "\"Failed to move file {$this->path} to {$destination}\"", ")", ";", "}", "}" ]
Move the uploaded file safely to another location. Ensures that files were actually uploaded through PHP before moving them. @param string $destination @throws FilesystemException @throws \ntentan\utils\exceptions\FileNotWriteableException
[ "Move", "the", "uploaded", "file", "safely", "to", "another", "location", ".", "Ensures", "that", "files", "were", "actually", "uploaded", "through", "PHP", "before", "moving", "them", "." ]
151f3582ee6007ea77a38d2b6c590289331e19a1
https://github.com/ntentan/utils/blob/151f3582ee6007ea77a38d2b6c590289331e19a1/src/filesystem/UploadedFile.php#L82-L89
4,949
nicolasherve/StimLog
src/StimLog/Event/LogEvent.php
LogEvent.create
public static function create($className, $level) { // Create the event $event = new LogEvent(); // Assign level and message $event->_setLevel(LogLevel::create($level)); // Initialize current date and time (with milliseconds) $event->_setDate(DateMilli::create()); // Initialize trace $trace = debug_backtrace(DEBUG_BACKTRACE_PROVIDE_OBJECT, 4); $trace['class'] = $className; $trace['file'] = $trace[2]['file']; $trace['line'] = $trace[2]['line']; $event->_setTrace($trace); return $event; }
php
public static function create($className, $level) { // Create the event $event = new LogEvent(); // Assign level and message $event->_setLevel(LogLevel::create($level)); // Initialize current date and time (with milliseconds) $event->_setDate(DateMilli::create()); // Initialize trace $trace = debug_backtrace(DEBUG_BACKTRACE_PROVIDE_OBJECT, 4); $trace['class'] = $className; $trace['file'] = $trace[2]['file']; $trace['line'] = $trace[2]['line']; $event->_setTrace($trace); return $event; }
[ "public", "static", "function", "create", "(", "$", "className", ",", "$", "level", ")", "{", "// Create the event\r", "$", "event", "=", "new", "LogEvent", "(", ")", ";", "// Assign level and message\r", "$", "event", "->", "_setLevel", "(", "LogLevel", "::", "create", "(", "$", "level", ")", ")", ";", "// Initialize current date and time (with milliseconds)\r", "$", "event", "->", "_setDate", "(", "DateMilli", "::", "create", "(", ")", ")", ";", "// Initialize trace\r", "$", "trace", "=", "debug_backtrace", "(", "DEBUG_BACKTRACE_PROVIDE_OBJECT", ",", "4", ")", ";", "$", "trace", "[", "'class'", "]", "=", "$", "className", ";", "$", "trace", "[", "'file'", "]", "=", "$", "trace", "[", "2", "]", "[", "'file'", "]", ";", "$", "trace", "[", "'line'", "]", "=", "$", "trace", "[", "2", "]", "[", "'line'", "]", ";", "$", "event", "->", "_setTrace", "(", "$", "trace", ")", ";", "return", "$", "event", ";", "}" ]
Create a new log event and return it @param string $className the class name where the event was created @param integer $level the log level of the event @return LogEvent
[ "Create", "a", "new", "log", "event", "and", "return", "it" ]
b9fabe8a5141a835c0d2a18a7ae67663359eb0f7
https://github.com/nicolasherve/StimLog/blob/b9fabe8a5141a835c0d2a18a7ae67663359eb0f7/src/StimLog/Event/LogEvent.php#L73-L92
4,950
helloandre/pressing
src/Ingester.php
Ingester.scandir
private function scandir($dir) { $dir = trim($dir, '/') . '/'; $absolute = $this->absolute($dir); $files = scandir($absolute); foreach ($files as $file) { // ignore relative references if ($file === "." || $file === "..") { continue; } if (is_dir($absolute . $file)) { $this->scandir($dir . $file); } else { // we want the relative path inside the input_dir so we can // put the file in the same place in the output_dir $path = preg_replace("#^" . Config::get('input_dir') . "#", "", $dir . $file); $this->paths[] = array( 'path' => $path ); } } }
php
private function scandir($dir) { $dir = trim($dir, '/') . '/'; $absolute = $this->absolute($dir); $files = scandir($absolute); foreach ($files as $file) { // ignore relative references if ($file === "." || $file === "..") { continue; } if (is_dir($absolute . $file)) { $this->scandir($dir . $file); } else { // we want the relative path inside the input_dir so we can // put the file in the same place in the output_dir $path = preg_replace("#^" . Config::get('input_dir') . "#", "", $dir . $file); $this->paths[] = array( 'path' => $path ); } } }
[ "private", "function", "scandir", "(", "$", "dir", ")", "{", "$", "dir", "=", "trim", "(", "$", "dir", ",", "'/'", ")", ".", "'/'", ";", "$", "absolute", "=", "$", "this", "->", "absolute", "(", "$", "dir", ")", ";", "$", "files", "=", "scandir", "(", "$", "absolute", ")", ";", "foreach", "(", "$", "files", "as", "$", "file", ")", "{", "// ignore relative references", "if", "(", "$", "file", "===", "\".\"", "||", "$", "file", "===", "\"..\"", ")", "{", "continue", ";", "}", "if", "(", "is_dir", "(", "$", "absolute", ".", "$", "file", ")", ")", "{", "$", "this", "->", "scandir", "(", "$", "dir", ".", "$", "file", ")", ";", "}", "else", "{", "// we want the relative path inside the input_dir so we can", "// put the file in the same place in the output_dir", "$", "path", "=", "preg_replace", "(", "\"#^\"", ".", "Config", "::", "get", "(", "'input_dir'", ")", ".", "\"#\"", ",", "\"\"", ",", "$", "dir", ".", "$", "file", ")", ";", "$", "this", "->", "paths", "[", "]", "=", "array", "(", "'path'", "=>", "$", "path", ")", ";", "}", "}", "}" ]
recursively scan the directory for any files @param String $dir - relative to getcwd()
[ "recursively", "scan", "the", "directory", "for", "any", "files" ]
e4244c7bbe90c38fa7d45e3c2da5d4b9153a0f54
https://github.com/helloandre/pressing/blob/e4244c7bbe90c38fa7d45e3c2da5d4b9153a0f54/src/Ingester.php#L62-L84
4,951
phlexible/phlexible
src/Phlexible/Component/MediaCache/Queue/InstructionCreator.php
InstructionCreator.createInstruction
public function createInstruction(InputDescriptor $input, TemplateInterface $template, array $flags = []) { if (!$template->getManaged()) { return null; } $cacheItem = $this->cacheManager->findByTemplateAndFile($template->getKey(), $input->getFileId(), $input->getFileVersion()); if (in_array(Batch::FILTER_ERROR, $flags) && $cacheItem && !$this->isError($cacheItem)) { $this->logger->info('Skipping non-error item'); return null; } if (in_array(Batch::FILTER_MISSING, $flags) && $cacheItem && !$this->isMissing($cacheItem)) { $this->logger->info('Skipping non-missing item'); return null; } if (in_array(Batch::FILTER_UNCACHED, $flags) && $cacheItem && $this->isCached($cacheItem)) { $this->logger->info('Skipping cached item'); return null; } if (!$cacheItem) { $cacheItem = new CacheItem(); $cacheItem ->setId($this->cacheIdStrategy->createCacheId($template, $input)) ->setVolumeId($input->getVolumeId()) ->setFileId($input->getFileId()) ->setFileVersion($input->getFileVersion()) ->setTemplateKey($template->getKey()) ->setTemplateRevision($template->getRevision()) ->setCacheStatus(CacheItem::STATUS_WAITING) ->setQueueStatus(CacheItem::QUEUE_WAITING) ->setCreatedAt(new \DateTime()); } $cacheItem ->setQueuedAt(new \DateTime()); return new Instruction($input, $template, $cacheItem); }
php
public function createInstruction(InputDescriptor $input, TemplateInterface $template, array $flags = []) { if (!$template->getManaged()) { return null; } $cacheItem = $this->cacheManager->findByTemplateAndFile($template->getKey(), $input->getFileId(), $input->getFileVersion()); if (in_array(Batch::FILTER_ERROR, $flags) && $cacheItem && !$this->isError($cacheItem)) { $this->logger->info('Skipping non-error item'); return null; } if (in_array(Batch::FILTER_MISSING, $flags) && $cacheItem && !$this->isMissing($cacheItem)) { $this->logger->info('Skipping non-missing item'); return null; } if (in_array(Batch::FILTER_UNCACHED, $flags) && $cacheItem && $this->isCached($cacheItem)) { $this->logger->info('Skipping cached item'); return null; } if (!$cacheItem) { $cacheItem = new CacheItem(); $cacheItem ->setId($this->cacheIdStrategy->createCacheId($template, $input)) ->setVolumeId($input->getVolumeId()) ->setFileId($input->getFileId()) ->setFileVersion($input->getFileVersion()) ->setTemplateKey($template->getKey()) ->setTemplateRevision($template->getRevision()) ->setCacheStatus(CacheItem::STATUS_WAITING) ->setQueueStatus(CacheItem::QUEUE_WAITING) ->setCreatedAt(new \DateTime()); } $cacheItem ->setQueuedAt(new \DateTime()); return new Instruction($input, $template, $cacheItem); }
[ "public", "function", "createInstruction", "(", "InputDescriptor", "$", "input", ",", "TemplateInterface", "$", "template", ",", "array", "$", "flags", "=", "[", "]", ")", "{", "if", "(", "!", "$", "template", "->", "getManaged", "(", ")", ")", "{", "return", "null", ";", "}", "$", "cacheItem", "=", "$", "this", "->", "cacheManager", "->", "findByTemplateAndFile", "(", "$", "template", "->", "getKey", "(", ")", ",", "$", "input", "->", "getFileId", "(", ")", ",", "$", "input", "->", "getFileVersion", "(", ")", ")", ";", "if", "(", "in_array", "(", "Batch", "::", "FILTER_ERROR", ",", "$", "flags", ")", "&&", "$", "cacheItem", "&&", "!", "$", "this", "->", "isError", "(", "$", "cacheItem", ")", ")", "{", "$", "this", "->", "logger", "->", "info", "(", "'Skipping non-error item'", ")", ";", "return", "null", ";", "}", "if", "(", "in_array", "(", "Batch", "::", "FILTER_MISSING", ",", "$", "flags", ")", "&&", "$", "cacheItem", "&&", "!", "$", "this", "->", "isMissing", "(", "$", "cacheItem", ")", ")", "{", "$", "this", "->", "logger", "->", "info", "(", "'Skipping non-missing item'", ")", ";", "return", "null", ";", "}", "if", "(", "in_array", "(", "Batch", "::", "FILTER_UNCACHED", ",", "$", "flags", ")", "&&", "$", "cacheItem", "&&", "$", "this", "->", "isCached", "(", "$", "cacheItem", ")", ")", "{", "$", "this", "->", "logger", "->", "info", "(", "'Skipping cached item'", ")", ";", "return", "null", ";", "}", "if", "(", "!", "$", "cacheItem", ")", "{", "$", "cacheItem", "=", "new", "CacheItem", "(", ")", ";", "$", "cacheItem", "->", "setId", "(", "$", "this", "->", "cacheIdStrategy", "->", "createCacheId", "(", "$", "template", ",", "$", "input", ")", ")", "->", "setVolumeId", "(", "$", "input", "->", "getVolumeId", "(", ")", ")", "->", "setFileId", "(", "$", "input", "->", "getFileId", "(", ")", ")", "->", "setFileVersion", "(", "$", "input", "->", "getFileVersion", "(", ")", ")", "->", "setTemplateKey", "(", "$", "template", "->", "getKey", "(", ")", ")", "->", "setTemplateRevision", "(", "$", "template", "->", "getRevision", "(", ")", ")", "->", "setCacheStatus", "(", "CacheItem", "::", "STATUS_WAITING", ")", "->", "setQueueStatus", "(", "CacheItem", "::", "QUEUE_WAITING", ")", "->", "setCreatedAt", "(", "new", "\\", "DateTime", "(", ")", ")", ";", "}", "$", "cacheItem", "->", "setQueuedAt", "(", "new", "\\", "DateTime", "(", ")", ")", ";", "return", "new", "Instruction", "(", "$", "input", ",", "$", "template", ",", "$", "cacheItem", ")", ";", "}" ]
Resolve batch to queue items. @param InputDescriptor $input @param TemplateInterface $template @param array $flags @return Instruction|null
[ "Resolve", "batch", "to", "queue", "items", "." ]
132f24924c9bb0dbb6c1ea84db0a463f97fa3893
https://github.com/phlexible/phlexible/blob/132f24924c9bb0dbb6c1ea84db0a463f97fa3893/src/Phlexible/Component/MediaCache/Queue/InstructionCreator.php#L64-L108
4,952
rad8329/Cordillera
middlewares/filters/request/Cors.php
Cors.prepareHeaders
public function prepareHeaders($requestHeaders) { $responseHeaders = []; if (isset($requestHeaders['Origin'], $this->_cors['Origin'])) { if (in_array('*', $this->_cors['Origin']) || in_array($requestHeaders['Origin'], $this->_cors['Origin'])) { $responseHeaders['Access-Control-Allow-Origin'] = $requestHeaders['Origin']; } } $this->prepareAllowHeaders('Headers', $requestHeaders, $responseHeaders); if (isset($requestHeaders['Access-Control-Request-Method'])) { $responseHeaders['Access-Control-Allow-Methods'] = implode(', ', $this->_cors['Access-Control-Request-Method']); } if (isset($this->_cors['Access-Control-Allow-Credentials'])) { $responseHeaders['Access-Control-Allow-Credentials'] = $this->_cors['Access-Control-Allow-Credentials'] ? 'true' : 'false'; } if (isset($this->_cors['Access-Control-Max-Age']) && $this->isOptions()) { $responseHeaders['Access-Control-Max-Age'] = $this->_cors['Access-Control-Max-Age']; } if (isset($this->_cors['Access-Control-Expose-Headers'])) { $responseHeaders['Access-Control-Expose-Headers'] = implode(', ', $this->_cors['Access-Control-Expose-Headers']); } return $responseHeaders; }
php
public function prepareHeaders($requestHeaders) { $responseHeaders = []; if (isset($requestHeaders['Origin'], $this->_cors['Origin'])) { if (in_array('*', $this->_cors['Origin']) || in_array($requestHeaders['Origin'], $this->_cors['Origin'])) { $responseHeaders['Access-Control-Allow-Origin'] = $requestHeaders['Origin']; } } $this->prepareAllowHeaders('Headers', $requestHeaders, $responseHeaders); if (isset($requestHeaders['Access-Control-Request-Method'])) { $responseHeaders['Access-Control-Allow-Methods'] = implode(', ', $this->_cors['Access-Control-Request-Method']); } if (isset($this->_cors['Access-Control-Allow-Credentials'])) { $responseHeaders['Access-Control-Allow-Credentials'] = $this->_cors['Access-Control-Allow-Credentials'] ? 'true' : 'false'; } if (isset($this->_cors['Access-Control-Max-Age']) && $this->isOptions()) { $responseHeaders['Access-Control-Max-Age'] = $this->_cors['Access-Control-Max-Age']; } if (isset($this->_cors['Access-Control-Expose-Headers'])) { $responseHeaders['Access-Control-Expose-Headers'] = implode(', ', $this->_cors['Access-Control-Expose-Headers']); } return $responseHeaders; }
[ "public", "function", "prepareHeaders", "(", "$", "requestHeaders", ")", "{", "$", "responseHeaders", "=", "[", "]", ";", "if", "(", "isset", "(", "$", "requestHeaders", "[", "'Origin'", "]", ",", "$", "this", "->", "_cors", "[", "'Origin'", "]", ")", ")", "{", "if", "(", "in_array", "(", "'*'", ",", "$", "this", "->", "_cors", "[", "'Origin'", "]", ")", "||", "in_array", "(", "$", "requestHeaders", "[", "'Origin'", "]", ",", "$", "this", "->", "_cors", "[", "'Origin'", "]", ")", ")", "{", "$", "responseHeaders", "[", "'Access-Control-Allow-Origin'", "]", "=", "$", "requestHeaders", "[", "'Origin'", "]", ";", "}", "}", "$", "this", "->", "prepareAllowHeaders", "(", "'Headers'", ",", "$", "requestHeaders", ",", "$", "responseHeaders", ")", ";", "if", "(", "isset", "(", "$", "requestHeaders", "[", "'Access-Control-Request-Method'", "]", ")", ")", "{", "$", "responseHeaders", "[", "'Access-Control-Allow-Methods'", "]", "=", "implode", "(", "', '", ",", "$", "this", "->", "_cors", "[", "'Access-Control-Request-Method'", "]", ")", ";", "}", "if", "(", "isset", "(", "$", "this", "->", "_cors", "[", "'Access-Control-Allow-Credentials'", "]", ")", ")", "{", "$", "responseHeaders", "[", "'Access-Control-Allow-Credentials'", "]", "=", "$", "this", "->", "_cors", "[", "'Access-Control-Allow-Credentials'", "]", "?", "'true'", ":", "'false'", ";", "}", "if", "(", "isset", "(", "$", "this", "->", "_cors", "[", "'Access-Control-Max-Age'", "]", ")", "&&", "$", "this", "->", "isOptions", "(", ")", ")", "{", "$", "responseHeaders", "[", "'Access-Control-Max-Age'", "]", "=", "$", "this", "->", "_cors", "[", "'Access-Control-Max-Age'", "]", ";", "}", "if", "(", "isset", "(", "$", "this", "->", "_cors", "[", "'Access-Control-Expose-Headers'", "]", ")", ")", "{", "$", "responseHeaders", "[", "'Access-Control-Expose-Headers'", "]", "=", "implode", "(", "', '", ",", "$", "this", "->", "_cors", "[", "'Access-Control-Expose-Headers'", "]", ")", ";", "}", "return", "$", "responseHeaders", ";", "}" ]
For each CORS headers create the specific response. @param array $requestHeaders CORS headers we have detected @return array CORS headers ready to be sent
[ "For", "each", "CORS", "headers", "create", "the", "specific", "response", "." ]
fbc16dee44116556537390628301feeb11c7639a
https://github.com/rad8329/Cordillera/blob/fbc16dee44116556537390628301feeb11c7639a/middlewares/filters/request/Cors.php#L84-L113
4,953
rad8329/Cordillera
middlewares/filters/request/Cors.php
Cors.prepareAllowHeaders
protected function prepareAllowHeaders($type, $requestHeaders, &$responseHeaders) { $requestHeaderField = 'Access-Control-Request-'.$type; $responseHeaderField = 'Access-Control-Allow-'.$type; if (!isset($requestHeaders[$requestHeaderField], $this->_cors[$requestHeaderField])) { return; } if (isset($this->_cors[$requestHeaderField]) && in_array('*', $this->_cors[$requestHeaderField])) { $responseHeaders[$responseHeaderField] = $this->headerize($requestHeaders[$requestHeaderField]); } else { $requestedData = preg_split('/[\\s,]+/', $requestHeaders[$requestHeaderField], -1, PREG_SPLIT_NO_EMPTY); $acceptedData = array_uintersect($requestedData, $this->_cors[$requestHeaderField], 'strcasecmp'); if (!empty($acceptedData)) { $responseHeaders[$responseHeaderField] = implode(', ', $acceptedData); } } }
php
protected function prepareAllowHeaders($type, $requestHeaders, &$responseHeaders) { $requestHeaderField = 'Access-Control-Request-'.$type; $responseHeaderField = 'Access-Control-Allow-'.$type; if (!isset($requestHeaders[$requestHeaderField], $this->_cors[$requestHeaderField])) { return; } if (isset($this->_cors[$requestHeaderField]) && in_array('*', $this->_cors[$requestHeaderField])) { $responseHeaders[$responseHeaderField] = $this->headerize($requestHeaders[$requestHeaderField]); } else { $requestedData = preg_split('/[\\s,]+/', $requestHeaders[$requestHeaderField], -1, PREG_SPLIT_NO_EMPTY); $acceptedData = array_uintersect($requestedData, $this->_cors[$requestHeaderField], 'strcasecmp'); if (!empty($acceptedData)) { $responseHeaders[$responseHeaderField] = implode(', ', $acceptedData); } } }
[ "protected", "function", "prepareAllowHeaders", "(", "$", "type", ",", "$", "requestHeaders", ",", "&", "$", "responseHeaders", ")", "{", "$", "requestHeaderField", "=", "'Access-Control-Request-'", ".", "$", "type", ";", "$", "responseHeaderField", "=", "'Access-Control-Allow-'", ".", "$", "type", ";", "if", "(", "!", "isset", "(", "$", "requestHeaders", "[", "$", "requestHeaderField", "]", ",", "$", "this", "->", "_cors", "[", "$", "requestHeaderField", "]", ")", ")", "{", "return", ";", "}", "if", "(", "isset", "(", "$", "this", "->", "_cors", "[", "$", "requestHeaderField", "]", ")", "&&", "in_array", "(", "'*'", ",", "$", "this", "->", "_cors", "[", "$", "requestHeaderField", "]", ")", ")", "{", "$", "responseHeaders", "[", "$", "responseHeaderField", "]", "=", "$", "this", "->", "headerize", "(", "$", "requestHeaders", "[", "$", "requestHeaderField", "]", ")", ";", "}", "else", "{", "$", "requestedData", "=", "preg_split", "(", "'/[\\\\s,]+/'", ",", "$", "requestHeaders", "[", "$", "requestHeaderField", "]", ",", "-", "1", ",", "PREG_SPLIT_NO_EMPTY", ")", ";", "$", "acceptedData", "=", "array_uintersect", "(", "$", "requestedData", ",", "$", "this", "->", "_cors", "[", "$", "requestHeaderField", "]", ",", "'strcasecmp'", ")", ";", "if", "(", "!", "empty", "(", "$", "acceptedData", ")", ")", "{", "$", "responseHeaders", "[", "$", "responseHeaderField", "]", "=", "implode", "(", "', '", ",", "$", "acceptedData", ")", ";", "}", "}", "}" ]
Handle classic CORS request to avoid duplicate code. @param string $type the kind of headers we would handle @param array $requestHeaders CORS headers request by client @param array $responseHeaders CORS response headers sent to the client
[ "Handle", "classic", "CORS", "request", "to", "avoid", "duplicate", "code", "." ]
fbc16dee44116556537390628301feeb11c7639a
https://github.com/rad8329/Cordillera/blob/fbc16dee44116556537390628301feeb11c7639a/middlewares/filters/request/Cors.php#L122-L138
4,954
Becklyn/BecklynBugsnagBundle
DependencyInjection/MonitoringCompilerPass.php
MonitoringCompilerPass.createClientDefinition
private function createClientDefinition ($rootDir) { $bugsnagClient = new Definition(Client::class, [ $this->configuration->getApiKey(), ]); $bugsnagClient->setFactory([Client::class, "make"]); $bugsnagClient->setPublic(false); // strip root dir from logs $rootDir = dirname($rootDir); $bugsnagClient->addMethodCall("setProjectRoot", [$rootDir]); $bugsnagClient->addMethodCall("setStripPath", [$rootDir]); $bugsnagClient->addMethodCall("setFilters", [['clientIp']]); return $bugsnagClient; }
php
private function createClientDefinition ($rootDir) { $bugsnagClient = new Definition(Client::class, [ $this->configuration->getApiKey(), ]); $bugsnagClient->setFactory([Client::class, "make"]); $bugsnagClient->setPublic(false); // strip root dir from logs $rootDir = dirname($rootDir); $bugsnagClient->addMethodCall("setProjectRoot", [$rootDir]); $bugsnagClient->addMethodCall("setStripPath", [$rootDir]); $bugsnagClient->addMethodCall("setFilters", [['clientIp']]); return $bugsnagClient; }
[ "private", "function", "createClientDefinition", "(", "$", "rootDir", ")", "{", "$", "bugsnagClient", "=", "new", "Definition", "(", "Client", "::", "class", ",", "[", "$", "this", "->", "configuration", "->", "getApiKey", "(", ")", ",", "]", ")", ";", "$", "bugsnagClient", "->", "setFactory", "(", "[", "Client", "::", "class", ",", "\"make\"", "]", ")", ";", "$", "bugsnagClient", "->", "setPublic", "(", "false", ")", ";", "// strip root dir from logs", "$", "rootDir", "=", "dirname", "(", "$", "rootDir", ")", ";", "$", "bugsnagClient", "->", "addMethodCall", "(", "\"setProjectRoot\"", ",", "[", "$", "rootDir", "]", ")", ";", "$", "bugsnagClient", "->", "addMethodCall", "(", "\"setStripPath\"", ",", "[", "$", "rootDir", "]", ")", ";", "$", "bugsnagClient", "->", "addMethodCall", "(", "\"setFilters\"", ",", "[", "[", "'clientIp'", "]", "]", ")", ";", "return", "$", "bugsnagClient", ";", "}" ]
Creates the bugsnag client @param string $rootDir @return Definition
[ "Creates", "the", "bugsnag", "client" ]
d9f0d0aef7fb2ba68975b8279364e744f56cb6ee
https://github.com/Becklyn/BecklynBugsnagBundle/blob/d9f0d0aef7fb2ba68975b8279364e744f56cb6ee/DependencyInjection/MonitoringCompilerPass.php#L88-L103
4,955
Becklyn/BecklynBugsnagBundle
DependencyInjection/MonitoringCompilerPass.php
MonitoringCompilerPass.addLoggerReferenceToContainer
private function addLoggerReferenceToContainer (Definition $handlerDefinition, ContainerBuilder $container) { // first wrap logger in FingersCrossedHandler $monitoringDefinition = new Definition(FingersCrossedHandler::class, [ $handlerDefinition, Logger::WARNING ]); $monitoringDefinition->setPublic(false); $container->setDefinition(self::MONOLOG_HANDLER_SERVICE_ID, $monitoringDefinition); }
php
private function addLoggerReferenceToContainer (Definition $handlerDefinition, ContainerBuilder $container) { // first wrap logger in FingersCrossedHandler $monitoringDefinition = new Definition(FingersCrossedHandler::class, [ $handlerDefinition, Logger::WARNING ]); $monitoringDefinition->setPublic(false); $container->setDefinition(self::MONOLOG_HANDLER_SERVICE_ID, $monitoringDefinition); }
[ "private", "function", "addLoggerReferenceToContainer", "(", "Definition", "$", "handlerDefinition", ",", "ContainerBuilder", "$", "container", ")", "{", "// first wrap logger in FingersCrossedHandler", "$", "monitoringDefinition", "=", "new", "Definition", "(", "FingersCrossedHandler", "::", "class", ",", "[", "$", "handlerDefinition", ",", "Logger", "::", "WARNING", "]", ")", ";", "$", "monitoringDefinition", "->", "setPublic", "(", "false", ")", ";", "$", "container", "->", "setDefinition", "(", "self", "::", "MONOLOG_HANDLER_SERVICE_ID", ",", "$", "monitoringDefinition", ")", ";", "}" ]
Adds the monolog handler to the service container @param Definition $handlerDefinition @param ContainerBuilder $container
[ "Adds", "the", "monolog", "handler", "to", "the", "service", "container" ]
d9f0d0aef7fb2ba68975b8279364e744f56cb6ee
https://github.com/Becklyn/BecklynBugsnagBundle/blob/d9f0d0aef7fb2ba68975b8279364e744f56cb6ee/DependencyInjection/MonitoringCompilerPass.php#L129-L139
4,956
Becklyn/BecklynBugsnagBundle
DependencyInjection/MonitoringCompilerPass.php
MonitoringCompilerPass.collectReportTransformers
private function collectReportTransformers (Definition $handler, ContainerBuilder $container) { $taggedServices = $container->findTaggedServiceIds(self::REPORT_TRANSFORMER_TAG); foreach ($taggedServices as $serviceId => $tags) { $handler->addMethodCall("addReportTransformer", [new Reference($serviceId)]); } }
php
private function collectReportTransformers (Definition $handler, ContainerBuilder $container) { $taggedServices = $container->findTaggedServiceIds(self::REPORT_TRANSFORMER_TAG); foreach ($taggedServices as $serviceId => $tags) { $handler->addMethodCall("addReportTransformer", [new Reference($serviceId)]); } }
[ "private", "function", "collectReportTransformers", "(", "Definition", "$", "handler", ",", "ContainerBuilder", "$", "container", ")", "{", "$", "taggedServices", "=", "$", "container", "->", "findTaggedServiceIds", "(", "self", "::", "REPORT_TRANSFORMER_TAG", ")", ";", "foreach", "(", "$", "taggedServices", "as", "$", "serviceId", "=>", "$", "tags", ")", "{", "$", "handler", "->", "addMethodCall", "(", "\"addReportTransformer\"", ",", "[", "new", "Reference", "(", "$", "serviceId", ")", "]", ")", ";", "}", "}" ]
Collects all report transformers and registers them in the handler @param Definition $handler @param ContainerBuilder $container
[ "Collects", "all", "report", "transformers", "and", "registers", "them", "in", "the", "handler" ]
d9f0d0aef7fb2ba68975b8279364e744f56cb6ee
https://github.com/Becklyn/BecklynBugsnagBundle/blob/d9f0d0aef7fb2ba68975b8279364e744f56cb6ee/DependencyInjection/MonitoringCompilerPass.php#L149-L157
4,957
Becklyn/BecklynBugsnagBundle
DependencyInjection/MonitoringCompilerPass.php
MonitoringCompilerPass.registerMonologHandlerInAllChannels
private function registerMonologHandlerInAllChannels (ContainerBuilder $container) { $monitoringReference = new Reference(self::MONOLOG_HANDLER_SERVICE_ID); // push reference as handler to every logger in the system foreach ($container->getDefinitions() as $key => $definition) { if (0 === strpos($key, "monolog.logger.")) { $definition->addMethodCall("pushHandler", [$monitoringReference]); } } }
php
private function registerMonologHandlerInAllChannels (ContainerBuilder $container) { $monitoringReference = new Reference(self::MONOLOG_HANDLER_SERVICE_ID); // push reference as handler to every logger in the system foreach ($container->getDefinitions() as $key => $definition) { if (0 === strpos($key, "monolog.logger.")) { $definition->addMethodCall("pushHandler", [$monitoringReference]); } } }
[ "private", "function", "registerMonologHandlerInAllChannels", "(", "ContainerBuilder", "$", "container", ")", "{", "$", "monitoringReference", "=", "new", "Reference", "(", "self", "::", "MONOLOG_HANDLER_SERVICE_ID", ")", ";", "// push reference as handler to every logger in the system", "foreach", "(", "$", "container", "->", "getDefinitions", "(", ")", "as", "$", "key", "=>", "$", "definition", ")", "{", "if", "(", "0", "===", "strpos", "(", "$", "key", ",", "\"monolog.logger.\"", ")", ")", "{", "$", "definition", "->", "addMethodCall", "(", "\"pushHandler\"", ",", "[", "$", "monitoringReference", "]", ")", ";", "}", "}", "}" ]
Registers the monolog handler in all channels @param ContainerBuilder $container
[ "Registers", "the", "monolog", "handler", "in", "all", "channels" ]
d9f0d0aef7fb2ba68975b8279364e744f56cb6ee
https://github.com/Becklyn/BecklynBugsnagBundle/blob/d9f0d0aef7fb2ba68975b8279364e744f56cb6ee/DependencyInjection/MonitoringCompilerPass.php#L166-L178
4,958
novuso/system
src/Collection/SortedTable.php
SortedTable.create
public static function create( Comparator $comparator, ?string $keyType = null, ?string $valueType = null ): SortedTable { return new static($comparator, $keyType, $valueType); }
php
public static function create( Comparator $comparator, ?string $keyType = null, ?string $valueType = null ): SortedTable { return new static($comparator, $keyType, $valueType); }
[ "public", "static", "function", "create", "(", "Comparator", "$", "comparator", ",", "?", "string", "$", "keyType", "=", "null", ",", "?", "string", "$", "valueType", "=", "null", ")", ":", "SortedTable", "{", "return", "new", "static", "(", "$", "comparator", ",", "$", "keyType", ",", "$", "valueType", ")", ";", "}" ]
Creates collection with a custom comparator If types are not provided, the types are dynamic. The type can be any fully-qualified class or interface name, or one of the following type strings: [array, object, bool, int, float, string, callable] @param Comparator $comparator The comparator @param string|null $keyType The key type @param string|null $valueType The value type @return SortedTable
[ "Creates", "collection", "with", "a", "custom", "comparator" ]
e34038b391826edc68d0b5fccfba96642de9d6f0
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Collection/SortedTable.php#L73-L79
4,959
novuso/system
src/Collection/SortedTable.php
SortedTable.comparable
public static function comparable(?string $keyType = null, ?string $valueType = null): SortedTable { assert( Validate::isNull($keyType) || Validate::implementsInterface($keyType, Comparable::class), sprintf('%s expects $keyType to implement %s', __METHOD__, Comparable::class) ); return new static(new ComparableComparator(), $keyType, $valueType); }
php
public static function comparable(?string $keyType = null, ?string $valueType = null): SortedTable { assert( Validate::isNull($keyType) || Validate::implementsInterface($keyType, Comparable::class), sprintf('%s expects $keyType to implement %s', __METHOD__, Comparable::class) ); return new static(new ComparableComparator(), $keyType, $valueType); }
[ "public", "static", "function", "comparable", "(", "?", "string", "$", "keyType", "=", "null", ",", "?", "string", "$", "valueType", "=", "null", ")", ":", "SortedTable", "{", "assert", "(", "Validate", "::", "isNull", "(", "$", "keyType", ")", "||", "Validate", "::", "implementsInterface", "(", "$", "keyType", ",", "Comparable", "::", "class", ")", ",", "sprintf", "(", "'%s expects $keyType to implement %s'", ",", "__METHOD__", ",", "Comparable", "::", "class", ")", ")", ";", "return", "new", "static", "(", "new", "ComparableComparator", "(", ")", ",", "$", "keyType", ",", "$", "valueType", ")", ";", "}" ]
Creates collection with comparable keys If types are not provided, the types are dynamic. The key type must be a fully-qualified class name that implements: `Novuso\System\Type\Comparable` The value type can be any fully-qualified class or interface name, or one of the following type strings: [array, object, bool, int, float, string, callable] @param string|null $keyType The key type @param string|null $valueType The value type @return SortedTable
[ "Creates", "collection", "with", "comparable", "keys" ]
e34038b391826edc68d0b5fccfba96642de9d6f0
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Collection/SortedTable.php#L98-L106
4,960
romeOz/rock-template
src/template/twig/ViewRenderer.php
ViewRenderer.addGlobals
public function addGlobals($globals) { foreach ($globals as $name => $value) { if (!is_object($value)) { $value = new ViewRendererStaticClassProxy($value); } $this->twig->addGlobal($name, $value); } }
php
public function addGlobals($globals) { foreach ($globals as $name => $value) { if (!is_object($value)) { $value = new ViewRendererStaticClassProxy($value); } $this->twig->addGlobal($name, $value); } }
[ "public", "function", "addGlobals", "(", "$", "globals", ")", "{", "foreach", "(", "$", "globals", "as", "$", "name", "=>", "$", "value", ")", "{", "if", "(", "!", "is_object", "(", "$", "value", ")", ")", "{", "$", "value", "=", "new", "ViewRendererStaticClassProxy", "(", "$", "value", ")", ";", "}", "$", "this", "->", "twig", "->", "addGlobal", "(", "$", "name", ",", "$", "value", ")", ";", "}", "}" ]
Adds a global objects or static classes @param array $globals @see self::$globals
[ "Adds", "a", "global", "objects", "or", "static", "classes" ]
fcb7bd6dd923d11f02a1c71a63065f3f49728e92
https://github.com/romeOz/rock-template/blob/fcb7bd6dd923d11f02a1c71a63065f3f49728e92/src/template/twig/ViewRenderer.php#L134-L142
4,961
romeOz/rock-template
src/template/twig/ViewRenderer.php
ViewRenderer.addLexerOptions
public function addLexerOptions($options) { $lexer = new \Twig_Lexer($this->twig, $options); $this->twig->setLexer($lexer); }
php
public function addLexerOptions($options) { $lexer = new \Twig_Lexer($this->twig, $options); $this->twig->setLexer($lexer); }
[ "public", "function", "addLexerOptions", "(", "$", "options", ")", "{", "$", "lexer", "=", "new", "\\", "Twig_Lexer", "(", "$", "this", "->", "twig", ",", "$", "options", ")", ";", "$", "this", "->", "twig", "->", "setLexer", "(", "$", "lexer", ")", ";", "}" ]
Sets a Twig lexer options to change templates syntax @param array $options @see self::$lexerOptions
[ "Sets", "a", "Twig", "lexer", "options", "to", "change", "templates", "syntax" ]
fcb7bd6dd923d11f02a1c71a63065f3f49728e92
https://github.com/romeOz/rock-template/blob/fcb7bd6dd923d11f02a1c71a63065f3f49728e92/src/template/twig/ViewRenderer.php#L177-L181
4,962
koolkode/event
src/AbstractListener.php
AbstractListener.loadArguments
protected function loadArguments(\ReflectionFunctionAbstract $ref, EventParamResolverInterface $resolver) { $args = []; if($ref->getNumberOfParameters() > 1) { foreach(array_slice($ref->getParameters(), 1) as $param) { $args[] = $resolver->resolve($param->getClass(), $param->isDefaultValueAvailable() ? $param->getDefaultValue() : false); } } return $args; }
php
protected function loadArguments(\ReflectionFunctionAbstract $ref, EventParamResolverInterface $resolver) { $args = []; if($ref->getNumberOfParameters() > 1) { foreach(array_slice($ref->getParameters(), 1) as $param) { $args[] = $resolver->resolve($param->getClass(), $param->isDefaultValueAvailable() ? $param->getDefaultValue() : false); } } return $args; }
[ "protected", "function", "loadArguments", "(", "\\", "ReflectionFunctionAbstract", "$", "ref", ",", "EventParamResolverInterface", "$", "resolver", ")", "{", "$", "args", "=", "[", "]", ";", "if", "(", "$", "ref", "->", "getNumberOfParameters", "(", ")", ">", "1", ")", "{", "foreach", "(", "array_slice", "(", "$", "ref", "->", "getParameters", "(", ")", ",", "1", ")", "as", "$", "param", ")", "{", "$", "args", "[", "]", "=", "$", "resolver", "->", "resolve", "(", "$", "param", "->", "getClass", "(", ")", ",", "$", "param", "->", "isDefaultValueAvailable", "(", ")", "?", "$", "param", "->", "getDefaultValue", "(", ")", ":", "false", ")", ";", "}", "}", "return", "$", "args", ";", "}" ]
Populates arguments assembled from the event and the given target function. @param \ReflectionFunctionAbstract $ref @param EventParamResolverInterface $resolver @return array
[ "Populates", "arguments", "assembled", "from", "the", "event", "and", "the", "given", "target", "function", "." ]
0f823ec5aaa2df0e3e437592a4dd3a4456af7be9
https://github.com/koolkode/event/blob/0f823ec5aaa2df0e3e437592a4dd3a4456af7be9/src/AbstractListener.php#L91-L104
4,963
rseyferth/activerecord
lib/ConnectionManager.php
ConnectionManager.dropConnection
public static function dropConnection($name=null) { if (isset(self::$connections[$name])) unset(self::$connections[$name]); }
php
public static function dropConnection($name=null) { if (isset(self::$connections[$name])) unset(self::$connections[$name]); }
[ "public", "static", "function", "dropConnection", "(", "$", "name", "=", "null", ")", "{", "if", "(", "isset", "(", "self", "::", "$", "connections", "[", "$", "name", "]", ")", ")", "unset", "(", "self", "::", "$", "connections", "[", "$", "name", "]", ")", ";", "}" ]
Drops the connection from the connection manager. Does not actually close it since there is no close method in PDO. @param string $name Name of the connection to forget about
[ "Drops", "the", "connection", "from", "the", "connection", "manager", ".", "Does", "not", "actually", "close", "it", "since", "there", "is", "no", "close", "method", "in", "PDO", "." ]
0e7b1cbddd6f967c3a09adf38753babd5f698e39
https://github.com/rseyferth/activerecord/blob/0e7b1cbddd6f967c3a09adf38753babd5f698e39/lib/ConnectionManager.php#L44-L48
4,964
schnittstabil/composer-extra
src/ComposerExtra.php
ComposerExtra.merge
protected function merge($target, $source) { if ($source === null) { return $target; } return call_user_func($this->merge, $target, $source); }
php
protected function merge($target, $source) { if ($source === null) { return $target; } return call_user_func($this->merge, $target, $source); }
[ "protected", "function", "merge", "(", "$", "target", ",", "$", "source", ")", "{", "if", "(", "$", "source", "===", "null", ")", "{", "return", "$", "target", ";", "}", "return", "call_user_func", "(", "$", "this", "->", "merge", ",", "$", "target", ",", "$", "source", ")", ";", "}" ]
Merge two configs. @param mixed $target Target config @param mixed $source Source config @return mixed The merged config
[ "Merge", "two", "configs", "." ]
918d14368102b979715f312e9258286abf6dece2
https://github.com/schnittstabil/composer-extra/blob/918d14368102b979715f312e9258286abf6dece2/src/ComposerExtra.php#L61-L68
4,965
rafflesargentina/l5-resource-controller
src/Traits/FormatsValidJsonResponses.php
FormatsValidJsonResponses.validInternalServerErrorJsonResponse
public function validInternalServerErrorJsonResponse($exception, $message = 'Error') { return response()->json( [ 'exception' => class_basename($exception), 'file' => basename($exception->getFile()), 'line' => $exception->getLine(), 'message' => $exception->getMessage(), 'trace' => $exception->getTrace(), ], 500, [], JSON_PRETTY_PRINT ); }
php
public function validInternalServerErrorJsonResponse($exception, $message = 'Error') { return response()->json( [ 'exception' => class_basename($exception), 'file' => basename($exception->getFile()), 'line' => $exception->getLine(), 'message' => $exception->getMessage(), 'trace' => $exception->getTrace(), ], 500, [], JSON_PRETTY_PRINT ); }
[ "public", "function", "validInternalServerErrorJsonResponse", "(", "$", "exception", ",", "$", "message", "=", "'Error'", ")", "{", "return", "response", "(", ")", "->", "json", "(", "[", "'exception'", "=>", "class_basename", "(", "$", "exception", ")", ",", "'file'", "=>", "basename", "(", "$", "exception", "->", "getFile", "(", ")", ")", ",", "'line'", "=>", "$", "exception", "->", "getLine", "(", ")", ",", "'message'", "=>", "$", "exception", "->", "getMessage", "(", ")", ",", "'trace'", "=>", "$", "exception", "->", "getTrace", "(", ")", ",", "]", ",", "500", ",", "[", "]", ",", "JSON_PRETTY_PRINT", ")", ";", "}" ]
Return a valid 500 Internal Server Error json response. @param Exception $exception The exception object. @param string $message The response message. @return \Illuminate\Http\JsonResponse
[ "Return", "a", "valid", "500", "Internal", "Server", "Error", "json", "response", "." ]
5ee5de4803a26d0592dd6f5db77aec40c1a56c09
https://github.com/rafflesargentina/l5-resource-controller/blob/5ee5de4803a26d0592dd6f5db77aec40c1a56c09/src/Traits/FormatsValidJsonResponses.php#L17-L28
4,966
rafflesargentina/l5-resource-controller
src/Traits/FormatsValidJsonResponses.php
FormatsValidJsonResponses.validSuccessJsonResponse
public function validSuccessJsonResponse($message = 'Success', $data = [], $redirect = null) { return response()->json( [ 'code' => '200', 'message' => $message, 'data' => $data, 'errors' => [], 'redirect' => $redirect, ], 200, [], JSON_PRETTY_PRINT ); }
php
public function validSuccessJsonResponse($message = 'Success', $data = [], $redirect = null) { return response()->json( [ 'code' => '200', 'message' => $message, 'data' => $data, 'errors' => [], 'redirect' => $redirect, ], 200, [], JSON_PRETTY_PRINT ); }
[ "public", "function", "validSuccessJsonResponse", "(", "$", "message", "=", "'Success'", ",", "$", "data", "=", "[", "]", ",", "$", "redirect", "=", "null", ")", "{", "return", "response", "(", ")", "->", "json", "(", "[", "'code'", "=>", "'200'", ",", "'message'", "=>", "$", "message", ",", "'data'", "=>", "$", "data", ",", "'errors'", "=>", "[", "]", ",", "'redirect'", "=>", "$", "redirect", ",", "]", ",", "200", ",", "[", "]", ",", "JSON_PRETTY_PRINT", ")", ";", "}" ]
Return a valid 200 Success json response. @param string $message The response message. @param array $data The passed data. @param string $redirect The redirection url. @return \Illuminate\Http\JsonResponse
[ "Return", "a", "valid", "200", "Success", "json", "response", "." ]
5ee5de4803a26d0592dd6f5db77aec40c1a56c09
https://github.com/rafflesargentina/l5-resource-controller/blob/5ee5de4803a26d0592dd6f5db77aec40c1a56c09/src/Traits/FormatsValidJsonResponses.php#L59-L70
4,967
rafflesargentina/l5-resource-controller
src/Traits/FormatsValidJsonResponses.php
FormatsValidJsonResponses.validUnprocessableEntityJsonResponse
public function validUnprocessableEntityJsonResponse(MessageBag $errors, $message = 'Unprocessable Entity', $redirect = null) { return response()->json( [ 'code' => '422', 'message' => $message, 'errors' => $errors, 'redirect' => $redirect, ], 422, [], JSON_PRETTY_PRINT ); }
php
public function validUnprocessableEntityJsonResponse(MessageBag $errors, $message = 'Unprocessable Entity', $redirect = null) { return response()->json( [ 'code' => '422', 'message' => $message, 'errors' => $errors, 'redirect' => $redirect, ], 422, [], JSON_PRETTY_PRINT ); }
[ "public", "function", "validUnprocessableEntityJsonResponse", "(", "MessageBag", "$", "errors", ",", "$", "message", "=", "'Unprocessable Entity'", ",", "$", "redirect", "=", "null", ")", "{", "return", "response", "(", ")", "->", "json", "(", "[", "'code'", "=>", "'422'", ",", "'message'", "=>", "$", "message", ",", "'errors'", "=>", "$", "errors", ",", "'redirect'", "=>", "$", "redirect", ",", "]", ",", "422", ",", "[", "]", ",", "JSON_PRETTY_PRINT", ")", ";", "}" ]
Return a valid 422 Unprocessable entity json response. @param \Illuminate\Support\MessageBag $errors The message bag errors. @param string $message The response message. @param string $redirect The redirection url. @return \Illuminate\Http\JsonResponse
[ "Return", "a", "valid", "422", "Unprocessable", "entity", "json", "response", "." ]
5ee5de4803a26d0592dd6f5db77aec40c1a56c09
https://github.com/rafflesargentina/l5-resource-controller/blob/5ee5de4803a26d0592dd6f5db77aec40c1a56c09/src/Traits/FormatsValidJsonResponses.php#L81-L91
4,968
setrun/setrun-component-user
src/entities/User.php
User.getStatusesArray
public static function getStatusesArray() : array { return [ self::STATUS_BLOCKED => Yii::t('setrun/user', 'Blocked'), self::STATUS_ACTIVE => Yii::t('setrun/user', 'Active'), self::STATUS_WAIT => Yii::t('setrun/user', 'Wait') ]; }
php
public static function getStatusesArray() : array { return [ self::STATUS_BLOCKED => Yii::t('setrun/user', 'Blocked'), self::STATUS_ACTIVE => Yii::t('setrun/user', 'Active'), self::STATUS_WAIT => Yii::t('setrun/user', 'Wait') ]; }
[ "public", "static", "function", "getStatusesArray", "(", ")", ":", "array", "{", "return", "[", "self", "::", "STATUS_BLOCKED", "=>", "Yii", "::", "t", "(", "'setrun/user'", ",", "'Blocked'", ")", ",", "self", "::", "STATUS_ACTIVE", "=>", "Yii", "::", "t", "(", "'setrun/user'", ",", "'Active'", ")", ",", "self", "::", "STATUS_WAIT", "=>", "Yii", "::", "t", "(", "'setrun/user'", ",", "'Wait'", ")", "]", ";", "}" ]
Get all statuses. @return array
[ "Get", "all", "statuses", "." ]
6aca4c62f099918032b66da1f94d7565694a0735
https://github.com/setrun/setrun-component-user/blob/6aca4c62f099918032b66da1f94d7565694a0735/src/entities/User.php#L98-L105
4,969
setrun/setrun-component-user
src/entities/User.php
User.create
public static function create(string $username, string $email, string $password) : User { $user = new User(); $user->username = $username; $user->email = $email; $user->status = self::STATUS_ACTIVE; $user->setPassword($password); $user->generateAuthKey(); return $user; }
php
public static function create(string $username, string $email, string $password) : User { $user = new User(); $user->username = $username; $user->email = $email; $user->status = self::STATUS_ACTIVE; $user->setPassword($password); $user->generateAuthKey(); return $user; }
[ "public", "static", "function", "create", "(", "string", "$", "username", ",", "string", "$", "email", ",", "string", "$", "password", ")", ":", "User", "{", "$", "user", "=", "new", "User", "(", ")", ";", "$", "user", "->", "username", "=", "$", "username", ";", "$", "user", "->", "email", "=", "$", "email", ";", "$", "user", "->", "status", "=", "self", "::", "STATUS_ACTIVE", ";", "$", "user", "->", "setPassword", "(", "$", "password", ")", ";", "$", "user", "->", "generateAuthKey", "(", ")", ";", "return", "$", "user", ";", "}" ]
Creating a user. @param string $username @param string $email @param string $password @return User
[ "Creating", "a", "user", "." ]
6aca4c62f099918032b66da1f94d7565694a0735
https://github.com/setrun/setrun-component-user/blob/6aca4c62f099918032b66da1f94d7565694a0735/src/entities/User.php#L114-L123
4,970
setrun/setrun-component-user
src/entities/User.php
User.edit
public function edit(string $username, string $email) : void { $this->username = $username; $this->email = $email; }
php
public function edit(string $username, string $email) : void { $this->username = $username; $this->email = $email; }
[ "public", "function", "edit", "(", "string", "$", "username", ",", "string", "$", "email", ")", ":", "void", "{", "$", "this", "->", "username", "=", "$", "username", ";", "$", "this", "->", "email", "=", "$", "email", ";", "}" ]
Editing a user. @param string $username @param string $email @return void
[ "Editing", "a", "user", "." ]
6aca4c62f099918032b66da1f94d7565694a0735
https://github.com/setrun/setrun-component-user/blob/6aca4c62f099918032b66da1f94d7565694a0735/src/entities/User.php#L131-L135
4,971
setrun/setrun-component-user
src/entities/User.php
User.requestSignup
public static function requestSignup(string $username, string $email, string $password) : User { $user = new User(); $user->username = $username; $user->email = $email; $user->status = self::STATUS_WAIT; $user->generateEmailConfirmToken(); $user->generateAuthKey(); $user->setPassword($password); return $user; }
php
public static function requestSignup(string $username, string $email, string $password) : User { $user = new User(); $user->username = $username; $user->email = $email; $user->status = self::STATUS_WAIT; $user->generateEmailConfirmToken(); $user->generateAuthKey(); $user->setPassword($password); return $user; }
[ "public", "static", "function", "requestSignup", "(", "string", "$", "username", ",", "string", "$", "email", ",", "string", "$", "password", ")", ":", "User", "{", "$", "user", "=", "new", "User", "(", ")", ";", "$", "user", "->", "username", "=", "$", "username", ";", "$", "user", "->", "email", "=", "$", "email", ";", "$", "user", "->", "status", "=", "self", "::", "STATUS_WAIT", ";", "$", "user", "->", "generateEmailConfirmToken", "(", ")", ";", "$", "user", "->", "generateAuthKey", "(", ")", ";", "$", "user", "->", "setPassword", "(", "$", "password", ")", ";", "return", "$", "user", ";", "}" ]
Request to sing up a new user. @param string $username @param string $email @param string $password @return User
[ "Request", "to", "sing", "up", "a", "new", "user", "." ]
6aca4c62f099918032b66da1f94d7565694a0735
https://github.com/setrun/setrun-component-user/blob/6aca4c62f099918032b66da1f94d7565694a0735/src/entities/User.php#L144-L154
4,972
setrun/setrun-component-user
src/entities/User.php
User.confirmSignup
public function confirmSignup() : void { if (!$this->isWait()) { throw new \DomainException(Yii::t('setrun/user', 'User is already active')); } $this->status = self::STATUS_ACTIVE; $this->removeEmailConfirmToken(); }
php
public function confirmSignup() : void { if (!$this->isWait()) { throw new \DomainException(Yii::t('setrun/user', 'User is already active')); } $this->status = self::STATUS_ACTIVE; $this->removeEmailConfirmToken(); }
[ "public", "function", "confirmSignup", "(", ")", ":", "void", "{", "if", "(", "!", "$", "this", "->", "isWait", "(", ")", ")", "{", "throw", "new", "\\", "DomainException", "(", "Yii", "::", "t", "(", "'setrun/user'", ",", "'User is already active'", ")", ")", ";", "}", "$", "this", "->", "status", "=", "self", "::", "STATUS_ACTIVE", ";", "$", "this", "->", "removeEmailConfirmToken", "(", ")", ";", "}" ]
Confirm user sing up. @return void
[ "Confirm", "user", "sing", "up", "." ]
6aca4c62f099918032b66da1f94d7565694a0735
https://github.com/setrun/setrun-component-user/blob/6aca4c62f099918032b66da1f94d7565694a0735/src/entities/User.php#L160-L167
4,973
setrun/setrun-component-user
src/entities/User.php
User.requestPasswordReset
public function requestPasswordReset() : void { if (!empty($this->password_reset_token) && self::isPasswordResetTokenValid($this->password_reset_token)) { throw new \DomainException(Yii::t('setrun/user', 'Password resetting is already requested')); } $this->generatePasswordResetToken(); }
php
public function requestPasswordReset() : void { if (!empty($this->password_reset_token) && self::isPasswordResetTokenValid($this->password_reset_token)) { throw new \DomainException(Yii::t('setrun/user', 'Password resetting is already requested')); } $this->generatePasswordResetToken(); }
[ "public", "function", "requestPasswordReset", "(", ")", ":", "void", "{", "if", "(", "!", "empty", "(", "$", "this", "->", "password_reset_token", ")", "&&", "self", "::", "isPasswordResetTokenValid", "(", "$", "this", "->", "password_reset_token", ")", ")", "{", "throw", "new", "\\", "DomainException", "(", "Yii", "::", "t", "(", "'setrun/user'", ",", "'Password resetting is already requested'", ")", ")", ";", "}", "$", "this", "->", "generatePasswordResetToken", "(", ")", ";", "}" ]
Request to reset the user's password. @return void
[ "Request", "to", "reset", "the", "user", "s", "password", "." ]
6aca4c62f099918032b66da1f94d7565694a0735
https://github.com/setrun/setrun-component-user/blob/6aca4c62f099918032b66da1f94d7565694a0735/src/entities/User.php#L173-L179
4,974
setrun/setrun-component-user
src/entities/User.php
User.resetPassword
public function resetPassword(string $password) : void { if (empty($this->password_reset_token)) { throw new \DomainException(Yii::t('setrun/user', 'Password resetting is not requested')); } $this->setPassword($password); $this->removePasswordResetToken(); }
php
public function resetPassword(string $password) : void { if (empty($this->password_reset_token)) { throw new \DomainException(Yii::t('setrun/user', 'Password resetting is not requested')); } $this->setPassword($password); $this->removePasswordResetToken(); }
[ "public", "function", "resetPassword", "(", "string", "$", "password", ")", ":", "void", "{", "if", "(", "empty", "(", "$", "this", "->", "password_reset_token", ")", ")", "{", "throw", "new", "\\", "DomainException", "(", "Yii", "::", "t", "(", "'setrun/user'", ",", "'Password resetting is not requested'", ")", ")", ";", "}", "$", "this", "->", "setPassword", "(", "$", "password", ")", ";", "$", "this", "->", "removePasswordResetToken", "(", ")", ";", "}" ]
Reset user password. @param string $password @return void
[ "Reset", "user", "password", "." ]
6aca4c62f099918032b66da1f94d7565694a0735
https://github.com/setrun/setrun-component-user/blob/6aca4c62f099918032b66da1f94d7565694a0735/src/entities/User.php#L186-L193
4,975
setrun/setrun-component-user
src/entities/User.php
User.findByPasswordResetToken
public static function findByPasswordResetToken(string $token) : ?self { if (!static::isPasswordResetTokenValid($token)) { return null; } return static::findOne([ 'password_reset_token' => $token, 'status' => self::STATUS_ACTIVE, ]); }
php
public static function findByPasswordResetToken(string $token) : ?self { if (!static::isPasswordResetTokenValid($token)) { return null; } return static::findOne([ 'password_reset_token' => $token, 'status' => self::STATUS_ACTIVE, ]); }
[ "public", "static", "function", "findByPasswordResetToken", "(", "string", "$", "token", ")", ":", "?", "self", "{", "if", "(", "!", "static", "::", "isPasswordResetTokenValid", "(", "$", "token", ")", ")", "{", "return", "null", ";", "}", "return", "static", "::", "findOne", "(", "[", "'password_reset_token'", "=>", "$", "token", ",", "'status'", "=>", "self", "::", "STATUS_ACTIVE", ",", "]", ")", ";", "}" ]
Finds user by password reset token. @param string $token password reset token. @return self
[ "Finds", "user", "by", "password", "reset", "token", "." ]
6aca4c62f099918032b66da1f94d7565694a0735
https://github.com/setrun/setrun-component-user/blob/6aca4c62f099918032b66da1f94d7565694a0735/src/entities/User.php#L238-L247
4,976
setrun/setrun-component-user
src/entities/User.php
User.setPassword
public function setPassword(string $password) : void { $this->password_hash = Yii::$app->security->generatePasswordHash($password); }
php
public function setPassword(string $password) : void { $this->password_hash = Yii::$app->security->generatePasswordHash($password); }
[ "public", "function", "setPassword", "(", "string", "$", "password", ")", ":", "void", "{", "$", "this", "->", "password_hash", "=", "Yii", "::", "$", "app", "->", "security", "->", "generatePasswordHash", "(", "$", "password", ")", ";", "}" ]
Generates password hash from password and sets it to the model. @param string $password @return void
[ "Generates", "password", "hash", "from", "password", "and", "sets", "it", "to", "the", "model", "." ]
6aca4c62f099918032b66da1f94d7565694a0735
https://github.com/setrun/setrun-component-user/blob/6aca4c62f099918032b66da1f94d7565694a0735/src/entities/User.php#L368-L371
4,977
phossa2/libs
src/Phossa2/Query/Traits/Clause/JoinTrait.php
JoinTrait.realJoin
protected function realJoin( /*# string */ $joinType, $secondTable, $onClause = '', /*# bool */ $rawMode = false ) { $alias = 0; // no alias list($secondTable, $alias) = $this->fixJoinTable($secondTable); if ($rawMode || '' === $onClause || $this->isRaw($onClause, false)) { $rawMode = true; } else { $onClause = $this->fixOnClause($onClause); } $clause = &$this->getClause('JOIN'); $clause[] = [$rawMode, $joinType, $secondTable, $alias, $onClause]; return $this; }
php
protected function realJoin( /*# string */ $joinType, $secondTable, $onClause = '', /*# bool */ $rawMode = false ) { $alias = 0; // no alias list($secondTable, $alias) = $this->fixJoinTable($secondTable); if ($rawMode || '' === $onClause || $this->isRaw($onClause, false)) { $rawMode = true; } else { $onClause = $this->fixOnClause($onClause); } $clause = &$this->getClause('JOIN'); $clause[] = [$rawMode, $joinType, $secondTable, $alias, $onClause]; return $this; }
[ "protected", "function", "realJoin", "(", "/*# string */", "$", "joinType", ",", "$", "secondTable", ",", "$", "onClause", "=", "''", ",", "/*# bool */", "$", "rawMode", "=", "false", ")", "{", "$", "alias", "=", "0", ";", "// no alias", "list", "(", "$", "secondTable", ",", "$", "alias", ")", "=", "$", "this", "->", "fixJoinTable", "(", "$", "secondTable", ")", ";", "if", "(", "$", "rawMode", "||", "''", "===", "$", "onClause", "||", "$", "this", "->", "isRaw", "(", "$", "onClause", ",", "false", ")", ")", "{", "$", "rawMode", "=", "true", ";", "}", "else", "{", "$", "onClause", "=", "$", "this", "->", "fixOnClause", "(", "$", "onClause", ")", ";", "}", "$", "clause", "=", "&", "$", "this", "->", "getClause", "(", "'JOIN'", ")", ";", "$", "clause", "[", "]", "=", "[", "$", "rawMode", ",", "$", "joinType", ",", "$", "secondTable", ",", "$", "alias", ",", "$", "onClause", "]", ";", "return", "$", "this", ";", "}" ]
The real join @param string $joinType @param string|string[]|SelectStatementInterface $secondTable @param string|string[]|ExpressionInterface $onClause @param bool $rawMode @return $this @access protected
[ "The", "real", "join" ]
921e485c8cc29067f279da2cdd06f47a9bddd115
https://github.com/phossa2/libs/blob/921e485c8cc29067f279da2cdd06f47a9bddd115/src/Phossa2/Query/Traits/Clause/JoinTrait.php#L115-L132
4,978
phossa2/libs
src/Phossa2/Query/Traits/Clause/JoinTrait.php
JoinTrait.fixJoinTable
protected function fixJoinTable($table) { if (is_array($table)) { return $table; } elseif (is_object($table) && $table instanceof StatementInterface) { return [$table, uniqid()]; } else { return [$table, 0]; // alias set 0 } }
php
protected function fixJoinTable($table) { if (is_array($table)) { return $table; } elseif (is_object($table) && $table instanceof StatementInterface) { return [$table, uniqid()]; } else { return [$table, 0]; // alias set 0 } }
[ "protected", "function", "fixJoinTable", "(", "$", "table", ")", "{", "if", "(", "is_array", "(", "$", "table", ")", ")", "{", "return", "$", "table", ";", "}", "elseif", "(", "is_object", "(", "$", "table", ")", "&&", "$", "table", "instanceof", "StatementInterface", ")", "{", "return", "[", "$", "table", ",", "uniqid", "(", ")", "]", ";", "}", "else", "{", "return", "[", "$", "table", ",", "0", "]", ";", "// alias set 0", "}", "}" ]
Fix join table @param string|string[]|SelectStatementInterface $table @return array [table, alias] @access protected
[ "Fix", "join", "table" ]
921e485c8cc29067f279da2cdd06f47a9bddd115
https://github.com/phossa2/libs/blob/921e485c8cc29067f279da2cdd06f47a9bddd115/src/Phossa2/Query/Traits/Clause/JoinTrait.php#L141-L150
4,979
phossa2/libs
src/Phossa2/Query/Traits/Clause/JoinTrait.php
JoinTrait.fixOnClause
protected function fixOnClause($onClause) { if (is_string($onClause)) { return [$onClause, '=', $onClause]; } elseif (is_array($onClause) && !isset($onClause[2])) { return [$onClause[0], '=', $onClause[1]]; } else { return $onClause; } }
php
protected function fixOnClause($onClause) { if (is_string($onClause)) { return [$onClause, '=', $onClause]; } elseif (is_array($onClause) && !isset($onClause[2])) { return [$onClause[0], '=', $onClause[1]]; } else { return $onClause; } }
[ "protected", "function", "fixOnClause", "(", "$", "onClause", ")", "{", "if", "(", "is_string", "(", "$", "onClause", ")", ")", "{", "return", "[", "$", "onClause", ",", "'='", ",", "$", "onClause", "]", ";", "}", "elseif", "(", "is_array", "(", "$", "onClause", ")", "&&", "!", "isset", "(", "$", "onClause", "[", "2", "]", ")", ")", "{", "return", "[", "$", "onClause", "[", "0", "]", ",", "'='", ",", "$", "onClause", "[", "1", "]", "]", ";", "}", "else", "{", "return", "$", "onClause", ";", "}", "}" ]
Fix 'ON' clause @param mixed $onClause @return array|ExpressionInterface @access protected
[ "Fix", "ON", "clause" ]
921e485c8cc29067f279da2cdd06f47a9bddd115
https://github.com/phossa2/libs/blob/921e485c8cc29067f279da2cdd06f47a9bddd115/src/Phossa2/Query/Traits/Clause/JoinTrait.php#L159-L168
4,980
phossa2/libs
src/Phossa2/Query/Traits/Clause/JoinTrait.php
JoinTrait.buildJoinTable
protected function buildJoinTable(array $cls, array $settings)/*# : string */ { $table = $cls[2]; $alias = $cls[3]; return $this->quoteItem($table, $settings) . $this->quoteAlias($alias, $settings); }
php
protected function buildJoinTable(array $cls, array $settings)/*# : string */ { $table = $cls[2]; $alias = $cls[3]; return $this->quoteItem($table, $settings) . $this->quoteAlias($alias, $settings); }
[ "protected", "function", "buildJoinTable", "(", "array", "$", "cls", ",", "array", "$", "settings", ")", "/*# : string */", "{", "$", "table", "=", "$", "cls", "[", "2", "]", ";", "$", "alias", "=", "$", "cls", "[", "3", "]", ";", "return", "$", "this", "->", "quoteItem", "(", "$", "table", ",", "$", "settings", ")", ".", "$", "this", "->", "quoteAlias", "(", "$", "alias", ",", "$", "settings", ")", ";", "}" ]
Build TABLE part @param array $cls @param array $settings @return string @access protected
[ "Build", "TABLE", "part" ]
921e485c8cc29067f279da2cdd06f47a9bddd115
https://github.com/phossa2/libs/blob/921e485c8cc29067f279da2cdd06f47a9bddd115/src/Phossa2/Query/Traits/Clause/JoinTrait.php#L204-L209
4,981
phossa2/libs
src/Phossa2/Query/Traits/Clause/JoinTrait.php
JoinTrait.buildJoinOn
protected function buildJoinOn(array $cls, array $settings)/*# : string */ { $res = ['ON']; $on = $cls[4]; if (is_string($on)) { // ON string $res[] = $on; } elseif (is_object($on)) { // ON is an object $res[] = $this->quoteItem($on, $settings); } else { // common on $res[] = $this->quote( // left $this->getFirstTableAlias($on[0]) . $on[0], $settings ); $res[] = $on[1]; // operator $res[] = $this->quote( // right $this->getSecondTableAlias($cls, $on[2]) . $on[2], $settings ); } return join(' ', $res); }
php
protected function buildJoinOn(array $cls, array $settings)/*# : string */ { $res = ['ON']; $on = $cls[4]; if (is_string($on)) { // ON string $res[] = $on; } elseif (is_object($on)) { // ON is an object $res[] = $this->quoteItem($on, $settings); } else { // common on $res[] = $this->quote( // left $this->getFirstTableAlias($on[0]) . $on[0], $settings ); $res[] = $on[1]; // operator $res[] = $this->quote( // right $this->getSecondTableAlias($cls, $on[2]) . $on[2], $settings ); } return join(' ', $res); }
[ "protected", "function", "buildJoinOn", "(", "array", "$", "cls", ",", "array", "$", "settings", ")", "/*# : string */", "{", "$", "res", "=", "[", "'ON'", "]", ";", "$", "on", "=", "$", "cls", "[", "4", "]", ";", "if", "(", "is_string", "(", "$", "on", ")", ")", "{", "// ON string", "$", "res", "[", "]", "=", "$", "on", ";", "}", "elseif", "(", "is_object", "(", "$", "on", ")", ")", "{", "// ON is an object", "$", "res", "[", "]", "=", "$", "this", "->", "quoteItem", "(", "$", "on", ",", "$", "settings", ")", ";", "}", "else", "{", "// common on", "$", "res", "[", "]", "=", "$", "this", "->", "quote", "(", "// left", "$", "this", "->", "getFirstTableAlias", "(", "$", "on", "[", "0", "]", ")", ".", "$", "on", "[", "0", "]", ",", "$", "settings", ")", ";", "$", "res", "[", "]", "=", "$", "on", "[", "1", "]", ";", "// operator", "$", "res", "[", "]", "=", "$", "this", "->", "quote", "(", "// right", "$", "this", "->", "getSecondTableAlias", "(", "$", "cls", ",", "$", "on", "[", "2", "]", ")", ".", "$", "on", "[", "2", "]", ",", "$", "settings", ")", ";", "}", "return", "join", "(", "' '", ",", "$", "res", ")", ";", "}" ]
Build ON part @param array $cls @param array $settings @return string @access protected
[ "Build", "ON", "part" ]
921e485c8cc29067f279da2cdd06f47a9bddd115
https://github.com/phossa2/libs/blob/921e485c8cc29067f279da2cdd06f47a9bddd115/src/Phossa2/Query/Traits/Clause/JoinTrait.php#L219-L239
4,982
phossa2/libs
src/Phossa2/Query/Traits/Clause/JoinTrait.php
JoinTrait.getFirstTableAlias
protected function getFirstTableAlias( /*# string */ $left )/*# : string */ { if (false !== strpos($left, '.')) { // alias exists return ''; } else { // prepend first table alias $tables = &$this->getClause('TABLE'); reset($tables); $alias = key($tables); return (is_int($alias) ? $tables[$alias][0] : $alias) . '.'; } }
php
protected function getFirstTableAlias( /*# string */ $left )/*# : string */ { if (false !== strpos($left, '.')) { // alias exists return ''; } else { // prepend first table alias $tables = &$this->getClause('TABLE'); reset($tables); $alias = key($tables); return (is_int($alias) ? $tables[$alias][0] : $alias) . '.'; } }
[ "protected", "function", "getFirstTableAlias", "(", "/*# string */", "$", "left", ")", "/*# : string */", "{", "if", "(", "false", "!==", "strpos", "(", "$", "left", ",", "'.'", ")", ")", "{", "// alias exists", "return", "''", ";", "}", "else", "{", "// prepend first table alias", "$", "tables", "=", "&", "$", "this", "->", "getClause", "(", "'TABLE'", ")", ";", "reset", "(", "$", "tables", ")", ";", "$", "alias", "=", "key", "(", "$", "tables", ")", ";", "return", "(", "is_int", "(", "$", "alias", ")", "?", "$", "tables", "[", "$", "alias", "]", "[", "0", "]", ":", "$", "alias", ")", ".", "'.'", ";", "}", "}" ]
Get first table alias @param string $left left part of eq @return string @access protected
[ "Get", "first", "table", "alias" ]
921e485c8cc29067f279da2cdd06f47a9bddd115
https://github.com/phossa2/libs/blob/921e485c8cc29067f279da2cdd06f47a9bddd115/src/Phossa2/Query/Traits/Clause/JoinTrait.php#L248-L259
4,983
phossa2/libs
src/Phossa2/Query/Traits/Clause/JoinTrait.php
JoinTrait.getSecondTableAlias
protected function getSecondTableAlias( array $cls, /*# string */ $right )/*# : string */ { if (false !== strpos($right, '.')) { return ''; } else { $alias = $cls[3]; if (!is_string($alias)) { $alias = $cls[2]; } return $alias . '.'; } }
php
protected function getSecondTableAlias( array $cls, /*# string */ $right )/*# : string */ { if (false !== strpos($right, '.')) { return ''; } else { $alias = $cls[3]; if (!is_string($alias)) { $alias = $cls[2]; } return $alias . '.'; } }
[ "protected", "function", "getSecondTableAlias", "(", "array", "$", "cls", ",", "/*# string */", "$", "right", ")", "/*# : string */", "{", "if", "(", "false", "!==", "strpos", "(", "$", "right", ",", "'.'", ")", ")", "{", "return", "''", ";", "}", "else", "{", "$", "alias", "=", "$", "cls", "[", "3", "]", ";", "if", "(", "!", "is_string", "(", "$", "alias", ")", ")", "{", "$", "alias", "=", "$", "cls", "[", "2", "]", ";", "}", "return", "$", "alias", ".", "'.'", ";", "}", "}" ]
Get second table alias @param array $cls @param string $right right part of eq @return string @access protected
[ "Get", "second", "table", "alias" ]
921e485c8cc29067f279da2cdd06f47a9bddd115
https://github.com/phossa2/libs/blob/921e485c8cc29067f279da2cdd06f47a9bddd115/src/Phossa2/Query/Traits/Clause/JoinTrait.php#L269-L282
4,984
synapsestudios/synapse-base
src/Synapse/User/RoleService.php
RoleService.addRoleForUser
public function addRoleForUser(UserEntity $user, $role) { $roles = $user->getRoles(); if (! in_array($role, $roles)) { $this->userRolePivotMapper->addRoleForUser($user->getId(), $role); array_push($roles, $role); $user->setRoles($roles); } }
php
public function addRoleForUser(UserEntity $user, $role) { $roles = $user->getRoles(); if (! in_array($role, $roles)) { $this->userRolePivotMapper->addRoleForUser($user->getId(), $role); array_push($roles, $role); $user->setRoles($roles); } }
[ "public", "function", "addRoleForUser", "(", "UserEntity", "$", "user", ",", "$", "role", ")", "{", "$", "roles", "=", "$", "user", "->", "getRoles", "(", ")", ";", "if", "(", "!", "in_array", "(", "$", "role", ",", "$", "roles", ")", ")", "{", "$", "this", "->", "userRolePivotMapper", "->", "addRoleForUser", "(", "$", "user", "->", "getId", "(", ")", ",", "$", "role", ")", ";", "array_push", "(", "$", "roles", ",", "$", "role", ")", ";", "$", "user", "->", "setRoles", "(", "$", "roles", ")", ";", "}", "}" ]
Add a role to a given user @param UserEntity $user @param string $role name of the role to add
[ "Add", "a", "role", "to", "a", "given", "user" ]
60c830550491742a077ab063f924e2f0b63825da
https://github.com/synapsestudios/synapse-base/blob/60c830550491742a077ab063f924e2f0b63825da/src/Synapse/User/RoleService.php#L29-L40
4,985
TeaLabs/uzi
src/Str.php
Str._format
public function _format($format, $placeholders = [], $default = '') { $placeholders = (array) $placeholders; $matches = []; if(!preg_match_all('/\{([^{}]*)\}+/u', $format, $matches)) return sprintf($format, ...array_values($placeholders)); ksort($placeholders, SORT_NATURAL); $placeholders['__default__'] = $default; $positions = array_flip(array_keys($placeholders)); $type_specifiers = '/([sducoxXbgGeEfF])$/u'; $replacements = []; foreach ($matches[1] as $match) { list($name, $options) = array_pad(explode(':', $match, 2), 2, ''); if(!preg_match($type_specifiers, $options)) $options .= 's'; $position = array_key_exists($name, $positions) ? $positions[$name]+1 : $positions['__default__']+1; $pattern = '%'.$position.'$'.$options; $replacements['{'.$match.'}'] = $pattern; } $format = str_replace(array_keys($replacements), array_values($replacements), $format); return sprintf($format, ...array_values($placeholders)); }
php
public function _format($format, $placeholders = [], $default = '') { $placeholders = (array) $placeholders; $matches = []; if(!preg_match_all('/\{([^{}]*)\}+/u', $format, $matches)) return sprintf($format, ...array_values($placeholders)); ksort($placeholders, SORT_NATURAL); $placeholders['__default__'] = $default; $positions = array_flip(array_keys($placeholders)); $type_specifiers = '/([sducoxXbgGeEfF])$/u'; $replacements = []; foreach ($matches[1] as $match) { list($name, $options) = array_pad(explode(':', $match, 2), 2, ''); if(!preg_match($type_specifiers, $options)) $options .= 's'; $position = array_key_exists($name, $positions) ? $positions[$name]+1 : $positions['__default__']+1; $pattern = '%'.$position.'$'.$options; $replacements['{'.$match.'}'] = $pattern; } $format = str_replace(array_keys($replacements), array_values($replacements), $format); return sprintf($format, ...array_values($placeholders)); }
[ "public", "function", "_format", "(", "$", "format", ",", "$", "placeholders", "=", "[", "]", ",", "$", "default", "=", "''", ")", "{", "$", "placeholders", "=", "(", "array", ")", "$", "placeholders", ";", "$", "matches", "=", "[", "]", ";", "if", "(", "!", "preg_match_all", "(", "'/\\{([^{}]*)\\}+/u'", ",", "$", "format", ",", "$", "matches", ")", ")", "return", "sprintf", "(", "$", "format", ",", "...", "array_values", "(", "$", "placeholders", ")", ")", ";", "ksort", "(", "$", "placeholders", ",", "SORT_NATURAL", ")", ";", "$", "placeholders", "[", "'__default__'", "]", "=", "$", "default", ";", "$", "positions", "=", "array_flip", "(", "array_keys", "(", "$", "placeholders", ")", ")", ";", "$", "type_specifiers", "=", "'/([sducoxXbgGeEfF])$/u'", ";", "$", "replacements", "=", "[", "]", ";", "foreach", "(", "$", "matches", "[", "1", "]", "as", "$", "match", ")", "{", "list", "(", "$", "name", ",", "$", "options", ")", "=", "array_pad", "(", "explode", "(", "':'", ",", "$", "match", ",", "2", ")", ",", "2", ",", "''", ")", ";", "if", "(", "!", "preg_match", "(", "$", "type_specifiers", ",", "$", "options", ")", ")", "$", "options", ".=", "'s'", ";", "$", "position", "=", "array_key_exists", "(", "$", "name", ",", "$", "positions", ")", "?", "$", "positions", "[", "$", "name", "]", "+", "1", ":", "$", "positions", "[", "'__default__'", "]", "+", "1", ";", "$", "pattern", "=", "'%'", ".", "$", "position", ".", "'$'", ".", "$", "options", ";", "$", "replacements", "[", "'{'", ".", "$", "match", ".", "'}'", "]", "=", "$", "pattern", ";", "}", "$", "format", "=", "str_replace", "(", "array_keys", "(", "$", "replacements", ")", ",", "array_values", "(", "$", "replacements", ")", ",", "$", "format", ")", ";", "return", "sprintf", "(", "$", "format", ",", "...", "array_values", "(", "$", "placeholders", ")", ")", ";", "}" ]
Return a formatted string. @param string $format @param array $placeholders @param mixed $default @return string
[ "Return", "a", "formatted", "string", "." ]
af7858caefcf8b972e61cf323280b3a9816cd8cc
https://github.com/TeaLabs/uzi/blob/af7858caefcf8b972e61cf323280b3a9816cd8cc/src/Str.php#L119-L149
4,986
TeaLabs/uzi
src/Str.php
Str.is
public function is($value, $wildcards = true, $caseSensitive = true) { if($this->str == $value) return true; return $this->regexPatternForIs($wildcards, $caseSensitive)->matches($value); }
php
public function is($value, $wildcards = true, $caseSensitive = true) { if($this->str == $value) return true; return $this->regexPatternForIs($wildcards, $caseSensitive)->matches($value); }
[ "public", "function", "is", "(", "$", "value", ",", "$", "wildcards", "=", "true", ",", "$", "caseSensitive", "=", "true", ")", "{", "if", "(", "$", "this", "->", "str", "==", "$", "value", ")", "return", "true", ";", "return", "$", "this", "->", "regexPatternForIs", "(", "$", "wildcards", ",", "$", "caseSensitive", ")", "->", "matches", "(", "$", "value", ")", ";", "}" ]
Determine if the string is a pattern matching the given value. Asterisks (*) in the string are translated into zero-or-more regular expression wildcards to make it convenient to check if the values starts with the given pattern such as "library/*", making any string check convenient. This can be disabled by setting wildcards to false. By default, the comparison is case-sensitive, but can be made insensitive by setting $caseSensitive to false. @param string $value @param bool $wildcards @param bool $caseSensitive @return bool
[ "Determine", "if", "the", "string", "is", "a", "pattern", "matching", "the", "given", "value", "." ]
af7858caefcf8b972e61cf323280b3a9816cd8cc
https://github.com/TeaLabs/uzi/blob/af7858caefcf8b972e61cf323280b3a9816cd8cc/src/Str.php#L209-L215
4,987
TeaLabs/uzi
src/Str.php
Str.isAll
public function isAll($values, $wildcards = true, $caseSensitive = true) { $regex = $this->regexPatternForIs($wildcards, $caseSensitive); return count($regex->filter(Helpers::toArray($values), true)) === 0; }
php
public function isAll($values, $wildcards = true, $caseSensitive = true) { $regex = $this->regexPatternForIs($wildcards, $caseSensitive); return count($regex->filter(Helpers::toArray($values), true)) === 0; }
[ "public", "function", "isAll", "(", "$", "values", ",", "$", "wildcards", "=", "true", ",", "$", "caseSensitive", "=", "true", ")", "{", "$", "regex", "=", "$", "this", "->", "regexPatternForIs", "(", "$", "wildcards", ",", "$", "caseSensitive", ")", ";", "return", "count", "(", "$", "regex", "->", "filter", "(", "Helpers", "::", "toArray", "(", "$", "values", ")", ",", "true", ")", ")", "===", "0", ";", "}" ]
Determine if the string is a pattern matching all the given values. Asterisks (*) in the string are translated into zero-or-more regular expression wildcards to make it convenient to check if the values starts with the given pattern such as "library/*", making any string check convenient. This can be disabled by setting wildcards to false. By default, the comparison is case-sensitive, but can be made insensitive by setting $caseSensitive to false. @param iterable $values @param bool $wildcards @param bool $caseSensitive @return bool
[ "Determine", "if", "the", "string", "is", "a", "pattern", "matching", "all", "the", "given", "values", "." ]
af7858caefcf8b972e61cf323280b3a9816cd8cc
https://github.com/TeaLabs/uzi/blob/af7858caefcf8b972e61cf323280b3a9816cd8cc/src/Str.php#L235-L240
4,988
TeaLabs/uzi
src/Str.php
Str.matches
public function matches($pattern, $caseSensitive = true) { $regex = $this->toRegex($pattern, ($caseSensitive ? "" : Modifiers::CASELESS )); return $regex->matches($this); }
php
public function matches($pattern, $caseSensitive = true) { $regex = $this->toRegex($pattern, ($caseSensitive ? "" : Modifiers::CASELESS )); return $regex->matches($this); }
[ "public", "function", "matches", "(", "$", "pattern", ",", "$", "caseSensitive", "=", "true", ")", "{", "$", "regex", "=", "$", "this", "->", "toRegex", "(", "$", "pattern", ",", "(", "$", "caseSensitive", "?", "\"\"", ":", "Modifiers", "::", "CASELESS", ")", ")", ";", "return", "$", "regex", "->", "matches", "(", "$", "this", ")", ";", "}" ]
Determine if the string matches the given regex pattern. Unless the case-less modifier is set on the pattern, the comparison is case-sensitive. This can be changed by passing $caseSensitive to FALSE. @param string|\Tea\Contracts\Regex\RegularExpression $pattern @param bool $caseSensitive @return bool
[ "Determine", "if", "the", "string", "matches", "the", "given", "regex", "pattern", "." ]
af7858caefcf8b972e61cf323280b3a9816cd8cc
https://github.com/TeaLabs/uzi/blob/af7858caefcf8b972e61cf323280b3a9816cd8cc/src/Str.php#L279-L284
4,989
TeaLabs/uzi
src/Str.php
Str.replace
public function replace($search, $replacement, &$count = 0) { return $this->getNew(str_replace($search, $replacement, $this->str, $count)); }
php
public function replace($search, $replacement, &$count = 0) { return $this->getNew(str_replace($search, $replacement, $this->str, $count)); }
[ "public", "function", "replace", "(", "$", "search", ",", "$", "replacement", ",", "&", "$", "count", "=", "0", ")", "{", "return", "$", "this", "->", "getNew", "(", "str_replace", "(", "$", "search", ",", "$", "replacement", ",", "$", "this", "->", "str", ",", "$", "count", ")", ")", ";", "}" ]
Replaces occurrences of search in string by replacement. @uses str_replace() @param string|array|\Tea\Contracts\Regex\RegularExpression $search @param string|array $replacement @param int $limit @param int &$count @return \Tea\Uzi\Str
[ "Replaces", "occurrences", "of", "search", "in", "string", "by", "replacement", "." ]
af7858caefcf8b972e61cf323280b3a9816cd8cc
https://github.com/TeaLabs/uzi/blob/af7858caefcf8b972e61cf323280b3a9816cd8cc/src/Str.php#L312-L315
4,990
TeaLabs/uzi
src/Str.php
Str.regexPatternForStrip
protected function regexPatternForStrip($substring, $limit) { $pattern = $substring ? Regex::quote($substring) : '\s'; return '(?:'.'(?:'.$pattern.')'. ($limit > 0 ? '{1,'.$limit.'}' : '+').')'; }
php
protected function regexPatternForStrip($substring, $limit) { $pattern = $substring ? Regex::quote($substring) : '\s'; return '(?:'.'(?:'.$pattern.')'. ($limit > 0 ? '{1,'.$limit.'}' : '+').')'; }
[ "protected", "function", "regexPatternForStrip", "(", "$", "substring", ",", "$", "limit", ")", "{", "$", "pattern", "=", "$", "substring", "?", "Regex", "::", "quote", "(", "$", "substring", ")", ":", "'\\s'", ";", "return", "'(?:'", ".", "'(?:'", ".", "$", "pattern", ".", "')'", ".", "(", "$", "limit", ">", "0", "?", "'{1,'", ".", "$", "limit", ".", "'}'", ":", "'+'", ")", ".", "')'", ";", "}" ]
Get the appropriate regex pattern for stripping a string
[ "Get", "the", "appropriate", "regex", "pattern", "for", "stripping", "a", "string" ]
af7858caefcf8b972e61cf323280b3a9816cd8cc
https://github.com/TeaLabs/uzi/blob/af7858caefcf8b972e61cf323280b3a9816cd8cc/src/Str.php#L895-L899
4,991
mrcoco/phalms-core
user/controllers/UserControlController.php
UserControlController.confirmEmailAction
public function confirmEmailAction() { $code = $this->dispatcher->getParam('code'); $confirmation = EmailConfirmations::findFirstByCode($code); if (!$confirmation) { return $this->dispatcher->forward([ 'controller' => 'index', 'action' => 'index' ]); } if ($confirmation->confirmed != 'N') { return $this->dispatcher->forward([ 'controller' => 'session', 'action' => 'login' ]); } $confirmation->confirmed = 'Y'; $confirmation->user->active = 'Y'; /** * Change the confirmation to 'confirmed' and update the user to 'active' */ if (!$confirmation->save()) { foreach ($confirmation->getMessages() as $message) { $this->flash->error($message); } return $this->dispatcher->forward([ 'controller' => 'index', 'action' => 'index' ]); } /** * Identify the user in the application */ $this->auth->authUserById($confirmation->user->id); /** * Check if the user must change his/her password */ if ($confirmation->user->mustChangePassword == 'Y') { $this->flash->success('The email was successfully confirmed. Now you must change your password'); return $this->dispatcher->forward([ 'controller' => 'users', 'action' => 'changePassword' ]); } $this->flash->success('The email was successfully confirmed'); return $this->dispatcher->forward([ 'controller' => 'users', 'action' => 'index' ]); }
php
public function confirmEmailAction() { $code = $this->dispatcher->getParam('code'); $confirmation = EmailConfirmations::findFirstByCode($code); if (!$confirmation) { return $this->dispatcher->forward([ 'controller' => 'index', 'action' => 'index' ]); } if ($confirmation->confirmed != 'N') { return $this->dispatcher->forward([ 'controller' => 'session', 'action' => 'login' ]); } $confirmation->confirmed = 'Y'; $confirmation->user->active = 'Y'; /** * Change the confirmation to 'confirmed' and update the user to 'active' */ if (!$confirmation->save()) { foreach ($confirmation->getMessages() as $message) { $this->flash->error($message); } return $this->dispatcher->forward([ 'controller' => 'index', 'action' => 'index' ]); } /** * Identify the user in the application */ $this->auth->authUserById($confirmation->user->id); /** * Check if the user must change his/her password */ if ($confirmation->user->mustChangePassword == 'Y') { $this->flash->success('The email was successfully confirmed. Now you must change your password'); return $this->dispatcher->forward([ 'controller' => 'users', 'action' => 'changePassword' ]); } $this->flash->success('The email was successfully confirmed'); return $this->dispatcher->forward([ 'controller' => 'users', 'action' => 'index' ]); }
[ "public", "function", "confirmEmailAction", "(", ")", "{", "$", "code", "=", "$", "this", "->", "dispatcher", "->", "getParam", "(", "'code'", ")", ";", "$", "confirmation", "=", "EmailConfirmations", "::", "findFirstByCode", "(", "$", "code", ")", ";", "if", "(", "!", "$", "confirmation", ")", "{", "return", "$", "this", "->", "dispatcher", "->", "forward", "(", "[", "'controller'", "=>", "'index'", ",", "'action'", "=>", "'index'", "]", ")", ";", "}", "if", "(", "$", "confirmation", "->", "confirmed", "!=", "'N'", ")", "{", "return", "$", "this", "->", "dispatcher", "->", "forward", "(", "[", "'controller'", "=>", "'session'", ",", "'action'", "=>", "'login'", "]", ")", ";", "}", "$", "confirmation", "->", "confirmed", "=", "'Y'", ";", "$", "confirmation", "->", "user", "->", "active", "=", "'Y'", ";", "/**\n * Change the confirmation to 'confirmed' and update the user to 'active'\n */", "if", "(", "!", "$", "confirmation", "->", "save", "(", ")", ")", "{", "foreach", "(", "$", "confirmation", "->", "getMessages", "(", ")", "as", "$", "message", ")", "{", "$", "this", "->", "flash", "->", "error", "(", "$", "message", ")", ";", "}", "return", "$", "this", "->", "dispatcher", "->", "forward", "(", "[", "'controller'", "=>", "'index'", ",", "'action'", "=>", "'index'", "]", ")", ";", "}", "/**\n * Identify the user in the application\n */", "$", "this", "->", "auth", "->", "authUserById", "(", "$", "confirmation", "->", "user", "->", "id", ")", ";", "/**\n * Check if the user must change his/her password\n */", "if", "(", "$", "confirmation", "->", "user", "->", "mustChangePassword", "==", "'Y'", ")", "{", "$", "this", "->", "flash", "->", "success", "(", "'The email was successfully confirmed. Now you must change your password'", ")", ";", "return", "$", "this", "->", "dispatcher", "->", "forward", "(", "[", "'controller'", "=>", "'users'", ",", "'action'", "=>", "'changePassword'", "]", ")", ";", "}", "$", "this", "->", "flash", "->", "success", "(", "'The email was successfully confirmed'", ")", ";", "return", "$", "this", "->", "dispatcher", "->", "forward", "(", "[", "'controller'", "=>", "'users'", ",", "'action'", "=>", "'index'", "]", ")", ";", "}" ]
Confirms an e-mail, if the user must change thier password then changes it
[ "Confirms", "an", "e", "-", "mail", "if", "the", "user", "must", "change", "thier", "password", "then", "changes", "it" ]
23486c3e75077896e708f0d2e257cde280a79ad4
https://github.com/mrcoco/phalms-core/blob/23486c3e75077896e708f0d2e257cde280a79ad4/user/controllers/UserControlController.php#L29-L92
4,992
sulazix/SeanceBundle
Controller/ContainerController.php
ContainerController.getContainersAction
public function getContainersAction() { $em = $this->getDoctrine()->getManager(); // TODO : Check user access ! $containers = $em->getRepository('InterneSeanceBundle:Container')->findAll(); $view = $this->view($containers, Response::HTTP_OK); return $this->handleView($view); }
php
public function getContainersAction() { $em = $this->getDoctrine()->getManager(); // TODO : Check user access ! $containers = $em->getRepository('InterneSeanceBundle:Container')->findAll(); $view = $this->view($containers, Response::HTTP_OK); return $this->handleView($view); }
[ "public", "function", "getContainersAction", "(", ")", "{", "$", "em", "=", "$", "this", "->", "getDoctrine", "(", ")", "->", "getManager", "(", ")", ";", "// TODO : Check user access !", "$", "containers", "=", "$", "em", "->", "getRepository", "(", "'InterneSeanceBundle:Container'", ")", "->", "findAll", "(", ")", ";", "$", "view", "=", "$", "this", "->", "view", "(", "$", "containers", ",", "Response", "::", "HTTP_OK", ")", ";", "return", "$", "this", "->", "handleView", "(", "$", "view", ")", ";", "}" ]
Gets the list of all Containers.
[ "Gets", "the", "list", "of", "all", "Containers", "." ]
6818f261dc5ca13a8f9664a46fad9bba273559c1
https://github.com/sulazix/SeanceBundle/blob/6818f261dc5ca13a8f9664a46fad9bba273559c1/Controller/ContainerController.php#L30-L40
4,993
lucifurious/kisma
src/Kisma/Core/Utility/EventManager.php
EventManager.discoverListeners
public static function discoverListeners( $object, $listeners = null, $pattern = self::LISTENER_DISCOVERY_PATTERN ) { // Allow for passed in listeners $_listeners = $listeners ?: static::_discoverObjectListeners( $object, $pattern ); // And wire them up... if ( empty( $_listeners ) || !is_array( $_listeners ) ) { return; } foreach ( $_listeners as $_eventName => $_callables ) { foreach ( $_callables as $_listener ) { static::on( $_eventName, $_listener ); } } }
php
public static function discoverListeners( $object, $listeners = null, $pattern = self::LISTENER_DISCOVERY_PATTERN ) { // Allow for passed in listeners $_listeners = $listeners ?: static::_discoverObjectListeners( $object, $pattern ); // And wire them up... if ( empty( $_listeners ) || !is_array( $_listeners ) ) { return; } foreach ( $_listeners as $_eventName => $_callables ) { foreach ( $_callables as $_listener ) { static::on( $_eventName, $_listener ); } } }
[ "public", "static", "function", "discoverListeners", "(", "$", "object", ",", "$", "listeners", "=", "null", ",", "$", "pattern", "=", "self", "::", "LISTENER_DISCOVERY_PATTERN", ")", "{", "//\tAllow for passed in listeners", "$", "_listeners", "=", "$", "listeners", "?", ":", "static", "::", "_discoverObjectListeners", "(", "$", "object", ",", "$", "pattern", ")", ";", "//\tAnd wire them up...", "if", "(", "empty", "(", "$", "_listeners", ")", "||", "!", "is_array", "(", "$", "_listeners", ")", ")", "{", "return", ";", "}", "foreach", "(", "$", "_listeners", "as", "$", "_eventName", "=>", "$", "_callables", ")", "{", "foreach", "(", "$", "_callables", "as", "$", "_listener", ")", "{", "static", "::", "on", "(", "$", "_eventName", ",", "$", "_listener", ")", ";", "}", "}", "}" ]
Wires up any event handlers automatically @param \Kisma\Core\Interfaces\SubscriberLike|string $object Object or class discovery target @param array|null $listeners Array of 'event.name' => callback/closure pairs @param string $pattern @return void
[ "Wires", "up", "any", "event", "handlers", "automatically" ]
4cc9954249da4e535b52f154e728935f07e648ae
https://github.com/lucifurious/kisma/blob/4cc9954249da4e535b52f154e728935f07e648ae/src/Kisma/Core/Utility/EventManager.php#L99-L117
4,994
lucifurious/kisma
src/Kisma/Core/Utility/EventManager.php
EventManager._discoverObjectListeners
public static function _discoverObjectListeners( $object, $pattern = self::LISTENER_DISCOVERY_PATTERN, $rediscover = false ) { static $_discovered = array(); $_listeners = array(); $_objectId = spl_object_hash( is_string( $object ) ? '_class.' . $object : $object ); if ( false === $rediscover && isset( $_discovered[$_objectId] ) ) { return true; } try { $_mirror = new \ReflectionClass( $object ); $_methods = $_mirror->getMethods( \ReflectionMethod::IS_PUBLIC | \ReflectionMethod::IS_PROTECTED ); // Check each method for the event handler signature foreach ( $_methods as $_method ) { // Event handler? if ( 0 == preg_match( $pattern, $_method->name, $_matches ) || empty( $_matches[1] ) ) { continue; } // Neutralize the name $_eventName = Inflector::neutralize( $_matches[1] ); if ( !isset( $_listeners[$_eventName] ) ) { $_listeners[$_eventName] = array(); } // Save off a callable $_listeners[$_eventName][] = array($object, $_method->name); // Clean up unset( $_matches, $_method ); } unset( $_methods, $_mirror ); $_discovered[$_objectId] = true; } catch ( \Exception $_ex ) { return false; } // Return the current map return $_listeners; }
php
public static function _discoverObjectListeners( $object, $pattern = self::LISTENER_DISCOVERY_PATTERN, $rediscover = false ) { static $_discovered = array(); $_listeners = array(); $_objectId = spl_object_hash( is_string( $object ) ? '_class.' . $object : $object ); if ( false === $rediscover && isset( $_discovered[$_objectId] ) ) { return true; } try { $_mirror = new \ReflectionClass( $object ); $_methods = $_mirror->getMethods( \ReflectionMethod::IS_PUBLIC | \ReflectionMethod::IS_PROTECTED ); // Check each method for the event handler signature foreach ( $_methods as $_method ) { // Event handler? if ( 0 == preg_match( $pattern, $_method->name, $_matches ) || empty( $_matches[1] ) ) { continue; } // Neutralize the name $_eventName = Inflector::neutralize( $_matches[1] ); if ( !isset( $_listeners[$_eventName] ) ) { $_listeners[$_eventName] = array(); } // Save off a callable $_listeners[$_eventName][] = array($object, $_method->name); // Clean up unset( $_matches, $_method ); } unset( $_methods, $_mirror ); $_discovered[$_objectId] = true; } catch ( \Exception $_ex ) { return false; } // Return the current map return $_listeners; }
[ "public", "static", "function", "_discoverObjectListeners", "(", "$", "object", ",", "$", "pattern", "=", "self", "::", "LISTENER_DISCOVERY_PATTERN", ",", "$", "rediscover", "=", "false", ")", "{", "static", "$", "_discovered", "=", "array", "(", ")", ";", "$", "_listeners", "=", "array", "(", ")", ";", "$", "_objectId", "=", "spl_object_hash", "(", "is_string", "(", "$", "object", ")", "?", "'_class.'", ".", "$", "object", ":", "$", "object", ")", ";", "if", "(", "false", "===", "$", "rediscover", "&&", "isset", "(", "$", "_discovered", "[", "$", "_objectId", "]", ")", ")", "{", "return", "true", ";", "}", "try", "{", "$", "_mirror", "=", "new", "\\", "ReflectionClass", "(", "$", "object", ")", ";", "$", "_methods", "=", "$", "_mirror", "->", "getMethods", "(", "\\", "ReflectionMethod", "::", "IS_PUBLIC", "|", "\\", "ReflectionMethod", "::", "IS_PROTECTED", ")", ";", "//\tCheck each method for the event handler signature", "foreach", "(", "$", "_methods", "as", "$", "_method", ")", "{", "//\tEvent handler?", "if", "(", "0", "==", "preg_match", "(", "$", "pattern", ",", "$", "_method", "->", "name", ",", "$", "_matches", ")", "||", "empty", "(", "$", "_matches", "[", "1", "]", ")", ")", "{", "continue", ";", "}", "//\tNeutralize the name", "$", "_eventName", "=", "Inflector", "::", "neutralize", "(", "$", "_matches", "[", "1", "]", ")", ";", "if", "(", "!", "isset", "(", "$", "_listeners", "[", "$", "_eventName", "]", ")", ")", "{", "$", "_listeners", "[", "$", "_eventName", "]", "=", "array", "(", ")", ";", "}", "//\tSave off a callable", "$", "_listeners", "[", "$", "_eventName", "]", "[", "]", "=", "array", "(", "$", "object", ",", "$", "_method", "->", "name", ")", ";", "//\tClean up", "unset", "(", "$", "_matches", ",", "$", "_method", ")", ";", "}", "unset", "(", "$", "_methods", ",", "$", "_mirror", ")", ";", "$", "_discovered", "[", "$", "_objectId", "]", "=", "true", ";", "}", "catch", "(", "\\", "Exception", "$", "_ex", ")", "{", "return", "false", ";", "}", "//\tReturn the current map", "return", "$", "_listeners", ";", "}" ]
Builds a hash of events and handlers that are present in this object based on the event handler signature. This merely builds the hash, nothing is done with it. @param \Kisma\Core\Interfaces\SubscriberLike|string $object The object or class to scan @param string $pattern The method listener pattern to scan for @param bool $rediscover By default, the discoverer will not wire up the same object's events more than once. Setting $rediscover to TRUE will force the rediscovery of the listeners, if any. The default is false. @return array|bool The listeners discovered. True if already discovered, False on error
[ "Builds", "a", "hash", "of", "events", "and", "handlers", "that", "are", "present", "in", "this", "object", "based", "on", "the", "event", "handler", "signature", ".", "This", "merely", "builds", "the", "hash", "nothing", "is", "done", "with", "it", "." ]
4cc9954249da4e535b52f154e728935f07e648ae
https://github.com/lucifurious/kisma/blob/4cc9954249da4e535b52f154e728935f07e648ae/src/Kisma/Core/Utility/EventManager.php#L131-L184
4,995
gourmet/common
View/Helper/NavigationHelper.php
NavigationHelper.render
public function render($paths, $navAttrs = array(), $listAttrs = array()) { if (false !== $navAttrs) { $navAttrs = array_merge(array('tag' => 'nav'), $navAttrs); $navTag = $navAttrs['tag']; unset($navAttrs['tag']); } $listAttrs = array_merge(array('tag' => 'ul'), $listAttrs); $this->_tag = $listAttrs['tag']; unset($listAttrs['tag']); if (is_string($paths)) { $paths = array(array('path' => $paths)); } $out = ''; foreach ($paths as $k => $path) { if (is_string($path)) { $paths[$k] = compact('path'); } else if (is_string($k)) { $attrs = (array) $path; $path = $k; if (!array_key_exists('navAttrs', $attrs) && !array_key_exists('listAttrs', $attrs)) { $attrs = array('navAttrs' => $attrs, 'listAttrs' => array()); } $out .= $this->render($path, $attrs['navAttrs'], $attrs['listAttrs']); continue; } $paths[$k] = Hash::merge(array('attrs' => $listAttrs), $paths[$k]); $out .= $this->_render($paths[$k]); } if (empty($out)) { return; } if (false === $navAttrs) { return $out; } return $this->Html->useTag('tag', $navTag, $navAttrs, $out, $navTag); }
php
public function render($paths, $navAttrs = array(), $listAttrs = array()) { if (false !== $navAttrs) { $navAttrs = array_merge(array('tag' => 'nav'), $navAttrs); $navTag = $navAttrs['tag']; unset($navAttrs['tag']); } $listAttrs = array_merge(array('tag' => 'ul'), $listAttrs); $this->_tag = $listAttrs['tag']; unset($listAttrs['tag']); if (is_string($paths)) { $paths = array(array('path' => $paths)); } $out = ''; foreach ($paths as $k => $path) { if (is_string($path)) { $paths[$k] = compact('path'); } else if (is_string($k)) { $attrs = (array) $path; $path = $k; if (!array_key_exists('navAttrs', $attrs) && !array_key_exists('listAttrs', $attrs)) { $attrs = array('navAttrs' => $attrs, 'listAttrs' => array()); } $out .= $this->render($path, $attrs['navAttrs'], $attrs['listAttrs']); continue; } $paths[$k] = Hash::merge(array('attrs' => $listAttrs), $paths[$k]); $out .= $this->_render($paths[$k]); } if (empty($out)) { return; } if (false === $navAttrs) { return $out; } return $this->Html->useTag('tag', $navTag, $navAttrs, $out, $navTag); }
[ "public", "function", "render", "(", "$", "paths", ",", "$", "navAttrs", "=", "array", "(", ")", ",", "$", "listAttrs", "=", "array", "(", ")", ")", "{", "if", "(", "false", "!==", "$", "navAttrs", ")", "{", "$", "navAttrs", "=", "array_merge", "(", "array", "(", "'tag'", "=>", "'nav'", ")", ",", "$", "navAttrs", ")", ";", "$", "navTag", "=", "$", "navAttrs", "[", "'tag'", "]", ";", "unset", "(", "$", "navAttrs", "[", "'tag'", "]", ")", ";", "}", "$", "listAttrs", "=", "array_merge", "(", "array", "(", "'tag'", "=>", "'ul'", ")", ",", "$", "listAttrs", ")", ";", "$", "this", "->", "_tag", "=", "$", "listAttrs", "[", "'tag'", "]", ";", "unset", "(", "$", "listAttrs", "[", "'tag'", "]", ")", ";", "if", "(", "is_string", "(", "$", "paths", ")", ")", "{", "$", "paths", "=", "array", "(", "array", "(", "'path'", "=>", "$", "paths", ")", ")", ";", "}", "$", "out", "=", "''", ";", "foreach", "(", "$", "paths", "as", "$", "k", "=>", "$", "path", ")", "{", "if", "(", "is_string", "(", "$", "path", ")", ")", "{", "$", "paths", "[", "$", "k", "]", "=", "compact", "(", "'path'", ")", ";", "}", "else", "if", "(", "is_string", "(", "$", "k", ")", ")", "{", "$", "attrs", "=", "(", "array", ")", "$", "path", ";", "$", "path", "=", "$", "k", ";", "if", "(", "!", "array_key_exists", "(", "'navAttrs'", ",", "$", "attrs", ")", "&&", "!", "array_key_exists", "(", "'listAttrs'", ",", "$", "attrs", ")", ")", "{", "$", "attrs", "=", "array", "(", "'navAttrs'", "=>", "$", "attrs", ",", "'listAttrs'", "=>", "array", "(", ")", ")", ";", "}", "$", "out", ".=", "$", "this", "->", "render", "(", "$", "path", ",", "$", "attrs", "[", "'navAttrs'", "]", ",", "$", "attrs", "[", "'listAttrs'", "]", ")", ";", "continue", ";", "}", "$", "paths", "[", "$", "k", "]", "=", "Hash", "::", "merge", "(", "array", "(", "'attrs'", "=>", "$", "listAttrs", ")", ",", "$", "paths", "[", "$", "k", "]", ")", ";", "$", "out", ".=", "$", "this", "->", "_render", "(", "$", "paths", "[", "$", "k", "]", ")", ";", "}", "if", "(", "empty", "(", "$", "out", ")", ")", "{", "return", ";", "}", "if", "(", "false", "===", "$", "navAttrs", ")", "{", "return", "$", "out", ";", "}", "return", "$", "this", "->", "Html", "->", "useTag", "(", "'tag'", ",", "$", "navTag", ",", "$", "navAttrs", ",", "$", "out", ",", "$", "navTag", ")", ";", "}" ]
Render navigation. @param string $path Optional. The navigation's item(s) `Hash` path. @param array $navAttrs Optional. Navigation's HTML attributes. @param array $listAttrs Optional. List's HTML attributes. @return string
[ "Render", "navigation", "." ]
53ad4e919c51606dc81f2c716267d01ee768ade5
https://github.com/gourmet/common/blob/53ad4e919c51606dc81f2c716267d01ee768ade5/View/Helper/NavigationHelper.php#L61-L102
4,996
budkit/budkit-framework
src/Budkit/Parameter/Repository/File.php
File.load
public function load($environment, $namespace) { //evironments = /config/<environment>/namespace.ini[section].key $file = $this->directory; $file .= !empty($environment) ? $environment . DS : DS; $file .= $namespace; $file .= $this->extension; //Check that we have a file named namespace if (!array_key_exists($this->extension, $this->handlers)) { throw new \Exception("config file handler for {$this->extension} does not exists"); } $handler = $this->handlers[$this->extension]; $params = $handler->readParams($file); return $params; }
php
public function load($environment, $namespace) { //evironments = /config/<environment>/namespace.ini[section].key $file = $this->directory; $file .= !empty($environment) ? $environment . DS : DS; $file .= $namespace; $file .= $this->extension; //Check that we have a file named namespace if (!array_key_exists($this->extension, $this->handlers)) { throw new \Exception("config file handler for {$this->extension} does not exists"); } $handler = $this->handlers[$this->extension]; $params = $handler->readParams($file); return $params; }
[ "public", "function", "load", "(", "$", "environment", ",", "$", "namespace", ")", "{", "//evironments = /config/<environment>/namespace.ini[section].key", "$", "file", "=", "$", "this", "->", "directory", ";", "$", "file", ".=", "!", "empty", "(", "$", "environment", ")", "?", "$", "environment", ".", "DS", ":", "DS", ";", "$", "file", ".=", "$", "namespace", ";", "$", "file", ".=", "$", "this", "->", "extension", ";", "//Check that we have a file named namespace", "if", "(", "!", "array_key_exists", "(", "$", "this", "->", "extension", ",", "$", "this", "->", "handlers", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "\"config file handler for {$this->extension} does not exists\"", ")", ";", "}", "$", "handler", "=", "$", "this", "->", "handlers", "[", "$", "this", "->", "extension", "]", ";", "$", "params", "=", "$", "handler", "->", "readParams", "(", "$", "file", ")", ";", "return", "$", "params", ";", "}" ]
Loads config from a specific namespace @param $env @param string $group @param string $namespace
[ "Loads", "config", "from", "a", "specific", "namespace" ]
0635061815fe07a8c63f9514b845d199b3c0d485
https://github.com/budkit/budkit-framework/blob/0635061815fe07a8c63f9514b845d199b3c0d485/src/Budkit/Parameter/Repository/File.php#L38-L59
4,997
ciims/cii
widgets/comments/CiiMSComments.php
CiiMSComments.init
public function init() { $asset = Yii::app()->assetManager->publish(YiiBase::getPathOfAlias('cii.assets.dist'), true, -1, YII_DEBUG); // Register CSS and Scripts Yii::app()->clientScript->registerScriptFile($asset. (YII_DEBUG ? '/ciimscomments.js' : '/ciimscomments.min.js'), CClientScript::POS_END); Yii::app()->clientScript->registerCssFile($asset. (YII_DEBUG ? '/ciimscomments.css' : '/ciimscomments.min.css')); if ($this->content != false) $this->renderCommentBox(); else $this->renderCommentCount(); }
php
public function init() { $asset = Yii::app()->assetManager->publish(YiiBase::getPathOfAlias('cii.assets.dist'), true, -1, YII_DEBUG); // Register CSS and Scripts Yii::app()->clientScript->registerScriptFile($asset. (YII_DEBUG ? '/ciimscomments.js' : '/ciimscomments.min.js'), CClientScript::POS_END); Yii::app()->clientScript->registerCssFile($asset. (YII_DEBUG ? '/ciimscomments.css' : '/ciimscomments.min.css')); if ($this->content != false) $this->renderCommentBox(); else $this->renderCommentCount(); }
[ "public", "function", "init", "(", ")", "{", "$", "asset", "=", "Yii", "::", "app", "(", ")", "->", "assetManager", "->", "publish", "(", "YiiBase", "::", "getPathOfAlias", "(", "'cii.assets.dist'", ")", ",", "true", ",", "-", "1", ",", "YII_DEBUG", ")", ";", "// Register CSS and Scripts\r", "Yii", "::", "app", "(", ")", "->", "clientScript", "->", "registerScriptFile", "(", "$", "asset", ".", "(", "YII_DEBUG", "?", "'/ciimscomments.js'", ":", "'/ciimscomments.min.js'", ")", ",", "CClientScript", "::", "POS_END", ")", ";", "Yii", "::", "app", "(", ")", "->", "clientScript", "->", "registerCssFile", "(", "$", "asset", ".", "(", "YII_DEBUG", "?", "'/ciimscomments.css'", ":", "'/ciimscomments.min.css'", ")", ")", ";", "if", "(", "$", "this", "->", "content", "!=", "false", ")", "$", "this", "->", "renderCommentBox", "(", ")", ";", "else", "$", "this", "->", "renderCommentCount", "(", ")", ";", "}" ]
Init function to start the rendering process
[ "Init", "function", "to", "start", "the", "rendering", "process" ]
cc8550b9a3a6a0bf0214554679de8743d50dc9ef
https://github.com/ciims/cii/blob/cc8550b9a3a6a0bf0214554679de8743d50dc9ef/widgets/comments/CiiMSComments.php#L14-L26
4,998
ciims/cii
widgets/comments/CiiMSComments.php
CiiMSComments.renderCommentBox
private function renderCommentBox() { $link = CHtml::link('0', Yii::app()->createAbsoluteUrl($this->content['slug']) . '#comment', array('data-ciimscomments-identifier' => $this->content['id'])); $id = $this->content['id']; Yii::app()->clientScript->registerScript('CiiMSComments', " $(document).ready(function() { // Load the Endpoint var endpoint = $('#endpoint').attr('data-attr-endpoint') + '/'; // Update the comments div $('.comment-count').attr('data-attr-id', '$id').addClass('registered').append('$link'); // Load the comments Comments.load(); Comments.commentCount(); }); "); }
php
private function renderCommentBox() { $link = CHtml::link('0', Yii::app()->createAbsoluteUrl($this->content['slug']) . '#comment', array('data-ciimscomments-identifier' => $this->content['id'])); $id = $this->content['id']; Yii::app()->clientScript->registerScript('CiiMSComments', " $(document).ready(function() { // Load the Endpoint var endpoint = $('#endpoint').attr('data-attr-endpoint') + '/'; // Update the comments div $('.comment-count').attr('data-attr-id', '$id').addClass('registered').append('$link'); // Load the comments Comments.load(); Comments.commentCount(); }); "); }
[ "private", "function", "renderCommentBox", "(", ")", "{", "$", "link", "=", "CHtml", "::", "link", "(", "'0'", ",", "Yii", "::", "app", "(", ")", "->", "createAbsoluteUrl", "(", "$", "this", "->", "content", "[", "'slug'", "]", ")", ".", "'#comment'", ",", "array", "(", "'data-ciimscomments-identifier'", "=>", "$", "this", "->", "content", "[", "'id'", "]", ")", ")", ";", "$", "id", "=", "$", "this", "->", "content", "[", "'id'", "]", ";", "Yii", "::", "app", "(", ")", "->", "clientScript", "->", "registerScript", "(", "'CiiMSComments'", ",", "\"\r\n $(document).ready(function() {\r\n\t\t\t\t// Load the Endpoint\r\n\t\t\t\tvar endpoint = $('#endpoint').attr('data-attr-endpoint') + '/';\r\n\r\n\t\t\t\t// Update the comments div\r\n\t $('.comment-count').attr('data-attr-id', '$id').addClass('registered').append('$link');\r\n\r\n\t // Load the comments\r\n\t Comments.load();\r\n\t Comments.commentCount();\r\n\t });\r\n\t \"", ")", ";", "}" ]
Renders the Disqus Comment Box on the page
[ "Renders", "the", "Disqus", "Comment", "Box", "on", "the", "page" ]
cc8550b9a3a6a0bf0214554679de8743d50dc9ef
https://github.com/ciims/cii/blob/cc8550b9a3a6a0bf0214554679de8743d50dc9ef/widgets/comments/CiiMSComments.php#L31-L49
4,999
sopinet/ApiHelperBundle
Service/ApiHelper.php
ApiHelper.handleForm
public function handleForm(Request $request,Form $form){ // The JSON PUT data will include all attributes in the entity, even // those that are not updateable by the user and are not in the form. // We need to remove these extra fields or we will get a // "This form should not contain extra fields" Form Error $data = $request->request->all(); $children = $form->all(); //Eliminamos los datos del request que no pertenecen al formulario $data = array_intersect_key($data, $children); $form->submit($data); return $form; }
php
public function handleForm(Request $request,Form $form){ // The JSON PUT data will include all attributes in the entity, even // those that are not updateable by the user and are not in the form. // We need to remove these extra fields or we will get a // "This form should not contain extra fields" Form Error $data = $request->request->all(); $children = $form->all(); //Eliminamos los datos del request que no pertenecen al formulario $data = array_intersect_key($data, $children); $form->submit($data); return $form; }
[ "public", "function", "handleForm", "(", "Request", "$", "request", ",", "Form", "$", "form", ")", "{", "// The JSON PUT data will include all attributes in the entity, even", "// those that are not updateable by the user and are not in the form.", "// We need to remove these extra fields or we will get a", "// \"This form should not contain extra fields\" Form Error", "$", "data", "=", "$", "request", "->", "request", "->", "all", "(", ")", ";", "$", "children", "=", "$", "form", "->", "all", "(", ")", ";", "//Eliminamos los datos del request que no pertenecen al formulario", "$", "data", "=", "array_intersect_key", "(", "$", "data", ",", "$", "children", ")", ";", "$", "form", "->", "submit", "(", "$", "data", ")", ";", "return", "$", "form", ";", "}" ]
Se hace un submit de los campos de un request que esten definidos en un formulario @param Request $request @param Form $form @return Form
[ "Se", "hace", "un", "submit", "de", "los", "campos", "de", "un", "request", "que", "esten", "definidos", "en", "un", "formulario" ]
878dd397445f5289afaa8ee1b1752dc111b557de
https://github.com/sopinet/ApiHelperBundle/blob/878dd397445f5289afaa8ee1b1752dc111b557de/Service/ApiHelper.php#L104-L115