repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_documentation_string
stringlengths
1
47.2k
func_code_url
stringlengths
85
339
nasumilu/geometry
src/Geometry.php
Geometry.contains
public function contains(Geometry $other): bool { $event = new SpatialRelationshipOpEvent($this, ['other' => $other]); $this->fireOperationEvent(SpatialRelationshipOpEvent::CONTAINS_EVENT, $event); return $event->getResults(); }
php
public function contains(Geometry $other): bool { $event = new SpatialRelationshipOpEvent($this, ['other' => $other]); $this->fireOperationEvent(SpatialRelationshipOpEvent::CONTAINS_EVENT, $event); return $event->getResults(); }
Indicates whether this Geometry "spatially contains" <code>$other</code>. @param \Nasumilu\Geometry\Geometry $other @return bool
https://github.com/nasumilu/geometry/blob/000fafe3e61f1d0682952ad236b7486dded65eae/src/Geometry.php#L315-L319
nasumilu/geometry
src/Geometry.php
Geometry.overlaps
public function overlaps(Geometry $other): bool { $event = new SpatialRelationshipOpEvent($this, ['other' => $other]); $this->fireOperationEvent(SpatialRelationshipOpEvent::OVERLAPS_EVENT, $event); return $event->getResults(); }
php
public function overlaps(Geometry $other): bool { $event = new SpatialRelationshipOpEvent($this, ['other' => $other]); $this->fireOperationEvent(SpatialRelationshipOpEvent::OVERLAPS_EVENT, $event); return $event->getResults(); }
Indicates whether this Geometry "spatially overlaps" <code>$other</code>. @param \Nasumilu\Geometry\Geometry $other @return bool
https://github.com/nasumilu/geometry/blob/000fafe3e61f1d0682952ad236b7486dded65eae/src/Geometry.php#L327-L331
nasumilu/geometry
src/Geometry.php
Geometry.relate
public function relate(Geometry $other, string $pattern): bool { $event = new SpatialRelationshipOpEvent($this, ['other' => $other, 'pattern' => $pattern]); $this->fireOperationEvent(SpatialRelationshipOpEvent::RELATE_EVENT, $event); return $event->getResults(); }
php
public function relate(Geometry $other, string $pattern): bool { $event = new SpatialRelationshipOpEvent($this, ['other' => $other, 'pattern' => $pattern]); $this->fireOperationEvent(SpatialRelationshipOpEvent::RELATE_EVENT, $event); return $event->getResults(); }
Indicates whether this Geometry is spatially related to <code>$other</code> by using the intersection pattern matrix <code>$pattern</code>. @see https://en.wikipedia.org/wiki/DE-9IM DE-9IM @param \Nasumilu\Geometry\Geometry $other @param string $pattern @return bool
https://github.com/nasumilu/geometry/blob/000fafe3e61f1d0682952ad236b7486dded65eae/src/Geometry.php#L342-L346
nasumilu/geometry
src/Geometry.php
Geometry.locateAlong
public function locateAlong(float $mValue, float $offset = 0): Geometry { $event = new LinearReferenceOpEvent($this, ['mValue' => $mValue, 'offset' => $offset]); $this->fireOperationEvent(LinearReferenceOpEvent::LOCATE_ALONG_EVENT, $event); return $event->getResults(); }
php
public function locateAlong(float $mValue, float $offset = 0): Geometry { $event = new LinearReferenceOpEvent($this, ['mValue' => $mValue, 'offset' => $offset]); $this->fireOperationEvent(LinearReferenceOpEvent::LOCATE_ALONG_EVENT, $event); return $event->getResults(); }
Gets a derived GeometryCollection value that matches the specified m-coordinate value (<code>$mValue</code>). If an <code>$offset</code>, the resultant will be offset to the left or right of the input line by the specified number of units. Positive offset will be to the left and negative to the right. @param float $mValue @param float $offset @return \Nasumilu\Geometry\Geometry
https://github.com/nasumilu/geometry/blob/000fafe3e61f1d0682952ad236b7486dded65eae/src/Geometry.php#L360-L364
nasumilu/geometry
src/Geometry.php
Geometry.locateBetween
public function locateBetween(float $mStart, float $mEnd, float $offset = 0): Geometry { $event = new LinearReferenceOpEvent($this, ['mStart' => $mStart, 'mEnd' => $mEnd, 'offset' => $offset]); $this->fireOperationEvent(LinearReferenceOpEvent::LOCATE_BETWEEN_EVENT, $event); return $event->getResults(); }
php
public function locateBetween(float $mStart, float $mEnd, float $offset = 0): Geometry { $event = new LinearReferenceOpEvent($this, ['mStart' => $mStart, 'mEnd' => $mEnd, 'offset' => $offset]); $this->fireOperationEvent(LinearReferenceOpEvent::LOCATE_BETWEEN_EVENT, $event); return $event->getResults(); }
Gets a derived GeometryCollection value that matches the specified range of m-coordinate (<code>$mStart</code> - <code>$mEnd</code>) values inclusively. If an <code>$offset</code> is provided, the resultant will be offset to the left or right of the input line by the specified number of units. A positive number will be to the left, and a negative to the right. @param float $mStart @param float $mEnd @param float $offset @return \Nasumilu\Geometry\Geometry
https://github.com/nasumilu/geometry/blob/000fafe3e61f1d0682952ad236b7486dded65eae/src/Geometry.php#L379-L383
nasumilu/geometry
src/Geometry.php
Geometry.buffer
public function buffer(float $radius): Geometry { $event = new ProcessOpEvent($this, ['radius' => $radius]); $this->fireOperationEvent(ProcessOpEvent::BUFFER_EVENT, $event); return $event->getResults(); }
php
public function buffer(float $radius): Geometry { $event = new ProcessOpEvent($this, ['radius' => $radius]); $this->fireOperationEvent(ProcessOpEvent::BUFFER_EVENT, $event); return $event->getResults(); }
Gets a Geometry object that represents all Points whose distance from this Geometry is less than or equal to <code>$radius</code>. @param float $radius @return \Nasumilu\Geometry\Geometry
https://github.com/nasumilu/geometry/blob/000fafe3e61f1d0682952ad236b7486dded65eae/src/Geometry.php#L392-L396
nasumilu/geometry
src/Geometry.php
Geometry.convexHull
public function convexHull(): Geometry { $event = new ProcessOpEvent($this); $this->fireOperationEvent(ProcessOpEvent::CONVEX_HULL_EVENT, $event); return $event->getResults(); }
php
public function convexHull(): Geometry { $event = new ProcessOpEvent($this); $this->fireOperationEvent(ProcessOpEvent::CONVEX_HULL_EVENT, $event); return $event->getResults(); }
Gets a Geometry that represents the convex hull of this Geometry. @return \Nasumilu\Geometry\Geometry
https://github.com/nasumilu/geometry/blob/000fafe3e61f1d0682952ad236b7486dded65eae/src/Geometry.php#L403-L407
nasumilu/geometry
src/Geometry.php
Geometry.intersection
public function intersection(Geometry $other): Geometry { $event = new ProcessOpEvent($this, ['other' => $other]); $this->fireOperationEvent(ProcessOpEvent::INTERSECTION_EVENT, $event); return $event->getResults(); }
php
public function intersection(Geometry $other): Geometry { $event = new ProcessOpEvent($this, ['other' => $other]); $this->fireOperationEvent(ProcessOpEvent::INTERSECTION_EVENT, $event); return $event->getResults(); }
Gets a Geometry that represents the Point set intersection of this Geometry with <code>$other</code>. @param \Nasumilu\Geometry\Geometry $other @return \Nasumilu\Geometry\Geometry
https://github.com/nasumilu/geometry/blob/000fafe3e61f1d0682952ad236b7486dded65eae/src/Geometry.php#L416-L420
nasumilu/geometry
src/Geometry.php
Geometry.union
public function union(Geometry $other): Geometry { $event = new ProcessOpEvent($this, ['other' => $other]); $this->fireOperationEvent(ProcessOpEvent::UNION_EVENT, $event); return $event->getResults(); }
php
public function union(Geometry $other): Geometry { $event = new ProcessOpEvent($this, ['other' => $other]); $this->fireOperationEvent(ProcessOpEvent::UNION_EVENT, $event); return $event->getResults(); }
Gets a Geometry that represents the Point set union of this Geometry with <code>$other</code>. @param \Nasumilu\Geometry\Geometry $other @return \Nasumilu\Geometry\Geometry
https://github.com/nasumilu/geometry/blob/000fafe3e61f1d0682952ad236b7486dded65eae/src/Geometry.php#L429-L433
nasumilu/geometry
src/Geometry.php
Geometry.difference
public function difference(Geometry $other): Geometry { $event = new ProcessOpEvent($this, ['other' => $other]); $this->fireOperationEvent(ProcessOpEvent::DIFFERENCE_EVENT, $event); return $event->getResults(); }
php
public function difference(Geometry $other): Geometry { $event = new ProcessOpEvent($this, ['other' => $other]); $this->fireOperationEvent(ProcessOpEvent::DIFFERENCE_EVENT, $event); return $event->getResults(); }
Gets a Geometry that represents the Point set difference of this Geometry with <code>$other</code>. @param \Nasumilu\Geometry\Geometry $other @return \Nasumilu\Geometry\Geometry
https://github.com/nasumilu/geometry/blob/000fafe3e61f1d0682952ad236b7486dded65eae/src/Geometry.php#L442-L446
nasumilu/geometry
src/Geometry.php
Geometry.symDifference
public function symDifference(Geometry $other): Geometry { $event = new ProcessOpEvent($this, ['other' => $other]); $this->fireOperationEvent(ProcessOpEvent::SYM_DIFFERENCE_EVENT, $event); return $event->getResults(); }
php
public function symDifference(Geometry $other): Geometry { $event = new ProcessOpEvent($this, ['other' => $other]); $this->fireOperationEvent(ProcessOpEvent::SYM_DIFFERENCE_EVENT, $event); return $event->getResults(); }
Gets a Geometry that represents the Point set symmetric difference of this Geometry with <code>$other</code>. @param \Nasumilu\Geometry\Geometry $other @return \Nasumilu\Geometry\Geometry
https://github.com/nasumilu/geometry/blob/000fafe3e61f1d0682952ad236b7486dded65eae/src/Geometry.php#L455-L459
nasumilu/geometry
src/Geometry.php
Geometry.getDistance
public function getDistance(Geometry $other, string $type = 'min', bool $_3D = false): float { $event = new MeasurementOpEvent($this, ['other' => $other, 'type' => $type, '3D' => $_3D]); $this->fireOperationEvent(MeasurementOpEvent::DISTANCE_EVENT, $event); return $event->getResults(); }
php
public function getDistance(Geometry $other, string $type = 'min', bool $_3D = false): float { $event = new MeasurementOpEvent($this, ['other' => $other, 'type' => $type, '3D' => $_3D]); $this->fireOperationEvent(MeasurementOpEvent::DISTANCE_EVENT, $event); return $event->getResults(); }
Gets the 2 or 3-dimensional distance between this Geometry and <code>$other</code>. There are two types of distance 'min' or 'max'. The 'min' type will return the minimum, while 'max' will return the maximum distance between this Geometry and the <code>$other</code>. If <code>$_3D</code> is true than the 3-dimensional distance is returned; otherwise the 2-dimensional distance. @param \Nasumilu\Geometry\Geometry $other @param string $type @param bool $_3D @return float
https://github.com/nasumilu/geometry/blob/000fafe3e61f1d0682952ad236b7486dded65eae/src/Geometry.php#L477-L481
nasumilu/geometry
src/Geometry.php
Geometry.getCentroid
public function getCentroid(bool $use_spheriod = false): Point { $event = new AccessorOpEvent($this, ['use_spheriod' => $use_spheriod]); $this->fireOperationEvent(AccessorOpEvent::CENTROID_EVENT, $event); return $event->getResults(); }
php
public function getCentroid(bool $use_spheriod = false): Point { $event = new AccessorOpEvent($this, ['use_spheriod' => $use_spheriod]); $this->fireOperationEvent(AccessorOpEvent::CENTROID_EVENT, $event); return $event->getResults(); }
The mathematical centroid for this Surface as a Point. The result is not guaranteed to be on this Surface. @param bool $use_spheriod @return \Nasumilu\Geometry\Point
https://github.com/nasumilu/geometry/blob/000fafe3e61f1d0682952ad236b7486dded65eae/src/Geometry.php#L490-L494
dark-prospect-games/obsidian-moon-engine
src/Modules/Benchmark.php
Benchmark.elapsedTime
public function elapsedTime( string $point1 = '', string $point2 = '', int $decimals = 4 ) { if ($point1 === '') { return '{elapsed_time}'; } if (!array_key_exists($point1, $this->_marker)) { return ''; } if (!array_key_exists($point2, $this->_marker)) { $this->_marker[$point2] = microtime(); } [$sm, $ss] = explode(' ', $this->_marker[$point1]); [$em, $es] = explode(' ', $this->_marker[$point2]); return number_format(($em + $es) - ($sm + $ss), $decimals); }
php
public function elapsedTime( string $point1 = '', string $point2 = '', int $decimals = 4 ) { if ($point1 === '') { return '{elapsed_time}'; } if (!array_key_exists($point1, $this->_marker)) { return ''; } if (!array_key_exists($point2, $this->_marker)) { $this->_marker[$point2] = microtime(); } [$sm, $ss] = explode(' ', $this->_marker[$point1]); [$em, $es] = explode(' ', $this->_marker[$point2]); return number_format(($em + $es) - ($sm + $ss), $decimals); }
Calculates the time difference between two marked points. If the first parameter is empty this function instead returns the {elapsed_time} pseudo-variable. This permits the full system execution time to be shown in a template. The output class will swap the real value for this variable. @param string $point1 a particular marked point @param string $point2 a particular marked point @param integer $decimals the number of decimal places @access public @return mixed
https://github.com/dark-prospect-games/obsidian-moon-engine/blob/83b82990bdea79960a93b52f963cc81b6fa009ba/src/Modules/Benchmark.php#L74-L95
SpoonX/SxCore
library/SxCore/Html/ExcerptExtractor.php
ExcerptExtractor.setMarkup
public function setMarkup($markup) { if (!is_string($markup)) { throw new Exception\InvalidArgumentException( 'Expected string. Got "' . gettype($markup) . '".' ); } $this->DOMDocument = new DOMDocument; $this->DOMDocument->loadHTML($markup); }
php
public function setMarkup($markup) { if (!is_string($markup)) { throw new Exception\InvalidArgumentException( 'Expected string. Got "' . gettype($markup) . '".' ); } $this->DOMDocument = new DOMDocument; $this->DOMDocument->loadHTML($markup); }
@param $markup @throws \SxCore\Html\Exception\InvalidArgumentException
https://github.com/SpoonX/SxCore/blob/8f914e3737826c408443d6d458dd9a169c82c940/library/SxCore/Html/ExcerptExtractor.php#L32-L43
SpoonX/SxCore
library/SxCore/Html/ExcerptExtractor.php
ExcerptExtractor.getExcerpt
public function getExcerpt($length) { $elements = $this->DOMDocument->getElementsByTagName('body')->item(0); $trimmed = $this->trimMarkup($elements->childNodes, $length); return $trimmed['markup']; }
php
public function getExcerpt($length) { $elements = $this->DOMDocument->getElementsByTagName('body')->item(0); $trimmed = $this->trimMarkup($elements->childNodes, $length); return $trimmed['markup']; }
Get the excerpt for constructed markup. Note: Text-only values will be wrapped in a paragraph tag. @param $length @return mixed
https://github.com/SpoonX/SxCore/blob/8f914e3737826c408443d6d458dd9a169c82c940/library/SxCore/Html/ExcerptExtractor.php#L53-L59
SpoonX/SxCore
library/SxCore/Html/ExcerptExtractor.php
ExcerptExtractor.trimDOMTextElement
protected function trimDOMTextElement($element, $length) { $textMetLimit = false; $textLength = strlen($element->nodeValue); if ($textLength >= ($length - 30)) { $textMetLimit = true; $element->nodeValue = substr($element->nodeValue, 0, ($length - $textLength)) . '...'; } return array( 'text_met_limit' => $textMetLimit, 'element' => $element, 'text_length' => $textLength, ); }
php
protected function trimDOMTextElement($element, $length) { $textMetLimit = false; $textLength = strlen($element->nodeValue); if ($textLength >= ($length - 30)) { $textMetLimit = true; $element->nodeValue = substr($element->nodeValue, 0, ($length - $textLength)) . '...'; } return array( 'text_met_limit' => $textMetLimit, 'element' => $element, 'text_length' => $textLength, ); }
@param $element @param $length @return array
https://github.com/SpoonX/SxCore/blob/8f914e3737826c408443d6d458dd9a169c82c940/library/SxCore/Html/ExcerptExtractor.php#L67-L82
SpoonX/SxCore
library/SxCore/Html/ExcerptExtractor.php
ExcerptExtractor.trimMarkup
protected function trimMarkup($elements, $length) { $markup = ''; $textLength = 0; foreach ($elements as $element) { $maxLength = $length - $textLength; $renderAlternative = false; if ($element->firstChild instanceof DOMText) { $renderAlternative = $element; $element = $element->firstChild; } if ($element instanceof DOMText) { $trimmedElement = $this->trimDOMTextElement($element, $maxLength); $textLength = $textLength + $trimmedElement['text_length']; if (false !== $renderAlternative) { $renderAlternative->firstChild->nodeValue = $this->DOMDocument->saveHTML($trimmedElement['element']); $trimmedElement['element'] = $renderAlternative; } $markup = $markup . $this->DOMDocument->saveHTML($trimmedElement['element']); if ($trimmedElement['text_met_limit']) { return array( 'finished' => true, 'markup' => $markup, 'element' => $elements, 'length' => $textLength, ); } continue; } throw new Exception\RuntimeException( 'Invalid markup detected. Only supports single-level dept.' ); } return array( 'finished' => false, 'markup' => $markup, 'element' => $elements, 'length' => $textLength, ); }
php
protected function trimMarkup($elements, $length) { $markup = ''; $textLength = 0; foreach ($elements as $element) { $maxLength = $length - $textLength; $renderAlternative = false; if ($element->firstChild instanceof DOMText) { $renderAlternative = $element; $element = $element->firstChild; } if ($element instanceof DOMText) { $trimmedElement = $this->trimDOMTextElement($element, $maxLength); $textLength = $textLength + $trimmedElement['text_length']; if (false !== $renderAlternative) { $renderAlternative->firstChild->nodeValue = $this->DOMDocument->saveHTML($trimmedElement['element']); $trimmedElement['element'] = $renderAlternative; } $markup = $markup . $this->DOMDocument->saveHTML($trimmedElement['element']); if ($trimmedElement['text_met_limit']) { return array( 'finished' => true, 'markup' => $markup, 'element' => $elements, 'length' => $textLength, ); } continue; } throw new Exception\RuntimeException( 'Invalid markup detected. Only supports single-level dept.' ); } return array( 'finished' => false, 'markup' => $markup, 'element' => $elements, 'length' => $textLength, ); }
@param $elements @param $length @throws Exception\RuntimeException @return array
https://github.com/SpoonX/SxCore/blob/8f914e3737826c408443d6d458dd9a169c82c940/library/SxCore/Html/ExcerptExtractor.php#L91-L140
caouecs/Laravel4-Clef
example/ClefController.php
ClefController.authentication
public function authentication() { $response = \Aperdia\Clef::authentication($_GET['code']); // error if (!$response) { $error = 'Error'; // error } elseif (isset($response['error'])) { $error = $response['error']; // success } elseif (isset($response['success'])) { // verif if exists account in Authentication table $verif = Authentication::whereprovider("clef")->whereprovider_uid($response['info']['id'])->first(); // no account if (empty($verif)) { // Find account } else { // Find the user using the user id $user = User::find($verif->user_id); // RAZ logout if ($user->logout == 1) { $user->logout = 0; $user->save(); } // Log the user in Auth::login($user); return Redirect::intended('/'); } // error } else { $error = 'Unknown error'; } return Redirect::to("login")->withErrors($error); }
php
public function authentication() { $response = \Aperdia\Clef::authentication($_GET['code']); // error if (!$response) { $error = 'Error'; // error } elseif (isset($response['error'])) { $error = $response['error']; // success } elseif (isset($response['success'])) { // verif if exists account in Authentication table $verif = Authentication::whereprovider("clef")->whereprovider_uid($response['info']['id'])->first(); // no account if (empty($verif)) { // Find account } else { // Find the user using the user id $user = User::find($verif->user_id); // RAZ logout if ($user->logout == 1) { $user->logout = 0; $user->save(); } // Log the user in Auth::login($user); return Redirect::intended('/'); } // error } else { $error = 'Unknown error'; } return Redirect::to("login")->withErrors($error); }
Authentication with Clef account @return Response
https://github.com/caouecs/Laravel4-Clef/blob/d9d3596df734184cc9937bd83fd06ab8f0f8f7b4/example/ClefController.php#L11-L52
caouecs/Laravel4-Clef
example/ClefController.php
ClefController.logout
public function logout() { // Token from Clef.io if (isset($_POST['logout_token'])) { // Verif token $clef = \Aperdia\Clef::logout($_POST['logout_token']); if (!$clef) { // Verif in Authentication table $auth = Authentication::whereprovider("clef")->whereprovider_uid($clef)->first(); if (!empty($auth)) { $user = User::find($auth->user_id); if (!empty($user)) { $user->logout = 1; $user->save(); } } } } }
php
public function logout() { // Token from Clef.io if (isset($_POST['logout_token'])) { // Verif token $clef = \Aperdia\Clef::logout($_POST['logout_token']); if (!$clef) { // Verif in Authentication table $auth = Authentication::whereprovider("clef")->whereprovider_uid($clef)->first(); if (!empty($auth)) { $user = User::find($auth->user_id); if (!empty($user)) { $user->logout = 1; $user->save(); } } } } }
Logout by WebHook @access public @return Response
https://github.com/caouecs/Laravel4-Clef/blob/d9d3596df734184cc9937bd83fd06ab8f0f8f7b4/example/ClefController.php#L60-L81
MetaModels/attribute_translatedurl
src/EventListener/UrlWizardHandler.php
UrlWizardHandler.getWizard
public function getWizard(ManipulateWidgetEvent $event) { if ($event->getModel()->getProviderName() !== $this->metaModel->getTableName() || $event->getProperty()->getName() !== $this->propertyName ) { return; } $propName = $event->getProperty()->getName(); $model = $event->getModel(); $inputId = $propName . (!$this->metaModel->getAttribute($this->propertyName)->get('trim_title') ? '_1' : ''); $translator = $event->getEnvironment()->getTranslator(); $this->addStylesheet('metamodelsattribute_url', 'bundles/metamodelsattributeurl/style.css'); $currentField = \deserialize($model->getProperty($propName), true); /** @var GenerateHtmlEvent $imageEvent */ $imageEvent = $event->getEnvironment()->getEventDispatcher()->dispatch( ContaoEvents::IMAGE_GET_HTML, new GenerateHtmlEvent( 'pickpage.gif', $translator->translate('pagepicker', 'MSC'), 'style="vertical-align:top;cursor:pointer"' ) ); $event->getWidget()->wizard = ' <a href="contao/page.php?do=' . Input::get('do') . '&amp;table=' . $this->metaModel->getTableName() . '&amp;field=' . $inputId . '&amp;value=' . \str_replace(array('{{link_url::', '}}'), '', $currentField[1]) . '" title="' . StringUtil::specialchars($translator->translate('pagepicker', 'MSC')) . '" onclick="Backend.getScrollOffset();'. 'Backend.openModalSelector({\'width\':765,\'title\':\'' . StringUtil::specialchars(\str_replace("'", "\\'", $translator->translate('page.0', 'MOD'))) . '\',\'url\':this.href,\'id\':\'' . $inputId . '\',\'tag\':\'ctrl_' . $inputId . '\',\'self\':this});' . 'return false">' . $imageEvent->getHtml() . '</a>'; }
php
public function getWizard(ManipulateWidgetEvent $event) { if ($event->getModel()->getProviderName() !== $this->metaModel->getTableName() || $event->getProperty()->getName() !== $this->propertyName ) { return; } $propName = $event->getProperty()->getName(); $model = $event->getModel(); $inputId = $propName . (!$this->metaModel->getAttribute($this->propertyName)->get('trim_title') ? '_1' : ''); $translator = $event->getEnvironment()->getTranslator(); $this->addStylesheet('metamodelsattribute_url', 'bundles/metamodelsattributeurl/style.css'); $currentField = \deserialize($model->getProperty($propName), true); /** @var GenerateHtmlEvent $imageEvent */ $imageEvent = $event->getEnvironment()->getEventDispatcher()->dispatch( ContaoEvents::IMAGE_GET_HTML, new GenerateHtmlEvent( 'pickpage.gif', $translator->translate('pagepicker', 'MSC'), 'style="vertical-align:top;cursor:pointer"' ) ); $event->getWidget()->wizard = ' <a href="contao/page.php?do=' . Input::get('do') . '&amp;table=' . $this->metaModel->getTableName() . '&amp;field=' . $inputId . '&amp;value=' . \str_replace(array('{{link_url::', '}}'), '', $currentField[1]) . '" title="' . StringUtil::specialchars($translator->translate('pagepicker', 'MSC')) . '" onclick="Backend.getScrollOffset();'. 'Backend.openModalSelector({\'width\':765,\'title\':\'' . StringUtil::specialchars(\str_replace("'", "\\'", $translator->translate('page.0', 'MOD'))) . '\',\'url\':this.href,\'id\':\'' . $inputId . '\',\'tag\':\'ctrl_' . $inputId . '\',\'self\':this});' . 'return false">' . $imageEvent->getHtml() . '</a>'; }
Build the wizard string. @param ManipulateWidgetEvent $event The event. @return void
https://github.com/MetaModels/attribute_translatedurl/blob/ad6b4967244614be49d382934043c766b5fa08d8/src/EventListener/UrlWizardHandler.php#L68-L106
pizepei/func
src/Func.php
Func.M
public static function M($name) { $name = explode('.',$name); if(count($name) >1){ return static::$class = 'pizepei\func\\'.$name[0].'\\'.ucfirst($name[1]); }else{ return static::$class = 'pizepei\func\\'.$name[0].'\\'.ucfirst($name[0]); } }
php
public static function M($name) { $name = explode('.',$name); if(count($name) >1){ return static::$class = 'pizepei\func\\'.$name[0].'\\'.ucfirst($name[1]); }else{ return static::$class = 'pizepei\func\\'.$name[0].'\\'.ucfirst($name[0]); } }
分类
https://github.com/pizepei/func/blob/83d4be52814d8b38c60c736ecdf82e5cd0518b27/src/Func.php#L18-L27
mlocati/concrete5-translation-library
src/Parser/DynamicItem/PermissionKey.php
PermissionKey.parseManual
public function parseManual(\Gettext\Translations $translations, $concrete5version) { if (class_exists('\PermissionKeyCategory', true) && method_exists('\PermissionKeyCategory', 'getList')) { foreach (\PermissionKeyCategory::getList() as $pkc) { $pkcHandle = $pkc->getPermissionKeyCategoryHandle(); foreach (\PermissionKey::getList($pkcHandle) as $pk) { $this->addTranslation($translations, $pk->getPermissionKeyName(), 'PermissionKeyName'); $this->addTranslation($translations, $pk->getPermissionKeyDescription(), 'PermissionKeyDescription'); } } } }
php
public function parseManual(\Gettext\Translations $translations, $concrete5version) { if (class_exists('\PermissionKeyCategory', true) && method_exists('\PermissionKeyCategory', 'getList')) { foreach (\PermissionKeyCategory::getList() as $pkc) { $pkcHandle = $pkc->getPermissionKeyCategoryHandle(); foreach (\PermissionKey::getList($pkcHandle) as $pk) { $this->addTranslation($translations, $pk->getPermissionKeyName(), 'PermissionKeyName'); $this->addTranslation($translations, $pk->getPermissionKeyDescription(), 'PermissionKeyDescription'); } } } }
{@inheritdoc} @see \C5TL\Parser\DynamicItem\DynamicItem::parseManual()
https://github.com/mlocati/concrete5-translation-library/blob/26f806c8c1ecb6ce63115a4058ab396303622e00/src/Parser/DynamicItem/PermissionKey.php#L35-L46
mlocati/concrete5-translation-library
src/Parser/DynamicItem/JobSet.php
JobSet.parseManual
public function parseManual(\Gettext\Translations $translations, $concrete5version) { if (class_exists('\JobSet', true)) { foreach (\JobSet::getList() as $js) { $this->addTranslation($translations, $js->getJobSetName(), 'JobSetName'); } } }
php
public function parseManual(\Gettext\Translations $translations, $concrete5version) { if (class_exists('\JobSet', true)) { foreach (\JobSet::getList() as $js) { $this->addTranslation($translations, $js->getJobSetName(), 'JobSetName'); } } }
{@inheritdoc} @see \C5TL\Parser\DynamicItem\DynamicItem::parseManual()
https://github.com/mlocati/concrete5-translation-library/blob/26f806c8c1ecb6ce63115a4058ab396303622e00/src/Parser/DynamicItem/JobSet.php#L35-L42
schpill/thin
src/Smb.php
smb.url_stat
function url_stat($url, $flags = STREAM_URL_STAT_LINK) { if ($s = smb::getstatcache($url)) { return $s; } list ($stat, $pu) = array(array(), smb::parse_url($url)); switch ($pu['type']) { case 'host': if ($o = smb::look ($pu)) $stat = stat ("/tmp"); else error_log ("url_stat(): list failed for host '{$host}'", E_USER_WARNING); break; case 'share': if ($o = smb::look($pu)) { $found = false; $lshare = strtolower ($pu['share']); # fix by Eric Leung foreach ($o['disk'] as $s) if ($lshare == strtolower($s)) { $found = true; $stat = stat ("/tmp"); break; } if (!$found) error_log ("url_stat(): disk resource '{$share}' not found in '{$host}'", E_USER_WARNING); } break; case 'path': if ($o = smb::execute('dir "' . $pu['path'] . '"', $pu)) { $p = explode("[\\]", $pu['path']); $name = $p[count($p)-1]; if (isset($o['info'][$name])) { $stat = smb::addstatcache ($url, $o['info'][$name]); } else { error_log("url_stat(): path '{$pu['path']}' not found", E_USER_WARNING); } } else { error_log("url_stat(): dir failed for path '{$pu['path']}'", E_USER_WARNING); } break; default: error_log('error in URL', E_USER_ERROR); } return $stat; }
php
function url_stat($url, $flags = STREAM_URL_STAT_LINK) { if ($s = smb::getstatcache($url)) { return $s; } list ($stat, $pu) = array(array(), smb::parse_url($url)); switch ($pu['type']) { case 'host': if ($o = smb::look ($pu)) $stat = stat ("/tmp"); else error_log ("url_stat(): list failed for host '{$host}'", E_USER_WARNING); break; case 'share': if ($o = smb::look($pu)) { $found = false; $lshare = strtolower ($pu['share']); # fix by Eric Leung foreach ($o['disk'] as $s) if ($lshare == strtolower($s)) { $found = true; $stat = stat ("/tmp"); break; } if (!$found) error_log ("url_stat(): disk resource '{$share}' not found in '{$host}'", E_USER_WARNING); } break; case 'path': if ($o = smb::execute('dir "' . $pu['path'] . '"', $pu)) { $p = explode("[\\]", $pu['path']); $name = $p[count($p)-1]; if (isset($o['info'][$name])) { $stat = smb::addstatcache ($url, $o['info'][$name]); } else { error_log("url_stat(): path '{$pu['path']}' not found", E_USER_WARNING); } } else { error_log("url_stat(): dir failed for path '{$pu['path']}'", E_USER_WARNING); } break; default: error_log('error in URL', E_USER_ERROR); } return $stat; }
# stats
https://github.com/schpill/thin/blob/a9102d9d6f70e8b0f6be93153f70849f46489ee1/src/Smb.php#L167-L209
schpill/thin
src/Smb.php
smb_stream_wrapper.dir_opendir
function dir_opendir ($url, $options) { if ($d = $this->getdircache ($url)) { $this->dir = $d; $this->dir_index = 0; return TRUE; } $pu = smb::parse_url ($url); switch ($pu['type']) { case 'host': if ($o = smb::look ($pu)) { $this->dir = $o['disk']; $this->dir_index = 0; } else { error_log ("dir_opendir(): list failed for host '{$pu['host']}'", E_USER_WARNING); } break; case 'share': case 'path': if ($o = smb::execute ('dir "'.$pu['path'].'\*"', $pu)) { $this->dir = array_keys($o['info']); $this->dir_index = 0; $this->adddircache ($url, $this->dir); foreach ($o['info'] as $name => $info) { smb::addstatcache($url . '/' . urlencode($name), $info); } } else { error_log ("dir_opendir(): dir failed for path '{$path}'", E_USER_WARNING); } break; default: error_log ('dir_opendir(): error in URL', E_USER_ERROR); } return TRUE; }
php
function dir_opendir ($url, $options) { if ($d = $this->getdircache ($url)) { $this->dir = $d; $this->dir_index = 0; return TRUE; } $pu = smb::parse_url ($url); switch ($pu['type']) { case 'host': if ($o = smb::look ($pu)) { $this->dir = $o['disk']; $this->dir_index = 0; } else { error_log ("dir_opendir(): list failed for host '{$pu['host']}'", E_USER_WARNING); } break; case 'share': case 'path': if ($o = smb::execute ('dir "'.$pu['path'].'\*"', $pu)) { $this->dir = array_keys($o['info']); $this->dir_index = 0; $this->adddircache ($url, $this->dir); foreach ($o['info'] as $name => $info) { smb::addstatcache($url . '/' . urlencode($name), $info); } } else { error_log ("dir_opendir(): dir failed for path '{$path}'", E_USER_WARNING); } break; default: error_log ('dir_opendir(): error in URL', E_USER_ERROR); } return TRUE; }
# directories
https://github.com/schpill/thin/blob/a9102d9d6f70e8b0f6be93153f70849f46489ee1/src/Smb.php#L293-L329
schpill/thin
src/Smb.php
smb_stream_wrapper.stream_open
function stream_open ($url, $mode, $options, $opened_path) { $this->url = $url; $this->mode = $mode; $this->parsed_url = $pu = smb::parse_url($url); if ($pu['type'] <> 'path') error_log('stream_open(): error in URL', E_USER_ERROR); switch ($mode) { case 'r': case 'r+': case 'rb': case 'a': case 'a+': $this->tmpfile = tempnam('/tmp', 'smb.down.'); smb::execute ('get "'.$pu['path'].'" "'.$this->tmpfile.'"', $pu); break; case 'w': case 'w+': case 'wb': case 'x': case 'x+': $this->cleardircache(); $this->tmpfile = tempnam('/tmp', 'smb.up.'); } $this->stream = fopen ($this->tmpfile, $mode); return TRUE; }
php
function stream_open ($url, $mode, $options, $opened_path) { $this->url = $url; $this->mode = $mode; $this->parsed_url = $pu = smb::parse_url($url); if ($pu['type'] <> 'path') error_log('stream_open(): error in URL', E_USER_ERROR); switch ($mode) { case 'r': case 'r+': case 'rb': case 'a': case 'a+': $this->tmpfile = tempnam('/tmp', 'smb.down.'); smb::execute ('get "'.$pu['path'].'" "'.$this->tmpfile.'"', $pu); break; case 'w': case 'w+': case 'wb': case 'x': case 'x+': $this->cleardircache(); $this->tmpfile = tempnam('/tmp', 'smb.up.'); } $this->stream = fopen ($this->tmpfile, $mode); return TRUE; }
# streams
https://github.com/schpill/thin/blob/a9102d9d6f70e8b0f6be93153f70849f46489ee1/src/Smb.php#L360-L383
CodeCollab/Http
src/Cookie/Factory.php
Factory.build
public function build(string $key, $value, \DateTimeInterface $expire = null): Cookie { return new Cookie($key, $this->encryptor->encrypt($value), $expire, '/', $this->domain, $this->secure); }
php
public function build(string $key, $value, \DateTimeInterface $expire = null): Cookie { return new Cookie($key, $this->encryptor->encrypt($value), $expire, '/', $this->domain, $this->secure); }
Builds a new cookie @param string $key The name of the cookie @param mixed $value The value of the cookie @param \DateTimeInterface $expire The expiration time of the cookie @return \CodeCollab\Http\Cookie\Cookie The built cookie
https://github.com/CodeCollab/Http/blob/b1f8306b20daebcf26ed4b13c032c5bc008a0861/src/Cookie/Factory.php#L67-L70
rujiali/acquia-site-factory-cli
src/AppBundle/Connector/ConnectorSites.php
ConnectorSites.clearCache
public function clearCache() { if ($this->connector->getURL() === null) { return 'Cannot find site URL from configuration.'; } $url = $this->connector->getURL().self::VERSION.$this->connector->getSiteID().'/cache-clear'; $params = []; $response = $this->connector->connecting($url, $params, 'POST'); return $response; }
php
public function clearCache() { if ($this->connector->getURL() === null) { return 'Cannot find site URL from configuration.'; } $url = $this->connector->getURL().self::VERSION.$this->connector->getSiteID().'/cache-clear'; $params = []; $response = $this->connector->connecting($url, $params, 'POST'); return $response; }
Clear site cache. @return mixed|string
https://github.com/rujiali/acquia-site-factory-cli/blob/c9dbb9dfd71408adff0ea26db94678a61c584df6/src/AppBundle/Connector/ConnectorSites.php#L34-L44
rujiali/acquia-site-factory-cli
src/AppBundle/Connector/ConnectorSites.php
ConnectorSites.createBackup
public function createBackup($label, $components) { if ($this->connector->getURL() === null) { return 'Cannot find site URL from configuration.'; } $url = $this->connector->getURL().self::VERSION.$this->connector->getSiteID().'/backup'; $params = [ 'label' => $label, 'components' => $components, ]; $response = $this->connector->connecting($url, $params, 'POST'); // @codingStandardsIgnoreStart if (isset($response->task_id)) { return $response->task_id; // @codingStandardsIgnoreEnd } return $response; }
php
public function createBackup($label, $components) { if ($this->connector->getURL() === null) { return 'Cannot find site URL from configuration.'; } $url = $this->connector->getURL().self::VERSION.$this->connector->getSiteID().'/backup'; $params = [ 'label' => $label, 'components' => $components, ]; $response = $this->connector->connecting($url, $params, 'POST'); // @codingStandardsIgnoreStart if (isset($response->task_id)) { return $response->task_id; // @codingStandardsIgnoreEnd } return $response; }
Create backup for specific site in site factory. @param string $label Backup label. @param array $components Backup components. @return integer Task ID.
https://github.com/rujiali/acquia-site-factory-cli/blob/c9dbb9dfd71408adff0ea26db94678a61c584df6/src/AppBundle/Connector/ConnectorSites.php#L55-L75
rujiali/acquia-site-factory-cli
src/AppBundle/Connector/ConnectorSites.php
ConnectorSites.deleteBackup
public function deleteBackup($backupId, $callbackUrl, $callbackMethod, $callerData) { if ($this->connector->getURL() === null) { return 'Cannot find site URL from configuration.'; } $url = $this->connector->getURL().self::VERSION.$this->connector->getSiteID().'/backups/'.$backupId; $params = [ 'callback_url' => $callbackUrl, 'callback_method' => $callbackMethod, 'callerData' => $callerData, ]; $response = $this->connector->connecting($url, $params, 'DELETE'); // @codingStandardsIgnoreStart if (isset($response->task_id)) { return $response->task_id; // @codingStandardsIgnoreEnd } return $response; }
php
public function deleteBackup($backupId, $callbackUrl, $callbackMethod, $callerData) { if ($this->connector->getURL() === null) { return 'Cannot find site URL from configuration.'; } $url = $this->connector->getURL().self::VERSION.$this->connector->getSiteID().'/backups/'.$backupId; $params = [ 'callback_url' => $callbackUrl, 'callback_method' => $callbackMethod, 'callerData' => $callerData, ]; $response = $this->connector->connecting($url, $params, 'DELETE'); // @codingStandardsIgnoreStart if (isset($response->task_id)) { return $response->task_id; // @codingStandardsIgnoreEnd } return $response; }
Delete backup. @param int $backupId BackupId. @param string $callbackUrl Callback URL. @param string $callbackMethod Callback method. @param string $callerData Caller data in JSON format. @return mixed|string
https://github.com/rujiali/acquia-site-factory-cli/blob/c9dbb9dfd71408adff0ea26db94678a61c584df6/src/AppBundle/Connector/ConnectorSites.php#L87-L108
rujiali/acquia-site-factory-cli
src/AppBundle/Connector/ConnectorSites.php
ConnectorSites.getBackupURL
public function getBackupURL($backupId) { if ($this->connector->getURL() === null) { return 'Cannot find site URL from configuration.'; } $url = $this->connector->getURL().self::VERSION.$this->connector->getSiteID().'/backups/'.$backupId.'/url'; $params = []; $response = $this->connector->connecting($url, $params, 'GET'); if (isset($response->url)) { return $response->url; } return $response; }
php
public function getBackupURL($backupId) { if ($this->connector->getURL() === null) { return 'Cannot find site URL from configuration.'; } $url = $this->connector->getURL().self::VERSION.$this->connector->getSiteID().'/backups/'.$backupId.'/url'; $params = []; $response = $this->connector->connecting($url, $params, 'GET'); if (isset($response->url)) { return $response->url; } return $response; }
Get backup URL. @param string $backupId Backup ID. @return string
https://github.com/rujiali/acquia-site-factory-cli/blob/c9dbb9dfd71408adff0ea26db94678a61c584df6/src/AppBundle/Connector/ConnectorSites.php#L117-L130
rujiali/acquia-site-factory-cli
src/AppBundle/Connector/ConnectorSites.php
ConnectorSites.getSiteDetails
public function getSiteDetails($siteId) { if ($this->connector->getURL() === null) { return 'Cannot find site URL from configuration.'; } $url = $this->connector->getURL().self::VERSION.$siteId; $params = []; $response = $this->connector->connecting($url, $params, 'GET'); return $response; }
php
public function getSiteDetails($siteId) { if ($this->connector->getURL() === null) { return 'Cannot find site URL from configuration.'; } $url = $this->connector->getURL().self::VERSION.$siteId; $params = []; $response = $this->connector->connecting($url, $params, 'GET'); return $response; }
Get site details @param int $siteId Site ID. @return mixed|string
https://github.com/rujiali/acquia-site-factory-cli/blob/c9dbb9dfd71408adff0ea26db94678a61c584df6/src/AppBundle/Connector/ConnectorSites.php#L161-L171
rujiali/acquia-site-factory-cli
src/AppBundle/Connector/ConnectorSites.php
ConnectorSites.listBackups
public function listBackups() { if ($this->connector->getURL() === null) { return 'Cannot find site URL from configuration.'; } $url = $this->connector->getURL().self::VERSION.$this->connector->getSiteID().'/backups'; $params = []; $response = $this->connector->connecting($url, $params, 'GET'); if (isset($response->backups)) { return $response->backups; } return $response; }
php
public function listBackups() { if ($this->connector->getURL() === null) { return 'Cannot find site URL from configuration.'; } $url = $this->connector->getURL().self::VERSION.$this->connector->getSiteID().'/backups'; $params = []; $response = $this->connector->connecting($url, $params, 'GET'); if (isset($response->backups)) { return $response->backups; } return $response; }
List all backups in for specific site in site factory. @return mixed
https://github.com/rujiali/acquia-site-factory-cli/blob/c9dbb9dfd71408adff0ea26db94678a61c584df6/src/AppBundle/Connector/ConnectorSites.php#L178-L192
rujiali/acquia-site-factory-cli
src/AppBundle/Connector/ConnectorSites.php
ConnectorSites.getLastBackupTime
public function getLastBackupTime() { $backups = $this->listBackups(); if (is_array($backups)) { if (!empty($backups)) { $timestamp = $backups[0]->timestamp; return $timestamp; } return 'There is no backup available.'; } return $backups; }
php
public function getLastBackupTime() { $backups = $this->listBackups(); if (is_array($backups)) { if (!empty($backups)) { $timestamp = $backups[0]->timestamp; return $timestamp; } return 'There is no backup available.'; } return $backups; }
Get the last backup timestamp. @return mixed|string
https://github.com/rujiali/acquia-site-factory-cli/blob/c9dbb9dfd71408adff0ea26db94678a61c584df6/src/AppBundle/Connector/ConnectorSites.php#L199-L213
rujiali/acquia-site-factory-cli
src/AppBundle/Connector/ConnectorSites.php
ConnectorSites.backupSuccessIndicator
public function backupSuccessIndicator($label) { $backups = $this->listBackups(); if (is_array($backups)) { if (!empty($backups)) { if ($backups[0]->label === $label) { return true; } return false; } return false; } }
php
public function backupSuccessIndicator($label) { $backups = $this->listBackups(); if (is_array($backups)) { if (!empty($backups)) { if ($backups[0]->label === $label) { return true; } return false; } return false; } }
Indicate when required backup is generated. @param string $label Backup label. @return bool
https://github.com/rujiali/acquia-site-factory-cli/blob/c9dbb9dfd71408adff0ea26db94678a61c584df6/src/AppBundle/Connector/ConnectorSites.php#L222-L236
rujiali/acquia-site-factory-cli
src/AppBundle/Connector/ConnectorSites.php
ConnectorSites.listSites
public function listSites($limit, $page, $canary = false) { if ($this->connector->getURL() === null) { return 'Cannot find site URL from configuration.'; } $params = [ 'limit' => $limit, 'page' => $page, 'canary' => $canary, ]; $url = $this->connector->getURL().self::VERSION; $response = $this->connector->connecting($url, $params, 'GET'); if (isset($response->sites)) { return $response->sites; } return $response; }
php
public function listSites($limit, $page, $canary = false) { if ($this->connector->getURL() === null) { return 'Cannot find site URL from configuration.'; } $params = [ 'limit' => $limit, 'page' => $page, 'canary' => $canary, ]; $url = $this->connector->getURL().self::VERSION; $response = $this->connector->connecting($url, $params, 'GET'); if (isset($response->sites)) { return $response->sites; } return $response; }
List sites. @param int $limit Limit number. @param int $page Page number. @param boolean $canary No value necessary. @return string
https://github.com/rujiali/acquia-site-factory-cli/blob/c9dbb9dfd71408adff0ea26db94678a61c584df6/src/AppBundle/Connector/ConnectorSites.php#L263-L282
anklimsk/cakephp-console-installer
Console/Helper/StateShellHelper.php
StateShellHelper._getState
protected function _getState($message = null, $state = null, $maxWidth = 63) { $maxWidth = (int)$maxWidth; if (empty($message) || empty($state) || ($maxWidth <= 0)) { return $message; } $lengthMessage = mb_strlen(strip_tags($message)); $lengthState = mb_strlen(strip_tags($state)); $nRepeat = $maxWidth - $lengthMessage - $lengthState; if ($nRepeat <= 0) { $nRepeat = 1; } $space = str_repeat(' ', $nRepeat); $result = $message . $space . $state; return $result; }
php
protected function _getState($message = null, $state = null, $maxWidth = 63) { $maxWidth = (int)$maxWidth; if (empty($message) || empty($state) || ($maxWidth <= 0)) { return $message; } $lengthMessage = mb_strlen(strip_tags($message)); $lengthState = mb_strlen(strip_tags($state)); $nRepeat = $maxWidth - $lengthMessage - $lengthState; if ($nRepeat <= 0) { $nRepeat = 1; } $space = str_repeat(' ', $nRepeat); $result = $message . $space . $state; return $result; }
Formatting messages add spaces to align the state on the right side @param string $message Message for formatting. @param string $state State for concatenation with message. @param int $maxWidth The maximum length of a formatted message. @return string Formatted string
https://github.com/anklimsk/cakephp-console-installer/blob/76136550e856ff4f8fd3634b77633f86510f63e9/Console/Helper/StateShellHelper.php#L32-L49
anklimsk/cakephp-console-installer
Console/Helper/StateShellHelper.php
StateShellHelper.getState
public function getState($message = null, $state = null, $maxWidth = 63) { return $this->_getState($message, $state, $maxWidth); }
php
public function getState($message = null, $state = null, $maxWidth = 63) { return $this->_getState($message, $state, $maxWidth); }
Formatting messages add spaces to align the state on the right side @param string $message Message for formatting. @param string $state State for concatenation with message. @param int $maxWidth The maximum length of a formatted message. @return string Formatted string
https://github.com/anklimsk/cakephp-console-installer/blob/76136550e856ff4f8fd3634b77633f86510f63e9/Console/Helper/StateShellHelper.php#L59-L61
anklimsk/cakephp-console-installer
Console/Helper/StateShellHelper.php
StateShellHelper.output
public function output($args) { $args += ['', '', 63]; $this->_consoleOutput->write($this->_getState($args[0], $args[1], $args[2])); }
php
public function output($args) { $args += ['', '', 63]; $this->_consoleOutput->write($this->_getState($args[0], $args[1], $args[2])); }
This method should output formatted message. @param array $args The arguments for the `StateShellHelper::_getState()`. @return void
https://github.com/anklimsk/cakephp-console-installer/blob/76136550e856ff4f8fd3634b77633f86510f63e9/Console/Helper/StateShellHelper.php#L69-L72
chilimatic/chilimatic-framework
lib/database/sql/mysql/Tool.php
Tool.db_sanitize
static public function db_sanitize($string = '') { function mres($string = '') { $search = array("\\", "\x00", "\n", "\r", "'", '"', "\x1a"); $replace = array("\\\\", "\\0", "\\n", "\\r", "\'", '\"', "\\Z"); return str_replace($search, $replace, $string); } if (empty($string)) return ''; // remove only double empty single quotes $string = (string)preg_replace("/[']{2}/", "'", $string); $string = (string)str_replace("\\n", "\n", $string); $string = (string)str_replace("\\r", "\r", $string); $string = (string)str_replace("\\\\", "\\", $string); $string = (string)mres($string); return $string; }
php
static public function db_sanitize($string = '') { function mres($string = '') { $search = array("\\", "\x00", "\n", "\r", "'", '"', "\x1a"); $replace = array("\\\\", "\\0", "\\n", "\\r", "\'", '\"', "\\Z"); return str_replace($search, $replace, $string); } if (empty($string)) return ''; // remove only double empty single quotes $string = (string)preg_replace("/[']{2}/", "'", $string); $string = (string)str_replace("\\n", "\n", $string); $string = (string)str_replace("\\r", "\r", $string); $string = (string)str_replace("\\\\", "\\", $string); $string = (string)mres($string); return $string; }
generic clean up from db_quoteStr() clone @param string $string @return string
https://github.com/chilimatic/chilimatic-framework/blob/8df7f12e75d75d3fd2197a58c80d39cbb4b9ff12/lib/database/sql/mysql/Tool.php#L19-L39
chilimatic/chilimatic-framework
lib/database/sql/mysql/Tool.php
Tool.mysql_aes_decrypt
static public function mysql_aes_decrypt($val, $ky) { if (empty($ky) && empty($val)) return null; $key = "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"; for ($a = 0; $a < strlen($ky); $a++) { $key[$a % 16] = chr(ord($key[$a % 16]) ^ ord($ky[$a])); } $mode = MCRYPT_MODE_ECB; $enc = MCRYPT_RIJNDAEL_128; $dec = @mcrypt_decrypt($enc, $key, $val, $mode, @mcrypt_create_iv(@mcrypt_get_iv_size($enc, $mode), MCRYPT_DEV_URANDOM)); return rtrim($dec, ((ord(substr($dec, strlen($dec) - 1, 1)) >= 0 && ord(substr($dec, strlen($dec) - 1, 1)) <= 16) ? chr(ord(substr($dec, strlen($dec) - 1, 1))) : null)); }
php
static public function mysql_aes_decrypt($val, $ky) { if (empty($ky) && empty($val)) return null; $key = "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"; for ($a = 0; $a < strlen($ky); $a++) { $key[$a % 16] = chr(ord($key[$a % 16]) ^ ord($ky[$a])); } $mode = MCRYPT_MODE_ECB; $enc = MCRYPT_RIJNDAEL_128; $dec = @mcrypt_decrypt($enc, $key, $val, $mode, @mcrypt_create_iv(@mcrypt_get_iv_size($enc, $mode), MCRYPT_DEV_URANDOM)); return rtrim($dec, ((ord(substr($dec, strlen($dec) - 1, 1)) >= 0 && ord(substr($dec, strlen($dec) - 1, 1)) <= 16) ? chr(ord(substr($dec, strlen($dec) - 1, 1))) : null)); }
aes mysql decryption (from php.net) http://php.net/manual/de/ref.mcrypt.php @param string $val @param string $ky @return null|string
https://github.com/chilimatic/chilimatic-framework/blob/8df7f12e75d75d3fd2197a58c80d39cbb4b9ff12/lib/database/sql/mysql/Tool.php#L51-L65
chilimatic/chilimatic-framework
lib/database/sql/mysql/Tool.php
Tool.mysql_aes_encrypt
static public function mysql_aes_encrypt($val, $ky) { if (empty($ky) && empty($val)) return null; $key = "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"; for ($a = 0; $a < strlen($ky); $a++) { $key[$a % 16] = chr(ord($key[$a % 16]) ^ ord($ky[$a])); } $mode = MCRYPT_MODE_ECB; $enc = MCRYPT_RIJNDAEL_128; $val = str_pad($val, (16 * (floor(strlen($val) / 16) + (strlen($val) % 16 == 0 ? 2 : 1))), chr(16 - (strlen($val) % 16))); return mcrypt_encrypt($enc, $key, $val, $mode, mcrypt_create_iv(mcrypt_get_iv_size($enc, $mode), MCRYPT_DEV_URANDOM)); }
php
static public function mysql_aes_encrypt($val, $ky) { if (empty($ky) && empty($val)) return null; $key = "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"; for ($a = 0; $a < strlen($ky); $a++) { $key[$a % 16] = chr(ord($key[$a % 16]) ^ ord($ky[$a])); } $mode = MCRYPT_MODE_ECB; $enc = MCRYPT_RIJNDAEL_128; $val = str_pad($val, (16 * (floor(strlen($val) / 16) + (strlen($val) % 16 == 0 ? 2 : 1))), chr(16 - (strlen($val) % 16))); return mcrypt_encrypt($enc, $key, $val, $mode, mcrypt_create_iv(mcrypt_get_iv_size($enc, $mode), MCRYPT_DEV_URANDOM)); }
aes mysql encryption @param string $val @param string $ky @return null|string
https://github.com/chilimatic/chilimatic-framework/blob/8df7f12e75d75d3fd2197a58c80d39cbb4b9ff12/lib/database/sql/mysql/Tool.php#L75-L89
schpill/thin
src/Url/Rule.php
Rule.resolveUrl
public function resolveUrl($url, &$parameters) { $parameters = array(); $patternSegments = $this->segments; $patternSegmentNum = count($patternSegments); $urlSegments = Helper::segmentizeUrl($url); /* * If the number of URL segments is more than the number of pattern segments - return false */ if (count($urlSegments) > count($patternSegments)) return false; /* * Compare pattern and URL segments */ foreach ($patternSegments as $index => $patternSegment) { $patternSegmentLower = mb_strtolower($patternSegment); if (strpos($patternSegment, ':') !== 0) { /* * Static segment */ if (!array_key_exists($index, $urlSegments) || $patternSegmentLower != mb_strtolower($urlSegments[$index])) return false; } else { /* * Dynamic segment. Initialize the parameter */ $paramName = Helper::getParameterName($patternSegment); $parameters[$paramName] = false; /* * Determine whether it is optional */ $optional = Helper::segmentIsOptional($patternSegment); /* * Check if the optional segment has no required segments following it */ if ($optional && $index < $patternSegmentNum - 1) { for ($i = $index + 1; $i < $patternSegmentNum; $i++) { if (!Helper::segmentIsOptional($patternSegments[$i])) { $optional = false; break; } } } /* * If the segment is optional and there is no corresponding value in the URL, assign the default value (if provided) * and skip to the next segment. */ $urlSegmentExists = array_key_exists($index, $urlSegments); if ($optional && !$urlSegmentExists) { $parameters[$paramName] = Helper::getSegmentDefaultValue($patternSegment); continue; } /* * If the segment is not optional and there is no corresponding value in the URL, return false */ if (!$optional && !$urlSegmentExists) return false; /* * Validate the value with the regular expression */ $regexp = Helper::getSegmentRegExp($patternSegment); if ($regexp) { try { if (!preg_match($regexp, $urlSegments[$index])) return false; } catch (\Exception $ex) {} } /* * Set the parameter value */ $parameters[$paramName] = $urlSegments[$index]; } } return true; }
php
public function resolveUrl($url, &$parameters) { $parameters = array(); $patternSegments = $this->segments; $patternSegmentNum = count($patternSegments); $urlSegments = Helper::segmentizeUrl($url); /* * If the number of URL segments is more than the number of pattern segments - return false */ if (count($urlSegments) > count($patternSegments)) return false; /* * Compare pattern and URL segments */ foreach ($patternSegments as $index => $patternSegment) { $patternSegmentLower = mb_strtolower($patternSegment); if (strpos($patternSegment, ':') !== 0) { /* * Static segment */ if (!array_key_exists($index, $urlSegments) || $patternSegmentLower != mb_strtolower($urlSegments[$index])) return false; } else { /* * Dynamic segment. Initialize the parameter */ $paramName = Helper::getParameterName($patternSegment); $parameters[$paramName] = false; /* * Determine whether it is optional */ $optional = Helper::segmentIsOptional($patternSegment); /* * Check if the optional segment has no required segments following it */ if ($optional && $index < $patternSegmentNum - 1) { for ($i = $index + 1; $i < $patternSegmentNum; $i++) { if (!Helper::segmentIsOptional($patternSegments[$i])) { $optional = false; break; } } } /* * If the segment is optional and there is no corresponding value in the URL, assign the default value (if provided) * and skip to the next segment. */ $urlSegmentExists = array_key_exists($index, $urlSegments); if ($optional && !$urlSegmentExists) { $parameters[$paramName] = Helper::getSegmentDefaultValue($patternSegment); continue; } /* * If the segment is not optional and there is no corresponding value in the URL, return false */ if (!$optional && !$urlSegmentExists) return false; /* * Validate the value with the regular expression */ $regexp = Helper::getSegmentRegExp($patternSegment); if ($regexp) { try { if (!preg_match($regexp, $urlSegments[$index])) return false; } catch (\Exception $ex) {} } /* * Set the parameter value */ $parameters[$paramName] = $urlSegments[$index]; } } return true; }
Checks whether a given URL matches a given pattern. @param string $url The URL to check. @param array $parameters A reference to a PHP array variable to return the parameter list fetched from URL. @return boolean Returns true if the URL matches the pattern. Otherwise returns false.
https://github.com/schpill/thin/blob/a9102d9d6f70e8b0f6be93153f70849f46489ee1/src/Url/Rule.php#L83-L169
schpill/thin
src/Url/Rule.php
Rule.name
public function name($name = null) { if ($name === null) return $this->ruleName; $this->ruleName = $name; return $this; }
php
public function name($name = null) { if ($name === null) return $this->ruleName; $this->ruleName = $name; return $this; }
Unique route name @param string $name Unique name for the router object @return object Self
https://github.com/schpill/thin/blob/a9102d9d6f70e8b0f6be93153f70849f46489ee1/src/Url/Rule.php#L177-L184
schpill/thin
src/Url/Rule.php
Rule.pattern
public function pattern($pattern = null) { if ($pattern === null) return $this->rulePattern; $this->rulePattern = $pattern; return $this; }
php
public function pattern($pattern = null) { if ($pattern === null) return $this->rulePattern; $this->rulePattern = $pattern; return $this; }
Route match pattern @param string $pattern Pattern used to match this rule @return object Self
https://github.com/schpill/thin/blob/a9102d9d6f70e8b0f6be93153f70849f46489ee1/src/Url/Rule.php#L192-L199
schpill/thin
src/Url/Rule.php
Rule.condition
public function condition($callback = null) { if ($callback !== null) { if (!is_callable($callback)) { throw new InvalidArgumentException( sprintf( "Condition provided is not a valid callback. Given (%s)", gettype($callback) ) ); } $this->conditionCallback = $callback; return $this; } return $this->conditionCallback; }
php
public function condition($callback = null) { if ($callback !== null) { if (!is_callable($callback)) { throw new InvalidArgumentException( sprintf( "Condition provided is not a valid callback. Given (%s)", gettype($callback) ) ); } $this->conditionCallback = $callback; return $this; } return $this->conditionCallback; }
Condition callback @param callback $callback Callback function to be used when providing custom route match conditions @throws InvalidArgumentException When supplied argument is not a valid callback @return callback
https://github.com/schpill/thin/blob/a9102d9d6f70e8b0f6be93153f70849f46489ee1/src/Url/Rule.php#L208-L226
schpill/thin
src/Url/Rule.php
Rule.afterMatch
public function afterMatch($callback = null) { if ($callback !== null) { if (!is_callable($callback)) { throw new InvalidArgumentException( sprintf( "The after match callback provided is not valid. Given (%s)", gettype($callback) ) ); } $this->afterMatchCallback = $callback; return $this; } return $this->afterMatchCallback; }
php
public function afterMatch($callback = null) { if ($callback !== null) { if (!is_callable($callback)) { throw new InvalidArgumentException( sprintf( "The after match callback provided is not valid. Given (%s)", gettype($callback) ) ); } $this->afterMatchCallback = $callback; return $this; } return $this->afterMatchCallback; }
After match callback @param callback $callback Callback function to be used to modify params after a successful match @throws InvalidArgumentException When supplied argument is not a valid callback @return callback
https://github.com/schpill/thin/blob/a9102d9d6f70e8b0f6be93153f70849f46489ee1/src/Url/Rule.php#L236-L254
znframework/package-hypertext
BuilderExtends.php
BuilderExtends.openCloseTag
protected function openCloseTag($string) { if( $this->tag === true ) { $script = $this->getScriptClass(); $string = $script->open() . $string . $script->close(); } $this->tag = false; return $string; }
php
protected function openCloseTag($string) { if( $this->tag === true ) { $script = $this->getScriptClass(); $string = $script->open() . $string . $script->close(); } $this->tag = false; return $string; }
Protected script open close tag
https://github.com/znframework/package-hypertext/blob/12bbc3bd47a2fae735f638a3e01cc82c1b9c9005/BuilderExtends.php#L64-L76
znframework/package-hypertext
BuilderExtends.php
BuilderExtends.isCallableOption
protected function isCallableOption($callback, $parameter) { $option = 'function(' . $parameter . '){' . PHP_EOL; $option .= Buffering\Callback::do($callback); $option .= '}'; return $option; }
php
protected function isCallableOption($callback, $parameter) { $option = 'function(' . $parameter . '){' . PHP_EOL; $option .= Buffering\Callback::do($callback); $option .= '}'; return $option; }
Protected is callable option
https://github.com/znframework/package-hypertext/blob/12bbc3bd47a2fae735f638a3e01cc82c1b9c9005/BuilderExtends.php#L81-L88
javihgil/genderize-io-client
Model/Name.php
Name.factory
public static function factory(array $data) { $name = new self(); $name->setName($data['name']); $name->setGender($data['gender']); if (isset($data['probability'])) { $name->setProbability(floatval($data['probability'])); } if (isset($data['count'])) { $name->setCount($data['count']); } if (isset($data['country_id'])) { $name->setCountry($data['country_id']); } if (isset($data['language_id'])) { $name->setLanguage($data['language_id']); } return $name; }
php
public static function factory(array $data) { $name = new self(); $name->setName($data['name']); $name->setGender($data['gender']); if (isset($data['probability'])) { $name->setProbability(floatval($data['probability'])); } if (isset($data['count'])) { $name->setCount($data['count']); } if (isset($data['country_id'])) { $name->setCountry($data['country_id']); } if (isset($data['language_id'])) { $name->setLanguage($data['language_id']); } return $name; }
@param array $data @return Name
https://github.com/javihgil/genderize-io-client/blob/e8d712d2fe9ae9df7fc0e53a748843516a4d3a89/Model/Name.php#L50-L74
wdbo/webdocbook
src/WebDocBook/Controller/WebDocBookController.php
WebDocBookController.docbookdocAction
public function docbookdocAction() { $title = _T('User manual'); $md_parser = $this->wdb->getMarkdownParser(); // user manual $path = Kernel::getPath('webdocbook_assets') . Kernel::getConfig('pages:user_manual', ''); $update = Helper::getDateTimeFromTimestamp(filemtime($path)); $file_content = file_get_contents($path); $md_content = $md_parser->transformString($file_content); $output_bag = $md_parser->get('OutputFormatBag'); $user_manual_menu = $output_bag->getHelper() ->getToc($md_content, $output_bag->getFormater()); $user_manual_content= $md_content->getBody(); // MD manual $path_md = Kernel::getPath('webdocbook_assets') . Kernel::getConfig('pages:md_manual', ''); $update_md = Helper::getDateTimeFromTimestamp(filemtime($path_md)); $file_content = file_get_contents($path_md); $md_content = $md_parser->transformString($file_content); $output_bag = $md_parser->get('OutputFormatBag'); $md_manual_menu = $output_bag->getHelper() ->getToc($md_content, $output_bag->getFormater()); $md_manual_content = $md_content->getBody(); // about content $about_content = $this->wdb->display( '', 'credits', array('page_tools'=>'false') ); // global page $page_infos = array( 'name' => $title, 'path' => 'docbookdoc', 'update' => $update_md > $update ? $update_md : $update ); $tpl_params = array( 'breadcrumbs' => array($title), 'title' => $title, 'page' => array(), 'page_tools' => 'false' ); $content = $this->wdb->display( '', 'user_manual', array( 'user_manual_content' => $user_manual_content, 'md_manual_content' => $md_manual_content, 'user_manual_menu' => $user_manual_menu, 'md_manual_menu' => $md_manual_menu, 'about_content' => $about_content, 'page' => $page_infos, 'page_tools' => 'false', 'page_title' => 'true', 'title' => $title, ) ); return array('default', $content, $tpl_params); }
php
public function docbookdocAction() { $title = _T('User manual'); $md_parser = $this->wdb->getMarkdownParser(); // user manual $path = Kernel::getPath('webdocbook_assets') . Kernel::getConfig('pages:user_manual', ''); $update = Helper::getDateTimeFromTimestamp(filemtime($path)); $file_content = file_get_contents($path); $md_content = $md_parser->transformString($file_content); $output_bag = $md_parser->get('OutputFormatBag'); $user_manual_menu = $output_bag->getHelper() ->getToc($md_content, $output_bag->getFormater()); $user_manual_content= $md_content->getBody(); // MD manual $path_md = Kernel::getPath('webdocbook_assets') . Kernel::getConfig('pages:md_manual', ''); $update_md = Helper::getDateTimeFromTimestamp(filemtime($path_md)); $file_content = file_get_contents($path_md); $md_content = $md_parser->transformString($file_content); $output_bag = $md_parser->get('OutputFormatBag'); $md_manual_menu = $output_bag->getHelper() ->getToc($md_content, $output_bag->getFormater()); $md_manual_content = $md_content->getBody(); // about content $about_content = $this->wdb->display( '', 'credits', array('page_tools'=>'false') ); // global page $page_infos = array( 'name' => $title, 'path' => 'docbookdoc', 'update' => $update_md > $update ? $update_md : $update ); $tpl_params = array( 'breadcrumbs' => array($title), 'title' => $title, 'page' => array(), 'page_tools' => 'false' ); $content = $this->wdb->display( '', 'user_manual', array( 'user_manual_content' => $user_manual_content, 'md_manual_content' => $md_manual_content, 'user_manual_menu' => $user_manual_menu, 'md_manual_menu' => $md_manual_menu, 'about_content' => $about_content, 'page' => $page_infos, 'page_tools' => 'false', 'page_title' => 'true', 'title' => $title, ) ); return array('default', $content, $tpl_params); }
The internal documentation action @return array
https://github.com/wdbo/webdocbook/blob/7d4e806f674b6222c9a3e85bfed34e72bc9d584e/src/WebDocBook/Controller/WebDocBookController.php#L91-L150
wdbo/webdocbook
src/WebDocBook/Controller/WebDocBookController.php
WebDocBookController.adminAction
public function adminAction() { $allowed = Kernel::getConfig('expose_admin', false, 'user_config'); $saveadmin = $this->wdb->getUser()->getSession()->get('saveadmin'); $this->wdb->getUser()->getSession()->remove('saveadmin'); if ( (!$allowed || ('true' !== $allowed && '1' !== $allowed)) && (is_null($saveadmin) || $saveadmin != time()) ) { throw new NotFoundException('Forbidden access!'); } $user_config_file = Kernel::getPath('user_config_filepath', true); $user_config = Kernel::get('user_config'); $title = _T('Administration panel'); $page_infos = array( 'name' => $title, 'path' => 'admin', ); $tpl_params = array( 'breadcrumbs' => array($title), 'title' => $title, 'page' => $page_infos, 'page_tools' => 'false' ); $content = $this->wdb->display( '', 'admin_panel', array( 'page' => $page_infos, 'page_tools' => 'false', 'page_title' => 'true', 'title' => $title, 'user_config_file'=> $user_config_file, 'user_config' => $user_config, 'config' => Kernel::getConfig(), ) ); return array('default', $content, $tpl_params); }
php
public function adminAction() { $allowed = Kernel::getConfig('expose_admin', false, 'user_config'); $saveadmin = $this->wdb->getUser()->getSession()->get('saveadmin'); $this->wdb->getUser()->getSession()->remove('saveadmin'); if ( (!$allowed || ('true' !== $allowed && '1' !== $allowed)) && (is_null($saveadmin) || $saveadmin != time()) ) { throw new NotFoundException('Forbidden access!'); } $user_config_file = Kernel::getPath('user_config_filepath', true); $user_config = Kernel::get('user_config'); $title = _T('Administration panel'); $page_infos = array( 'name' => $title, 'path' => 'admin', ); $tpl_params = array( 'breadcrumbs' => array($title), 'title' => $title, 'page' => $page_infos, 'page_tools' => 'false' ); $content = $this->wdb->display( '', 'admin_panel', array( 'page' => $page_infos, 'page_tools' => 'false', 'page_title' => 'true', 'title' => $title, 'user_config_file'=> $user_config_file, 'user_config' => $user_config, 'config' => Kernel::getConfig(), ) ); return array('default', $content, $tpl_params); }
Admin panel action @return array @throws \WebDocBook\Exception\NotFoundException
https://github.com/wdbo/webdocbook/blob/7d4e806f674b6222c9a3e85bfed34e72bc9d584e/src/WebDocBook/Controller/WebDocBookController.php#L157-L198
jasny/iterator-stream
src/CsvOutputStream.php
CsvOutputStream.writeElement
protected function writeElement($element): void { if (!is_array($element)) { $type = (is_object($element) ? get_class($element) . ' ' : '') . gettype($element); trigger_error("Unable to write to element to CSV stream; expect array, $type given", E_USER_WARNING); fwrite($this->stream, "\n"); return; } fputcsv($this->stream, $element, $this->delimiter, $this->enclosure, $this->escapeChar); }
php
protected function writeElement($element): void { if (!is_array($element)) { $type = (is_object($element) ? get_class($element) . ' ' : '') . gettype($element); trigger_error("Unable to write to element to CSV stream; expect array, $type given", E_USER_WARNING); fwrite($this->stream, "\n"); return; } fputcsv($this->stream, $element, $this->delimiter, $this->enclosure, $this->escapeChar); }
Write an element to the stream. @param string[]|mixed $element @return void
https://github.com/jasny/iterator-stream/blob/a4d63eb2825956a879740cc44addd6170f7a481d/src/CsvOutputStream.php#L70-L81
jasny/iterator-stream
src/CsvOutputStream.php
CsvOutputStream.write
public function write(iterable $data, ?array $headers = null): void { $this->assertAttached(); $this->begin($headers); foreach ($data as $element) { $this->writeElement($element); } $this->end(); }
php
public function write(iterable $data, ?array $headers = null): void { $this->assertAttached(); $this->begin($headers); foreach ($data as $element) { $this->writeElement($element); } $this->end(); }
Write to traversable data to stream. @param iterable $data @param string[]|null $headers @return void
https://github.com/jasny/iterator-stream/blob/a4d63eb2825956a879740cc44addd6170f7a481d/src/CsvOutputStream.php#L90-L101
alekitto/metadata
lib/Factory/MetadataFactory.php
MetadataFactory.setMetadataClass
public function setMetadataClass(string $metadataClass): void { if (! class_exists($metadataClass) || ! (new \ReflectionClass($metadataClass))->implementsInterface(ClassMetadataInterface::class)) { throw InvalidArgumentException::create(InvalidArgumentException::INVALID_METADATA_CLASS, $metadataClass); } $this->metadataClass = $metadataClass; }
php
public function setMetadataClass(string $metadataClass): void { if (! class_exists($metadataClass) || ! (new \ReflectionClass($metadataClass))->implementsInterface(ClassMetadataInterface::class)) { throw InvalidArgumentException::create(InvalidArgumentException::INVALID_METADATA_CLASS, $metadataClass); } $this->metadataClass = $metadataClass; }
Set the metadata class to be created by this factory. @param string $metadataClass
https://github.com/alekitto/metadata/blob/0422ac8d7fe72d5fa8cc51b6f1e173866e8afb2c/lib/Factory/MetadataFactory.php#L23-L30
oliwierptak/Everon1
src/Everon/Logger.php
Logger.write
protected function write($message, $level, array $parameters) { if ($this->enabled === false) { return null; } if ($this->log_request_identifier === null) { $this->log_request_identifier = "MISSING_REQUEST_ID"; } $ExceptionToTrace = $message; if ($message instanceof \Exception) { $message = (string) $message; //casting to string will append exception name } $LogDate = ($this->getFactory()->buildDateTime(null, $this->getLogDateTimeZone())); $Filename = $this->getFilenameByLevel($level); if ($Filename->isFile() && $Filename->isWritable() === false) { return $LogDate; } $this->logRotate($Filename); $this->write_count++; $request_id = substr($this->log_request_identifier, 0, 6); $trace_id = substr(md5(uniqid()), 0, 6); $write_count = $this->write_count; $id = "$request_id/$trace_id ($write_count)"; $message = empty($parameters) === false ? vsprintf($message, $parameters) : $message; $message = $LogDate->format($this->getLogDateFormat())." ${id} ".$message; if ($ExceptionToTrace instanceof \Exception) { $trace = $ExceptionToTrace->getTraceAsString().$this->getPreviousTraceDump($ExceptionToTrace->getPrevious()); if ($trace !== '') { $message .= "\n".$trace."\n"; } } if (is_dir($Filename->getPath()) === false) { @mkdir($Filename->getPath(), 0775, true); } @error_log($message."\n", 3, $Filename->getPathname()); return $LogDate; }
php
protected function write($message, $level, array $parameters) { if ($this->enabled === false) { return null; } if ($this->log_request_identifier === null) { $this->log_request_identifier = "MISSING_REQUEST_ID"; } $ExceptionToTrace = $message; if ($message instanceof \Exception) { $message = (string) $message; //casting to string will append exception name } $LogDate = ($this->getFactory()->buildDateTime(null, $this->getLogDateTimeZone())); $Filename = $this->getFilenameByLevel($level); if ($Filename->isFile() && $Filename->isWritable() === false) { return $LogDate; } $this->logRotate($Filename); $this->write_count++; $request_id = substr($this->log_request_identifier, 0, 6); $trace_id = substr(md5(uniqid()), 0, 6); $write_count = $this->write_count; $id = "$request_id/$trace_id ($write_count)"; $message = empty($parameters) === false ? vsprintf($message, $parameters) : $message; $message = $LogDate->format($this->getLogDateFormat())." ${id} ".$message; if ($ExceptionToTrace instanceof \Exception) { $trace = $ExceptionToTrace->getTraceAsString().$this->getPreviousTraceDump($ExceptionToTrace->getPrevious()); if ($trace !== '') { $message .= "\n".$trace."\n"; } } if (is_dir($Filename->getPath()) === false) { @mkdir($Filename->getPath(), 0775, true); } @error_log($message."\n", 3, $Filename->getPathname()); return $LogDate; }
Don't generate errors and only write to log file when possible @param $message \Exception or string @param $level @param $parameters @return \DateTime @throws Exception\Logger
https://github.com/oliwierptak/Everon1/blob/ac93793d1fa517a8394db5f00062f1925dc218a3/src/Everon/Logger.php#L72-L119
vi-kon/laravel-bootstrap
src/ViKon/Bootstrap/Compiler.php
Compiler.enableComponent
public function enableComponent($name) { if (!array_key_exists($name, $this->components)) { throw new NotValidCompoenentException($name . ' component is not valid'); } $this->components[$name] = true; return $this; }
php
public function enableComponent($name) { if (!array_key_exists($name, $this->components)) { throw new NotValidCompoenentException($name . ' component is not valid'); } $this->components[$name] = true; return $this; }
Enable named component for compiler @param string $name component name @return $this
https://github.com/vi-kon/laravel-bootstrap/blob/f4bdfd19241ad19344bef3d2bdbf3658bbbb2ddd/src/ViKon/Bootstrap/Compiler.php#L101-L110
vi-kon/laravel-bootstrap
src/ViKon/Bootstrap/Compiler.php
Compiler.enableAll
public function enableAll(array $except = []) { // Check if excluded components name are exists or not foreach ($except as $name) { if (!array_key_exists($name, $this->components)) { throw new NotValidCompoenentException($name . ' component is not valid'); } } // Enable components foreach ($this->components as $name => &$status) { $status = !in_array($name, $except, true); } return $this; }
php
public function enableAll(array $except = []) { // Check if excluded components name are exists or not foreach ($except as $name) { if (!array_key_exists($name, $this->components)) { throw new NotValidCompoenentException($name . ' component is not valid'); } } // Enable components foreach ($this->components as $name => &$status) { $status = !in_array($name, $except, true); } return $this; }
Enable all components except listed ones @param string[] $except list of components that will be not enabled @return $this
https://github.com/vi-kon/laravel-bootstrap/blob/f4bdfd19241ad19344bef3d2bdbf3658bbbb2ddd/src/ViKon/Bootstrap/Compiler.php#L119-L134
vi-kon/laravel-bootstrap
src/ViKon/Bootstrap/Compiler.php
Compiler.compile
public function compile($force = false) { $jsOutputPath = $this->outputPath['js'] . '/bootstrap.min.js'; $cssOutputPath = $this->outputPath['css'] . '/bootstrap.min.css'; if ($force === true || !$this->filesystem->exists($jsOutputPath)) { $this->filesystem->makeDirectory(dirname($jsOutputPath), 0755, true, true); $this->filesystem->put($jsOutputPath, $this->minifyJs()); $this->lineToOutput('Compiled <info>JavaScript</info> was successfully written to <info>' . $jsOutputPath . '</info> file'); } if ($force === true || !$this->filesystem->exists($cssOutputPath)) { $this->filesystem->makeDirectory(dirname($cssOutputPath), 0755, true, true); $this->filesystem->put($cssOutputPath, $this->minifyCss()); $this->lineToOutput('Compiled <info>StyleSheet</info> was successfully written to <info>' . $jsOutputPath . '</info> file'); } }
php
public function compile($force = false) { $jsOutputPath = $this->outputPath['js'] . '/bootstrap.min.js'; $cssOutputPath = $this->outputPath['css'] . '/bootstrap.min.css'; if ($force === true || !$this->filesystem->exists($jsOutputPath)) { $this->filesystem->makeDirectory(dirname($jsOutputPath), 0755, true, true); $this->filesystem->put($jsOutputPath, $this->minifyJs()); $this->lineToOutput('Compiled <info>JavaScript</info> was successfully written to <info>' . $jsOutputPath . '</info> file'); } if ($force === true || !$this->filesystem->exists($cssOutputPath)) { $this->filesystem->makeDirectory(dirname($cssOutputPath), 0755, true, true); $this->filesystem->put($cssOutputPath, $this->minifyCss()); $this->lineToOutput('Compiled <info>StyleSheet</info> was successfully written to <info>' . $jsOutputPath . '</info> file'); } }
Compile enabled components @param bool $force if TRUE cache will be invalidated and new compiled resources will be created @return void @throws \ViKon\Bootstrap\Exception\CompilerException
https://github.com/vi-kon/laravel-bootstrap/blob/f4bdfd19241ad19344bef3d2bdbf3658bbbb2ddd/src/ViKon/Bootstrap/Compiler.php#L194-L210
vi-kon/laravel-bootstrap
src/ViKon/Bootstrap/Compiler.php
Compiler.minifyJs
protected function minifyJs() { $minifier = new Minify\JS(); // Components $this->addJsToMinifier($minifier, 'dropdowns', 'dropdown'); // Components w/ JavaScript $this->addJsToMinifier($minifier, 'modals', 'modal'); $this->addJsToMinifier($minifier, 'tooltip'); $this->addJsToMinifier($minifier, 'popovers', 'popover'); $this->addJsToMinifier($minifier, 'carousel'); // Pure JavaScript components $this->addJsToMinifier($minifier, 'affix'); $this->addJsToMinifier($minifier, 'alert'); $this->addJsToMinifier($minifier, 'button'); $this->addJsToMinifier($minifier, 'collapse'); $this->addJsToMinifier($minifier, 'scrollspy'); $this->addJsToMinifier($minifier, 'tab'); $this->addJsToMinifier($minifier, 'transition'); return $minifier->minify(); }
php
protected function minifyJs() { $minifier = new Minify\JS(); // Components $this->addJsToMinifier($minifier, 'dropdowns', 'dropdown'); // Components w/ JavaScript $this->addJsToMinifier($minifier, 'modals', 'modal'); $this->addJsToMinifier($minifier, 'tooltip'); $this->addJsToMinifier($minifier, 'popovers', 'popover'); $this->addJsToMinifier($minifier, 'carousel'); // Pure JavaScript components $this->addJsToMinifier($minifier, 'affix'); $this->addJsToMinifier($minifier, 'alert'); $this->addJsToMinifier($minifier, 'button'); $this->addJsToMinifier($minifier, 'collapse'); $this->addJsToMinifier($minifier, 'scrollspy'); $this->addJsToMinifier($minifier, 'tab'); $this->addJsToMinifier($minifier, 'transition'); return $minifier->minify(); }
Minify JS components to single string @return string
https://github.com/vi-kon/laravel-bootstrap/blob/f4bdfd19241ad19344bef3d2bdbf3658bbbb2ddd/src/ViKon/Bootstrap/Compiler.php#L217-L240
vi-kon/laravel-bootstrap
src/ViKon/Bootstrap/Compiler.php
Compiler.addJsToMinifier
protected function addJsToMinifier(Minify\JS $minify, $componentName, $fileName = null) { if ($fileName === null) { $fileName = $componentName; } // Add component data to minifier if it is enabled if ($this->components[$componentName] === true) { $minify->add(base_path("vendor/twbs/bootstrap/js/{$fileName}.js")); } }
php
protected function addJsToMinifier(Minify\JS $minify, $componentName, $fileName = null) { if ($fileName === null) { $fileName = $componentName; } // Add component data to minifier if it is enabled if ($this->components[$componentName] === true) { $minify->add(base_path("vendor/twbs/bootstrap/js/{$fileName}.js")); } }
Add components javascript file to minifier if component is enabled @param \MatthiasMullie\Minify\JS $minify minifier instance @param string $componentName valid component name @param string|null $fileName file name (if not set component name is used) @return void
https://github.com/vi-kon/laravel-bootstrap/blob/f4bdfd19241ad19344bef3d2bdbf3658bbbb2ddd/src/ViKon/Bootstrap/Compiler.php#L251-L261
vi-kon/laravel-bootstrap
src/ViKon/Bootstrap/Compiler.php
Compiler.minifyCss
protected function minifyCss() { $output = ''; // Core variables and mixins $output .= '@import "variables.less";'; $output .= '@import "mixins.less";'; // Reset and dependencies $output .= $this->prepareCssForLess('normalize'); $output .= $this->prepareCssForLess('print'); $output .= $this->prepareCssForLess('glyphicons'); // Core CSS $output .= $this->prepareCssForLess('scaffolding'); $output .= $this->prepareCssForLess('type'); $output .= $this->prepareCssForLess('code'); $output .= $this->prepareCssForLess('grid'); $output .= $this->prepareCssForLess('tables'); $output .= $this->prepareCssForLess('forms'); $output .= $this->prepareCssForLess('buttons'); // Components $output .= $this->prepareCssForLess('component-animations'); $output .= $this->prepareCssForLess('dropdowns'); $output .= $this->prepareCssForLess('button-groups'); $output .= $this->prepareCssForLess('input-groups'); $output .= $this->prepareCssForLess('navs'); $output .= $this->prepareCssForLess('navbar'); $output .= $this->prepareCssForLess('breadcrumbs'); $output .= $this->prepareCssForLess('pagination'); $output .= $this->prepareCssForLess('pager'); $output .= $this->prepareCssForLess('labels'); $output .= $this->prepareCssForLess('badges'); $output .= $this->prepareCssForLess('jumbotron'); $output .= $this->prepareCssForLess('thumbnails'); $output .= $this->prepareCssForLess('alerts'); $output .= $this->prepareCssForLess('progress-bars'); $output .= $this->prepareCssForLess('media'); $output .= $this->prepareCssForLess('list-group'); $output .= $this->prepareCssForLess('panels'); $output .= $this->prepareCssForLess('responsive-embed'); $output .= $this->prepareCssForLess('wells'); $output .= $this->prepareCssForLess('close'); // Components w/ JavaScript $output .= $this->prepareCssForLess('modals'); $output .= $this->prepareCssForLess('tooltip'); $output .= $this->prepareCssForLess('popovers'); $output .= $this->prepareCssForLess('carousel'); // Utility classes $output .= $this->prepareCssForLess('utilities'); $output .= $this->prepareCssForLess('responsive-utilities'); $less = new \Less_Parser(); $less->SetImportDirs([base_path('vendor/twbs/bootstrap/less') => 'bootstrap']); $css = $less->parse($output, 'bootstrap.components.less')->getCss(); $minifier = new Minify\CSS(); $minifier->add($css); return $minifier->minify(); }
php
protected function minifyCss() { $output = ''; // Core variables and mixins $output .= '@import "variables.less";'; $output .= '@import "mixins.less";'; // Reset and dependencies $output .= $this->prepareCssForLess('normalize'); $output .= $this->prepareCssForLess('print'); $output .= $this->prepareCssForLess('glyphicons'); // Core CSS $output .= $this->prepareCssForLess('scaffolding'); $output .= $this->prepareCssForLess('type'); $output .= $this->prepareCssForLess('code'); $output .= $this->prepareCssForLess('grid'); $output .= $this->prepareCssForLess('tables'); $output .= $this->prepareCssForLess('forms'); $output .= $this->prepareCssForLess('buttons'); // Components $output .= $this->prepareCssForLess('component-animations'); $output .= $this->prepareCssForLess('dropdowns'); $output .= $this->prepareCssForLess('button-groups'); $output .= $this->prepareCssForLess('input-groups'); $output .= $this->prepareCssForLess('navs'); $output .= $this->prepareCssForLess('navbar'); $output .= $this->prepareCssForLess('breadcrumbs'); $output .= $this->prepareCssForLess('pagination'); $output .= $this->prepareCssForLess('pager'); $output .= $this->prepareCssForLess('labels'); $output .= $this->prepareCssForLess('badges'); $output .= $this->prepareCssForLess('jumbotron'); $output .= $this->prepareCssForLess('thumbnails'); $output .= $this->prepareCssForLess('alerts'); $output .= $this->prepareCssForLess('progress-bars'); $output .= $this->prepareCssForLess('media'); $output .= $this->prepareCssForLess('list-group'); $output .= $this->prepareCssForLess('panels'); $output .= $this->prepareCssForLess('responsive-embed'); $output .= $this->prepareCssForLess('wells'); $output .= $this->prepareCssForLess('close'); // Components w/ JavaScript $output .= $this->prepareCssForLess('modals'); $output .= $this->prepareCssForLess('tooltip'); $output .= $this->prepareCssForLess('popovers'); $output .= $this->prepareCssForLess('carousel'); // Utility classes $output .= $this->prepareCssForLess('utilities'); $output .= $this->prepareCssForLess('responsive-utilities'); $less = new \Less_Parser(); $less->SetImportDirs([base_path('vendor/twbs/bootstrap/less') => 'bootstrap']); $css = $less->parse($output, 'bootstrap.components.less')->getCss(); $minifier = new Minify\CSS(); $minifier->add($css); return $minifier->minify(); }
Minify CSS @return string
https://github.com/vi-kon/laravel-bootstrap/blob/f4bdfd19241ad19344bef3d2bdbf3658bbbb2ddd/src/ViKon/Bootstrap/Compiler.php#L284-L348
vi-kon/laravel-bootstrap
src/ViKon/Bootstrap/Compiler.php
Compiler.prepareCssForLess
protected function prepareCssForLess($componentName, $fileName = null) { if ($fileName === null) { $fileName = $componentName; } // Add component data to minifier if it is enabled if ($this->components[$componentName] === true) { return "@import \"{$fileName}.less\";"; } return ''; }
php
protected function prepareCssForLess($componentName, $fileName = null) { if ($fileName === null) { $fileName = $componentName; } // Add component data to minifier if it is enabled if ($this->components[$componentName] === true) { return "@import \"{$fileName}.less\";"; } return ''; }
Prepare components less file for less processor's input if component is enabled @param string $componentName valid component name @param string|null $fileName file name (if not set component name is used) @return string
https://github.com/vi-kon/laravel-bootstrap/blob/f4bdfd19241ad19344bef3d2bdbf3658bbbb2ddd/src/ViKon/Bootstrap/Compiler.php#L358-L370
ThrusterIO/http-modifier
src/RequestModifierCollection.php
RequestModifierCollection.modify
public function modify(RequestInterface $request) : RequestInterface { /** @var RequestModifierInterface $modifier */ foreach ($this->collection as $modifier) { $request = $modifier->modify($request); } return $request; }
php
public function modify(RequestInterface $request) : RequestInterface { /** @var RequestModifierInterface $modifier */ foreach ($this->collection as $modifier) { $request = $modifier->modify($request); } return $request; }
@param RequestInterface $request @return RequestInterface
https://github.com/ThrusterIO/http-modifier/blob/47c806ef5c4df8ca3ae7811206ebdce16547aa3e/src/RequestModifierCollection.php#L44-L52
inhere/php-library-plus
libs/Html/Pagination.php
Pagination.handleLogic
protected function handleLogic() { $page = $this->getOption('page', 1); $btnNum = $this->getOption('btnNum', 5); // 计算 $this->pageTotal = ceil($this->getOption('total') / $this->getOption('pageSize')); $this->offsetPage = floor($btnNum / 2);//偏移页数 $this->prevPage = $page - 1; // 上一页 $this->nextPage = $page + 1; // 下一页 $this->firstPage = $page - $this->offsetPage; //第一个数字按钮,当前页数减去偏移页数; $this->lastPage = $page + $this->offsetPage; //最后一个数字按钮 //当第一个数字按钮小于1时; if ($this->firstPage < 1) { $this->firstPage = 1; $this->lastPage = $btnNum; } //当最后一个数字按钮大于总页数时;通常情况下 if ($this->lastPage > $this->pageTotal) { $this->lastPage = $this->pageTotal; $this->firstPage = $this->pageTotal - $btnNum + 1; } //当总页数小于翻页的数字按钮个数时; if ($btnNum > $this->pageTotal) { $this->lastPage = $this->pageTotal; $this->firstPage = 1; } }
php
protected function handleLogic() { $page = $this->getOption('page', 1); $btnNum = $this->getOption('btnNum', 5); // 计算 $this->pageTotal = ceil($this->getOption('total') / $this->getOption('pageSize')); $this->offsetPage = floor($btnNum / 2);//偏移页数 $this->prevPage = $page - 1; // 上一页 $this->nextPage = $page + 1; // 下一页 $this->firstPage = $page - $this->offsetPage; //第一个数字按钮,当前页数减去偏移页数; $this->lastPage = $page + $this->offsetPage; //最后一个数字按钮 //当第一个数字按钮小于1时; if ($this->firstPage < 1) { $this->firstPage = 1; $this->lastPage = $btnNum; } //当最后一个数字按钮大于总页数时;通常情况下 if ($this->lastPage > $this->pageTotal) { $this->lastPage = $this->pageTotal; $this->firstPage = $this->pageTotal - $btnNum + 1; } //当总页数小于翻页的数字按钮个数时; if ($btnNum > $this->pageTotal) { $this->lastPage = $this->pageTotal; $this->firstPage = 1; } }
处理中间数字分页按钮的逻辑
https://github.com/inhere/php-library-plus/blob/8604e037937d31fa2338d79aaf9d0910cb48f559/libs/Html/Pagination.php#L159-L189
rackberg/para
src/EventSubscriber/AddEnvironmentVariableEventSubscriber.php
AddEnvironmentVariableEventSubscriber.addEnvironmentVariable
public function addEnvironmentVariable(PostProcessCreationEvent $event) { // Get the current set environment variables. $env = $event->getProcess()->getEnv(); // Add the "para_project" environment variable $env['para_project'] = $event->getProject()->getName(); // Save the environment variables in the process. $event->getProcess()->setEnv($env); }
php
public function addEnvironmentVariable(PostProcessCreationEvent $event) { // Get the current set environment variables. $env = $event->getProcess()->getEnv(); // Add the "para_project" environment variable $env['para_project'] = $event->getProject()->getName(); // Save the environment variables in the process. $event->getProcess()->setEnv($env); }
This callback method adds an environment variable to a created process. @param \Para\Event\PostProcessCreationEvent $event
https://github.com/rackberg/para/blob/e0ef1356ed2979670eb7c670d88921406cade46e/src/EventSubscriber/AddEnvironmentVariableEventSubscriber.php#L37-L47
comoyi/redis
src/Redis/RedisSentinel.php
RedisSentinel.addNode
public function addNode($host, $port) { $len = count($this->nodes); $this->nodes[$len]['host'] = $host; $this->nodes[$len]['port'] = $port; }
php
public function addNode($host, $port) { $len = count($this->nodes); $this->nodes[$len]['host'] = $host; $this->nodes[$len]['port'] = $port; }
加入多个节点
https://github.com/comoyi/redis/blob/1c9313ce49e17b141dd87b900457b159f554f065/src/Redis/RedisSentinel.php#L17-L21
comoyi/redis
src/Redis/RedisSentinel.php
RedisSentinel.connection
public function connection() { if (!$this->handle) { for($i=0; $i < count($this->nodes); $i++){ if (!$sock = fsockopen($this->nodes[$i]['host'], $this->nodes[$i]['port'], $errno, $errstr)) {continue;} $this->handle = $sock; return $this->handle; } } return false; }
php
public function connection() { if (!$this->handle) { for($i=0; $i < count($this->nodes); $i++){ if (!$sock = fsockopen($this->nodes[$i]['host'], $this->nodes[$i]['port'], $errno, $errstr)) {continue;} $this->handle = $sock; return $this->handle; } } return false; }
建立连接
https://github.com/comoyi/redis/blob/1c9313ce49e17b141dd87b900457b159f554f065/src/Redis/RedisSentinel.php#L24-L33
comoyi/redis
src/Redis/RedisSentinel.php
RedisSentinel.command
public function command($commands) { $this->connection(); if ( !$this->handle ) {return false;} if ( is_array($commands) ){$commands = implode("\r\n", $commands);} $command = $commands . "\r\n"; for ( $written = 0; $written < strlen($command); $written += $fwrite ){ if ( !$fwrite = fwrite($this->handle, substr($command, $written)) ) {return false;} } return true; }
php
public function command($commands) { $this->connection(); if ( !$this->handle ) {return false;} if ( is_array($commands) ){$commands = implode("\r\n", $commands);} $command = $commands . "\r\n"; for ( $written = 0; $written < strlen($command); $written += $fwrite ){ if ( !$fwrite = fwrite($this->handle, substr($command, $written)) ) {return false;} } return true; }
执行命令
https://github.com/comoyi/redis/blob/1c9313ce49e17b141dd87b900457b159f554f065/src/Redis/RedisSentinel.php#L36-L45
comoyi/redis
src/Redis/RedisSentinel.php
RedisSentinel.getSlaves
public function getSlaves($mastername) { $key = 'slaves '.$mastername; if ($this->command("SENTINEL {$key}") == false){ return false; } return $this->getNodeInfo($this->handle); }
php
public function getSlaves($mastername) { $key = 'slaves '.$mastername; if ($this->command("SENTINEL {$key}") == false){ return false; } return $this->getNodeInfo($this->handle); }
获取子节点
https://github.com/comoyi/redis/blob/1c9313ce49e17b141dd87b900457b159f554f065/src/Redis/RedisSentinel.php#L48-L54
comoyi/redis
src/Redis/RedisSentinel.php
RedisSentinel.getMasters
public function getMasters($mastername) { $key = 'get-master-addr-by-name '.$mastername; if ($this->command("SENTINEL {$key}") == false){ return false; } return $this->getMasterInfo($this->handle); }
php
public function getMasters($mastername) { $key = 'get-master-addr-by-name '.$mastername; if ($this->command("SENTINEL {$key}") == false){ return false; } return $this->getMasterInfo($this->handle); }
masters,获取主服务
https://github.com/comoyi/redis/blob/1c9313ce49e17b141dd87b900457b159f554f065/src/Redis/RedisSentinel.php#L57-L63
comoyi/redis
src/Redis/RedisSentinel.php
RedisSentinel.ping
public function ping(){ $this->command("PING"); if (strpos($this->getResponse($this->handle), "PONG") === false){ return false; } return true; }
php
public function ping(){ $this->command("PING"); if (strpos($this->getResponse($this->handle), "PONG") === false){ return false; } return true; }
ping,检测sentinels是否可用
https://github.com/comoyi/redis/blob/1c9313ce49e17b141dd87b900457b159f554f065/src/Redis/RedisSentinel.php#L66-L72
comoyi/redis
src/Redis/RedisSentinel.php
RedisSentinel.getMasterInfo
public function getMasterInfo($handle) { if ( !$handle ) return false; $col = intval(substr(trim(fgets($handle)), 1)); if(feof($handle)) return false; for($i = 0; $i < $col; $i++){ $len = intval(substr(trim(fgets($handle)), 1)); if(feof($handle)) break; $value = substr(trim(fgets($handle)), 0, $len); $sentinels[$i] = $value; if(feof($handle)) break; } return $sentinels; }
php
public function getMasterInfo($handle) { if ( !$handle ) return false; $col = intval(substr(trim(fgets($handle)), 1)); if(feof($handle)) return false; for($i = 0; $i < $col; $i++){ $len = intval(substr(trim(fgets($handle)), 1)); if(feof($handle)) break; $value = substr(trim(fgets($handle)), 0, $len); $sentinels[$i] = $value; if(feof($handle)) break; } return $sentinels; }
获取master信息
https://github.com/comoyi/redis/blob/1c9313ce49e17b141dd87b900457b159f554f065/src/Redis/RedisSentinel.php#L81-L95
comoyi/redis
src/Redis/RedisSentinel.php
RedisSentinel.getNodeInfo
public function getNodeInfo($handle) { if ( !$handle ) return false; $col = intval(substr(trim(fgets($handle)), 1)); if(feof($handle)) return false; for($i = 0; $i < $col; $i++){ $row = intval(substr(trim(fgets($handle)), 1))/2; if(feof($handle)) return false; for($j = 0; $j < $row; $j++){ $len = intval(substr(trim(fgets($handle)), 1)); if(feof($handle)) break; $key = substr(trim(fgets($handle)), 0, $len); if(feof($handle)) break; $len = intval(substr(trim(fgets($handle)), 1)); if(feof($handle)) break; $value = substr(trim(fgets($handle)), 0, $len); $sentinels[$i][$key] = $value; if(feof($handle)) break; } } return $sentinels; }
php
public function getNodeInfo($handle) { if ( !$handle ) return false; $col = intval(substr(trim(fgets($handle)), 1)); if(feof($handle)) return false; for($i = 0; $i < $col; $i++){ $row = intval(substr(trim(fgets($handle)), 1))/2; if(feof($handle)) return false; for($j = 0; $j < $row; $j++){ $len = intval(substr(trim(fgets($handle)), 1)); if(feof($handle)) break; $key = substr(trim(fgets($handle)), 0, $len); if(feof($handle)) break; $len = intval(substr(trim(fgets($handle)), 1)); if(feof($handle)) break; $value = substr(trim(fgets($handle)), 0, $len); $sentinels[$i][$key] = $value; if(feof($handle)) break; } } return $sentinels; }
获取节点信息
https://github.com/comoyi/redis/blob/1c9313ce49e17b141dd87b900457b159f554f065/src/Redis/RedisSentinel.php#L98-L122
inc2734/wp-awesome-components
src/Awesome_Components.php
Awesome_Components._media_buttons
public function _media_buttons( $editor_id = 'content' ) { $post_type = get_post_type(); if ( ! $post_type ) { return; } $post_type_object = get_post_type_object( $post_type ); if ( ! $post_type_object || ! $post_type_object->public ) { return; } ?> <button type="button" id="button-wp-awesome-components" class="button" href="#" data-editor="<?php echo esc_attr( $editor_id ); ?>"> <span class="dashicons dashicons-editor-kitchensink"></span> <?php esc_html_e( 'Add Components', 'inc2734-wp-awesome-components' ); ?> </button> <?php }
php
public function _media_buttons( $editor_id = 'content' ) { $post_type = get_post_type(); if ( ! $post_type ) { return; } $post_type_object = get_post_type_object( $post_type ); if ( ! $post_type_object || ! $post_type_object->public ) { return; } ?> <button type="button" id="button-wp-awesome-components" class="button" href="#" data-editor="<?php echo esc_attr( $editor_id ); ?>"> <span class="dashicons dashicons-editor-kitchensink"></span> <?php esc_html_e( 'Add Components', 'inc2734-wp-awesome-components' ); ?> </button> <?php }
Added "Add components" button @param string $editor_id @return void
https://github.com/inc2734/wp-awesome-components/blob/45ce014943db141350a001d4138921b1c7bec0a2/src/Awesome_Components.php#L32-L49
inc2734/wp-awesome-components
src/Awesome_Components.php
Awesome_Components._edit_form_after_editor
public function _edit_form_after_editor() { $post_type = get_post_type(); if ( ! $post_type ) { return; } if ( false === get_post_type_object( $post_type )->public ) { return; } ob_start(); include( __DIR__ . '/view/modal.php' ); // @codingStandardsIgnoreStart echo ob_get_clean(); // @codingStandardsIgnoreEnd }
php
public function _edit_form_after_editor() { $post_type = get_post_type(); if ( ! $post_type ) { return; } if ( false === get_post_type_object( $post_type )->public ) { return; } ob_start(); include( __DIR__ . '/view/modal.php' ); // @codingStandardsIgnoreStart echo ob_get_clean(); // @codingStandardsIgnoreEnd }
Added modal html @return void
https://github.com/inc2734/wp-awesome-components/blob/45ce014943db141350a001d4138921b1c7bec0a2/src/Awesome_Components.php#L56-L72
inc2734/wp-awesome-components
src/Awesome_Components.php
Awesome_Components._admin_enqueue_scripts
public function _admin_enqueue_scripts() { $relative_path = '/vendor/inc2734/wp-awesome-components/src/assets/js/app.js'; $src = get_template_directory_uri() . $relative_path; $path = get_template_directory() . $relative_path; wp_enqueue_script( 'wp-awesome-components', $src, [ 'jquery' ], filemtime( $path ), true ); wp_localize_script( 'wp-awesome-components', 'wp_awesome_components_text', [ 'insert_html' => esc_html__( 'Insert HTML', 'inc2734-wp-awesome-components' ), 'highlighter' => esc_html__( 'Highlighter', 'inc2734-wp-awesome-components' ), ] ); $relative_path = '/vendor/inc2734/wp-awesome-components/src/assets/css/app.css'; $src = get_template_directory_uri() . $relative_path; $path = get_template_directory() . $relative_path; wp_enqueue_style( 'wp-awesome-components', $src, [], filemtime( $path ) ); }
php
public function _admin_enqueue_scripts() { $relative_path = '/vendor/inc2734/wp-awesome-components/src/assets/js/app.js'; $src = get_template_directory_uri() . $relative_path; $path = get_template_directory() . $relative_path; wp_enqueue_script( 'wp-awesome-components', $src, [ 'jquery' ], filemtime( $path ), true ); wp_localize_script( 'wp-awesome-components', 'wp_awesome_components_text', [ 'insert_html' => esc_html__( 'Insert HTML', 'inc2734-wp-awesome-components' ), 'highlighter' => esc_html__( 'Highlighter', 'inc2734-wp-awesome-components' ), ] ); $relative_path = '/vendor/inc2734/wp-awesome-components/src/assets/css/app.css'; $src = get_template_directory_uri() . $relative_path; $path = get_template_directory() . $relative_path; wp_enqueue_style( 'wp-awesome-components', $src, [], filemtime( $path ) ); }
Enqueue assets @return void
https://github.com/inc2734/wp-awesome-components/blob/45ce014943db141350a001d4138921b1c7bec0a2/src/Awesome_Components.php#L79-L111
LoggerEssentials/LoggerEssentials
src/Extenders/ContextExtender.php
ContextExtender.log
public function log($level, $message, array $context = array()) { foreach($this->keyValueArray as $key => $value) { if(is_object($value)) { if(method_exists($value, '__toString')) { $value = (string)$value; } else { $value = json_encode($value); } } $context[$key] = $value; } $this->logger()->log($level, $message, $context); }
php
public function log($level, $message, array $context = array()) { foreach($this->keyValueArray as $key => $value) { if(is_object($value)) { if(method_exists($value, '__toString')) { $value = (string)$value; } else { $value = json_encode($value); } } $context[$key] = $value; } $this->logger()->log($level, $message, $context); }
Logs with an arbitrary level. @param string $level @param string $message @param array $context @return void
https://github.com/LoggerEssentials/LoggerEssentials/blob/f32f9b865eacfccced90697f3eb69dc4ad80dc96/src/Extenders/ContextExtender.php#L27-L39
gplcart/file_manager
models/Command.php
Command.getHandlers
public function getHandlers() { $commands = &gplcart_static('module.file_manager.handlers'); if (isset($commands)) { return $commands; } $commands = (array) gplcart_config_get(__DIR__ . '/../config/commands.php'); foreach ($commands as $id => &$command) { $command['command_id'] = $id; } $this->hook->attach('module.file_manager.handlers', $commands, $this); return $commands; }
php
public function getHandlers() { $commands = &gplcart_static('module.file_manager.handlers'); if (isset($commands)) { return $commands; } $commands = (array) gplcart_config_get(__DIR__ . '/../config/commands.php'); foreach ($commands as $id => &$command) { $command['command_id'] = $id; } $this->hook->attach('module.file_manager.handlers', $commands, $this); return $commands; }
Returns an array of supported commands @return array
https://github.com/gplcart/file_manager/blob/45424e93eafea75d31af6410ac9cf110f08e500a/models/Command.php#L41-L57
gplcart/file_manager
models/Command.php
Command.get
public function get($command) { $commands = $this->getHandlers(); return empty($commands[$command]) ? array() : $commands[$command]; }
php
public function get($command) { $commands = $this->getHandlers(); return empty($commands[$command]) ? array() : $commands[$command]; }
Returns a single command @param string $command @return array
https://github.com/gplcart/file_manager/blob/45424e93eafea75d31af6410ac9cf110f08e500a/models/Command.php#L64-L68
gplcart/file_manager
models/Command.php
Command.getAllowed
public function getAllowed($file) { $commands = array(); foreach ($this->getHandlers() as $id => $command) { if ($this->isAllowed($command, $file)) { $commands[$id] = $command; } } return $commands; }
php
public function getAllowed($file) { $commands = array(); foreach ($this->getHandlers() as $id => $command) { if ($this->isAllowed($command, $file)) { $commands[$id] = $command; } } return $commands; }
Returns an array of allowed commands for the given file @param SplFileInfo|array $file @return array
https://github.com/gplcart/file_manager/blob/45424e93eafea75d31af6410ac9cf110f08e500a/models/Command.php#L75-L86
gplcart/file_manager
models/Command.php
Command.isAllowed
public function isAllowed(array $command, $file) { if (!$file instanceof SplFileInfo || empty($command['command_id'])) { return false; } $result = $this->callHandler($command, 'allowed', array($file, $command)); return is_bool($result) ? $result : false; }
php
public function isAllowed(array $command, $file) { if (!$file instanceof SplFileInfo || empty($command['command_id'])) { return false; } $result = $this->callHandler($command, 'allowed', array($file, $command)); return is_bool($result) ? $result : false; }
Whether the command is allowed for the file @param array $command @param SplFileInfo $file @return boolean
https://github.com/gplcart/file_manager/blob/45424e93eafea75d31af6410ac9cf110f08e500a/models/Command.php#L94-L103
gplcart/file_manager
models/Command.php
Command.callHandler
public function callHandler(array $command, $method, $args = array()) { try { $handlers = $this->getHandlers(); return Handler::call($handlers, $command['command_id'], $method, $args); } catch (Exception $ex) { return $ex->getMessage(); } }
php
public function callHandler(array $command, $method, $args = array()) { try { $handlers = $this->getHandlers(); return Handler::call($handlers, $command['command_id'], $method, $args); } catch (Exception $ex) { return $ex->getMessage(); } }
Call a command handler @param array $command @param string $method @param array $args @return mixed
https://github.com/gplcart/file_manager/blob/45424e93eafea75d31af6410ac9cf110f08e500a/models/Command.php#L112-L120
gplcart/file_manager
models/Command.php
Command.submit
public function submit(array $command, array $args) { $result = (array) $this->callHandler($command, 'submit', $args); $result += array('redirect' => '', 'message' => '', 'severity' => ''); return $result; }
php
public function submit(array $command, array $args) { $result = (array) $this->callHandler($command, 'submit', $args); $result += array('redirect' => '', 'message' => '', 'severity' => ''); return $result; }
Submit a command @param array $command @param array $args @return array
https://github.com/gplcart/file_manager/blob/45424e93eafea75d31af6410ac9cf110f08e500a/models/Command.php#L128-L133
activecollab/humannameparser
src/Name.php
Name.setStr
public function setStr($str) { if (!mb_check_encoding($str)) { throw new Exception('Name is not encoded in UTF-8'); } $this->str = $str; $this->norm(); return true; }
php
public function setStr($str) { if (!mb_check_encoding($str)) { throw new Exception('Name is not encoded in UTF-8'); } $this->str = $str; $this->norm(); return true; }
Checks encoding, normalizes whitespace/punctuation, and sets the name string. @param string $str a utf8-encoding string. @return bool True on success @throws Exception
https://github.com/activecollab/humannameparser/blob/5170a5d85a505e74c1dd8ebfc4546ce412680823/src/Name.php#L39-L48
activecollab/humannameparser
src/Name.php
Name.chopWithRegex
public function chopWithRegex($regex, $submatchIndex = 0, $regexFlags = '') { $regex = $regex . 'ui' . $regexFlags; // unicode + case-insensitive preg_match($regex, $this->str, $m); $subset = (isset($m[$submatchIndex])) ? $m[$submatchIndex] : ''; if ($subset) { $this->str = preg_replace($regex, ' ', $this->str, -1, $numReplacements); if ($numReplacements > 1) { throw new Exception('The regex being used to find the name has multiple matches.'); } $this->norm(); return $subset; } else { return ''; } }
php
public function chopWithRegex($regex, $submatchIndex = 0, $regexFlags = '') { $regex = $regex . 'ui' . $regexFlags; // unicode + case-insensitive preg_match($regex, $this->str, $m); $subset = (isset($m[$submatchIndex])) ? $m[$submatchIndex] : ''; if ($subset) { $this->str = preg_replace($regex, ' ', $this->str, -1, $numReplacements); if ($numReplacements > 1) { throw new Exception('The regex being used to find the name has multiple matches.'); } $this->norm(); return $subset; } else { return ''; } }
Uses a regex to chop off and return part of the namestring There are two parts: first, it returns the matched substring, and then it removes that substring from $this->str and normalizes. @param string $regex matches the part of the namestring to chop off @param int $submatchIndex which of the parenthesized submatches to use @param string $regexFlags optional regex flags @return string the part of the namestring that got chopped off @throws Exception
https://github.com/activecollab/humannameparser/blob/5170a5d85a505e74c1dd8ebfc4546ce412680823/src/Name.php#L66-L83
activecollab/humannameparser
src/Name.php
Name.flip
public function flip($flipAroundChar) { $substrings = preg_split("/$flipAroundChar/u", $this->str); if (count($substrings) == 2) { $this->str = $substrings[1] . ' ' . $substrings[0]; $this->norm(); } else { if (count($substrings) > 2) { throw new Exception("Can't flip around multiple '$flipAroundChar' characters in namestring."); } } return true; // if there's 1 or 0 $flipAroundChar found }
php
public function flip($flipAroundChar) { $substrings = preg_split("/$flipAroundChar/u", $this->str); if (count($substrings) == 2) { $this->str = $substrings[1] . ' ' . $substrings[0]; $this->norm(); } else { if (count($substrings) > 2) { throw new Exception("Can't flip around multiple '$flipAroundChar' characters in namestring."); } } return true; // if there's 1 or 0 $flipAroundChar found }
/* Flips the front and back parts of a name with one another. Front and back are determined by a specified character somewhere in the middle of the string. @param String $flipAroundChar the character(s) demarcating the two halves you want to flip. @return Bool True on success.
https://github.com/activecollab/humannameparser/blob/5170a5d85a505e74c1dd8ebfc4546ce412680823/src/Name.php#L93-L106
activecollab/humannameparser
src/Name.php
Name.norm
private function norm() { $this->str = preg_replace("#^\s*#u", '', $this->str); $this->str = preg_replace("#\s*$#u", '', $this->str); $this->str = preg_replace("#\s+#u", ' ', $this->str); $this->str = preg_replace('#,$#u', ' ', $this->str); return true; }
php
private function norm() { $this->str = preg_replace("#^\s*#u", '', $this->str); $this->str = preg_replace("#\s*$#u", '', $this->str); $this->str = preg_replace("#\s+#u", ' ', $this->str); $this->str = preg_replace('#,$#u', ' ', $this->str); return true; }
Removes extra whitespace and punctuation from $this->str. Strips whitespace chars from ends, strips redundant whitespace, converts whitespace chars to " ". @return bool True on success
https://github.com/activecollab/humannameparser/blob/5170a5d85a505e74c1dd8ebfc4546ce412680823/src/Name.php#L115-L123
Phpillip/phpillip
src/Console/Command/ExposeCommand.php
ExposeCommand.execute
protected function execute(InputInterface $input, OutputInterface $output) { $output->writeln('[ Exposing public directory ]'); $app = $this->getApplication()->getKernel(); $source = $app['root'] . $app['public_path']; $destination = $input->getArgument('destination') ?: $app['root'] . $app['dst_path']; $finder = new Finder(); $files = new Filesystem(); foreach ($finder->files()->in($source) as $file) { $files->copy( $file->getPathName(), str_replace($source, $destination, $file->getPathName()), true ); } }
php
protected function execute(InputInterface $input, OutputInterface $output) { $output->writeln('[ Exposing public directory ]'); $app = $this->getApplication()->getKernel(); $source = $app['root'] . $app['public_path']; $destination = $input->getArgument('destination') ?: $app['root'] . $app['dst_path']; $finder = new Finder(); $files = new Filesystem(); foreach ($finder->files()->in($source) as $file) { $files->copy( $file->getPathName(), str_replace($source, $destination, $file->getPathName()), true ); } }
{@inheritdoc}
https://github.com/Phpillip/phpillip/blob/c37afaafb536361e7e0b564659f1cd5b80b98be9/src/Console/Command/ExposeCommand.php#L32-L49
ruvents/ruwork-synchronizer
Context.php
Context.getSynchronizer
public function getSynchronizer(string $type): SynchronizerInterface { if (isset($this->synchronizers[$type])) { return $this->synchronizers[$type]; } /** @var TypeInterface $typeObject */ $typeObject = $this->types->get($type); $configurator = new Configurator(); $typeObject->configure($configurator, $this); return $this->synchronizers[$type] = new Synchronizer( $type, $this->eventDispatcher, $this, $configurator, $this->cacheFactory->createCache(self::class.$type) ); }
php
public function getSynchronizer(string $type): SynchronizerInterface { if (isset($this->synchronizers[$type])) { return $this->synchronizers[$type]; } /** @var TypeInterface $typeObject */ $typeObject = $this->types->get($type); $configurator = new Configurator(); $typeObject->configure($configurator, $this); return $this->synchronizers[$type] = new Synchronizer( $type, $this->eventDispatcher, $this, $configurator, $this->cacheFactory->createCache(self::class.$type) ); }
{@inheritdoc}
https://github.com/ruvents/ruwork-synchronizer/blob/68aa35d48f04634828e76eb2a49e504985da92a9/Context.php#L47-L65
as3io/modlr
src/Rest/RestRequest.php
RestRequest.getUrl
public function getUrl() { $query = $this->getQueryString(); return sprintf('%s://%s/%s/%s%s', $this->getScheme(), trim($this->getHost(), '/'), trim($this->config->getRootEndpoint(), '/'), $this->getEntityType(), empty($query) ? '' : sprintf('?%s', $query) ); }
php
public function getUrl() { $query = $this->getQueryString(); return sprintf('%s://%s/%s/%s%s', $this->getScheme(), trim($this->getHost(), '/'), trim($this->config->getRootEndpoint(), '/'), $this->getEntityType(), empty($query) ? '' : sprintf('?%s', $query) ); }
Generates the request URL based on its current object state. @todo Add support for inclusions and other items. @return string
https://github.com/as3io/modlr/blob/7e684b88bb22a2e18397df9402075c6533084b16/src/Rest/RestRequest.php#L150-L160
as3io/modlr
src/Rest/RestRequest.php
RestRequest.getQueryString
public function getQueryString() { $query = []; if (!empty($this->pagination)) { $query[self::PARAM_PAGINATION] = $this->pagination; } if (!empty($this->filters)) { $query[self::PARAM_FILTERING] = $this->filters; } foreach ($this->fields as $modelType => $fields) { $query[self::PARAM_FIELDSETS][$modelType] = implode(',', $fields); } $sort = []; foreach ($this->sorting as $key => $direction) { $sort[] = (1 === $direction) ? $key : sprintf('-%s', $key); } if (!empty($sort)) { $query[self::PARAM_SORTING] = implode(',', $sort); } return http_build_query($query); }
php
public function getQueryString() { $query = []; if (!empty($this->pagination)) { $query[self::PARAM_PAGINATION] = $this->pagination; } if (!empty($this->filters)) { $query[self::PARAM_FILTERING] = $this->filters; } foreach ($this->fields as $modelType => $fields) { $query[self::PARAM_FIELDSETS][$modelType] = implode(',', $fields); } $sort = []; foreach ($this->sorting as $key => $direction) { $sort[] = (1 === $direction) ? $key : sprintf('-%s', $key); } if (!empty($sort)) { $query[self::PARAM_SORTING] = implode(',', $sort); } return http_build_query($query); }
Gets the query string based on the current object properties. @return string
https://github.com/as3io/modlr/blob/7e684b88bb22a2e18397df9402075c6533084b16/src/Rest/RestRequest.php#L227-L247
as3io/modlr
src/Rest/RestRequest.php
RestRequest.isAutocomplete
public function isAutocomplete() { if (false === $this->hasFilter(self::FILTER_AUTOCOMPLETE)) { return false; } $autocomplete = $this->getFilter(self::FILTER_AUTOCOMPLETE); return isset($autocomplete[self::FILTER_AUTOCOMPLETE_KEY]) && isset($autocomplete[self::FILTER_AUTOCOMPLETE_VALUE]); }
php
public function isAutocomplete() { if (false === $this->hasFilter(self::FILTER_AUTOCOMPLETE)) { return false; } $autocomplete = $this->getFilter(self::FILTER_AUTOCOMPLETE); return isset($autocomplete[self::FILTER_AUTOCOMPLETE_KEY]) && isset($autocomplete[self::FILTER_AUTOCOMPLETE_VALUE]); }
Determines if this has an autocomplete filter enabled. @return bool
https://github.com/as3io/modlr/blob/7e684b88bb22a2e18397df9402075c6533084b16/src/Rest/RestRequest.php#L323-L330
as3io/modlr
src/Rest/RestRequest.php
RestRequest.getAutocompleteKey
public function getAutocompleteKey() { if (false === $this->isAutocomplete()) { return null; } return $this->getFilter(self::FILTER_AUTOCOMPLETE)[self::FILTER_AUTOCOMPLETE_KEY]; }
php
public function getAutocompleteKey() { if (false === $this->isAutocomplete()) { return null; } return $this->getFilter(self::FILTER_AUTOCOMPLETE)[self::FILTER_AUTOCOMPLETE_KEY]; }
Gets the autocomplete attribute key. @return string|null
https://github.com/as3io/modlr/blob/7e684b88bb22a2e18397df9402075c6533084b16/src/Rest/RestRequest.php#L337-L343
as3io/modlr
src/Rest/RestRequest.php
RestRequest.getAutocompleteValue
public function getAutocompleteValue() { if (false === $this->isAutocomplete()) { return null; } return $this->getFilter(self::FILTER_AUTOCOMPLETE)[self::FILTER_AUTOCOMPLETE_VALUE]; }
php
public function getAutocompleteValue() { if (false === $this->isAutocomplete()) { return null; } return $this->getFilter(self::FILTER_AUTOCOMPLETE)[self::FILTER_AUTOCOMPLETE_VALUE]; }
Gets the autocomplete search value. @return string|null
https://github.com/as3io/modlr/blob/7e684b88bb22a2e18397df9402075c6533084b16/src/Rest/RestRequest.php#L350-L356
as3io/modlr
src/Rest/RestRequest.php
RestRequest.isQuery
public function isQuery() { if (false === $this->hasFilter(self::FILTER_QUERY)) { return false; } $query = $this->getFilter(self::FILTER_QUERY); return isset($query[self::FILTER_QUERY_CRITERIA]); }
php
public function isQuery() { if (false === $this->hasFilter(self::FILTER_QUERY)) { return false; } $query = $this->getFilter(self::FILTER_QUERY); return isset($query[self::FILTER_QUERY_CRITERIA]); }
Determines if this has the database query filter enabled. @return bool
https://github.com/as3io/modlr/blob/7e684b88bb22a2e18397df9402075c6533084b16/src/Rest/RestRequest.php#L363-L370
as3io/modlr
src/Rest/RestRequest.php
RestRequest.getQueryCriteria
public function getQueryCriteria() { if (false === $this->isQuery()) { return []; } $queryKey = self::FILTER_QUERY; $criteriaKey = self::FILTER_QUERY_CRITERIA; $decoded = @json_decode($this->getFilter($queryKey)[$criteriaKey], true); if (!is_array($decoded)) { $param = sprintf('%s[%s][%s]', self::PARAM_FILTERING, $queryKey, $criteriaKey); throw RestException::invalidQueryParam($param, 'Was the value sent as valid JSON?'); } return $decoded; }
php
public function getQueryCriteria() { if (false === $this->isQuery()) { return []; } $queryKey = self::FILTER_QUERY; $criteriaKey = self::FILTER_QUERY_CRITERIA; $decoded = @json_decode($this->getFilter($queryKey)[$criteriaKey], true); if (!is_array($decoded)) { $param = sprintf('%s[%s][%s]', self::PARAM_FILTERING, $queryKey, $criteriaKey); throw RestException::invalidQueryParam($param, 'Was the value sent as valid JSON?'); } return $decoded; }
Gets the query criteria value. @return array
https://github.com/as3io/modlr/blob/7e684b88bb22a2e18397df9402075c6533084b16/src/Rest/RestRequest.php#L377-L392
as3io/modlr
src/Rest/RestRequest.php
RestRequest.setPagination
public function setPagination($offset, $limit) { $this->pagination['offset'] = (Integer) $offset; $this->pagination['limit'] = (Integer) $limit; return $this; }
php
public function setPagination($offset, $limit) { $this->pagination['offset'] = (Integer) $offset; $this->pagination['limit'] = (Integer) $limit; return $this; }
Sets the pagination (limit/offset) criteria. @param int $offset @param int $limit @return self
https://github.com/as3io/modlr/blob/7e684b88bb22a2e18397df9402075c6533084b16/src/Rest/RestRequest.php#L485-L490
as3io/modlr
src/Rest/RestRequest.php
RestRequest.getFilter
public function getFilter($key) { if (!isset($this->filters[$key])) { return null; } return $this->filters[$key]; }
php
public function getFilter($key) { if (!isset($this->filters[$key])) { return null; } return $this->filters[$key]; }
Gets a specific filter, by key. @param string $key @return mixed|null
https://github.com/as3io/modlr/blob/7e684b88bb22a2e18397df9402075c6533084b16/src/Rest/RestRequest.php#L519-L525