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
amarcinkowski/hospitalplugin
src/utils/Utils.php
Utils.diffDates
public static function diffDates($date1, $date2) { $ts1 = strtotime($date1); $ts2 = strtotime($date2); $seconds_diff = $ts2 - $ts1; return floor($seconds_diff / 3600 / 24); }
php
public static function diffDates($date1, $date2) { $ts1 = strtotime($date1); $ts2 = strtotime($date2); $seconds_diff = $ts2 - $ts1; return floor($seconds_diff / 3600 / 24); }
diff in days @param $date1 $date1 string parsable date strtotime(date) @param $date2 $date2 string parsable date strtotime(date) @return number
https://github.com/amarcinkowski/hospitalplugin/blob/acdc2be5157abfbdcafb4dcf6c6ba505e291263f/src/utils/Utils.php#L49-L57
amarcinkowski/hospitalplugin
src/utils/Utils.php
Utils.getStartDate
public static function getStartDate($month = null, $day = null) { if ($month == null && $day == null) { // today $date = new \DateTime(date('Y-m-d')); } else if ($day == null) { // first day of mnth $date = new \DateTime(date('Y-') . $month . '-01'); } else { // date $date = new \DateTime(date('Y-' . $month . '-' . $day)); } return $date->format('Y-m-d'); }
php
public static function getStartDate($month = null, $day = null) { if ($month == null && $day == null) { // today $date = new \DateTime(date('Y-m-d')); } else if ($day == null) { // first day of mnth $date = new \DateTime(date('Y-') . $month . '-01'); } else { // date $date = new \DateTime(date('Y-' . $month . '-' . $day)); } return $date->format('Y-m-d'); }
getStartDate Returns today if no date specified, First date of month if just month specified, Exact date if month and date specified. @example getStartDate() will return today (2014-09-28) @example getStartDate(2) will return 2014-02-01 @example getStartDate(12,7) will return 2014-12-07 @return string date @param $month int default null @param $day int default null
https://github.com/amarcinkowski/hospitalplugin/blob/acdc2be5157abfbdcafb4dcf6c6ba505e291263f/src/utils/Utils.php#L124-L138
amarcinkowski/hospitalplugin
src/utils/Utils.php
Utils.getEndDate
public static function getEndDate($month = null, $day = null) { if ($month == null && $day == null) { // tomorrow $date = new \DateTime(Utils::getNextDay(date('m'), date('d'))); } else if ($day == null) { // first day of next mnth $date = new \DateTime(Utils::getNextMonthFirstDay($month, $day)); } else { // date +1 day $date = new \DateTime(Utils::getNextDay($month, $day)); } return $date->format('Y-m-d'); }
php
public static function getEndDate($month = null, $day = null) { if ($month == null && $day == null) { // tomorrow $date = new \DateTime(Utils::getNextDay(date('m'), date('d'))); } else if ($day == null) { // first day of next mnth $date = new \DateTime(Utils::getNextMonthFirstDay($month, $day)); } else { // date +1 day $date = new \DateTime(Utils::getNextDay($month, $day)); } return $date->format('Y-m-d'); }
getEndDate @param $month int default null @param $day int default null
https://github.com/amarcinkowski/hospitalplugin/blob/acdc2be5157abfbdcafb4dcf6c6ba505e291263f/src/utils/Utils.php#L146-L160
amarcinkowski/hospitalplugin
src/utils/Utils.php
Utils.getStartEndDate
public static function getStartEndDate($dateParam) { if (empty($dateParam) || ! in_array($dateParam, array( 0, 1, 7 ))) { $dateParam = 0; } $date = array(); $today = (new \DateTime("now"))->format("Y-m-d"); $tomorrow = Utils::getNextDayDate($today); $yesterday = Utils::getPreviousDay($today); switch ($dateParam) { case 0: $date['startDate'] = $today; $date['endDate'] = $tomorrow; break; case 1: $date['startDate'] = $yesterday; $date['endDate'] = $today; break; case 7: $date['endDate'] = $tomorrow; $date['startDate'] = Utils::getDateWeekAgo(); break; } return $date; }
php
public static function getStartEndDate($dateParam) { if (empty($dateParam) || ! in_array($dateParam, array( 0, 1, 7 ))) { $dateParam = 0; } $date = array(); $today = (new \DateTime("now"))->format("Y-m-d"); $tomorrow = Utils::getNextDayDate($today); $yesterday = Utils::getPreviousDay($today); switch ($dateParam) { case 0: $date['startDate'] = $today; $date['endDate'] = $tomorrow; break; case 1: $date['startDate'] = $yesterday; $date['endDate'] = $today; break; case 7: $date['endDate'] = $tomorrow; $date['startDate'] = Utils::getDateWeekAgo(); break; } return $date; }
getStartEndDate pobierz date $_GET['date']; / domyslnie dzisiaj 0 - dzisiaj; 1 - wczoraj; 7 - week @param unknown $dateParam @return unknown
https://github.com/amarcinkowski/hospitalplugin/blob/acdc2be5157abfbdcafb4dcf6c6ba505e291263f/src/utils/Utils.php#L171-L199
amarcinkowski/hospitalplugin
src/utils/Utils.php
Utils.getDateWeekAgo
public static function getDateWeekAgo() { // today $date = new \DateTime(date('Y-m-d')); // minus 7 days $date = $date->sub(new \DateInterval('P7D')); return $date->format('Y-m-d'); }
php
public static function getDateWeekAgo() { // today $date = new \DateTime(date('Y-m-d')); // minus 7 days $date = $date->sub(new \DateInterval('P7D')); return $date->format('Y-m-d'); }
getDateWeekAgo @param $month int default null @param $day int default null
https://github.com/amarcinkowski/hospitalplugin/blob/acdc2be5157abfbdcafb4dcf6c6ba505e291263f/src/utils/Utils.php#L207-L214
amarcinkowski/hospitalplugin
src/utils/Utils.php
Utils.readFileToArray
public static function readFileToArray($url, $delm = ";", $encl = "\"", $head = false) { $csvxrow = file($url); // ---- csv rows to array ---- $csvxrow[0] = chop($csvxrow[0]); $csvxrow[0] = str_replace($encl, '', $csvxrow[0]); $keydata = explode($delm, $csvxrow[0]); $keynumb = count($keydata); $csv_data = array(); $out = array(); if ($head === true) { $anzdata = count($csvxrow); $z = 0; for ($x = 1; $x < $anzdata; $x ++) { $csvxrow[$x] = chop($csvxrow[$x]); $csvxrow[$x] = str_replace($encl, '', $csvxrow[$x]); $csv_data[$x] = explode($delm, $csvxrow[$x]); $i = 0; foreach ($keydata as $key) { $out[$z][$key] = $csv_data[$x][$i]; $i ++; } $z ++; } } else { $i = 0; foreach ($csvxrow as $item) { $item = chop($item); $item = str_replace($encl, '', $item); $csv_data = explode($delm, $item); for ($y = 0; $y < $keynumb; $y ++) { $out[$i][$y] = $csv_data[$y]; } $i ++; } } return $out; }
php
public static function readFileToArray($url, $delm = ";", $encl = "\"", $head = false) { $csvxrow = file($url); // ---- csv rows to array ---- $csvxrow[0] = chop($csvxrow[0]); $csvxrow[0] = str_replace($encl, '', $csvxrow[0]); $keydata = explode($delm, $csvxrow[0]); $keynumb = count($keydata); $csv_data = array(); $out = array(); if ($head === true) { $anzdata = count($csvxrow); $z = 0; for ($x = 1; $x < $anzdata; $x ++) { $csvxrow[$x] = chop($csvxrow[$x]); $csvxrow[$x] = str_replace($encl, '', $csvxrow[$x]); $csv_data[$x] = explode($delm, $csvxrow[$x]); $i = 0; foreach ($keydata as $key) { $out[$z][$key] = $csv_data[$x][$i]; $i ++; } $z ++; } } else { $i = 0; foreach ($csvxrow as $item) { $item = chop($item); $item = str_replace($encl, '', $item); $csv_data = explode($delm, $item); for ($y = 0; $y < $keynumb; $y ++) { $out[$i][$y] = $csv_data[$y]; } $i ++; } } return $out; }
read file to array @param $url file url @param $delm default ; @param $encl default \ @param $head default false @return array of strings
https://github.com/amarcinkowski/hospitalplugin/blob/acdc2be5157abfbdcafb4dcf6c6ba505e291263f/src/utils/Utils.php#L225-L263
amarcinkowski/hospitalplugin
src/utils/Utils.php
Utils.w1250_to_utf8
public static function w1250_to_utf8($text) { // map based on: // http://konfiguracja.c0.pl/iso02vscp1250en.html // http://konfiguracja.c0.pl/webpl/index_en.html#examp // http://www.htmlentities.com/html/entities/ $map = array( chr(0x8A) => chr(0xA9), chr(0x8C) => chr(0xA6), chr(0x8D) => chr(0xAB), chr(0x8E) => chr(0xAE), chr(0x8F) => chr(0xAC), chr(0x9C) => chr(0xB6), chr(0x9D) => chr(0xBB), chr(0xA1) => chr(0xB7), chr(0xA5) => chr(0xA1), //chr(0xBC) => chr(0xA5), // chr ( 0x9F ) => chr ( 0xBC ), chr(0xB9) => chr(0xB1), chr(0x9A) => chr(0xB9), chr(0xBE) => chr(0xB5), chr(0x9E) => chr(0xBE), chr(0x80) => '&euro;', chr(0x82) => '&sbquo;', chr(0x84) => '&bdquo;', chr(0x85) => '&hellip;', chr(0x86) => '&dagger;', chr(0x87) => '&Dagger;', chr(0x89) => '&permil;', chr(0x8B) => '&lsaquo;', chr(0x91) => '&lsquo;', chr(0x92) => '&rsquo;', chr(0x93) => '&ldquo;', chr(0x94) => '&rdquo;', chr(0x95) => '&bull;', chr(0x96) => '&ndash;', chr(0x97) => '&mdash;', chr(0x99) => '&trade;', chr(0x9B) => '&rsquo;', chr(0xA9) => '&copy;', chr(0xAB) => '&laquo;', chr(0xAE) => '&reg;', chr(0xB1) => '&plusmn;', chr(0xB5) => '&micro;', chr(0xB7) => '&middot;', chr(0xBB) => '&raquo;', // ś chr(0xB6) => '&#347;', // ą chr(0xB1) => '&#261;', // Ś chr(0xA6) => '&#346;', // ż chr(0xBF) => '&#380;', // ź chr(0x9F) => '&#378;', chr(0xBC) => '&#378;' ); return html_entity_decode(mb_convert_encoding(strtr($text, $map), 'UTF-8', 'ISO-8859-2'), ENT_QUOTES, 'UTF-8'); }
php
public static function w1250_to_utf8($text) { // map based on: // http://konfiguracja.c0.pl/iso02vscp1250en.html // http://konfiguracja.c0.pl/webpl/index_en.html#examp // http://www.htmlentities.com/html/entities/ $map = array( chr(0x8A) => chr(0xA9), chr(0x8C) => chr(0xA6), chr(0x8D) => chr(0xAB), chr(0x8E) => chr(0xAE), chr(0x8F) => chr(0xAC), chr(0x9C) => chr(0xB6), chr(0x9D) => chr(0xBB), chr(0xA1) => chr(0xB7), chr(0xA5) => chr(0xA1), //chr(0xBC) => chr(0xA5), // chr ( 0x9F ) => chr ( 0xBC ), chr(0xB9) => chr(0xB1), chr(0x9A) => chr(0xB9), chr(0xBE) => chr(0xB5), chr(0x9E) => chr(0xBE), chr(0x80) => '&euro;', chr(0x82) => '&sbquo;', chr(0x84) => '&bdquo;', chr(0x85) => '&hellip;', chr(0x86) => '&dagger;', chr(0x87) => '&Dagger;', chr(0x89) => '&permil;', chr(0x8B) => '&lsaquo;', chr(0x91) => '&lsquo;', chr(0x92) => '&rsquo;', chr(0x93) => '&ldquo;', chr(0x94) => '&rdquo;', chr(0x95) => '&bull;', chr(0x96) => '&ndash;', chr(0x97) => '&mdash;', chr(0x99) => '&trade;', chr(0x9B) => '&rsquo;', chr(0xA9) => '&copy;', chr(0xAB) => '&laquo;', chr(0xAE) => '&reg;', chr(0xB1) => '&plusmn;', chr(0xB5) => '&micro;', chr(0xB7) => '&middot;', chr(0xBB) => '&raquo;', // ś chr(0xB6) => '&#347;', // ą chr(0xB1) => '&#261;', // Ś chr(0xA6) => '&#346;', // ż chr(0xBF) => '&#380;', // ź chr(0x9F) => '&#378;', chr(0xBC) => '&#378;' ); return html_entity_decode(mb_convert_encoding(strtr($text, $map), 'UTF-8', 'ISO-8859-2'), ENT_QUOTES, 'UTF-8'); }
PL chars conv iso8859-2 => win1250 => utf8 @param text string with PL chars @return string encoded
https://github.com/amarcinkowski/hospitalplugin/blob/acdc2be5157abfbdcafb4dcf6c6ba505e291263f/src/utils/Utils.php#L271-L336
amarcinkowski/hospitalplugin
src/utils/Utils.php
Utils.cast
static function cast($destination, $sourceObject, $arguments = NULL) { if (is_string($destination)) { $destination = new $destination($arguments); } $sourceReflection = new \ReflectionObject($sourceObject); $destinationReflection = new \ReflectionObject($destination); $sourceProperties = $sourceReflection->getProperties(); foreach ($sourceProperties as $sourceProperty) { $sourceProperty->setAccessible(true); $name = $sourceProperty->getName(); $value = $sourceProperty->getValue($sourceObject); if ($destinationReflection->hasProperty($name)) { $propDest = $destinationReflection->getProperty($name); $propDest->setAccessible(true); $propDest->setValue($destination, $value); } else { $destination->$name = $value; } } return $destination; }
php
static function cast($destination, $sourceObject, $arguments = NULL) { if (is_string($destination)) { $destination = new $destination($arguments); } $sourceReflection = new \ReflectionObject($sourceObject); $destinationReflection = new \ReflectionObject($destination); $sourceProperties = $sourceReflection->getProperties(); foreach ($sourceProperties as $sourceProperty) { $sourceProperty->setAccessible(true); $name = $sourceProperty->getName(); $value = $sourceProperty->getValue($sourceObject); if ($destinationReflection->hasProperty($name)) { $propDest = $destinationReflection->getProperty($name); $propDest->setAccessible(true); $propDest->setValue($destination, $value); } else { $destination->$name = $value; } } return $destination; }
Class casting @param string|object $destination @param object $sourceObject @return object
https://github.com/amarcinkowski/hospitalplugin/blob/acdc2be5157abfbdcafb4dcf6c6ba505e291263f/src/utils/Utils.php#L345-L366
thelia-modules/SmartyFilter
Model/Base/SmartyFilterQuery.php
SmartyFilterQuery.create
public static function create($modelAlias = null, $criteria = null) { if ($criteria instanceof \SmartyFilter\Model\SmartyFilterQuery) { return $criteria; } $query = new \SmartyFilter\Model\SmartyFilterQuery(); if (null !== $modelAlias) { $query->setModelAlias($modelAlias); } if ($criteria instanceof Criteria) { $query->mergeWith($criteria); } return $query; }
php
public static function create($modelAlias = null, $criteria = null) { if ($criteria instanceof \SmartyFilter\Model\SmartyFilterQuery) { return $criteria; } $query = new \SmartyFilter\Model\SmartyFilterQuery(); if (null !== $modelAlias) { $query->setModelAlias($modelAlias); } if ($criteria instanceof Criteria) { $query->mergeWith($criteria); } return $query; }
Returns a new ChildSmartyFilterQuery object. @param string $modelAlias The alias of a model in the query @param Criteria $criteria Optional Criteria to build the query from @return ChildSmartyFilterQuery
https://github.com/thelia-modules/SmartyFilter/blob/e510d281f51ddc4344e563d0f6aaa192fa7171e9/Model/Base/SmartyFilterQuery.php#L80-L94
thelia-modules/SmartyFilter
Model/Base/SmartyFilterQuery.php
SmartyFilterQuery.filterByActive
public function filterByActive($active = null, $comparison = null) { if (is_array($active)) { $useMinMax = false; if (isset($active['min'])) { $this->addUsingAlias(SmartyFilterTableMap::ACTIVE, $active['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($active['max'])) { $this->addUsingAlias(SmartyFilterTableMap::ACTIVE, $active['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { return $this; } if (null === $comparison) { $comparison = Criteria::IN; } } return $this->addUsingAlias(SmartyFilterTableMap::ACTIVE, $active, $comparison); }
php
public function filterByActive($active = null, $comparison = null) { if (is_array($active)) { $useMinMax = false; if (isset($active['min'])) { $this->addUsingAlias(SmartyFilterTableMap::ACTIVE, $active['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($active['max'])) { $this->addUsingAlias(SmartyFilterTableMap::ACTIVE, $active['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { return $this; } if (null === $comparison) { $comparison = Criteria::IN; } } return $this->addUsingAlias(SmartyFilterTableMap::ACTIVE, $active, $comparison); }
Filter the query on the active column Example usage: <code> $query->filterByActive(1234); // WHERE active = 1234 $query->filterByActive(array(12, 34)); // WHERE active IN (12, 34) $query->filterByActive(array('min' => 12)); // WHERE active > 12 </code> @param mixed $active The value to use as filter. Use scalar values for equality. Use array values for in_array() equivalent. Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL @return ChildSmartyFilterQuery The current query, for fluid interface
https://github.com/thelia-modules/SmartyFilter/blob/e510d281f51ddc4344e563d0f6aaa192fa7171e9/Model/Base/SmartyFilterQuery.php#L289-L310
thelia-modules/SmartyFilter
Model/Base/SmartyFilterQuery.php
SmartyFilterQuery.filterByFiltertype
public function filterByFiltertype($filtertype = null, $comparison = null) { if (null === $comparison) { if (is_array($filtertype)) { $comparison = Criteria::IN; } elseif (preg_match('/[\%\*]/', $filtertype)) { $filtertype = str_replace('*', '%', $filtertype); $comparison = Criteria::LIKE; } } return $this->addUsingAlias(SmartyFilterTableMap::FILTERTYPE, $filtertype, $comparison); }
php
public function filterByFiltertype($filtertype = null, $comparison = null) { if (null === $comparison) { if (is_array($filtertype)) { $comparison = Criteria::IN; } elseif (preg_match('/[\%\*]/', $filtertype)) { $filtertype = str_replace('*', '%', $filtertype); $comparison = Criteria::LIKE; } } return $this->addUsingAlias(SmartyFilterTableMap::FILTERTYPE, $filtertype, $comparison); }
Filter the query on the filtertype column Example usage: <code> $query->filterByFiltertype('fooValue'); // WHERE filtertype = 'fooValue' $query->filterByFiltertype('%fooValue%'); // WHERE filtertype LIKE '%fooValue%' </code> @param string $filtertype The value to use as filter. Accepts wildcards (* and % trigger a LIKE) @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL @return ChildSmartyFilterQuery The current query, for fluid interface
https://github.com/thelia-modules/SmartyFilter/blob/e510d281f51ddc4344e563d0f6aaa192fa7171e9/Model/Base/SmartyFilterQuery.php#L327-L339
thelia-modules/SmartyFilter
Model/Base/SmartyFilterQuery.php
SmartyFilterQuery.filterBySmartyFilterI18n
public function filterBySmartyFilterI18n($smartyFilterI18n, $comparison = null) { if ($smartyFilterI18n instanceof \SmartyFilter\Model\SmartyFilterI18n) { return $this ->addUsingAlias(SmartyFilterTableMap::ID, $smartyFilterI18n->getId(), $comparison); } elseif ($smartyFilterI18n instanceof ObjectCollection) { return $this ->useSmartyFilterI18nQuery() ->filterByPrimaryKeys($smartyFilterI18n->getPrimaryKeys()) ->endUse(); } else { throw new PropelException('filterBySmartyFilterI18n() only accepts arguments of type \SmartyFilter\Model\SmartyFilterI18n or Collection'); } }
php
public function filterBySmartyFilterI18n($smartyFilterI18n, $comparison = null) { if ($smartyFilterI18n instanceof \SmartyFilter\Model\SmartyFilterI18n) { return $this ->addUsingAlias(SmartyFilterTableMap::ID, $smartyFilterI18n->getId(), $comparison); } elseif ($smartyFilterI18n instanceof ObjectCollection) { return $this ->useSmartyFilterI18nQuery() ->filterByPrimaryKeys($smartyFilterI18n->getPrimaryKeys()) ->endUse(); } else { throw new PropelException('filterBySmartyFilterI18n() only accepts arguments of type \SmartyFilter\Model\SmartyFilterI18n or Collection'); } }
Filter the query by a related \SmartyFilter\Model\SmartyFilterI18n object @param \SmartyFilter\Model\SmartyFilterI18n|ObjectCollection $smartyFilterI18n the related object to use as filter @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL @return ChildSmartyFilterQuery The current query, for fluid interface
https://github.com/thelia-modules/SmartyFilter/blob/e510d281f51ddc4344e563d0f6aaa192fa7171e9/Model/Base/SmartyFilterQuery.php#L378-L391
thelia-modules/SmartyFilter
Model/Base/SmartyFilterQuery.php
SmartyFilterQuery.useSmartyFilterI18nQuery
public function useSmartyFilterI18nQuery($relationAlias = null, $joinType = 'LEFT JOIN') { return $this ->joinSmartyFilterI18n($relationAlias, $joinType) ->useQuery($relationAlias ? $relationAlias : 'SmartyFilterI18n', '\SmartyFilter\Model\SmartyFilterI18nQuery'); }
php
public function useSmartyFilterI18nQuery($relationAlias = null, $joinType = 'LEFT JOIN') { return $this ->joinSmartyFilterI18n($relationAlias, $joinType) ->useQuery($relationAlias ? $relationAlias : 'SmartyFilterI18n', '\SmartyFilter\Model\SmartyFilterI18nQuery'); }
Use the SmartyFilterI18n relation SmartyFilterI18n object @see useQuery() @param string $relationAlias optional alias for the relation, to be used as main alias in the secondary query @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' @return \SmartyFilter\Model\SmartyFilterI18nQuery A secondary query class using the current class as primary query
https://github.com/thelia-modules/SmartyFilter/blob/e510d281f51ddc4344e563d0f6aaa192fa7171e9/Model/Base/SmartyFilterQuery.php#L436-L441
thelia-modules/SmartyFilter
Model/Base/SmartyFilterQuery.php
SmartyFilterQuery.prune
public function prune($smartyFilter = null) { if ($smartyFilter) { $this->addUsingAlias(SmartyFilterTableMap::ID, $smartyFilter->getId(), Criteria::NOT_EQUAL); } return $this; }
php
public function prune($smartyFilter = null) { if ($smartyFilter) { $this->addUsingAlias(SmartyFilterTableMap::ID, $smartyFilter->getId(), Criteria::NOT_EQUAL); } return $this; }
Exclude object from result @param ChildSmartyFilter $smartyFilter Object to remove from the list of results @return ChildSmartyFilterQuery The current query, for fluid interface
https://github.com/thelia-modules/SmartyFilter/blob/e510d281f51ddc4344e563d0f6aaa192fa7171e9/Model/Base/SmartyFilterQuery.php#L450-L457
SpoonX/SxBootstrap
src/SxBootstrap/View/Helper/Bootstrap/NavigationMenu.php
NavigationMenu.renderDropDownMenu
public function renderDropDownMenu($container = null, array $options = array()) { $menu = $this->getNavigationMenu()->renderMenu($container, $options); $query = new Query($menu, strtolower(mb_detect_encoding($menu))); $uls = $query->execute('li>ul'); /** @var \DOMElement $ul */ foreach ($uls as $key => $ul) { $caret = $uls->getDocument()->createDocumentFragment(); $caret->appendXML('<b class="caret" />'); $index = $key+1; $this->addCss('dropdown-menu', $ul); $ul->setAttribute('role', 'menu'); $ul->setAttribute('aria-labelledby', "drop{$index}"); $li = $ul->parentNode; $this->addCss('dropdown', $li); $a = $li->firstChild; $this->addCss('dropdown-toggle', $a); $a->setAttribute('role', 'button'); $a->setAttribute('data-toggle', 'dropdown'); $a->setAttribute('href', '#'); $a->setAttribute('id', "drop{$index}"); $a->appendChild($caret); } return preg_replace('~<(?:!DOCTYPE|/?(?:html|body))[^>]*>\s*~i', '', $uls->getDocument()->saveHTML()); }
php
public function renderDropDownMenu($container = null, array $options = array()) { $menu = $this->getNavigationMenu()->renderMenu($container, $options); $query = new Query($menu, strtolower(mb_detect_encoding($menu))); $uls = $query->execute('li>ul'); /** @var \DOMElement $ul */ foreach ($uls as $key => $ul) { $caret = $uls->getDocument()->createDocumentFragment(); $caret->appendXML('<b class="caret" />'); $index = $key+1; $this->addCss('dropdown-menu', $ul); $ul->setAttribute('role', 'menu'); $ul->setAttribute('aria-labelledby', "drop{$index}"); $li = $ul->parentNode; $this->addCss('dropdown', $li); $a = $li->firstChild; $this->addCss('dropdown-toggle', $a); $a->setAttribute('role', 'button'); $a->setAttribute('data-toggle', 'dropdown'); $a->setAttribute('href', '#'); $a->setAttribute('id', "drop{$index}"); $a->appendChild($caret); } return preg_replace('~<(?:!DOCTYPE|/?(?:html|body))[^>]*>\s*~i', '', $uls->getDocument()->saveHTML()); }
Render a dropdown menu @param string|\SpiffyNavigation\Container|null $container @param array $options @return string
https://github.com/SpoonX/SxBootstrap/blob/768b02e3b65f7dfe560e821cb0ff41ad3f86b3b6/src/SxBootstrap/View/Helper/Bootstrap/NavigationMenu.php#L37-L66
SpoonX/SxBootstrap
src/SxBootstrap/View/Helper/Bootstrap/NavigationMenu.php
NavigationMenu.addCss
protected function addCss($css, \DOMElement $el) { $el->setAttribute( 'class', $el->getAttribute('class') ? $el->getAttribute('class') . ' ' . $css : $css ); return $el; }
php
protected function addCss($css, \DOMElement $el) { $el->setAttribute( 'class', $el->getAttribute('class') ? $el->getAttribute('class') . ' ' . $css : $css ); return $el; }
Add css to a DomElement @param $css @param \DOMElement $el @return \DOMElement
https://github.com/SpoonX/SxBootstrap/blob/768b02e3b65f7dfe560e821cb0ff41ad3f86b3b6/src/SxBootstrap/View/Helper/Bootstrap/NavigationMenu.php#L75-L85
SpoonX/SxBootstrap
src/SxBootstrap/View/Helper/Bootstrap/NavigationMenu.php
NavigationMenu.renderPartial
public function renderPartial($container = null, $partial = null) { return $this->getView()->renderPartial($container, $partial); }
php
public function renderPartial($container = null, $partial = null) { return $this->getView()->renderPartial($container, $partial); }
Renders the given $container by invoking the partial view helper The container will simply be passed on as a model to the view script as-is, and will be available in the partial script as 'container', e.g. <code>echo 'Number of pages: ', count($this->container);</code>. @param string|\SpiffyNavigation\Container|null $container [optional] container to pass to view script. @param string $partial [optional] partial view script to use. @return string
https://github.com/SpoonX/SxBootstrap/blob/768b02e3b65f7dfe560e821cb0ff41ad3f86b3b6/src/SxBootstrap/View/Helper/Bootstrap/NavigationMenu.php#L98-L101
Nextpertise/PdoBulk
src/PdoBulk/PdoBulk.php
PdoBulk.flushQueue
public function flushQueue($table, $onduplicate = null) { if (gettype($table) != 'string') { throw new Exception('First parameter should be string, ' . gettype($table) . ' given.'); } if (isset($this->queue[$table]) && $this->queue[$table]) { // Define query $query = "INSERT INTO `" . $table . "` (`" . implode("`,`", array_keys($this->queue[$table][0])) . "`) VALUES "; // Count number of parameters in element $prefixOuter = ''; $rowPlaces = ''; foreach ($this->queue[$table] as $entry) { $prefixInner = ''; $rowPlaces .= $prefixOuter . '('; foreach ($entry as $column) { if (is_object($column) && $column instanceof PdoBulkSubquery) { $rowPlaces .= $prefixInner . '(' . $column->getQuery() . ')'; } else { $rowPlaces .= $prefixInner . '?'; } $prefixInner = ','; } $rowPlaces .= ')'; $prefixOuter = ','; } $query .= $rowPlaces; if ($onduplicate && gettype($onduplicate) == 'string') { $query .= ' ' . $onduplicate; } $stmt = $this->getPdo()->prepare($query); // Prepare binding values for execution $values = array(); foreach ($this->queue[$table] as $entry) { foreach ($entry as $column_name => $column_value) { if (is_object($column_value) && $column_value instanceof PdoBulkSubquery) { unset($entry[$column_name]); } } $values = array_merge($values, array_values($entry)); } $stmt->execute($values); $this->queue[$table] = array(); return true; } else { return false; } }
php
public function flushQueue($table, $onduplicate = null) { if (gettype($table) != 'string') { throw new Exception('First parameter should be string, ' . gettype($table) . ' given.'); } if (isset($this->queue[$table]) && $this->queue[$table]) { // Define query $query = "INSERT INTO `" . $table . "` (`" . implode("`,`", array_keys($this->queue[$table][0])) . "`) VALUES "; // Count number of parameters in element $prefixOuter = ''; $rowPlaces = ''; foreach ($this->queue[$table] as $entry) { $prefixInner = ''; $rowPlaces .= $prefixOuter . '('; foreach ($entry as $column) { if (is_object($column) && $column instanceof PdoBulkSubquery) { $rowPlaces .= $prefixInner . '(' . $column->getQuery() . ')'; } else { $rowPlaces .= $prefixInner . '?'; } $prefixInner = ','; } $rowPlaces .= ')'; $prefixOuter = ','; } $query .= $rowPlaces; if ($onduplicate && gettype($onduplicate) == 'string') { $query .= ' ' . $onduplicate; } $stmt = $this->getPdo()->prepare($query); // Prepare binding values for execution $values = array(); foreach ($this->queue[$table] as $entry) { foreach ($entry as $column_name => $column_value) { if (is_object($column_value) && $column_value instanceof PdoBulkSubquery) { unset($entry[$column_name]); } } $values = array_merge($values, array_values($entry)); } $stmt->execute($values); $this->queue[$table] = array(); return true; } else { return false; } }
Bulk insert logic
https://github.com/Nextpertise/PdoBulk/blob/21426f998fe292c11c356e75ffa6f716e2c507c7/src/PdoBulk/PdoBulk.php#L31-L81
chilimatic/chilimatic-framework
lib/cache/engine/Memcached.php
Memcached.saveCacheListing
public function saveCacheListing() { if (md5(json_encode($this->cacheListing)) === $this->md5Sum) return false; return parent::set('cacheListing', $this->cacheListing); }
php
public function saveCacheListing() { if (md5(json_encode($this->cacheListing)) === $this->md5Sum) return false; return parent::set('cacheListing', $this->cacheListing); }
Save the cacheListing to memcached @return boolean
https://github.com/chilimatic/chilimatic-framework/blob/8df7f12e75d75d3fd2197a58c80d39cbb4b9ff12/lib/cache/engine/Memcached.php#L66-L72
chilimatic/chilimatic-framework
lib/cache/engine/Memcached.php
Memcached.listCache
public function listCache() { $newlist = array(); foreach ($this->cacheListing as $key => $val) { $newlist [$key] = new \stdClass(); foreach ($val as $skey => $sval) { $newlist [$key]->$skey = $sval; } } $this->list = $newlist; return true; }
php
public function listCache() { $newlist = array(); foreach ($this->cacheListing as $key => $val) { $newlist [$key] = new \stdClass(); foreach ($val as $skey => $sval) { $newlist [$key]->$skey = $sval; } } $this->list = $newlist; return true; }
a listing of all cached entries which have been inserted through this wrapper @return boolean
https://github.com/chilimatic/chilimatic-framework/blob/8df7f12e75d75d3fd2197a58c80d39cbb4b9ff12/lib/cache/engine/Memcached.php#L80-L96
chilimatic/chilimatic-framework
lib/cache/engine/Memcached.php
Memcached.getStatus
public function getStatus() { $info_array = array(); $info_array ['status'] = parent::getStats(); $info_array ['version'] = parent::getVersion(); $info_array ['server_list'] = parent::getServerList(); return $info_array; }
php
public function getStatus() { $info_array = array(); $info_array ['status'] = parent::getStats(); $info_array ['version'] = parent::getVersion(); $info_array ['server_list'] = parent::getServerList(); return $info_array; }
returns the current status
https://github.com/chilimatic/chilimatic-framework/blob/8df7f12e75d75d3fd2197a58c80d39cbb4b9ff12/lib/cache/engine/Memcached.php#L102-L111
chilimatic/chilimatic-framework
lib/cache/engine/Memcached.php
Memcached.get
public function get($key = null, $cache_cb = null, &$cas_token = null) { if (isset($this->cacheListing [$key])) { return parent::get($key, $cache_cb, $cas_token); } return false; }
php
public function get($key = null, $cache_cb = null, &$cas_token = null) { if (isset($this->cacheListing [$key])) { return parent::get($key, $cache_cb, $cas_token); } return false; }
get method @param $key string @param $cache_cb callable [optional] @param $cas_token float [optional] @return mixed
https://github.com/chilimatic/chilimatic-framework/blob/8df7f12e75d75d3fd2197a58c80d39cbb4b9ff12/lib/cache/engine/Memcached.php#L160-L168
chilimatic/chilimatic-framework
lib/cache/engine/Memcached.php
Memcached.flush
public function flush($delay = 0) { if (parent::flush((int)$delay)) { $this->cacheListing = array(); return true; } return false; }
php
public function flush($delay = 0) { if (parent::flush((int)$delay)) { $this->cacheListing = array(); return true; } return false; }
flush the whole cache @param $delay integer delay in seconds @return boolean
https://github.com/chilimatic/chilimatic-framework/blob/8df7f12e75d75d3fd2197a58c80d39cbb4b9ff12/lib/cache/engine/Memcached.php#L178-L188
chilimatic/chilimatic-framework
lib/cache/engine/Memcached.php
Memcached.add
public function add($key, $value, $expiration = null) { return $this->set($key, $value, $expiration); }
php
public function add($key, $value, $expiration = null) { return $this->set($key, $value, $expiration); }
add method @param $key string @param $value mixed @param $expiration int @return boolean
https://github.com/chilimatic/chilimatic-framework/blob/8df7f12e75d75d3fd2197a58c80d39cbb4b9ff12/lib/cache/engine/Memcached.php#L199-L203
chilimatic/chilimatic-framework
lib/cache/engine/Memcached.php
Memcached.delete
public function delete($key, $time = 0) { if (parent::delete($key, ($time ? $time : null))) { unset($this->cacheListing [$key]); $this->saveCacheListing(); return true; } return false; }
php
public function delete($key, $time = 0) { if (parent::delete($key, ($time ? $time : null))) { unset($this->cacheListing [$key]); $this->saveCacheListing(); return true; } return false; }
delete method @param $key string @param $time int @return boolean
https://github.com/chilimatic/chilimatic-framework/blob/8df7f12e75d75d3fd2197a58c80d39cbb4b9ff12/lib/cache/engine/Memcached.php#L213-L224
chilimatic/chilimatic-framework
lib/cache/engine/Memcached.php
Memcached.deleteByKey
public function deleteByKey($server_key, $key, $time = 0) { if (parent::deleteByKey($server_key, $key, ($time ? $time : null))) { unset($this->cacheListing [$key]); $this->saveCacheListing(); return true; } return false; }
php
public function deleteByKey($server_key, $key, $time = 0) { if (parent::deleteByKey($server_key, $key, ($time ? $time : null))) { unset($this->cacheListing [$key]); $this->saveCacheListing(); return true; } return false; }
delete method multiserver pools @param $server_key string @param $key string @param $time int @return boolean
https://github.com/chilimatic/chilimatic-framework/blob/8df7f12e75d75d3fd2197a58c80d39cbb4b9ff12/lib/cache/engine/Memcached.php#L235-L246
chilimatic/chilimatic-framework
lib/cache/engine/Memcached.php
Memcached.deleteFromList
public function deleteFromList($key_array = array()) { if (empty($key_array)) return false; foreach ($key_array as $key_del) { if (empty($this->cacheListing)) break; foreach ($this->cacheListing as $key) { if (mb_strpos(mb_strtolower($key), mb_strtolower($key_del)) !== false) $this->delete($key); } } return true; }
php
public function deleteFromList($key_array = array()) { if (empty($key_array)) return false; foreach ($key_array as $key_del) { if (empty($this->cacheListing)) break; foreach ($this->cacheListing as $key) { if (mb_strpos(mb_strtolower($key), mb_strtolower($key_del)) !== false) $this->delete($key); } } return true; }
delete memcached values based on an input array @param array $key_array @return bool
https://github.com/chilimatic/chilimatic-framework/blob/8df7f12e75d75d3fd2197a58c80d39cbb4b9ff12/lib/cache/engine/Memcached.php#L256-L269
zhengb302/LumengPHP
src/LumengPHP/Kernel/Annotation/Parser/Lexer.php
Lexer.ANNOTATION
private function ANNOTATION() { $text = ''; do { $text .= $this->ch; $this->consume(); } while ($this->isLETTER()); $tokenType = null; switch ($text) { case '@var': $tokenType = Token::T_VAR; break; case '@get': case '@post': case '@request': case '@session': case '@config': case '@service': case '@currentEvent': $tokenType = Token::T_PROPERTY_INJECTOR; break; case '@keepDefault': case '@queued': case '@queue': $tokenType = Token::T_ACTION; break; default: $tokenType = Token::T_UNKNOWN_ANNOTATION; } return new Token($tokenType, $text); }
php
private function ANNOTATION() { $text = ''; do { $text .= $this->ch; $this->consume(); } while ($this->isLETTER()); $tokenType = null; switch ($text) { case '@var': $tokenType = Token::T_VAR; break; case '@get': case '@post': case '@request': case '@session': case '@config': case '@service': case '@currentEvent': $tokenType = Token::T_PROPERTY_INJECTOR; break; case '@keepDefault': case '@queued': case '@queue': $tokenType = Token::T_ACTION; break; default: $tokenType = Token::T_UNKNOWN_ANNOTATION; } return new Token($tokenType, $text); }
识别注解 @return Token @throws Exception
https://github.com/zhengb302/LumengPHP/blob/77f41c32a5c6ba71c65956e5c4650707b6168c41/src/LumengPHP/Kernel/Annotation/Parser/Lexer.php#L105-L135
zhengb302/LumengPHP
src/LumengPHP/Kernel/Annotation/Parser/Lexer.php
Lexer.ID
private function ID() { $text = ''; do { $text .= $this->ch; $this->consume(); } while ($this->isLETTER() || $this->isNUMBER() || $this->ch == '_'); return new Token(Token::T_ID, $text); }
php
private function ID() { $text = ''; do { $text .= $this->ch; $this->consume(); } while ($this->isLETTER() || $this->isNUMBER() || $this->ch == '_'); return new Token(Token::T_ID, $text); }
识别标识符 @return Token
https://github.com/zhengb302/LumengPHP/blob/77f41c32a5c6ba71c65956e5c4650707b6168c41/src/LumengPHP/Kernel/Annotation/Parser/Lexer.php#L141-L149
zhengb302/LumengPHP
src/LumengPHP/Kernel/Annotation/Parser/Lexer.php
Lexer.consume
private function consume() { $this->i++; if ($this->i >= $this->len) { $this->ch = self::EOF; } else { $this->ch = $this->docComment[$this->i]; } }
php
private function consume() { $this->i++; if ($this->i >= $this->len) { $this->ch = self::EOF; } else { $this->ch = $this->docComment[$this->i]; } }
向前移动一个字符,同时检测输入的结束
https://github.com/zhengb302/LumengPHP/blob/77f41c32a5c6ba71c65956e5c4650707b6168c41/src/LumengPHP/Kernel/Annotation/Parser/Lexer.php#L154-L161
phPoirot/AuthSystem
Authenticate/RepoIdentityCredential/IdentityCredentialWrapIdentityMap.php
IdentityCredentialWrapIdentityMap.findIdentityMatch
function findIdentityMatch() { $identity = $this->wrap->findIdentityMatch(); if (!$identity) return false; $return = $this->identity_map->clean(); $return->import($identity); return $identity; }
php
function findIdentityMatch() { $identity = $this->wrap->findIdentityMatch(); if (!$identity) return false; $return = $this->identity_map->clean(); $return->import($identity); return $identity; }
Get Identity Match By Credential as Options @return iIdentity @throws exAuthentication @throws \Exception credential not fulfilled, etc..
https://github.com/phPoirot/AuthSystem/blob/bb8d02f72a7c2686d7d453021143361fa704a5a6/Authenticate/RepoIdentityCredential/IdentityCredentialWrapIdentityMap.php#L39-L48
gbprod/doctrine-specification
src/DoctrineSpecification/Handler.php
Handler.handle
public function handle(Specification $spec) { $factory = $this->registry->getFactory($spec); return $factory->create($spec, $this->qb); }
php
public function handle(Specification $spec) { $factory = $this->registry->getFactory($spec); return $factory->create($spec, $this->qb); }
handle specification for queryfactory @param Specification $spec @return Base
https://github.com/gbprod/doctrine-specification/blob/348e8ec31547f4949a193d21b3a1d5cdb48b23cb/src/DoctrineSpecification/Handler.php#L56-L61
WolfMicrosystems/ldap
src/WMS/Library/Ldap/Enum/AbstractEnum.php
AbstractEnum.isValid
public static function isValid($value) { if (__CLASS__ === get_called_class()) { throw new \RuntimeException('Cannot call isValid() on ' . __CLASS__); } $reflectionClass = new \ReflectionClass(get_called_class()); $validValues = $reflectionClass->getConstants(); if (static::isBitFlag()) { $bitFlagAllOn = 0; foreach ($validValues as $validValue) { $bitFlagAllOn |= $validValue; } return ($value | $bitFlagAllOn) === $bitFlagAllOn; } return in_array($value, $validValues, true); }
php
public static function isValid($value) { if (__CLASS__ === get_called_class()) { throw new \RuntimeException('Cannot call isValid() on ' . __CLASS__); } $reflectionClass = new \ReflectionClass(get_called_class()); $validValues = $reflectionClass->getConstants(); if (static::isBitFlag()) { $bitFlagAllOn = 0; foreach ($validValues as $validValue) { $bitFlagAllOn |= $validValue; } return ($value | $bitFlagAllOn) === $bitFlagAllOn; } return in_array($value, $validValues, true); }
Checks if the value is valid according to the enumeration. @param mixed $value @return bool @throws \RuntimeException
https://github.com/WolfMicrosystems/ldap/blob/872bbdc6127a41f0c51f2aa73425b8063a5c8148/src/WMS/Library/Ldap/Enum/AbstractEnum.php#L28-L48
spiral/views
src/ViewSource.php
ViewSource.withCode
public function withCode(string $code): ViewSource { $context = clone $this; $context->code = $code; return $context; }
php
public function withCode(string $code): ViewSource { $context = clone $this; $context->code = $code; return $context; }
Get source copy with redefined code. @param string $code @return self
https://github.com/spiral/views/blob/0e35697204dfffabf71546d20e89f14b50414a9a/src/ViewSource.php#L87-L93
alanfm/htmlbuilder
src/Elements/Table.php
Table.thead_render
private function thead_render() { if (is_null($this->thead)) { return; } $tr = ElementFactory::make('tr'); foreach ($this->thead as $text) { $tr->value(ElementFactory::make('th')->value($text)); } return ElementFactory::make('thead')->value($tr)->render(); }
php
private function thead_render() { if (is_null($this->thead)) { return; } $tr = ElementFactory::make('tr'); foreach ($this->thead as $text) { $tr->value(ElementFactory::make('th')->value($text)); } return ElementFactory::make('thead')->value($tr)->render(); }
@method thead_render() Constroi a tag thead @return string
https://github.com/alanfm/htmlbuilder/blob/37fba0d2d3d69df47fe99d55aad76363432dc3f6/src/Elements/Table.php#L86-L99
alanfm/htmlbuilder
src/Elements/Table.php
Table.tbody_render
private function tbody_render() { $tbody = ElementFactory::make('tbody'); foreach ($this->tbody as $row) { $tr = ElementFactory::make('tr'); foreach ($row as $cell) { $tr->value(ElementFactory::make('td')->value($cell)->render()); } $tbody->value($tr); } return $tbody->render(); }
php
private function tbody_render() { $tbody = ElementFactory::make('tbody'); foreach ($this->tbody as $row) { $tr = ElementFactory::make('tr'); foreach ($row as $cell) { $tr->value(ElementFactory::make('td')->value($cell)->render()); } $tbody->value($tr); } return $tbody->render(); }
@method tbody_render() Constroi a tag tbody @return string
https://github.com/alanfm/htmlbuilder/blob/37fba0d2d3d69df47fe99d55aad76363432dc3f6/src/Elements/Table.php#L108-L123
alanfm/htmlbuilder
src/Elements/Table.php
Table.tbody
public function tbody(array $tbody) { if (!is_array($tbody)) { throw new \Exception('Parametro inválido! O valor esperado é uma matriz.'); } foreach ($tbody as $row) { if (!is_array($row)) { throw new \Exception('Parametro inválido! O valor esperado é uma matriz.'); } } $this->tbody = $tbody; return $this; }
php
public function tbody(array $tbody) { if (!is_array($tbody)) { throw new \Exception('Parametro inválido! O valor esperado é uma matriz.'); } foreach ($tbody as $row) { if (!is_array($row)) { throw new \Exception('Parametro inválido! O valor esperado é uma matriz.'); } } $this->tbody = $tbody; return $this; }
@method tbody() Seta o conteúdo da tabela @param array(matriz) $tbody @return InterfaceElement(Table)
https://github.com/alanfm/htmlbuilder/blob/37fba0d2d3d69df47fe99d55aad76363432dc3f6/src/Elements/Table.php#L134-L149
alanfm/htmlbuilder
src/Elements/Table.php
Table.render
public function render() { $this->table->value($this->thead_render()) ->value($this->tbody_render()); return $this->table->render(); }
php
public function render() { $this->table->value($this->thead_render()) ->value($this->tbody_render()); return $this->table->render(); }
@method render() Renderiza o elemento table @return string
https://github.com/alanfm/htmlbuilder/blob/37fba0d2d3d69df47fe99d55aad76363432dc3f6/src/Elements/Table.php#L175-L181
vi-kon/laravel-parser-markdown
src/ViKon/ParserMarkdown/Skin/Bootstrap/Single/LinkBootstrapRenderer.php
LinkBootstrapRenderer.register
public function register(Renderer $renderer) { $this->registerTokenRenderer(LinkInlineRule::NAME, 'renderInline', $renderer); $this->registerTokenRenderer(LinkReferenceRule::NAME, 'renderReference', $renderer); $this->registerTokenRenderer(LinkAutoRule::NAME, 'renderAuto', $renderer); }
php
public function register(Renderer $renderer) { $this->registerTokenRenderer(LinkInlineRule::NAME, 'renderInline', $renderer); $this->registerTokenRenderer(LinkReferenceRule::NAME, 'renderReference', $renderer); $this->registerTokenRenderer(LinkAutoRule::NAME, 'renderAuto', $renderer); }
Register renderer @param \ViKon\Parser\Renderer\Renderer $renderer
https://github.com/vi-kon/laravel-parser-markdown/blob/4b258b407df95f6b6be284252762ef3ddbef1e35/src/ViKon/ParserMarkdown/Skin/Bootstrap/Single/LinkBootstrapRenderer.php#L27-L31
g4code/http
src/Response.php
Response.setRedirect
public function setRedirect($url, $code = 302) { $this->canSendHeaders(true); $this->setHeader('Location', $url, true) ->setHttpResponseCode($code); return $this; }
php
public function setRedirect($url, $code = 302) { $this->canSendHeaders(true); $this->setHeader('Location', $url, true) ->setHttpResponseCode($code); return $this; }
Set redirect URL Sets Location header and response code. Forces replacement of any prior redirects. @param string $url @param int $code @return \G4\Http\Response
https://github.com/g4code/http/blob/270a6b30d49a3656aea6d85e400f18293427926e/src/Response.php#L146-L153
g4code/http
src/Response.php
Response.setHttpResponseCode
public function setHttpResponseCode($code) { if (!is_int($code) || (100 > $code) || (599 < $code)) { throw new \Exception('Invalid HTTP response code'); } $this->_isRedirect = (300 <= $code) && (307 >= $code); $this->_httpResponseCode = $code; return $this; }
php
public function setHttpResponseCode($code) { if (!is_int($code) || (100 > $code) || (599 < $code)) { throw new \Exception('Invalid HTTP response code'); } $this->_isRedirect = (300 <= $code) && (307 >= $code); $this->_httpResponseCode = $code; return $this; }
Set HTTP response code to use with headers @param int $code @return \G4\Http\Response
https://github.com/g4code/http/blob/270a6b30d49a3656aea6d85e400f18293427926e/src/Response.php#L243-L252
g4code/http
src/Response.php
Response.sendHeaders
public function sendHeaders() { // Only check if we can send headers if we have headers to send if (count($this->_headersRaw) || count($this->_headers) || (200 != $this->_httpResponseCode)) { $this->canSendHeaders(true); } elseif (200 == $this->_httpResponseCode) { // Haven't changed the response code, and we have no headers return $this; } $httpCodeSent = false; foreach ($this->_headersRaw as $header) { if (!$httpCodeSent && $this->_httpResponseCode) { header($header, true, $this->_httpResponseCode); $httpCodeSent = true; } else { header($header); } } foreach ($this->_headers as $header) { if (!$httpCodeSent && $this->_httpResponseCode) { header($header['name'] . ': ' . $header['value'], $header['replace'], $this->_httpResponseCode); $httpCodeSent = true; } else { header($header['name'] . ': ' . $header['value'], $header['replace']); } } if (!$httpCodeSent) { header('HTTP/1.1 ' . $this->_httpResponseCode); $httpCodeSent = true; } return $this; }
php
public function sendHeaders() { // Only check if we can send headers if we have headers to send if (count($this->_headersRaw) || count($this->_headers) || (200 != $this->_httpResponseCode)) { $this->canSendHeaders(true); } elseif (200 == $this->_httpResponseCode) { // Haven't changed the response code, and we have no headers return $this; } $httpCodeSent = false; foreach ($this->_headersRaw as $header) { if (!$httpCodeSent && $this->_httpResponseCode) { header($header, true, $this->_httpResponseCode); $httpCodeSent = true; } else { header($header); } } foreach ($this->_headers as $header) { if (!$httpCodeSent && $this->_httpResponseCode) { header($header['name'] . ': ' . $header['value'], $header['replace'], $this->_httpResponseCode); $httpCodeSent = true; } else { header($header['name'] . ': ' . $header['value'], $header['replace']); } } if (!$httpCodeSent) { header('HTTP/1.1 ' . $this->_httpResponseCode); $httpCodeSent = true; } return $this; }
Send all headers Sends any headers specified. If an {@link setHttpResponseCode() HTTP response code} has been specified, it is sent with the first header. @return \G4\Http\Response
https://github.com/g4code/http/blob/270a6b30d49a3656aea6d85e400f18293427926e/src/Response.php#L289-L325
g4code/http
src/Response.php
Response.setBody
public function setBody($content, $name = null) { if ((null === $name) || !is_string($name)) { $this->_body = array('default' => (string) $content); } else { $this->_body[$name] = (string) $content; } return $this; }
php
public function setBody($content, $name = null) { if ((null === $name) || !is_string($name)) { $this->_body = array('default' => (string) $content); } else { $this->_body[$name] = (string) $content; } return $this; }
Set body content If $name is not passed, or is not a string, resets the entire body and sets the 'default' key to $content. If $name is a string, sets the named segment in the body array to $content. @param string $content @param null|string $name @return \G4\Http\Response
https://github.com/g4code/http/blob/270a6b30d49a3656aea6d85e400f18293427926e/src/Response.php#L340-L349
g4code/http
src/Response.php
Response.appendBody
public function appendBody($content, $name = null) { if ((null === $name) || !is_string($name)) { if (isset($this->_body['default'])) { $this->_body['default'] .= (string) $content; } else { return $this->append('default', $content); } } elseif (isset($this->_body[$name])) { $this->_body[$name] .= (string) $content; } else { return $this->append($name, $content); } return $this; }
php
public function appendBody($content, $name = null) { if ((null === $name) || !is_string($name)) { if (isset($this->_body['default'])) { $this->_body['default'] .= (string) $content; } else { return $this->append('default', $content); } } elseif (isset($this->_body[$name])) { $this->_body[$name] .= (string) $content; } else { return $this->append($name, $content); } return $this; }
Append content to the body content @param string $content @param null|string $name @return \G4\Http\Response
https://github.com/g4code/http/blob/270a6b30d49a3656aea6d85e400f18293427926e/src/Response.php#L358-L373
g4code/http
src/Response.php
Response.clearBody
public function clearBody($name = null) { if (null !== $name) { $name = (string) $name; if (isset($this->_body[$name])) { unset($this->_body[$name]); return true; } return false; } $this->_body = array(); return true; }
php
public function clearBody($name = null) { if (null !== $name) { $name = (string) $name; if (isset($this->_body[$name])) { unset($this->_body[$name]); return true; } return false; } $this->_body = array(); return true; }
Clear body array With no arguments, clears the entire body array. Given a $name, clears just that named segment; if no segment matching $name exists, returns false to indicate an error. @param string $name Named segment to clear @return boolean
https://github.com/g4code/http/blob/270a6b30d49a3656aea6d85e400f18293427926e/src/Response.php#L385-L399
g4code/http
src/Response.php
Response.getBody
public function getBody($spec = false) { if (false === $spec) { ob_start(); $this->outputBody(); return ob_get_clean(); } elseif (true === $spec) { return $this->_body; } elseif (is_string($spec) && isset($this->_body[$spec])) { return $this->_body[$spec]; } return null; }
php
public function getBody($spec = false) { if (false === $spec) { ob_start(); $this->outputBody(); return ob_get_clean(); } elseif (true === $spec) { return $this->_body; } elseif (is_string($spec) && isset($this->_body[$spec])) { return $this->_body[$spec]; } return null; }
Return the body content If $spec is false, returns the concatenated values of the body content array. If $spec is boolean true, returns the body content array. If $spec is a string and matches a named segment, returns the contents of that segment; otherwise, returns null. @param boolean $spec @return string|array|null
https://github.com/g4code/http/blob/270a6b30d49a3656aea6d85e400f18293427926e/src/Response.php#L412-L425
g4code/http
src/Response.php
Response.append
public function append($name, $content) { if (!is_string($name)) { throw new \Exception('Invalid body segment key ("' . gettype($name) . '")'); } if (isset($this->_body[$name])) { unset($this->_body[$name]); } $this->_body[$name] = (string) $content; return $this; }
php
public function append($name, $content) { if (!is_string($name)) { throw new \Exception('Invalid body segment key ("' . gettype($name) . '")'); } if (isset($this->_body[$name])) { unset($this->_body[$name]); } $this->_body[$name] = (string) $content; return $this; }
Append a named body segment to the body content array If segment already exists, replaces with $content and places at end of array. @param string $name @param string $content @return \G4\Http\Response
https://github.com/g4code/http/blob/270a6b30d49a3656aea6d85e400f18293427926e/src/Response.php#L437-L449
g4code/http
src/Response.php
Response.insert
public function insert($name, $content, $parent = null, $before = false) { if (!is_string($name)) { throw new \Exception('Invalid body segment key ("' . gettype($name) . '")'); } if ((null !== $parent) && !is_string($parent)) { throw new \Exception('Invalid body segment parent key ("' . gettype($parent) . '")'); } if (isset($this->_body[$name])) { unset($this->_body[$name]); } if ((null === $parent) || !isset($this->_body[$parent])) { return $this->append($name, $content); } $ins = array($name => (string) $content); $keys = array_keys($this->_body); $loc = array_search($parent, $keys); if (!$before) { // Increment location if not inserting before ++$loc; } if (0 === $loc) { // If location of key is 0, we're prepending $this->_body = $ins + $this->_body; } elseif ($loc >= (count($this->_body))) { // If location of key is maximal, we're appending $this->_body = $this->_body + $ins; } else { // Otherwise, insert at location specified $pre = array_slice($this->_body, 0, $loc); $post = array_slice($this->_body, $loc); $this->_body = $pre + $ins + $post; } return $this; }
php
public function insert($name, $content, $parent = null, $before = false) { if (!is_string($name)) { throw new \Exception('Invalid body segment key ("' . gettype($name) . '")'); } if ((null !== $parent) && !is_string($parent)) { throw new \Exception('Invalid body segment parent key ("' . gettype($parent) . '")'); } if (isset($this->_body[$name])) { unset($this->_body[$name]); } if ((null === $parent) || !isset($this->_body[$parent])) { return $this->append($name, $content); } $ins = array($name => (string) $content); $keys = array_keys($this->_body); $loc = array_search($parent, $keys); if (!$before) { // Increment location if not inserting before ++$loc; } if (0 === $loc) { // If location of key is 0, we're prepending $this->_body = $ins + $this->_body; } elseif ($loc >= (count($this->_body))) { // If location of key is maximal, we're appending $this->_body = $this->_body + $ins; } else { // Otherwise, insert at location specified $pre = array_slice($this->_body, 0, $loc); $post = array_slice($this->_body, $loc); $this->_body = $pre + $ins + $post; } return $this; }
Insert a named segment into the body content array @param string $name @param string $content @param string $parent @param boolean $before Whether to insert the new segment before or after the parent. Defaults to false (after) @return \G4\Http\Response
https://github.com/g4code/http/blob/270a6b30d49a3656aea6d85e400f18293427926e/src/Response.php#L487-L527
g4code/http
src/Response.php
Response.hasExceptionOfType
public function hasExceptionOfType($type) { foreach ($this->_exceptions as $e) { if ($e instanceof $type) { return true; } } return false; }
php
public function hasExceptionOfType($type) { foreach ($this->_exceptions as $e) { if ($e instanceof $type) { return true; } } return false; }
Does the response object contain an exception of a given type? @param string $type @return boolean
https://github.com/g4code/http/blob/270a6b30d49a3656aea6d85e400f18293427926e/src/Response.php#L578-L587
g4code/http
src/Response.php
Response.hasExceptionOfMessage
public function hasExceptionOfMessage($message) { foreach ($this->_exceptions as $e) { if ($message == $e->getMessage()) { return true; } } return false; }
php
public function hasExceptionOfMessage($message) { foreach ($this->_exceptions as $e) { if ($message == $e->getMessage()) { return true; } } return false; }
Does the response object contain an exception with a given message? @param string $message @return boolean
https://github.com/g4code/http/blob/270a6b30d49a3656aea6d85e400f18293427926e/src/Response.php#L595-L604
g4code/http
src/Response.php
Response.hasExceptionOfCode
public function hasExceptionOfCode($code) { $code = (int) $code; foreach ($this->_exceptions as $e) { if ($code == $e->getCode()) { return true; } } return false; }
php
public function hasExceptionOfCode($code) { $code = (int) $code; foreach ($this->_exceptions as $e) { if ($code == $e->getCode()) { return true; } } return false; }
Does the response object contain an exception with a given code? @param int $code @return boolean
https://github.com/g4code/http/blob/270a6b30d49a3656aea6d85e400f18293427926e/src/Response.php#L612-L622
g4code/http
src/Response.php
Response.getExceptionByType
public function getExceptionByType($type) { $exceptions = array(); foreach ($this->_exceptions as $e) { if ($e instanceof $type) { $exceptions[] = $e; } } if (empty($exceptions)) { $exceptions = false; } return $exceptions; }
php
public function getExceptionByType($type) { $exceptions = array(); foreach ($this->_exceptions as $e) { if ($e instanceof $type) { $exceptions[] = $e; } } if (empty($exceptions)) { $exceptions = false; } return $exceptions; }
Retrieve all exceptions of a given type @param string $type @return false|array
https://github.com/g4code/http/blob/270a6b30d49a3656aea6d85e400f18293427926e/src/Response.php#L630-L644
g4code/http
src/Response.php
Response.getExceptionByMessage
public function getExceptionByMessage($message) { $exceptions = array(); foreach ($this->_exceptions as $e) { if ($message == $e->getMessage()) { $exceptions[] = $e; } } if (empty($exceptions)) { $exceptions = false; } return $exceptions; }
php
public function getExceptionByMessage($message) { $exceptions = array(); foreach ($this->_exceptions as $e) { if ($message == $e->getMessage()) { $exceptions[] = $e; } } if (empty($exceptions)) { $exceptions = false; } return $exceptions; }
Retrieve all exceptions of a given message @param string $message @return false|array
https://github.com/g4code/http/blob/270a6b30d49a3656aea6d85e400f18293427926e/src/Response.php#L652-L666
g4code/http
src/Response.php
Response.getExceptionByCode
public function getExceptionByCode($code) { $code = (int) $code; $exceptions = array(); foreach ($this->_exceptions as $e) { if ($code == $e->getCode()) { $exceptions[] = $e; } } if (empty($exceptions)) { $exceptions = false; } return $exceptions; }
php
public function getExceptionByCode($code) { $code = (int) $code; $exceptions = array(); foreach ($this->_exceptions as $e) { if ($code == $e->getCode()) { $exceptions[] = $e; } } if (empty($exceptions)) { $exceptions = false; } return $exceptions; }
Retrieve all exceptions of a given code @param mixed $code @return void
https://github.com/g4code/http/blob/270a6b30d49a3656aea6d85e400f18293427926e/src/Response.php#L674-L689
g4code/http
src/Response.php
Response.renderExceptions
public function renderExceptions($flag = null) { if (null !== $flag) { $this->_renderExceptions = $flag ? true : false; } return $this->_renderExceptions; }
php
public function renderExceptions($flag = null) { if (null !== $flag) { $this->_renderExceptions = $flag ? true : false; } return $this->_renderExceptions; }
Whether or not to render exceptions (off by default) If called with no arguments or a null argument, returns the value of the flag; otherwise, sets it and returns the current value. @param boolean $flag Optional @return boolean
https://github.com/g4code/http/blob/270a6b30d49a3656aea6d85e400f18293427926e/src/Response.php#L700-L708
g4code/http
src/Response.php
Response.sendResponse
public function sendResponse() { $this->sendHeaders(); if ($this->isException() && $this->renderExceptions()) { $exceptions = ''; foreach ($this->getException() as $e) { $exceptions .= $e->__toString() . "\n"; } echo $exceptions; return; } $this->outputBody(); }
php
public function sendResponse() { $this->sendHeaders(); if ($this->isException() && $this->renderExceptions()) { $exceptions = ''; foreach ($this->getException() as $e) { $exceptions .= $e->__toString() . "\n"; } echo $exceptions; return; } $this->outputBody(); }
Send the response, including all headers, rendering exceptions if so requested. @return void
https://github.com/g4code/http/blob/270a6b30d49a3656aea6d85e400f18293427926e/src/Response.php#L716-L732
vi-kon/laravel-parser-markdown
src/ViKon/ParserMarkdown/Rule/Block/CodeBlockRule.php
CodeBlockRule.parseToken
public function parseToken($content, $position, $state, TokenList $tokenList) { switch ($state) { case Lexer::STATE_MATCHED: $token = $tokenList->addToken($this->name, $position); $token->set('content', str_repeat("\n", substr_count($content, "\n"))); break; default: parent::parseToken($content, $position, $state, $tokenList); break; } }
php
public function parseToken($content, $position, $state, TokenList $tokenList) { switch ($state) { case Lexer::STATE_MATCHED: $token = $tokenList->addToken($this->name, $position); $token->set('content', str_repeat("\n", substr_count($content, "\n"))); break; default: parent::parseToken($content, $position, $state, $tokenList); break; } }
@param string $content @param int $position @param int $state @param \ViKon\Parser\TokenList $tokenList @throws \ViKon\Parser\Rule\RuleException
https://github.com/vi-kon/laravel-parser-markdown/blob/4b258b407df95f6b6be284252762ef3ddbef1e35/src/ViKon/ParserMarkdown/Rule/Block/CodeBlockRule.php#L57-L67
vi-kon/laravel-parser-markdown
src/ViKon/ParserMarkdown/Rule/Block/CodeBlockRule.php
CodeBlockRule.handleUnmatchedState
protected function handleUnmatchedState($content, $position, TokenList $tokenList) { if (!empty($content)) { $this->parseContent($content, $tokenList); } }
php
protected function handleUnmatchedState($content, $position, TokenList $tokenList) { if (!empty($content)) { $this->parseContent($content, $tokenList); } }
Handle lexers unmatched state @param string $content @param int $position @param \ViKon\Parser\TokenList $tokenList
https://github.com/vi-kon/laravel-parser-markdown/blob/4b258b407df95f6b6be284252762ef3ddbef1e35/src/ViKon/ParserMarkdown/Rule/Block/CodeBlockRule.php#L85-L89
Phpillip/phpillip
src/Provider/PygmentsServiceProvider.php
PygmentsServiceProvider.register
public function register(Application $app) { if ($app['pygments_class']::isAvailable()) { $app['pygments'] = $app->share(function ($app) { return new $app['pygments_class'](); }); } }
php
public function register(Application $app) { if ($app['pygments_class']::isAvailable()) { $app['pygments'] = $app->share(function ($app) { return new $app['pygments_class'](); }); } }
{@inheritdoc}
https://github.com/Phpillip/phpillip/blob/c37afaafb536361e7e0b564659f1cd5b80b98be9/src/Provider/PygmentsServiceProvider.php#L16-L23
Fuzzyma/contao-eloquent-bundle
Traits/ContaoFilesModelTrait.php
ContaoFilesModelTrait.getContaoFile
private function getContaoFile($uuid) { $uuid = StringUtil::deserialize($uuid); if (is_array($uuid)) return FilesModel::findMultipleByUuids($uuid); return FilesModel::findByUuid($uuid); }
php
private function getContaoFile($uuid) { $uuid = StringUtil::deserialize($uuid); if (is_array($uuid)) return FilesModel::findMultipleByUuids($uuid); return FilesModel::findByUuid($uuid); }
Always return a contao file model since its more suitable when working with contao
https://github.com/Fuzzyma/contao-eloquent-bundle/blob/d5af2a3f48807db278ec3c92df463171f9514179/Traits/ContaoFilesModelTrait.php#L19-L25
Fuzzyma/contao-eloquent-bundle
Traits/ContaoFilesModelTrait.php
ContaoFilesModelTrait.setContaoFile
private function setContaoFile($file) { if (is_array($file)) { return serialize(array_map([__CLASS__, 'setContaoFile'], $file)); } if ($file instanceof FilesModel) { return $file->uuid; } if (Validator::isStringUuid($file)) { return StringUtil::uuidToBin($file); } return $file; }
php
private function setContaoFile($file) { if (is_array($file)) { return serialize(array_map([__CLASS__, 'setContaoFile'], $file)); } if ($file instanceof FilesModel) { return $file->uuid; } if (Validator::isStringUuid($file)) { return StringUtil::uuidToBin($file); } return $file; }
we check if its a file model and extract the uuid. If its a string we convert it.
https://github.com/Fuzzyma/contao-eloquent-bundle/blob/d5af2a3f48807db278ec3c92df463171f9514179/Traits/ContaoFilesModelTrait.php#L28-L41
octris/sqlbuilder
libs/Sqlbuilder.php
Sqlbuilder.resolveSnippet
public function resolveSnippet($name, array &$parameters) { $name = strtoupper($name); if (isset($this->clauses[$name])) { $snippet = $this->clauses[$name]->resolveClauses($parameters); } elseif (isset($this->snippets[$name])) { $snippet = $this->snippets[$name]; } else { $snippet = ''; } return $snippet; }
php
public function resolveSnippet($name, array &$parameters) { $name = strtoupper($name); if (isset($this->clauses[$name])) { $snippet = $this->clauses[$name]->resolveClauses($parameters); } elseif (isset($this->snippets[$name])) { $snippet = $this->snippets[$name]; } else { $snippet = ''; } return $snippet; }
Resolve template snippet. @param string $name Name of snippet to resolve. @param array $parameters Parameters for resolving snippet. @return array Array of resolved template snippet and parameters.
https://github.com/octris/sqlbuilder/blob/d22a494fd4814b3245fce20b4076eec1b382ffd3/libs/Sqlbuilder.php#L60-L73
octris/sqlbuilder
libs/Sqlbuilder.php
Sqlbuilder.resolveParameter
public function resolveParameter($idx, $type, $name) { return $this->dialect->resolveParameter($idx, $type, $name); }
php
public function resolveParameter($idx, $type, $name) { return $this->dialect->resolveParameter($idx, $type, $name); }
Resolve query parameter. @param int $idx Position of the parameter in the query. @param string $type Type of the parameter. @param string $name Name of the parameter.
https://github.com/octris/sqlbuilder/blob/d22a494fd4814b3245fce20b4076eec1b382ffd3/libs/Sqlbuilder.php#L82-L85
octris/sqlbuilder
libs/Sqlbuilder.php
Sqlbuilder.addClause
protected function addClause($name, $sql, array $parameters, $joiner, $prefix = '', $postfix = '', $is_inclusive = false) { $name = strtoupper($name); if (!isset($this->clauses[$name])) { $this->clauses[$name] = new \Octris\Sqlbuilder\Clauses($joiner, $prefix, $postfix); } $this->clauses[$name]->addClause($sql, $parameters, $is_inclusive); }
php
protected function addClause($name, $sql, array $parameters, $joiner, $prefix = '', $postfix = '', $is_inclusive = false) { $name = strtoupper($name); if (!isset($this->clauses[$name])) { $this->clauses[$name] = new \Octris\Sqlbuilder\Clauses($joiner, $prefix, $postfix); } $this->clauses[$name]->addClause($sql, $parameters, $is_inclusive); }
Add clause. @param string $name Name of clause to add. @param string $sql SQL snippet of clause. @param array $parameters Parameters for clause. @param string $joiner String to use for joining multiple clauses of the same name. @param string $prefix Optional prefix string for joined clauses. @param string $postfix Optional postfix string for joined clauses. @param bool $is_inclusive Optional clause mode.
https://github.com/octris/sqlbuilder/blob/d22a494fd4814b3245fce20b4076eec1b382ffd3/libs/Sqlbuilder.php#L125-L134
octris/sqlbuilder
libs/Sqlbuilder.php
Sqlbuilder.addPaging
public function addPaging($limit, $page = 1) { $this->addClause('PAGING', $this->dialect->getLimitString($limit, ($page - 1) * $limit), [], '', '', "\n", false); return $this; }
php
public function addPaging($limit, $page = 1) { $this->addClause('PAGING', $this->dialect->getLimitString($limit, ($page - 1) * $limit), [], '', '', "\n", false); return $this; }
Add paging. @param int $limit Limit rows to return. @param int $page Optional page to start querying at. @return \Octris\Sqlbuilder This instance for method chaining.
https://github.com/octris/sqlbuilder/blob/d22a494fd4814b3245fce20b4076eec1b382ffd3/libs/Sqlbuilder.php#L295-L300
buse974/Dal
src/Dal/Mapper/AbstractMapper.php
AbstractMapper.select
public function select(AbstractModel $model, $order = null) { if ($this->usePaginator === true) { $sl = $this->tableGateway->getSql()->select(); $sl->where($model->toArrayCurrent()); if ($order) { $sl->order($order); } return $this->initPaginator($sl); } $this->result = $this->tableGateway->select($model->toArrayCurrent(), $order); return $this->result; }
php
public function select(AbstractModel $model, $order = null) { if ($this->usePaginator === true) { $sl = $this->tableGateway->getSql()->select(); $sl->where($model->toArrayCurrent()); if ($order) { $sl->order($order); } return $this->initPaginator($sl); } $this->result = $this->tableGateway->select($model->toArrayCurrent(), $order); return $this->result; }
Update a modele. @param \Dal\Model\AbstractModel $model @param array $order @return \Dal\Db\ResultSet\ResultSet
https://github.com/buse974/Dal/blob/faeac9e260c5e675bc7ed1fcea77c7ba251bf8ab/src/Dal/Mapper/AbstractMapper.php#L48-L64
buse974/Dal
src/Dal/Mapper/AbstractMapper.php
AbstractMapper.requestPdo
public function requestPdo($request, $param = null) { $this->result = $this->tableGateway->requestPdo($request, $param); return $this->result; }
php
public function requestPdo($request, $param = null) { $this->result = $this->tableGateway->requestPdo($request, $param); return $this->result; }
Excecute request directly by PDO. @param string $request @param array $param @return \Dal\Db\ResultSet\ResultSet
https://github.com/buse974/Dal/blob/faeac9e260c5e675bc7ed1fcea77c7ba251bf8ab/src/Dal/Mapper/AbstractMapper.php#L74-L79
buse974/Dal
src/Dal/Mapper/AbstractMapper.php
AbstractMapper.selectBridge
public function selectBridge(Select $select) { if ($this->usePaginator === true) { return $this->initPaginator($select); } $this->result = $this->tableGateway->selectBridge($select); return $this->result; }
php
public function selectBridge(Select $select) { if ($this->usePaginator === true) { return $this->initPaginator($select); } $this->result = $this->tableGateway->selectBridge($select); return $this->result; }
Excecute select directly by PDO. @param string $select @param array $param @return \Dal\Db\ResultSet\ResultSet
https://github.com/buse974/Dal/blob/faeac9e260c5e675bc7ed1fcea77c7ba251bf8ab/src/Dal/Mapper/AbstractMapper.php#L89-L98
buse974/Dal
src/Dal/Mapper/AbstractMapper.php
AbstractMapper.selectPdo
public function selectPdo($select, $param = null) { if ($this->usePaginator === true) { return $this->initPaginator(array($select, $param)); } $this->result = $this->tableGateway->selectPdo($select, $param); return $this->result; }
php
public function selectPdo($select, $param = null) { if ($this->usePaginator === true) { return $this->initPaginator(array($select, $param)); } $this->result = $this->tableGateway->selectPdo($select, $param); return $this->result; }
Excecute select directly by PDO. @param string $select @param array $param @return \Dal\Db\ResultSet\ResultSet
https://github.com/buse974/Dal/blob/faeac9e260c5e675bc7ed1fcea77c7ba251bf8ab/src/Dal/Mapper/AbstractMapper.php#L108-L116
buse974/Dal
src/Dal/Mapper/AbstractMapper.php
AbstractMapper.selectWith
public function selectWith(\Zend\Db\Sql\Select $select) { if ($this->usePaginator === true) { return $this->initPaginator($select); } $this->result = $this->tableGateway->selectWith($select); return $this->result; }
php
public function selectWith(\Zend\Db\Sql\Select $select) { if ($this->usePaginator === true) { return $this->initPaginator($select); } $this->result = $this->tableGateway->selectWith($select); return $this->result; }
Select request. @param \Zend\Db\Sql\Select @return \Zend\Db\ResultSet\ResultSet
https://github.com/buse974/Dal/blob/faeac9e260c5e675bc7ed1fcea77c7ba251bf8ab/src/Dal/Mapper/AbstractMapper.php#L143-L152
buse974/Dal
src/Dal/Mapper/AbstractMapper.php
AbstractMapper.fetchAll
public function fetchAll() { if ($this->usePaginator === true) { return $this->initPaginator($this->tableGateway->getSql()->select()); } $this->result = $this->tableGateway->select(); return $this->result; }
php
public function fetchAll() { if ($this->usePaginator === true) { return $this->initPaginator($this->tableGateway->getSql()->select()); } $this->result = $this->tableGateway->select(); return $this->result; }
Fetch All. @return \Zend\Db\ResultSet\ResultSet
https://github.com/buse974/Dal/blob/faeac9e260c5e675bc7ed1fcea77c7ba251bf8ab/src/Dal/Mapper/AbstractMapper.php#L159-L167
buse974/Dal
src/Dal/Mapper/AbstractMapper.php
AbstractMapper.deleteWith
public function deleteWith(\Zend\Db\Sql\Delete $delete) { return $this->tableGateway->deleteWith($delete); }
php
public function deleteWith(\Zend\Db\Sql\Delete $delete) { return $this->tableGateway->deleteWith($delete); }
Delete request. @param \Zend\Db\Sql\Delete @return int
https://github.com/buse974/Dal/blob/faeac9e260c5e675bc7ed1fcea77c7ba251bf8ab/src/Dal/Mapper/AbstractMapper.php#L176-L179
buse974/Dal
src/Dal/Mapper/AbstractMapper.php
AbstractMapper.insertWith
public function insertWith(\Zend\Db\Sql\Insert $insert) { return $this->tableGateway->insertWith($insert); }
php
public function insertWith(\Zend\Db\Sql\Insert $insert) { return $this->tableGateway->insertWith($insert); }
Insert request. @param \Zend\Db\Sql\Insert @return int
https://github.com/buse974/Dal/blob/faeac9e260c5e675bc7ed1fcea77c7ba251bf8ab/src/Dal/Mapper/AbstractMapper.php#L188-L191
buse974/Dal
src/Dal/Mapper/AbstractMapper.php
AbstractMapper.updateWith
public function updateWith(\Zend\Db\Sql\Update $update) { return $this->tableGateway->updateWith($update); }
php
public function updateWith(\Zend\Db\Sql\Update $update) { return $this->tableGateway->updateWith($update); }
Update request. @param \Zend\Db\Sql\Update @return int
https://github.com/buse974/Dal/blob/faeac9e260c5e675bc7ed1fcea77c7ba251bf8ab/src/Dal/Mapper/AbstractMapper.php#L200-L203
buse974/Dal
src/Dal/Mapper/AbstractMapper.php
AbstractMapper.fetchRow
public function fetchRow($column, $value) { $where = array($column, $value); return $this->tableGateway->select($where)->current(); }
php
public function fetchRow($column, $value) { $where = array($column, $value); return $this->tableGateway->select($where)->current(); }
Get row. @param string $column @param multitype $value @return \Dal\Model\AbstractModel
https://github.com/buse974/Dal/blob/faeac9e260c5e675bc7ed1fcea77c7ba251bf8ab/src/Dal/Mapper/AbstractMapper.php#L213-L218
buse974/Dal
src/Dal/Mapper/AbstractMapper.php
AbstractMapper.update
public function update(AbstractModel $model, $where = null) { $datas = $model->toArrayCurrentNoPredicate(); if ($where === null) { foreach ($this->tableGateway->getPrimaryKey() as $key) { $where[$key] = $datas[$key]; unset($datas[$key]); } } return (count($datas) > 0) ? $this->tableGateway->update($datas, $where) : false; }
php
public function update(AbstractModel $model, $where = null) { $datas = $model->toArrayCurrentNoPredicate(); if ($where === null) { foreach ($this->tableGateway->getPrimaryKey() as $key) { $where[$key] = $datas[$key]; unset($datas[$key]); } } return (count($datas) > 0) ? $this->tableGateway->update($datas, $where) : false; }
Update a modele. @param \Dal\Model\AbstractModel $model @param array $where @return int
https://github.com/buse974/Dal/blob/faeac9e260c5e675bc7ed1fcea77c7ba251bf8ab/src/Dal/Mapper/AbstractMapper.php#L250-L263
buse974/Dal
src/Dal/Mapper/AbstractMapper.php
AbstractMapper.delete
public function delete(AbstractModel $model) { $array = $model->toArrayCurrent(); if (empty($array)) { throw new \Exception('Error : delete used an empty model'); } return $this->tableGateway->delete($array); }
php
public function delete(AbstractModel $model) { $array = $model->toArrayCurrent(); if (empty($array)) { throw new \Exception('Error : delete used an empty model'); } return $this->tableGateway->delete($array); }
Delete full modele. @param \Dal\Model\AbstractModel $model @return bool
https://github.com/buse974/Dal/blob/faeac9e260c5e675bc7ed1fcea77c7ba251bf8ab/src/Dal/Mapper/AbstractMapper.php#L272-L281
buse974/Dal
src/Dal/Mapper/AbstractMapper.php
AbstractMapper.usePaginator
public function usePaginator($options) { if ($options === null) { $this->usePaginator = false; return $this; } $this->usePaginator = true; $this->paginatorOptions['s'] = (isset($options['s'])) ? $options['s'] : null; $this->paginatorOptions['d'] = (isset($options['d'])) ? $options['d'] : null; $this->paginatorOptions['c'] = (isset($options['c'])) ? $options['c'] : null; $this->paginatorOptions['n'] = (isset($options['n'])) ? $options['n'] : (isset($options['p']) ? 10 : null ); $this->paginatorOptions['o'] = (isset($options['o'])) ? $options['o'] : []; $this->paginatorOptions['p'] = (isset($options['p'])) ? $options['p'] : (isset($options['n']) ? 1 : null ); return $this; }
php
public function usePaginator($options) { if ($options === null) { $this->usePaginator = false; return $this; } $this->usePaginator = true; $this->paginatorOptions['s'] = (isset($options['s'])) ? $options['s'] : null; $this->paginatorOptions['d'] = (isset($options['d'])) ? $options['d'] : null; $this->paginatorOptions['c'] = (isset($options['c'])) ? $options['c'] : null; $this->paginatorOptions['n'] = (isset($options['n'])) ? $options['n'] : (isset($options['p']) ? 10 : null ); $this->paginatorOptions['o'] = (isset($options['o'])) ? $options['o'] : []; $this->paginatorOptions['p'] = (isset($options['p'])) ? $options['p'] : (isset($options['n']) ? 1 : null ); return $this; }
Set the mapper options and enable the mapper. @param array $options @return AbstractMapper
https://github.com/buse974/Dal/blob/faeac9e260c5e675bc7ed1fcea77c7ba251bf8ab/src/Dal/Mapper/AbstractMapper.php#L290-L308
buse974/Dal
src/Dal/Mapper/AbstractMapper.php
AbstractMapper.initPaginator
protected function initPaginator($select) { $this->usePaginator = false; $this->paginator = new Paginator( $select, $this->tableGateway->getAdapter(), $this->tableGateway->getResultSetPrototype()); if (isset($this->paginatorOptions['n'])) { $this->paginator->setN($this->paginatorOptions['n']); } if (isset($this->paginatorOptions['p'])) { $this->paginator->setP($this->paginatorOptions['p']); } if (isset($this->paginatorOptions['c'])) { $this->paginator->setC($this->paginatorOptions['c']); } if (isset($this->paginatorOptions['s'])) { $this->paginator->setS($this->paginatorOptions['s']); } if (isset($this->paginatorOptions['d'])) { $this->paginator->setD($this->paginatorOptions['d']); } if (isset($this->paginatorOptions['o'])) { $this->paginator->setO($this->paginatorOptions['o']); } return $this->paginator->getItems(); }
php
protected function initPaginator($select) { $this->usePaginator = false; $this->paginator = new Paginator( $select, $this->tableGateway->getAdapter(), $this->tableGateway->getResultSetPrototype()); if (isset($this->paginatorOptions['n'])) { $this->paginator->setN($this->paginatorOptions['n']); } if (isset($this->paginatorOptions['p'])) { $this->paginator->setP($this->paginatorOptions['p']); } if (isset($this->paginatorOptions['c'])) { $this->paginator->setC($this->paginatorOptions['c']); } if (isset($this->paginatorOptions['s'])) { $this->paginator->setS($this->paginatorOptions['s']); } if (isset($this->paginatorOptions['d'])) { $this->paginator->setD($this->paginatorOptions['d']); } if (isset($this->paginatorOptions['o'])) { $this->paginator->setO($this->paginatorOptions['o']); } return $this->paginator->getItems(); }
Init the paginator with a select object. @param \Zend\Db\Sql\Select|array $select @return mixed
https://github.com/buse974/Dal/blob/faeac9e260c5e675bc7ed1fcea77c7ba251bf8ab/src/Dal/Mapper/AbstractMapper.php#L317-L346
buse974/Dal
src/Dal/Mapper/AbstractMapper.php
AbstractMapper.printSql
public function printSql(\Zend\Db\Sql\SqlInterface $request) { return $request->getSqlString($this->tableGateway->getAdapter()->getPlatform()); }
php
public function printSql(\Zend\Db\Sql\SqlInterface $request) { return $request->getSqlString($this->tableGateway->getAdapter()->getPlatform()); }
Return request sql. @param \Zend\Db\Sql\SqlInterface $request @return string
https://github.com/buse974/Dal/blob/faeac9e260c5e675bc7ed1fcea77c7ba251bf8ab/src/Dal/Mapper/AbstractMapper.php#L371-L374
phpalchemy/phpalchemy
Alchemy/Component/ClassLoader/ClassLoader.php
ClassLoader.register
public function register($namespace, $includePath) { if (array_key_exists($namespace, $this->includePaths)) { throw new \Exception("Error: Namespace '$namespace' is already registered!"); } $this->includePaths[$namespace] = rtrim($includePath, DS) . DS; }
php
public function register($namespace, $includePath) { if (array_key_exists($namespace, $this->includePaths)) { throw new \Exception("Error: Namespace '$namespace' is already registered!"); } $this->includePaths[$namespace] = rtrim($includePath, DS) . DS; }
Register a determinated namespace and its include path to find it. @param string $namespace namespace of a class given @param string $includePath path where the class exists
https://github.com/phpalchemy/phpalchemy/blob/5b7e9b13acfda38c61b2da2639e8a56f298dc32e/Alchemy/Component/ClassLoader/ClassLoader.php#L70-L77
phpalchemy/phpalchemy
Alchemy/Component/ClassLoader/ClassLoader.php
ClassLoader.registerClass
public function registerClass($className, $includeFile) { if (array_key_exists($className, $this->includePaths)) { throw new \Exception("Error: Class '$className' is already registered!"); } $this->includePaths[$className] = $includeFile; }
php
public function registerClass($className, $includeFile) { if (array_key_exists($className, $this->includePaths)) { throw new \Exception("Error: Class '$className' is already registered!"); } $this->includePaths[$className] = $includeFile; }
Register a determinated class to autoloader Example: $classLoader = ClassLoader::getInstance(); $classLoader->registerClass('MyClass', '/classes/class.myclass.php'); This is useful when we want to add autoloading to a class without naming convention and therefore the class name is different of class file, or the class have not not namespaces, etc.
https://github.com/phpalchemy/phpalchemy/blob/5b7e9b13acfda38c61b2da2639e8a56f298dc32e/Alchemy/Component/ClassLoader/ClassLoader.php#L90-L97
phpalchemy/phpalchemy
Alchemy/Component/ClassLoader/ClassLoader.php
ClassLoader.loadClass
protected function loadClass($className) { if (strpos($className, NS) !== false) { $className = str_replace(NS, DS, ltrim($className, NS)); } $filename = str_replace('_', DS, $className) . '.php'; if (array_key_exists($className, $this->includePaths)) { @require_once $this->includePaths[$className]; if (class_exists('\\' . trim("$className", '\\'))) { return true; } } foreach ($this->includePaths as $namespace => $includePath) { if (file_exists($includePath . $filename)) { require_once $includePath . $filename; return true; } } return false; }
php
protected function loadClass($className) { if (strpos($className, NS) !== false) { $className = str_replace(NS, DS, ltrim($className, NS)); } $filename = str_replace('_', DS, $className) . '.php'; if (array_key_exists($className, $this->includePaths)) { @require_once $this->includePaths[$className]; if (class_exists('\\' . trim("$className", '\\'))) { return true; } } foreach ($this->includePaths as $namespace => $includePath) { if (file_exists($includePath . $filename)) { require_once $includePath . $filename; return true; } } return false; }
Loads the given class or interface. @param string $className The name of the class to load. @return void
https://github.com/phpalchemy/phpalchemy/blob/5b7e9b13acfda38c61b2da2639e8a56f298dc32e/Alchemy/Component/ClassLoader/ClassLoader.php#L113-L138
tanmotop/laravel-api
src/Providers/ApiServiceProvider.php
ApiServiceProvider.boot
public function boot() { if (file_exists($routes = api_path('routes.php'))) { $this->loadRoutesFrom($routes); } if ($this->app->runningInConsole()) { $this->publishes([ __DIR__ . '/../../config' => config_path() ], 'laravel-api-config'); } }
php
public function boot() { if (file_exists($routes = api_path('routes.php'))) { $this->loadRoutesFrom($routes); } if ($this->app->runningInConsole()) { $this->publishes([ __DIR__ . '/../../config' => config_path() ], 'laravel-api-config'); } }
Bootstrap services. @return void
https://github.com/tanmotop/laravel-api/blob/dc0f00e61c52744acdaf1a013e62500156f75828/src/Providers/ApiServiceProvider.php#L14-L25
eneav/laravel-authorization
src/AuthorizationServiceProvider.php
AuthorizationServiceProvider.register
public function register(): void { $this->app->register(EventServiceProvider::class); $this->commands([ InstallCommand::class ]); $this->registerBindings(); }
php
public function register(): void { $this->app->register(EventServiceProvider::class); $this->commands([ InstallCommand::class ]); $this->registerBindings(); }
Register the application services. @return void
https://github.com/eneav/laravel-authorization/blob/db947bdfb5990ca5975efe9646262d655a68394c/src/AuthorizationServiceProvider.php#L42-L51
jasny/entity
src/Traits/DispatchEventTrait.php
DispatchEventTrait.dispatchEvent
public function dispatchEvent(object $event): object { if (isset($this->i__dispatcher)) { $this->i__dispatcher->dispatch($event); } return $event; }
php
public function dispatchEvent(object $event): object { if (isset($this->i__dispatcher)) { $this->i__dispatcher->dispatch($event); } return $event; }
Dispatch an event. @param object $event @return object The event.
https://github.com/jasny/entity/blob/5af7c94645671a3257d6565ff1891ff61fdcf69b/src/Traits/DispatchEventTrait.php#L55-L62
alexpts/php-tools
src/PTS/Tools/Collection.php
Collection.addItem
public function addItem(string $name, $item, int $priority = 50): self { if ($this->has($name)) { throw new DuplicateKeyException('Item with name '.$name.' already defined'); } $this->items[$priority][$name] = $item; return $this; }
php
public function addItem(string $name, $item, int $priority = 50): self { if ($this->has($name)) { throw new DuplicateKeyException('Item with name '.$name.' already defined'); } $this->items[$priority][$name] = $item; return $this; }
@param string $name @param mixed $item @param int $priority @return $this @throws DuplicateKeyException
https://github.com/alexpts/php-tools/blob/aeb8b501576011c7c7d5169a2ef2a0193561b85c/src/PTS/Tools/Collection.php#L20-L28
alexpts/php-tools
src/PTS/Tools/Collection.php
Collection.removeItem
public function removeItem(string $name, int $priority = null): self { if ($priority !== null) { if (isset($this->items[$priority][$name])) { unset($this->items[$priority][$name]); } return $this; } return $this->removeItemWithoutPriority($name); }
php
public function removeItem(string $name, int $priority = null): self { if ($priority !== null) { if (isset($this->items[$priority][$name])) { unset($this->items[$priority][$name]); } return $this; } return $this->removeItemWithoutPriority($name); }
@param string $name @param null|int $priority @return $this
https://github.com/alexpts/php-tools/blob/aeb8b501576011c7c7d5169a2ef2a0193561b85c/src/PTS/Tools/Collection.php#L36-L47
alexpts/php-tools
src/PTS/Tools/Collection.php
Collection.removeItemWithoutPriority
protected function removeItemWithoutPriority(string $name): self { foreach ($this->items as $priority => $items) { if (isset($items[$name])) { unset($this->items[$priority][$name]); } } return $this; }
php
protected function removeItemWithoutPriority(string $name): self { foreach ($this->items as $priority => $items) { if (isset($items[$name])) { unset($this->items[$priority][$name]); } } return $this; }
@param string $name @return $this
https://github.com/alexpts/php-tools/blob/aeb8b501576011c7c7d5169a2ef2a0193561b85c/src/PTS/Tools/Collection.php#L54-L63
fxpio/fxp-gluon
Block/Extension/PanelExtension.php
PanelExtension.addChild
public function addChild(BlockInterface $child, BlockInterface $block, array $options) { if ($options['collapsible'] && BlockUtil::isBlockType($child, PanelHeaderType::class)) { $child->add('_panel_actions', PanelActionsType::class, []); $child->get('_panel_actions')->add('_button_collapse', ButtonType::class, [ 'label' => '', 'attr' => ['class' => 'btn-panel-collapse'], 'style' => 'default', 'prepend' => '<span class="caret"></span>', ]); } elseif (BlockUtil::isBlockType($child, PanelType::class)) { if ($block->getOption('recursive_style')) { $child->setOption('style', $block->getOption('style')); } } elseif (BlockUtil::isBlockType($child, PanelSectionType::class)) { $cOptions = []; if (null !== $block->getOption('cell_label_style') && null === $child->getOption('cell_label_style')) { $cOptions['cell_label_style'] = $block->getOption('cell_label_style'); } if (null !== $block->getOption('cell_layout_size') && null === $child->getOption('layout_size')) { $cOptions['layout_size'] = $block->getOption('cell_layout_size'); } if (\count($cOptions) > 0) { $child->setOptions($cOptions); } } }
php
public function addChild(BlockInterface $child, BlockInterface $block, array $options) { if ($options['collapsible'] && BlockUtil::isBlockType($child, PanelHeaderType::class)) { $child->add('_panel_actions', PanelActionsType::class, []); $child->get('_panel_actions')->add('_button_collapse', ButtonType::class, [ 'label' => '', 'attr' => ['class' => 'btn-panel-collapse'], 'style' => 'default', 'prepend' => '<span class="caret"></span>', ]); } elseif (BlockUtil::isBlockType($child, PanelType::class)) { if ($block->getOption('recursive_style')) { $child->setOption('style', $block->getOption('style')); } } elseif (BlockUtil::isBlockType($child, PanelSectionType::class)) { $cOptions = []; if (null !== $block->getOption('cell_label_style') && null === $child->getOption('cell_label_style')) { $cOptions['cell_label_style'] = $block->getOption('cell_label_style'); } if (null !== $block->getOption('cell_layout_size') && null === $child->getOption('layout_size')) { $cOptions['layout_size'] = $block->getOption('cell_layout_size'); } if (\count($cOptions) > 0) { $child->setOptions($cOptions); } } }
{@inheritdoc}
https://github.com/fxpio/fxp-gluon/blob/0548b7d598ef4b0785b5df3b849a10f439b2dc65/Block/Extension/PanelExtension.php#L35-L64
fxpio/fxp-gluon
Block/Extension/PanelExtension.php
PanelExtension.finishView
public function finishView(BlockView $view, BlockInterface $block, array $options) { $relatedPanels = []; foreach ($view->children as $name => $child) { if (\in_array('panel', $child->vars['block_prefixes'])) { $relatedPanels[] = $child; unset($view->children[$name]); } } $view->vars['related_panels'] = $relatedPanels; }
php
public function finishView(BlockView $view, BlockInterface $block, array $options) { $relatedPanels = []; foreach ($view->children as $name => $child) { if (\in_array('panel', $child->vars['block_prefixes'])) { $relatedPanels[] = $child; unset($view->children[$name]); } } $view->vars['related_panels'] = $relatedPanels; }
{@inheritdoc}
https://github.com/fxpio/fxp-gluon/blob/0548b7d598ef4b0785b5df3b849a10f439b2dc65/Block/Extension/PanelExtension.php#L85-L97
fxpio/fxp-gluon
Block/Extension/PanelExtension.php
PanelExtension.configureOptions
public function configureOptions(OptionsResolver $resolver) { $resolver->setDefaults([ 'border_top_style' => null, 'cell_label_style' => null, 'cell_layout_size' => null, 'collapsible' => false, 'collapsed' => false, 'panels_rendered' => true, 'hidden_if_empty' => true, 'recursive_style' => false, 'main' => false, ]); $resolver->addAllowedTypes('border_top_style', ['null', 'string']); $resolver->addAllowedTypes('cell_label_style', ['null', 'string']); $resolver->addAllowedTypes('cell_layout_size', ['null', 'string']); $resolver->addAllowedTypes('collapsible', 'bool'); $resolver->addAllowedTypes('collapsed', 'bool'); $resolver->addAllowedTypes('panels_rendered', 'bool'); $resolver->addAllowedTypes('hidden_if_empty', 'bool'); $resolver->addAllowedTypes('recursive_style', 'bool'); $resolver->addAllowedTypes('main', 'bool'); $resolver->addAllowedValues('style', [ null, 'accent', 'primary-box', 'accent-box', 'success-box', 'info-box', 'warning-box', 'danger-box', 'default-wire', 'primary-wire', 'accent-wire', 'success-wire', 'info-wire', 'warning-wire', 'danger-wire', 'default-frame', 'primary-frame', 'accent-frame', 'success-frame', 'info-frame', 'warning-frame', 'danger-frame', 'default-lite', 'primary-lite', 'accent-lite', 'success-lite', 'info-lite', 'warning-lite', 'danger-lite', 'default-pref', 'primary-pref', 'accent-pref', 'success-pref', 'info-pref', 'warning-pref', 'danger-pref', ]); $resolver->addAllowedValues('border_top_style', [ null, 'default', 'primary', 'accent', 'success', 'info', 'warning', 'danger', ]); }
php
public function configureOptions(OptionsResolver $resolver) { $resolver->setDefaults([ 'border_top_style' => null, 'cell_label_style' => null, 'cell_layout_size' => null, 'collapsible' => false, 'collapsed' => false, 'panels_rendered' => true, 'hidden_if_empty' => true, 'recursive_style' => false, 'main' => false, ]); $resolver->addAllowedTypes('border_top_style', ['null', 'string']); $resolver->addAllowedTypes('cell_label_style', ['null', 'string']); $resolver->addAllowedTypes('cell_layout_size', ['null', 'string']); $resolver->addAllowedTypes('collapsible', 'bool'); $resolver->addAllowedTypes('collapsed', 'bool'); $resolver->addAllowedTypes('panels_rendered', 'bool'); $resolver->addAllowedTypes('hidden_if_empty', 'bool'); $resolver->addAllowedTypes('recursive_style', 'bool'); $resolver->addAllowedTypes('main', 'bool'); $resolver->addAllowedValues('style', [ null, 'accent', 'primary-box', 'accent-box', 'success-box', 'info-box', 'warning-box', 'danger-box', 'default-wire', 'primary-wire', 'accent-wire', 'success-wire', 'info-wire', 'warning-wire', 'danger-wire', 'default-frame', 'primary-frame', 'accent-frame', 'success-frame', 'info-frame', 'warning-frame', 'danger-frame', 'default-lite', 'primary-lite', 'accent-lite', 'success-lite', 'info-lite', 'warning-lite', 'danger-lite', 'default-pref', 'primary-pref', 'accent-pref', 'success-pref', 'info-pref', 'warning-pref', 'danger-pref', ]); $resolver->addAllowedValues('border_top_style', [ null, 'default', 'primary', 'accent', 'success', 'info', 'warning', 'danger', ]); }
{@inheritdoc}
https://github.com/fxpio/fxp-gluon/blob/0548b7d598ef4b0785b5df3b849a10f439b2dc65/Block/Extension/PanelExtension.php#L102-L174
honeylex/honeylex
app/lib/Console/Scaffold/SkeletonGenerator.php
SkeletonGenerator.createFolders
protected function createFolders() { foreach ($this->getFolderStructure() as $folder) { $newFolder = $this->twigStringRenderer->renderToString($folder, $this->data); $this->fs->mkdir($this->targetPath.DIRECTORY_SEPARATOR.$newFolder, self::DIRECTORY_MODE); $msg = '[mkdir] '.$this->targetPath.DIRECTORY_SEPARATOR.$newFolder; if ($this->reportingEnabled) { $this->report[] =$msg; } } }
php
protected function createFolders() { foreach ($this->getFolderStructure() as $folder) { $newFolder = $this->twigStringRenderer->renderToString($folder, $this->data); $this->fs->mkdir($this->targetPath.DIRECTORY_SEPARATOR.$newFolder, self::DIRECTORY_MODE); $msg = '[mkdir] '.$this->targetPath.DIRECTORY_SEPARATOR.$newFolder; if ($this->reportingEnabled) { $this->report[] =$msg; } } }
Creates all folders specified by getFolderStructure within the target location.
https://github.com/honeylex/honeylex/blob/ad0a177ec365793a2c3813b948a1750c77ef00c1/app/lib/Console/Scaffold/SkeletonGenerator.php#L120-L131
honeylex/honeylex
app/lib/Console/Scaffold/SkeletonGenerator.php
SkeletonGenerator.copyFiles
protected function copyFiles() { $skeletonFinder = new SkeletonFinder($this->lookupPaths); $sourcePath = $skeletonFinder->findByName($this->skeletonName)->getRealpath(); $finder = $this->getFinderForFilesToCopy($sourcePath); foreach ($finder as $file) { $targetFilePath = $this->targetPath.DIRECTORY_SEPARATOR.$file->getRelativePathname(); $targetFilePath = $this->twigStringRenderer->renderToString($targetFilePath, $this->data); $this->fs->copy($file->getRealpath(), $targetFilePath, $this->overwriteEnabled); $msg = '[copy] '.$file->getRealpath().' => '.$targetFilePath; if ($this->reportingEnabled) { $this->report[] = $msg; } } }
php
protected function copyFiles() { $skeletonFinder = new SkeletonFinder($this->lookupPaths); $sourcePath = $skeletonFinder->findByName($this->skeletonName)->getRealpath(); $finder = $this->getFinderForFilesToCopy($sourcePath); foreach ($finder as $file) { $targetFilePath = $this->targetPath.DIRECTORY_SEPARATOR.$file->getRelativePathname(); $targetFilePath = $this->twigStringRenderer->renderToString($targetFilePath, $this->data); $this->fs->copy($file->getRealpath(), $targetFilePath, $this->overwriteEnabled); $msg = '[copy] '.$file->getRealpath().' => '.$targetFilePath; if ($this->reportingEnabled) { $this->report[] = $msg; } } }
Copies all files from the source location to the target location.
https://github.com/honeylex/honeylex/blob/ad0a177ec365793a2c3813b948a1750c77ef00c1/app/lib/Console/Scaffold/SkeletonGenerator.php#L136-L155
honeylex/honeylex
app/lib/Console/Scaffold/SkeletonGenerator.php
SkeletonGenerator.renderTemplates
protected function renderTemplates() { $finder = new Finder; $finder->files()->name('*'.self::TEMPLATE_FILENAME_EXTENSION)->in($this->targetPath); $twigRenderer = TwigRenderer::create( [ 'twig_extensions' => [ new ProjectExtension($this->configProvider) ], 'twig_options' => [ 'autoescape' => false, 'cache' => false, 'debug' => true, 'strict_variables' => true ], 'template_paths' => [ $this->targetPath ] ] ); foreach ($finder as $template) { $targetFilePath = $template->getPath().DIRECTORY_SEPARATOR. $template->getBasename(self::TEMPLATE_FILENAME_EXTENSION); if (!file_exists($targetFilePath) || (is_readable($targetFilePath) && $this->overwriteEnabled)) { $twigRenderer->renderToFile( $template->getRelativePathname(), $targetFilePath, $this->data ); } $msg = '[render] '.$template->getRelativePathname().' => '.$targetFilePath; if ($this->reportingEnabled) { $this->report[] = $msg; } } $this->fs->remove($finder); }
php
protected function renderTemplates() { $finder = new Finder; $finder->files()->name('*'.self::TEMPLATE_FILENAME_EXTENSION)->in($this->targetPath); $twigRenderer = TwigRenderer::create( [ 'twig_extensions' => [ new ProjectExtension($this->configProvider) ], 'twig_options' => [ 'autoescape' => false, 'cache' => false, 'debug' => true, 'strict_variables' => true ], 'template_paths' => [ $this->targetPath ] ] ); foreach ($finder as $template) { $targetFilePath = $template->getPath().DIRECTORY_SEPARATOR. $template->getBasename(self::TEMPLATE_FILENAME_EXTENSION); if (!file_exists($targetFilePath) || (is_readable($targetFilePath) && $this->overwriteEnabled)) { $twigRenderer->renderToFile( $template->getRelativePathname(), $targetFilePath, $this->data ); } $msg = '[render] '.$template->getRelativePathname().' => '.$targetFilePath; if ($this->reportingEnabled) { $this->report[] = $msg; } } $this->fs->remove($finder); }
Renders all files within the target location whose extension is ".tmpl.twig" onto a file that has the same name without that extension. After the rendering all the ".tmpl.twig" files will be deleted in the target location.
https://github.com/honeylex/honeylex/blob/ad0a177ec365793a2c3813b948a1750c77ef00c1/app/lib/Console/Scaffold/SkeletonGenerator.php#L176-L217
buse974/Dal
src/Dal/Stdlib/Hydrator/ClassMethods.php
ClassMethods.hydrate
public function hydrate(array &$data, $object) { foreach ($data as $property => $value) { $this->hydrateProperty($property, $value, $object); } return $object; }
php
public function hydrate(array &$data, $object) { foreach ($data as $property => $value) { $this->hydrateProperty($property, $value, $object); } return $object; }
Hydrate an object by populating getter/setter methods. Hydrates an object by getter/setter methods of the object. @param array $data @param object $object @return object @throws Exception\BadMethodCallException for a non-object $object
https://github.com/buse974/Dal/blob/faeac9e260c5e675bc7ed1fcea77c7ba251bf8ab/src/Dal/Stdlib/Hydrator/ClassMethods.php#L34-L41
bennybi/yii2-cza-base
widgets/ui/jui/ActiveField.php
ActiveField.spinnerInput
public function spinnerInput($options = ['style' => 'width: 20px;height: 20px;'], $clientOptions = ['step' => 1, 'min' => 0]) { $options = array_replace_recursive($this->inputOptions, $options); $this->adjustLabelFor($options); $this->parts['{input}'] = \yii\jui\Spinner::widget([ 'model' => $this->model, 'attribute' => $this->attribute, 'options' => $options, 'clientOptions' => $clientOptions, ]); return $this; }
php
public function spinnerInput($options = ['style' => 'width: 20px;height: 20px;'], $clientOptions = ['step' => 1, 'min' => 0]) { $options = array_replace_recursive($this->inputOptions, $options); $this->adjustLabelFor($options); $this->parts['{input}'] = \yii\jui\Spinner::widget([ 'model' => $this->model, 'attribute' => $this->attribute, 'options' => $options, 'clientOptions' => $clientOptions, ]); return $this; }
Renders a text input. This method will generate the "name" and "value" tag attributes automatically for the model attribute unless they are explicitly specified in `$options`. @param array $options the tag options in terms of name-value pairs. These will be rendered as the attributes of the resulting tag. The values will be HTML-encoded using [[Html::encode()]]. @return static the field object itself
https://github.com/bennybi/yii2-cza-base/blob/8257db8034bd948712fa469062921f210f0ba8da/widgets/ui/jui/ActiveField.php#L39-L50
bluetree-service/data
src/Calculation/Math.php
Math.end
public static function end($edition, $used, $start, $timeNow) { if (!$used) { return 0; } $end = $edition / ($used / ($timeNow - $start)); $end += $timeNow; return $end; }
php
public static function end($edition, $used, $start, $timeNow) { if (!$used) { return 0; } $end = $edition / ($used / ($timeNow - $start)); $end += $timeNow; return $end; }
Estimate time to end, by given current usage value and max value @param float $edition maximum number of value @param float $used how many was used @param integer $start start time in unix timestamp @param integer $timeNow current unix timestamp @return integer estimated end time in unix timestamp
https://github.com/bluetree-service/data/blob/a8df78ee4f7b97b862f989d3effc75f022fd75cb/src/Calculation/Math.php#L71-L81
3ev/wordpress-core
src/Tev/Field/Model/AuthorField.php
AuthorField.getValue
public function getValue() { $val = $this->base['value']; if (is_array($val)) { if (isset($val['ID'])) { return $this->authorFactory->create($val['ID']); } else { $authors = array(); foreach ($val as $a) { $authors[] = $this->authorFactory->create($a['ID']); } return $authors; } } else { if (isset($this->base['multiple']) && $this->base['multiple']) { return array(); } else { return null; } } }
php
public function getValue() { $val = $this->base['value']; if (is_array($val)) { if (isset($val['ID'])) { return $this->authorFactory->create($val['ID']); } else { $authors = array(); foreach ($val as $a) { $authors[] = $this->authorFactory->create($a['ID']); } return $authors; } } else { if (isset($this->base['multiple']) && $this->base['multiple']) { return array(); } else { return null; } } }
Get a single author object or array of author objects. If no authors are configured, returned will result will be an empty array if this is a mutli-select, or null if not. @return \Tev\Author\Model\Author|\Tev\Author\Model\Author[]|null
https://github.com/3ev/wordpress-core/blob/da674fbec5bf3d5bd2a2141680a4c141113eb6b0/src/Tev/Field/Model/AuthorField.php#L43-L66
soliphp/web
src/Web/Response.php
Response.setStatusCode
public function setStatusCode(int $code, string $message = null) { $this->code = $code; $this->message = $message; return $this; }
php
public function setStatusCode(int $code, string $message = null) { $this->code = $code; $this->message = $message; return $this; }
设置响应状态 @param int $code 状态码 @param string $message 状态描述 @return $this
https://github.com/soliphp/web/blob/40c884ef06afa5739c94f0bffdcc69d3c6c44e96/src/Web/Response.php#L99-L105