id
int32
0
241k
repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
13,800
arckinteractive/events_api
classes/Events/API/Calendar.php
Calendar.getIcalURL
public function getIcalURL($base_url = '', array $params = array()) { $user = elgg_get_logged_in_user_entity(); $params['view'] = 'ical'; $params['u'] = $user->guid; $params['t'] = $this->getUserToken($user->guid); $url = elgg_http_add_url_query_elements($base_url, $params); return elgg_normalize_url($url); }
php
public function getIcalURL($base_url = '', array $params = array()) { $user = elgg_get_logged_in_user_entity(); $params['view'] = 'ical'; $params['u'] = $user->guid; $params['t'] = $this->getUserToken($user->guid); $url = elgg_http_add_url_query_elements($base_url, $params); return elgg_normalize_url($url); }
[ "public", "function", "getIcalURL", "(", "$", "base_url", "=", "''", ",", "array", "$", "params", "=", "array", "(", ")", ")", "{", "$", "user", "=", "elgg_get_logged_in_user_entity", "(", ")", ";", "$", "params", "[", "'view'", "]", "=", "'ical'", ";", "$", "params", "[", "'u'", "]", "=", "$", "user", "->", "guid", ";", "$", "params", "[", "'t'", "]", "=", "$", "this", "->", "getUserToken", "(", "$", "user", "->", "guid", ")", ";", "$", "url", "=", "elgg_http_add_url_query_elements", "(", "$", "base_url", ",", "$", "params", ")", ";", "return", "elgg_normalize_url", "(", "$", "url", ")", ";", "}" ]
Returns a URL of the iCal feed @param string $base_url Base URL @param array $params Additional params @return string
[ "Returns", "a", "URL", "of", "the", "iCal", "feed" ]
56c0f0ae403af1672a913db5dc259db9cb712491
https://github.com/arckinteractive/events_api/blob/56c0f0ae403af1672a913db5dc259db9cb712491/classes/Events/API/Calendar.php#L360-L370
13,801
arckinteractive/events_api
classes/Events/API/Calendar.php
Calendar.toIcal
public function toIcal($starttime = null, $endtime = null, $filename = 'calendar.ics') { if (is_null($starttime)) { $starttime = time(); } if (is_null($endtime)) { $endtime = strtotime('+1 year', $starttime); } $instances = $this->getAllEventInstances($starttime, $endtime, true, 'ical'); $config = array( 'unique_id' => $this->guid, // setting these explicitly until icalcreator bug #14 is solved 'allowEmpty' => true, 'nl' => "\r\n", 'format' => 'iCal', 'delimiter' => DIRECTORY_SEPARATOR, 'filename' => $filename, // this is last until #14 is solved ); $v = new vcalendar($config); $v->setProperty('method', 'PUBLISH'); $v->setProperty("X-WR-CALNAME", implode(' - ', array(elgg_get_config('sitename'), $this->getDisplayName()))); $v->setProperty("X-WR-CALDESC", strip_tags($this->description)); $v->setProperty("X-WR-TIMEZONE", Util::UTC); foreach ($instances as $instance) { $e = & $v->newComponent('vevent'); $organizer = elgg_extract('organizer', $instance, array()); unset($instance['organizer']); $reminders = elgg_extract('reminders', $instance, array()); unset($instance['reminders']); foreach ($instance as $property => $value) { $e->setProperty($property, $value); } if (!empty($organizer)) { if (is_email_address($organizer)) { $e->setProperty('organizer', $organizer); } else { $e->setProperty('organizer', elgg_get_site_entity()->email, array( 'CN' => $organizer, )); } } if (!empty($reminders)) { foreach ($reminders as $reminder) { $a = & $e->newComponent('valarm'); $a->setProperty('action', 'DISPLAY'); $a->setProperty('trigger', "-PT{$reminder}S"); } } } $v->returnCalendar(); }
php
public function toIcal($starttime = null, $endtime = null, $filename = 'calendar.ics') { if (is_null($starttime)) { $starttime = time(); } if (is_null($endtime)) { $endtime = strtotime('+1 year', $starttime); } $instances = $this->getAllEventInstances($starttime, $endtime, true, 'ical'); $config = array( 'unique_id' => $this->guid, // setting these explicitly until icalcreator bug #14 is solved 'allowEmpty' => true, 'nl' => "\r\n", 'format' => 'iCal', 'delimiter' => DIRECTORY_SEPARATOR, 'filename' => $filename, // this is last until #14 is solved ); $v = new vcalendar($config); $v->setProperty('method', 'PUBLISH'); $v->setProperty("X-WR-CALNAME", implode(' - ', array(elgg_get_config('sitename'), $this->getDisplayName()))); $v->setProperty("X-WR-CALDESC", strip_tags($this->description)); $v->setProperty("X-WR-TIMEZONE", Util::UTC); foreach ($instances as $instance) { $e = & $v->newComponent('vevent'); $organizer = elgg_extract('organizer', $instance, array()); unset($instance['organizer']); $reminders = elgg_extract('reminders', $instance, array()); unset($instance['reminders']); foreach ($instance as $property => $value) { $e->setProperty($property, $value); } if (!empty($organizer)) { if (is_email_address($organizer)) { $e->setProperty('organizer', $organizer); } else { $e->setProperty('organizer', elgg_get_site_entity()->email, array( 'CN' => $organizer, )); } } if (!empty($reminders)) { foreach ($reminders as $reminder) { $a = & $e->newComponent('valarm'); $a->setProperty('action', 'DISPLAY'); $a->setProperty('trigger', "-PT{$reminder}S"); } } } $v->returnCalendar(); }
[ "public", "function", "toIcal", "(", "$", "starttime", "=", "null", ",", "$", "endtime", "=", "null", ",", "$", "filename", "=", "'calendar.ics'", ")", "{", "if", "(", "is_null", "(", "$", "starttime", ")", ")", "{", "$", "starttime", "=", "time", "(", ")", ";", "}", "if", "(", "is_null", "(", "$", "endtime", ")", ")", "{", "$", "endtime", "=", "strtotime", "(", "'+1 year'", ",", "$", "starttime", ")", ";", "}", "$", "instances", "=", "$", "this", "->", "getAllEventInstances", "(", "$", "starttime", ",", "$", "endtime", ",", "true", ",", "'ical'", ")", ";", "$", "config", "=", "array", "(", "'unique_id'", "=>", "$", "this", "->", "guid", ",", "// setting these explicitly until icalcreator bug #14 is solved", "'allowEmpty'", "=>", "true", ",", "'nl'", "=>", "\"\\r\\n\"", ",", "'format'", "=>", "'iCal'", ",", "'delimiter'", "=>", "DIRECTORY_SEPARATOR", ",", "'filename'", "=>", "$", "filename", ",", "// this is last until #14 is solved", ")", ";", "$", "v", "=", "new", "vcalendar", "(", "$", "config", ")", ";", "$", "v", "->", "setProperty", "(", "'method'", ",", "'PUBLISH'", ")", ";", "$", "v", "->", "setProperty", "(", "\"X-WR-CALNAME\"", ",", "implode", "(", "' - '", ",", "array", "(", "elgg_get_config", "(", "'sitename'", ")", ",", "$", "this", "->", "getDisplayName", "(", ")", ")", ")", ")", ";", "$", "v", "->", "setProperty", "(", "\"X-WR-CALDESC\"", ",", "strip_tags", "(", "$", "this", "->", "description", ")", ")", ";", "$", "v", "->", "setProperty", "(", "\"X-WR-TIMEZONE\"", ",", "Util", "::", "UTC", ")", ";", "foreach", "(", "$", "instances", "as", "$", "instance", ")", "{", "$", "e", "=", "&", "$", "v", "->", "newComponent", "(", "'vevent'", ")", ";", "$", "organizer", "=", "elgg_extract", "(", "'organizer'", ",", "$", "instance", ",", "array", "(", ")", ")", ";", "unset", "(", "$", "instance", "[", "'organizer'", "]", ")", ";", "$", "reminders", "=", "elgg_extract", "(", "'reminders'", ",", "$", "instance", ",", "array", "(", ")", ")", ";", "unset", "(", "$", "instance", "[", "'reminders'", "]", ")", ";", "foreach", "(", "$", "instance", "as", "$", "property", "=>", "$", "value", ")", "{", "$", "e", "->", "setProperty", "(", "$", "property", ",", "$", "value", ")", ";", "}", "if", "(", "!", "empty", "(", "$", "organizer", ")", ")", "{", "if", "(", "is_email_address", "(", "$", "organizer", ")", ")", "{", "$", "e", "->", "setProperty", "(", "'organizer'", ",", "$", "organizer", ")", ";", "}", "else", "{", "$", "e", "->", "setProperty", "(", "'organizer'", ",", "elgg_get_site_entity", "(", ")", "->", "email", ",", "array", "(", "'CN'", "=>", "$", "organizer", ",", ")", ")", ";", "}", "}", "if", "(", "!", "empty", "(", "$", "reminders", ")", ")", "{", "foreach", "(", "$", "reminders", "as", "$", "reminder", ")", "{", "$", "a", "=", "&", "$", "e", "->", "newComponent", "(", "'valarm'", ")", ";", "$", "a", "->", "setProperty", "(", "'action'", ",", "'DISPLAY'", ")", ";", "$", "a", "->", "setProperty", "(", "'trigger'", ",", "\"-PT{$reminder}S\"", ")", ";", "}", "}", "}", "$", "v", "->", "returnCalendar", "(", ")", ";", "}" ]
Returns an iCal feed for this calendar @param int $starttime Range start timestamp @param int $endtime Range end timestamp @param string $filename Filename used for output file @return string
[ "Returns", "an", "iCal", "feed", "for", "this", "calendar" ]
56c0f0ae403af1672a913db5dc259db9cb712491
https://github.com/arckinteractive/events_api/blob/56c0f0ae403af1672a913db5dc259db9cb712491/classes/Events/API/Calendar.php#L380-L440
13,802
arckinteractive/events_api
classes/Events/API/Calendar.php
Calendar.createPublicCalendar
public static function createPublicCalendar($container) { if (!$container instanceof ElggEntity) { return false; } try { $calendar = new Calendar(); $calendar->access_id = ACCESS_PUBLIC; $calendar->owner_guid = $container->guid; $calendar->container_guid = $container->guid; $calendar->__public_calendar = true; // flag we can use to manipulate permissions $ia = elgg_set_ignore_access(true); $calendar->save(); elgg_set_ignore_access($ia); elgg_log("Created public calendar for $container->name [$container->guid]", 'NOTICE'); } catch (Exception $ex) { elgg_log($ex->getMessage(), 'ERROR'); } return $calendar; }
php
public static function createPublicCalendar($container) { if (!$container instanceof ElggEntity) { return false; } try { $calendar = new Calendar(); $calendar->access_id = ACCESS_PUBLIC; $calendar->owner_guid = $container->guid; $calendar->container_guid = $container->guid; $calendar->__public_calendar = true; // flag we can use to manipulate permissions $ia = elgg_set_ignore_access(true); $calendar->save(); elgg_set_ignore_access($ia); elgg_log("Created public calendar for $container->name [$container->guid]", 'NOTICE'); } catch (Exception $ex) { elgg_log($ex->getMessage(), 'ERROR'); } return $calendar; }
[ "public", "static", "function", "createPublicCalendar", "(", "$", "container", ")", "{", "if", "(", "!", "$", "container", "instanceof", "ElggEntity", ")", "{", "return", "false", ";", "}", "try", "{", "$", "calendar", "=", "new", "Calendar", "(", ")", ";", "$", "calendar", "->", "access_id", "=", "ACCESS_PUBLIC", ";", "$", "calendar", "->", "owner_guid", "=", "$", "container", "->", "guid", ";", "$", "calendar", "->", "container_guid", "=", "$", "container", "->", "guid", ";", "$", "calendar", "->", "__public_calendar", "=", "true", ";", "// flag we can use to manipulate permissions", "$", "ia", "=", "elgg_set_ignore_access", "(", "true", ")", ";", "$", "calendar", "->", "save", "(", ")", ";", "elgg_set_ignore_access", "(", "$", "ia", ")", ";", "elgg_log", "(", "\"Created public calendar for $container->name [$container->guid]\"", ",", "'NOTICE'", ")", ";", "}", "catch", "(", "Exception", "$", "ex", ")", "{", "elgg_log", "(", "$", "ex", "->", "getMessage", "(", ")", ",", "'ERROR'", ")", ";", "}", "return", "$", "calendar", ";", "}" ]
Creates a public calendar for a container @param ElggEntity $container User or group @return Calendar
[ "Creates", "a", "public", "calendar", "for", "a", "container" ]
56c0f0ae403af1672a913db5dc259db9cb712491
https://github.com/arckinteractive/events_api/blob/56c0f0ae403af1672a913db5dc259db9cb712491/classes/Events/API/Calendar.php#L448-L471
13,803
arckinteractive/events_api
classes/Events/API/Calendar.php
Calendar.getCalendars
public static function getCalendars($container, $count = false) { if (!$container instanceof ElggEntity) { return false; } $options = array( 'type' => 'object', 'subtype' => 'calendar', 'container_guid' => $container->guid, 'limit' => false ); if ($count) { $options['count'] = true; return elgg_get_entities($options); } return new ElggBatch('elgg_get_entities', $options); }
php
public static function getCalendars($container, $count = false) { if (!$container instanceof ElggEntity) { return false; } $options = array( 'type' => 'object', 'subtype' => 'calendar', 'container_guid' => $container->guid, 'limit' => false ); if ($count) { $options['count'] = true; return elgg_get_entities($options); } return new ElggBatch('elgg_get_entities', $options); }
[ "public", "static", "function", "getCalendars", "(", "$", "container", ",", "$", "count", "=", "false", ")", "{", "if", "(", "!", "$", "container", "instanceof", "ElggEntity", ")", "{", "return", "false", ";", "}", "$", "options", "=", "array", "(", "'type'", "=>", "'object'", ",", "'subtype'", "=>", "'calendar'", ",", "'container_guid'", "=>", "$", "container", "->", "guid", ",", "'limit'", "=>", "false", ")", ";", "if", "(", "$", "count", ")", "{", "$", "options", "[", "'count'", "]", "=", "true", ";", "return", "elgg_get_entities", "(", "$", "options", ")", ";", "}", "return", "new", "ElggBatch", "(", "'elgg_get_entities'", ",", "$", "options", ")", ";", "}" ]
Retrieves all calendars for a container @param type $container @param type $count
[ "Retrieves", "all", "calendars", "for", "a", "container" ]
56c0f0ae403af1672a913db5dc259db9cb712491
https://github.com/arckinteractive/events_api/blob/56c0f0ae403af1672a913db5dc259db9cb712491/classes/Events/API/Calendar.php#L479-L497
13,804
arckinteractive/events_api
classes/Events/API/Calendar.php
Calendar.getPublicCalendar
public static function getPublicCalendar($container) { if (!$container instanceof ElggEntity) { return false; } $calendars = elgg_get_entities(array( 'type' => 'object', 'subtype' => Calendar::SUBTYPE, 'container_guid' => $container->guid, 'limit' => 1, 'metadata_name_value_pairs' => array( 'name' => '__public_calendar', 'value' => true, ), 'order_by' => 'e.time_created ASC', // get the first one )); return (empty($calendars)) ? Calendar::createPublicCalendar($container) : $calendars[0]; }
php
public static function getPublicCalendar($container) { if (!$container instanceof ElggEntity) { return false; } $calendars = elgg_get_entities(array( 'type' => 'object', 'subtype' => Calendar::SUBTYPE, 'container_guid' => $container->guid, 'limit' => 1, 'metadata_name_value_pairs' => array( 'name' => '__public_calendar', 'value' => true, ), 'order_by' => 'e.time_created ASC', // get the first one )); return (empty($calendars)) ? Calendar::createPublicCalendar($container) : $calendars[0]; }
[ "public", "static", "function", "getPublicCalendar", "(", "$", "container", ")", "{", "if", "(", "!", "$", "container", "instanceof", "ElggEntity", ")", "{", "return", "false", ";", "}", "$", "calendars", "=", "elgg_get_entities", "(", "array", "(", "'type'", "=>", "'object'", ",", "'subtype'", "=>", "Calendar", "::", "SUBTYPE", ",", "'container_guid'", "=>", "$", "container", "->", "guid", ",", "'limit'", "=>", "1", ",", "'metadata_name_value_pairs'", "=>", "array", "(", "'name'", "=>", "'__public_calendar'", ",", "'value'", "=>", "true", ",", ")", ",", "'order_by'", "=>", "'e.time_created ASC'", ",", "// get the first one", ")", ")", ";", "return", "(", "empty", "(", "$", "calendars", ")", ")", "?", "Calendar", "::", "createPublicCalendar", "(", "$", "container", ")", ":", "$", "calendars", "[", "0", "]", ";", "}" ]
Retrieves user's or group's public calendar @param ElggEntity $container User or group @return Calendar|false
[ "Retrieves", "user", "s", "or", "group", "s", "public", "calendar" ]
56c0f0ae403af1672a913db5dc259db9cb712491
https://github.com/arckinteractive/events_api/blob/56c0f0ae403af1672a913db5dc259db9cb712491/classes/Events/API/Calendar.php#L505-L524
13,805
iP1SMS/ip1-php-sdk
src/Recipient/ProcessedGroup.php
ProcessedGroup.getMemberships
public function getMemberships(Communicator $communicator = null): ClassValidationArray { if ($communicator !== null) { $membershipJSON = $communicator->get("api/groups/".$this->groupID."/memberships"); $membershipStd = json_decode($membershipJSON); $memberships = []; foreach ($membershipStd as $value) { $memberships[] = RecipientFactory::createProcessedMembershipFromStdClass($value); } $this->memberships = $memberships; $this->fetchedMemberships = true; } return $this->memberships; }
php
public function getMemberships(Communicator $communicator = null): ClassValidationArray { if ($communicator !== null) { $membershipJSON = $communicator->get("api/groups/".$this->groupID."/memberships"); $membershipStd = json_decode($membershipJSON); $memberships = []; foreach ($membershipStd as $value) { $memberships[] = RecipientFactory::createProcessedMembershipFromStdClass($value); } $this->memberships = $memberships; $this->fetchedMemberships = true; } return $this->memberships; }
[ "public", "function", "getMemberships", "(", "Communicator", "$", "communicator", "=", "null", ")", ":", "ClassValidationArray", "{", "if", "(", "$", "communicator", "!==", "null", ")", "{", "$", "membershipJSON", "=", "$", "communicator", "->", "get", "(", "\"api/groups/\"", ".", "$", "this", "->", "groupID", ".", "\"/memberships\"", ")", ";", "$", "membershipStd", "=", "json_decode", "(", "$", "membershipJSON", ")", ";", "$", "memberships", "=", "[", "]", ";", "foreach", "(", "$", "membershipStd", "as", "$", "value", ")", "{", "$", "memberships", "[", "]", "=", "RecipientFactory", "::", "createProcessedMembershipFromStdClass", "(", "$", "value", ")", ";", "}", "$", "this", "->", "memberships", "=", "$", "memberships", ";", "$", "this", "->", "fetchedMemberships", "=", "true", ";", "}", "return", "$", "this", "->", "memberships", ";", "}" ]
Returns an array of all the memberships the group is referenced in. If a communicator is not provided it will not fetch memberships from the API but return those that has been fetched, if any. @param Communicator $communicator Used to fetch memberships from the API. @return array An array of Membership objects
[ "Returns", "an", "array", "of", "all", "the", "memberships", "the", "group", "is", "referenced", "in", ".", "If", "a", "communicator", "is", "not", "provided", "it", "will", "not", "fetch", "memberships", "from", "the", "API", "but", "return", "those", "that", "has", "been", "fetched", "if", "any", "." ]
348e6572a279363ba689c9e0f5689b83a25930f5
https://github.com/iP1SMS/ip1-php-sdk/blob/348e6572a279363ba689c9e0f5689b83a25930f5/src/Recipient/ProcessedGroup.php#L130-L143
13,806
iP1SMS/ip1-php-sdk
src/Recipient/ProcessedGroup.php
ProcessedGroup.getContacts
public function getContacts(Communicator $communicator = null): ClassValidationArray { if ($communicator !== null) { $contactStd = $communicator->get('api/groups/'.$this->groupID. '/contacts'); $contactStd = json_decode($contactStd); $contacts = RecipientFactory::createProcessedGroupsFromStdClassArray($contactStd); $this->contacts = $contacts; $this->contactsFetched = true; } return $this->contacts; }
php
public function getContacts(Communicator $communicator = null): ClassValidationArray { if ($communicator !== null) { $contactStd = $communicator->get('api/groups/'.$this->groupID. '/contacts'); $contactStd = json_decode($contactStd); $contacts = RecipientFactory::createProcessedGroupsFromStdClassArray($contactStd); $this->contacts = $contacts; $this->contactsFetched = true; } return $this->contacts; }
[ "public", "function", "getContacts", "(", "Communicator", "$", "communicator", "=", "null", ")", ":", "ClassValidationArray", "{", "if", "(", "$", "communicator", "!==", "null", ")", "{", "$", "contactStd", "=", "$", "communicator", "->", "get", "(", "'api/groups/'", ".", "$", "this", "->", "groupID", ".", "'/contacts'", ")", ";", "$", "contactStd", "=", "json_decode", "(", "$", "contactStd", ")", ";", "$", "contacts", "=", "RecipientFactory", "::", "createProcessedGroupsFromStdClassArray", "(", "$", "contactStd", ")", ";", "$", "this", "->", "contacts", "=", "$", "contacts", ";", "$", "this", "->", "contactsFetched", "=", "true", ";", "}", "return", "$", "this", "->", "contacts", ";", "}" ]
Returns an array of all the Contacts that belong to the Group. If a communicator is not provided it will not fetch Contacts from the API but return those that has been fetched, if any. @param Communicator $communicator Used to fetch Contacts from the API. @return ClassValidationArray An array of ProcessedContact objects.
[ "Returns", "an", "array", "of", "all", "the", "Contacts", "that", "belong", "to", "the", "Group", ".", "If", "a", "communicator", "is", "not", "provided", "it", "will", "not", "fetch", "Contacts", "from", "the", "API", "but", "return", "those", "that", "has", "been", "fetched", "if", "any", "." ]
348e6572a279363ba689c9e0f5689b83a25930f5
https://github.com/iP1SMS/ip1-php-sdk/blob/348e6572a279363ba689c9e0f5689b83a25930f5/src/Recipient/ProcessedGroup.php#L159-L169
13,807
nyeholt/silverstripe-simplewiki
thirdparty/htmlpurifier-4.0.0-lite/library/HTMLPurifier/Lexer/PEARSax3.php
HTMLPurifier_Lexer_PEARSax3.openHandler
public function openHandler(&$parser, $name, $attrs, $closed) { // entities are not resolved in attrs foreach ($attrs as $key => $attr) { $attrs[$key] = $this->parseData($attr); } if ($closed) { $this->tokens[] = new HTMLPurifier_Token_Empty($name, $attrs); } else { $this->tokens[] = new HTMLPurifier_Token_Start($name, $attrs); } return true; }
php
public function openHandler(&$parser, $name, $attrs, $closed) { // entities are not resolved in attrs foreach ($attrs as $key => $attr) { $attrs[$key] = $this->parseData($attr); } if ($closed) { $this->tokens[] = new HTMLPurifier_Token_Empty($name, $attrs); } else { $this->tokens[] = new HTMLPurifier_Token_Start($name, $attrs); } return true; }
[ "public", "function", "openHandler", "(", "&", "$", "parser", ",", "$", "name", ",", "$", "attrs", ",", "$", "closed", ")", "{", "// entities are not resolved in attrs", "foreach", "(", "$", "attrs", "as", "$", "key", "=>", "$", "attr", ")", "{", "$", "attrs", "[", "$", "key", "]", "=", "$", "this", "->", "parseData", "(", "$", "attr", ")", ";", "}", "if", "(", "$", "closed", ")", "{", "$", "this", "->", "tokens", "[", "]", "=", "new", "HTMLPurifier_Token_Empty", "(", "$", "name", ",", "$", "attrs", ")", ";", "}", "else", "{", "$", "this", "->", "tokens", "[", "]", "=", "new", "HTMLPurifier_Token_Start", "(", "$", "name", ",", "$", "attrs", ")", ";", "}", "return", "true", ";", "}" ]
Open tag event handler, interface is defined by PEAR package.
[ "Open", "tag", "event", "handler", "interface", "is", "defined", "by", "PEAR", "package", "." ]
ecffed0d75be1454901e1cb24633472b8f67c967
https://github.com/nyeholt/silverstripe-simplewiki/blob/ecffed0d75be1454901e1cb24633472b8f67c967/thirdparty/htmlpurifier-4.0.0-lite/library/HTMLPurifier/Lexer/PEARSax3.php#L54-L65
13,808
nyeholt/silverstripe-simplewiki
thirdparty/htmlpurifier-4.0.0-lite/library/HTMLPurifier/Lexer/PEARSax3.php
HTMLPurifier_Lexer_PEARSax3.closeHandler
public function closeHandler(&$parser, $name) { // HTMLSax3 seems to always send empty tags an extra close tag // check and ignore if you see it: // [TESTME] to make sure it doesn't overreach if ($this->tokens[count($this->tokens)-1] instanceof HTMLPurifier_Token_Empty) { return true; } $this->tokens[] = new HTMLPurifier_Token_End($name); return true; }
php
public function closeHandler(&$parser, $name) { // HTMLSax3 seems to always send empty tags an extra close tag // check and ignore if you see it: // [TESTME] to make sure it doesn't overreach if ($this->tokens[count($this->tokens)-1] instanceof HTMLPurifier_Token_Empty) { return true; } $this->tokens[] = new HTMLPurifier_Token_End($name); return true; }
[ "public", "function", "closeHandler", "(", "&", "$", "parser", ",", "$", "name", ")", "{", "// HTMLSax3 seems to always send empty tags an extra close tag", "// check and ignore if you see it:", "// [TESTME] to make sure it doesn't overreach", "if", "(", "$", "this", "->", "tokens", "[", "count", "(", "$", "this", "->", "tokens", ")", "-", "1", "]", "instanceof", "HTMLPurifier_Token_Empty", ")", "{", "return", "true", ";", "}", "$", "this", "->", "tokens", "[", "]", "=", "new", "HTMLPurifier_Token_End", "(", "$", "name", ")", ";", "return", "true", ";", "}" ]
Close tag event handler, interface is defined by PEAR package.
[ "Close", "tag", "event", "handler", "interface", "is", "defined", "by", "PEAR", "package", "." ]
ecffed0d75be1454901e1cb24633472b8f67c967
https://github.com/nyeholt/silverstripe-simplewiki/blob/ecffed0d75be1454901e1cb24633472b8f67c967/thirdparty/htmlpurifier-4.0.0-lite/library/HTMLPurifier/Lexer/PEARSax3.php#L70-L79
13,809
nyeholt/silverstripe-simplewiki
thirdparty/htmlpurifier-4.0.0-lite/library/HTMLPurifier/Lexer/PEARSax3.php
HTMLPurifier_Lexer_PEARSax3.escapeHandler
public function escapeHandler(&$parser, $data) { if (strpos($data, '--') === 0) { $this->tokens[] = new HTMLPurifier_Token_Comment($data); } // CDATA is handled elsewhere, but if it was handled here: //if (strpos($data, '[CDATA[') === 0) { // $this->tokens[] = new HTMLPurifier_Token_Text( // substr($data, 7, strlen($data) - 9) ); //} return true; }
php
public function escapeHandler(&$parser, $data) { if (strpos($data, '--') === 0) { $this->tokens[] = new HTMLPurifier_Token_Comment($data); } // CDATA is handled elsewhere, but if it was handled here: //if (strpos($data, '[CDATA[') === 0) { // $this->tokens[] = new HTMLPurifier_Token_Text( // substr($data, 7, strlen($data) - 9) ); //} return true; }
[ "public", "function", "escapeHandler", "(", "&", "$", "parser", ",", "$", "data", ")", "{", "if", "(", "strpos", "(", "$", "data", ",", "'--'", ")", "===", "0", ")", "{", "$", "this", "->", "tokens", "[", "]", "=", "new", "HTMLPurifier_Token_Comment", "(", "$", "data", ")", ";", "}", "// CDATA is handled elsewhere, but if it was handled here:", "//if (strpos($data, '[CDATA[') === 0) {", "// $this->tokens[] = new HTMLPurifier_Token_Text(", "// substr($data, 7, strlen($data) - 9) );", "//}", "return", "true", ";", "}" ]
Escaped text handler, interface is defined by PEAR package.
[ "Escaped", "text", "handler", "interface", "is", "defined", "by", "PEAR", "package", "." ]
ecffed0d75be1454901e1cb24633472b8f67c967
https://github.com/nyeholt/silverstripe-simplewiki/blob/ecffed0d75be1454901e1cb24633472b8f67c967/thirdparty/htmlpurifier-4.0.0-lite/library/HTMLPurifier/Lexer/PEARSax3.php#L92-L102
13,810
dphn/ScContent
src/ScContent/Mapper/Installation/LayoutMapper.php
LayoutMapper.findExistingWidgets
public function findExistingWidgets($theme, $names) { if (! is_array($names)) { $names = [$names]; } $select = $this->getSql()->select() ->from($this->getTable(self::LayoutTableAlias)) ->columns([ 'name', ]) ->where([ 'theme' => $theme, 'name' => $names, // = new In('name', $names) ]); $result = $this->execute($select); return $this->toList($result, 'name'); }
php
public function findExistingWidgets($theme, $names) { if (! is_array($names)) { $names = [$names]; } $select = $this->getSql()->select() ->from($this->getTable(self::LayoutTableAlias)) ->columns([ 'name', ]) ->where([ 'theme' => $theme, 'name' => $names, // = new In('name', $names) ]); $result = $this->execute($select); return $this->toList($result, 'name'); }
[ "public", "function", "findExistingWidgets", "(", "$", "theme", ",", "$", "names", ")", "{", "if", "(", "!", "is_array", "(", "$", "names", ")", ")", "{", "$", "names", "=", "[", "$", "names", "]", ";", "}", "$", "select", "=", "$", "this", "->", "getSql", "(", ")", "->", "select", "(", ")", "->", "from", "(", "$", "this", "->", "getTable", "(", "self", "::", "LayoutTableAlias", ")", ")", "->", "columns", "(", "[", "'name'", ",", "]", ")", "->", "where", "(", "[", "'theme'", "=>", "$", "theme", ",", "'name'", "=>", "$", "names", ",", "// = new In('name', $names)", "]", ")", ";", "$", "result", "=", "$", "this", "->", "execute", "(", "$", "select", ")", ";", "return", "$", "this", "->", "toList", "(", "$", "result", ",", "'name'", ")", ";", "}" ]
Returns the names of the widgets from a predefined list, that are registered in the database. @param string $theme @param string $names @return array
[ "Returns", "the", "names", "of", "the", "widgets", "from", "a", "predefined", "list", "that", "are", "registered", "in", "the", "database", "." ]
9dd5732490c45fd788b96cedf7b3c7adfacb30d2
https://github.com/dphn/ScContent/blob/9dd5732490c45fd788b96cedf7b3c7adfacb30d2/src/ScContent/Mapper/Installation/LayoutMapper.php#L30-L47
13,811
venta/framework
src/Container/src/MutableContainer.php
MutableContainer.isResolvableCallable
private function isResolvableCallable(Invokable $reflectedCallable): bool { // If array represents callable we need to be sure it's an object or a resolvable service id. $callable = $reflectedCallable->callable(); return $reflectedCallable->isFunction() || is_object($callable[0]) || $this->isResolvableService($callable[0]); }
php
private function isResolvableCallable(Invokable $reflectedCallable): bool { // If array represents callable we need to be sure it's an object or a resolvable service id. $callable = $reflectedCallable->callable(); return $reflectedCallable->isFunction() || is_object($callable[0]) || $this->isResolvableService($callable[0]); }
[ "private", "function", "isResolvableCallable", "(", "Invokable", "$", "reflectedCallable", ")", ":", "bool", "{", "// If array represents callable we need to be sure it's an object or a resolvable service id.", "$", "callable", "=", "$", "reflectedCallable", "->", "callable", "(", ")", ";", "return", "$", "reflectedCallable", "->", "isFunction", "(", ")", "||", "is_object", "(", "$", "callable", "[", "0", "]", ")", "||", "$", "this", "->", "isResolvableService", "(", "$", "callable", "[", "0", "]", ")", ";", "}" ]
Verifies that provided callable can be called by service container. @param Invokable $reflectedCallable @return bool
[ "Verifies", "that", "provided", "callable", "can", "be", "called", "by", "service", "container", "." ]
514a7854cc69f84f47e62a58cc55efd68b7c9f83
https://github.com/venta/framework/blob/514a7854cc69f84f47e62a58cc55efd68b7c9f83/src/Container/src/MutableContainer.php#L171-L179
13,812
venta/framework
src/Container/src/MutableContainer.php
MutableContainer.register
private function register(string $id, bool $shared, Closure $registrationCallback) { // Check if correct service is provided. $this->validateId($id); $id = $this->normalize($id); // Clean up previous bindings, if any. unset($this->instances[$id], $this->shared[$id], $this->keys[$id]); // Register service with provided callback. $registrationCallback($id); // Mark service as shared when needed. $this->shared[$id] = $shared ?: null; // Save service key to make it recognizable by container. $this->keys[$id] = true; }
php
private function register(string $id, bool $shared, Closure $registrationCallback) { // Check if correct service is provided. $this->validateId($id); $id = $this->normalize($id); // Clean up previous bindings, if any. unset($this->instances[$id], $this->shared[$id], $this->keys[$id]); // Register service with provided callback. $registrationCallback($id); // Mark service as shared when needed. $this->shared[$id] = $shared ?: null; // Save service key to make it recognizable by container. $this->keys[$id] = true; }
[ "private", "function", "register", "(", "string", "$", "id", ",", "bool", "$", "shared", ",", "Closure", "$", "registrationCallback", ")", "{", "// Check if correct service is provided.", "$", "this", "->", "validateId", "(", "$", "id", ")", ";", "$", "id", "=", "$", "this", "->", "normalize", "(", "$", "id", ")", ";", "// Clean up previous bindings, if any.", "unset", "(", "$", "this", "->", "instances", "[", "$", "id", "]", ",", "$", "this", "->", "shared", "[", "$", "id", "]", ",", "$", "this", "->", "keys", "[", "$", "id", "]", ")", ";", "// Register service with provided callback.", "$", "registrationCallback", "(", "$", "id", ")", ";", "// Mark service as shared when needed.", "$", "this", "->", "shared", "[", "$", "id", "]", "=", "$", "shared", "?", ":", "null", ";", "// Save service key to make it recognizable by container.", "$", "this", "->", "keys", "[", "$", "id", "]", "=", "true", ";", "}" ]
Registers binding. After this method call binding can be resolved by container. @param string $id @param bool $shared @param Closure $registrationCallback @return void
[ "Registers", "binding", ".", "After", "this", "method", "call", "binding", "can", "be", "resolved", "by", "container", "." ]
514a7854cc69f84f47e62a58cc55efd68b7c9f83
https://github.com/venta/framework/blob/514a7854cc69f84f47e62a58cc55efd68b7c9f83/src/Container/src/MutableContainer.php#L190-L207
13,813
venta/framework
src/Container/src/MutableContainer.php
MutableContainer.validateId
private function validateId(string $id) { if (!interface_exists($id) && !class_exists($id)) { throw new InvalidArgumentException( sprintf('Invalid service id "%s". Service id must be an existing interface or class name.', $id) ); } }
php
private function validateId(string $id) { if (!interface_exists($id) && !class_exists($id)) { throw new InvalidArgumentException( sprintf('Invalid service id "%s". Service id must be an existing interface or class name.', $id) ); } }
[ "private", "function", "validateId", "(", "string", "$", "id", ")", "{", "if", "(", "!", "interface_exists", "(", "$", "id", ")", "&&", "!", "class_exists", "(", "$", "id", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "sprintf", "(", "'Invalid service id \"%s\". Service id must be an existing interface or class name.'", ",", "$", "id", ")", ")", ";", "}", "}" ]
Validate service identifier. Throw an Exception in case of invalid value. @param string $id @return void @throws InvalidArgumentException
[ "Validate", "service", "identifier", ".", "Throw", "an", "Exception", "in", "case", "of", "invalid", "value", "." ]
514a7854cc69f84f47e62a58cc55efd68b7c9f83
https://github.com/venta/framework/blob/514a7854cc69f84f47e62a58cc55efd68b7c9f83/src/Container/src/MutableContainer.php#L216-L223
13,814
activecollab/bootstrap
src/Router/Router.php
Router.getModelNameFromClass
private function getModelNameFromClass($model_class) { if (($pos = strrpos($model_class, '\\')) !== false) { return Inflector::pluralize(Inflector::tableize(substr($model_class, $pos + 1))); } else { return Inflector::pluralize(Inflector::tableize($model_class)); } }
php
private function getModelNameFromClass($model_class) { if (($pos = strrpos($model_class, '\\')) !== false) { return Inflector::pluralize(Inflector::tableize(substr($model_class, $pos + 1))); } else { return Inflector::pluralize(Inflector::tableize($model_class)); } }
[ "private", "function", "getModelNameFromClass", "(", "$", "model_class", ")", "{", "if", "(", "(", "$", "pos", "=", "strrpos", "(", "$", "model_class", ",", "'\\\\'", ")", ")", "!==", "false", ")", "{", "return", "Inflector", "::", "pluralize", "(", "Inflector", "::", "tableize", "(", "substr", "(", "$", "model_class", ",", "$", "pos", "+", "1", ")", ")", ")", ";", "}", "else", "{", "return", "Inflector", "::", "pluralize", "(", "Inflector", "::", "tableize", "(", "$", "model_class", ")", ")", ";", "}", "}" ]
Get model name from model class. @param string $model_class @return string
[ "Get", "model", "name", "from", "model", "class", "." ]
92eea19b2b2b329035f20e855a78f36e74084ccf
https://github.com/activecollab/bootstrap/blob/92eea19b2b2b329035f20e855a78f36e74084ccf/src/Router/Router.php#L131-L138
13,815
antarestupin/Accessible
lib/Accessible/Reader/Reader.php
Reader.getClassesToRead
public static function getClassesToRead(\ReflectionObject $reflectionObject) { $cacheId = md5("classesToRead:" . $reflectionObject->getName()); $objectClasses = self::getFromCache($cacheId); if ($objectClasses !== null) { return $objectClasses; } $objectClasses = array($reflectionObject); $objectTraits = $reflectionObject->getTraits(); if (!empty($objectTraits)) { foreach ($objectTraits as $trait) { $objectClasses[] = $trait; } } $parentClass = $reflectionObject->getParentClass(); while ($parentClass) { $objectClasses[] = $parentClass; $parentTraits = $parentClass->getTraits(); if (!empty($parentTraits)) { foreach ($parentTraits as $trait) { $objectClasses[] = $trait; } } $parentClass = $parentClass->getParentClass(); } self::saveToCache($cacheId, $objectClasses); return $objectClasses; }
php
public static function getClassesToRead(\ReflectionObject $reflectionObject) { $cacheId = md5("classesToRead:" . $reflectionObject->getName()); $objectClasses = self::getFromCache($cacheId); if ($objectClasses !== null) { return $objectClasses; } $objectClasses = array($reflectionObject); $objectTraits = $reflectionObject->getTraits(); if (!empty($objectTraits)) { foreach ($objectTraits as $trait) { $objectClasses[] = $trait; } } $parentClass = $reflectionObject->getParentClass(); while ($parentClass) { $objectClasses[] = $parentClass; $parentTraits = $parentClass->getTraits(); if (!empty($parentTraits)) { foreach ($parentTraits as $trait) { $objectClasses[] = $trait; } } $parentClass = $parentClass->getParentClass(); } self::saveToCache($cacheId, $objectClasses); return $objectClasses; }
[ "public", "static", "function", "getClassesToRead", "(", "\\", "ReflectionObject", "$", "reflectionObject", ")", "{", "$", "cacheId", "=", "md5", "(", "\"classesToRead:\"", ".", "$", "reflectionObject", "->", "getName", "(", ")", ")", ";", "$", "objectClasses", "=", "self", "::", "getFromCache", "(", "$", "cacheId", ")", ";", "if", "(", "$", "objectClasses", "!==", "null", ")", "{", "return", "$", "objectClasses", ";", "}", "$", "objectClasses", "=", "array", "(", "$", "reflectionObject", ")", ";", "$", "objectTraits", "=", "$", "reflectionObject", "->", "getTraits", "(", ")", ";", "if", "(", "!", "empty", "(", "$", "objectTraits", ")", ")", "{", "foreach", "(", "$", "objectTraits", "as", "$", "trait", ")", "{", "$", "objectClasses", "[", "]", "=", "$", "trait", ";", "}", "}", "$", "parentClass", "=", "$", "reflectionObject", "->", "getParentClass", "(", ")", ";", "while", "(", "$", "parentClass", ")", "{", "$", "objectClasses", "[", "]", "=", "$", "parentClass", ";", "$", "parentTraits", "=", "$", "parentClass", "->", "getTraits", "(", ")", ";", "if", "(", "!", "empty", "(", "$", "parentTraits", ")", ")", "{", "foreach", "(", "$", "parentTraits", "as", "$", "trait", ")", "{", "$", "objectClasses", "[", "]", "=", "$", "trait", ";", "}", "}", "$", "parentClass", "=", "$", "parentClass", "->", "getParentClass", "(", ")", ";", "}", "self", "::", "saveToCache", "(", "$", "cacheId", ",", "$", "objectClasses", ")", ";", "return", "$", "objectClasses", ";", "}" ]
Get a list of classes and traits to analyze. @param \ReflectionObject $reflectionObject The object to get the parents from. @return array The list of classes to read.
[ "Get", "a", "list", "of", "classes", "and", "traits", "to", "analyze", "." ]
d12ce93d72f74c099dfd2109371fcd6ddfffdca4
https://github.com/antarestupin/Accessible/blob/d12ce93d72f74c099dfd2109371fcd6ddfffdca4/lib/Accessible/Reader/Reader.php#L27-L60
13,816
antarestupin/Accessible
lib/Accessible/Reader/Reader.php
Reader.getProperties
public static function getProperties($classes) { array_reverse($classes); $properties = array(); foreach ($classes as $class) { foreach ($class->getProperties() as $property) { $properties[$property->getName()] = $property; } } return $properties; }
php
public static function getProperties($classes) { array_reverse($classes); $properties = array(); foreach ($classes as $class) { foreach ($class->getProperties() as $property) { $properties[$property->getName()] = $property; } } return $properties; }
[ "public", "static", "function", "getProperties", "(", "$", "classes", ")", "{", "array_reverse", "(", "$", "classes", ")", ";", "$", "properties", "=", "array", "(", ")", ";", "foreach", "(", "$", "classes", "as", "$", "class", ")", "{", "foreach", "(", "$", "class", "->", "getProperties", "(", ")", "as", "$", "property", ")", "{", "$", "properties", "[", "$", "property", "->", "getName", "(", ")", "]", "=", "$", "property", ";", "}", "}", "return", "$", "properties", ";", "}" ]
Get the properties from a list of classes. @param array $classes @return array
[ "Get", "the", "properties", "from", "a", "list", "of", "classes", "." ]
d12ce93d72f74c099dfd2109371fcd6ddfffdca4
https://github.com/antarestupin/Accessible/blob/d12ce93d72f74c099dfd2109371fcd6ddfffdca4/lib/Accessible/Reader/Reader.php#L69-L80
13,817
antarestupin/Accessible
lib/Accessible/Reader/Reader.php
Reader.getClassInformation
public static function getClassInformation($object) { $reflectionObject = new \ReflectionObject($object); $cacheId = md5("classInformation:" . $reflectionObject->getName()); $classInfo = self::getFromCache($cacheId); if ($classInfo !== null) { return $classInfo; } $objectClasses = self::getClassesToRead($reflectionObject); $objectProperties = self::getProperties($objectClasses); $annotationReader = Configuration::getAnnotationReader(); $classInfo = array( 'accessProperties' => AccessReader::getAccessProperties($objectProperties, $annotationReader), 'collectionsItemNames' => CollectionsReader::getCollectionsItemNames($objectProperties, $annotationReader), 'associationsList' => AssociationReader::getAssociations($objectProperties, $annotationReader), 'constraintsValidationEnabled' => ConstraintsReader::isConstraintsValidationEnabled($objectClasses, $annotationReader), 'initialPropertiesValues' => AutoConstructReader::getPropertiesToInitialize($objectProperties, $annotationReader), 'initializationNeededArguments' => AutoConstructReader::getConstructArguments($objectClasses, $annotationReader) ); self::saveToCache($cacheId, $classInfo); return $classInfo; }
php
public static function getClassInformation($object) { $reflectionObject = new \ReflectionObject($object); $cacheId = md5("classInformation:" . $reflectionObject->getName()); $classInfo = self::getFromCache($cacheId); if ($classInfo !== null) { return $classInfo; } $objectClasses = self::getClassesToRead($reflectionObject); $objectProperties = self::getProperties($objectClasses); $annotationReader = Configuration::getAnnotationReader(); $classInfo = array( 'accessProperties' => AccessReader::getAccessProperties($objectProperties, $annotationReader), 'collectionsItemNames' => CollectionsReader::getCollectionsItemNames($objectProperties, $annotationReader), 'associationsList' => AssociationReader::getAssociations($objectProperties, $annotationReader), 'constraintsValidationEnabled' => ConstraintsReader::isConstraintsValidationEnabled($objectClasses, $annotationReader), 'initialPropertiesValues' => AutoConstructReader::getPropertiesToInitialize($objectProperties, $annotationReader), 'initializationNeededArguments' => AutoConstructReader::getConstructArguments($objectClasses, $annotationReader) ); self::saveToCache($cacheId, $classInfo); return $classInfo; }
[ "public", "static", "function", "getClassInformation", "(", "$", "object", ")", "{", "$", "reflectionObject", "=", "new", "\\", "ReflectionObject", "(", "$", "object", ")", ";", "$", "cacheId", "=", "md5", "(", "\"classInformation:\"", ".", "$", "reflectionObject", "->", "getName", "(", ")", ")", ";", "$", "classInfo", "=", "self", "::", "getFromCache", "(", "$", "cacheId", ")", ";", "if", "(", "$", "classInfo", "!==", "null", ")", "{", "return", "$", "classInfo", ";", "}", "$", "objectClasses", "=", "self", "::", "getClassesToRead", "(", "$", "reflectionObject", ")", ";", "$", "objectProperties", "=", "self", "::", "getProperties", "(", "$", "objectClasses", ")", ";", "$", "annotationReader", "=", "Configuration", "::", "getAnnotationReader", "(", ")", ";", "$", "classInfo", "=", "array", "(", "'accessProperties'", "=>", "AccessReader", "::", "getAccessProperties", "(", "$", "objectProperties", ",", "$", "annotationReader", ")", ",", "'collectionsItemNames'", "=>", "CollectionsReader", "::", "getCollectionsItemNames", "(", "$", "objectProperties", ",", "$", "annotationReader", ")", ",", "'associationsList'", "=>", "AssociationReader", "::", "getAssociations", "(", "$", "objectProperties", ",", "$", "annotationReader", ")", ",", "'constraintsValidationEnabled'", "=>", "ConstraintsReader", "::", "isConstraintsValidationEnabled", "(", "$", "objectClasses", ",", "$", "annotationReader", ")", ",", "'initialPropertiesValues'", "=>", "AutoConstructReader", "::", "getPropertiesToInitialize", "(", "$", "objectProperties", ",", "$", "annotationReader", ")", ",", "'initializationNeededArguments'", "=>", "AutoConstructReader", "::", "getConstructArguments", "(", "$", "objectClasses", ",", "$", "annotationReader", ")", ")", ";", "self", "::", "saveToCache", "(", "$", "cacheId", ",", "$", "classInfo", ")", ";", "return", "$", "classInfo", ";", "}" ]
Get the information on a class from its instance. @param object $object @return array
[ "Get", "the", "information", "on", "a", "class", "from", "its", "instance", "." ]
d12ce93d72f74c099dfd2109371fcd6ddfffdca4
https://github.com/antarestupin/Accessible/blob/d12ce93d72f74c099dfd2109371fcd6ddfffdca4/lib/Accessible/Reader/Reader.php#L89-L114
13,818
antarestupin/Accessible
lib/Accessible/Reader/Reader.php
Reader.saveToCache
public static function saveToCache($id, $value) { $arrayCache = Configuration::getArrayCache(); $cacheDriver = Configuration::getCacheDriver(); $arrayCache->save($id, $value); if ($cacheDriver !== null) { $cacheDriver->save($id, $value); } }
php
public static function saveToCache($id, $value) { $arrayCache = Configuration::getArrayCache(); $cacheDriver = Configuration::getCacheDriver(); $arrayCache->save($id, $value); if ($cacheDriver !== null) { $cacheDriver->save($id, $value); } }
[ "public", "static", "function", "saveToCache", "(", "$", "id", ",", "$", "value", ")", "{", "$", "arrayCache", "=", "Configuration", "::", "getArrayCache", "(", ")", ";", "$", "cacheDriver", "=", "Configuration", "::", "getCacheDriver", "(", ")", ";", "$", "arrayCache", "->", "save", "(", "$", "id", ",", "$", "value", ")", ";", "if", "(", "$", "cacheDriver", "!==", "null", ")", "{", "$", "cacheDriver", "->", "save", "(", "$", "id", ",", "$", "value", ")", ";", "}", "}" ]
Save a value to the cache. @param string $id @param mixed $value
[ "Save", "a", "value", "to", "the", "cache", "." ]
d12ce93d72f74c099dfd2109371fcd6ddfffdca4
https://github.com/antarestupin/Accessible/blob/d12ce93d72f74c099dfd2109371fcd6ddfffdca4/lib/Accessible/Reader/Reader.php#L148-L157
13,819
antarestupin/Accessible
lib/Accessible/MethodManager/SetManager.php
SetManager.add
public static function add(&$set, $args) { self::assertArgsNumber(1, $args); $value = $args[0]; foreach ($set as $item) { if ($item === $value) { return; } } $set[] = $value; }
php
public static function add(&$set, $args) { self::assertArgsNumber(1, $args); $value = $args[0]; foreach ($set as $item) { if ($item === $value) { return; } } $set[] = $value; }
[ "public", "static", "function", "add", "(", "&", "$", "set", ",", "$", "args", ")", "{", "self", "::", "assertArgsNumber", "(", "1", ",", "$", "args", ")", ";", "$", "value", "=", "$", "args", "[", "0", "]", ";", "foreach", "(", "$", "set", "as", "$", "item", ")", "{", "if", "(", "$", "item", "===", "$", "value", ")", "{", "return", ";", "}", "}", "$", "set", "[", "]", "=", "$", "value", ";", "}" ]
Adds an element to the set if it is not already present. @param array|Traversable $set @param array $args
[ "Adds", "an", "element", "to", "the", "set", "if", "it", "is", "not", "already", "present", "." ]
d12ce93d72f74c099dfd2109371fcd6ddfffdca4
https://github.com/antarestupin/Accessible/blob/d12ce93d72f74c099dfd2109371fcd6ddfffdca4/lib/Accessible/MethodManager/SetManager.php#L13-L26
13,820
antarestupin/Accessible
lib/Accessible/MethodManager/SetManager.php
SetManager.remove
public static function remove(&$set, $args) { self::assertArgsNumber(1, $args); foreach ($set as $key => $value) { if ($value === $args[0]) { unset($set[$key]); return; } } }
php
public static function remove(&$set, $args) { self::assertArgsNumber(1, $args); foreach ($set as $key => $value) { if ($value === $args[0]) { unset($set[$key]); return; } } }
[ "public", "static", "function", "remove", "(", "&", "$", "set", ",", "$", "args", ")", "{", "self", "::", "assertArgsNumber", "(", "1", ",", "$", "args", ")", ";", "foreach", "(", "$", "set", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "$", "value", "===", "$", "args", "[", "0", "]", ")", "{", "unset", "(", "$", "set", "[", "$", "key", "]", ")", ";", "return", ";", "}", "}", "}" ]
Removes an element from the set. @param array|Traversable $set @param array $args
[ "Removes", "an", "element", "from", "the", "set", "." ]
d12ce93d72f74c099dfd2109371fcd6ddfffdca4
https://github.com/antarestupin/Accessible/blob/d12ce93d72f74c099dfd2109371fcd6ddfffdca4/lib/Accessible/MethodManager/SetManager.php#L34-L44
13,821
PandaPlatform/framework
src/Panda/Events/Event.php
Event.dispatch
public function dispatch() { foreach ($this->getSubscribers() as $channelIdentifier => $subscribers) { // Get channel from ChannelFactory $channel = $this->getChannelFactory()->getChannel($channelIdentifier); // Get proper message for the given channel $message = $this->getMessage($channel); // Decorate message $message = $this->decorate($message, $channel); // Dispatch to all subscribers /** @var SubscriberInterface $subscriber */ foreach ($subscribers as $subscriber) { // Decorate the message $message->decorate(); // Dispatch to the subscriber $channel->dispatch($subscriber, $message); } } }
php
public function dispatch() { foreach ($this->getSubscribers() as $channelIdentifier => $subscribers) { // Get channel from ChannelFactory $channel = $this->getChannelFactory()->getChannel($channelIdentifier); // Get proper message for the given channel $message = $this->getMessage($channel); // Decorate message $message = $this->decorate($message, $channel); // Dispatch to all subscribers /** @var SubscriberInterface $subscriber */ foreach ($subscribers as $subscriber) { // Decorate the message $message->decorate(); // Dispatch to the subscriber $channel->dispatch($subscriber, $message); } } }
[ "public", "function", "dispatch", "(", ")", "{", "foreach", "(", "$", "this", "->", "getSubscribers", "(", ")", "as", "$", "channelIdentifier", "=>", "$", "subscribers", ")", "{", "// Get channel from ChannelFactory", "$", "channel", "=", "$", "this", "->", "getChannelFactory", "(", ")", "->", "getChannel", "(", "$", "channelIdentifier", ")", ";", "// Get proper message for the given channel", "$", "message", "=", "$", "this", "->", "getMessage", "(", "$", "channel", ")", ";", "// Decorate message", "$", "message", "=", "$", "this", "->", "decorate", "(", "$", "message", ",", "$", "channel", ")", ";", "// Dispatch to all subscribers", "/** @var SubscriberInterface $subscriber */", "foreach", "(", "$", "subscribers", "as", "$", "subscriber", ")", "{", "// Decorate the message", "$", "message", "->", "decorate", "(", ")", ";", "// Dispatch to the subscriber", "$", "channel", "->", "dispatch", "(", "$", "subscriber", ",", "$", "message", ")", ";", "}", "}", "}" ]
Dispatch the event to its subscribers through the subscribed channels. @throws Exceptions\MessageNotSupportedException
[ "Dispatch", "the", "event", "to", "its", "subscribers", "through", "the", "subscribed", "channels", "." ]
a78cf051b379896b5a4d5df620988e37a0e632f5
https://github.com/PandaPlatform/framework/blob/a78cf051b379896b5a4d5df620988e37a0e632f5/src/Panda/Events/Event.php#L66-L88
13,822
AbuseIO/parser-common
src/Factory.php
Factory.getParsers
public static function getParsers() { $parsers = []; $parserClassList = ClassMapGenerator::createMap(base_path().'/vendor/abuseio'); /** @noinspection PhpUnusedParameterInspection */ $parserClassListFiltered = array_where( array_keys($parserClassList), function ($value, $key) { // Get all parsers, ignore all other packages. if (strpos($value, 'AbuseIO\Parsers\\') !== false) { return $value; } return false; } ); $parserList = array_map('class_basename', $parserClassListFiltered); foreach ($parserList as $parser) { if (!in_array($parser, ['Factory', 'Parser'])) { $parsers[] = $parser; } } return $parsers; }
php
public static function getParsers() { $parsers = []; $parserClassList = ClassMapGenerator::createMap(base_path().'/vendor/abuseio'); /** @noinspection PhpUnusedParameterInspection */ $parserClassListFiltered = array_where( array_keys($parserClassList), function ($value, $key) { // Get all parsers, ignore all other packages. if (strpos($value, 'AbuseIO\Parsers\\') !== false) { return $value; } return false; } ); $parserList = array_map('class_basename', $parserClassListFiltered); foreach ($parserList as $parser) { if (!in_array($parser, ['Factory', 'Parser'])) { $parsers[] = $parser; } } return $parsers; }
[ "public", "static", "function", "getParsers", "(", ")", "{", "$", "parsers", "=", "[", "]", ";", "$", "parserClassList", "=", "ClassMapGenerator", "::", "createMap", "(", "base_path", "(", ")", ".", "'/vendor/abuseio'", ")", ";", "/** @noinspection PhpUnusedParameterInspection */", "$", "parserClassListFiltered", "=", "array_where", "(", "array_keys", "(", "$", "parserClassList", ")", ",", "function", "(", "$", "value", ",", "$", "key", ")", "{", "// Get all parsers, ignore all other packages.", "if", "(", "strpos", "(", "$", "value", ",", "'AbuseIO\\Parsers\\\\'", ")", "!==", "false", ")", "{", "return", "$", "value", ";", "}", "return", "false", ";", "}", ")", ";", "$", "parserList", "=", "array_map", "(", "'class_basename'", ",", "$", "parserClassListFiltered", ")", ";", "foreach", "(", "$", "parserList", "as", "$", "parser", ")", "{", "if", "(", "!", "in_array", "(", "$", "parser", ",", "[", "'Factory'", ",", "'Parser'", "]", ")", ")", "{", "$", "parsers", "[", "]", "=", "$", "parser", ";", "}", "}", "return", "$", "parsers", ";", "}" ]
Get a list of installed AbuseIO parsers and return as an array @return array
[ "Get", "a", "list", "of", "installed", "AbuseIO", "parsers", "and", "return", "as", "an", "array" ]
a77707df73908a3e9770f5bd8504fe444b5576b8
https://github.com/AbuseIO/parser-common/blob/a77707df73908a3e9770f5bd8504fe444b5576b8/src/Factory.php#L26-L49
13,823
AbuseIO/parser-common
src/Factory.php
Factory.create
public static function create($parsedMail, $arfMail) { /** * Loop through the parser list and try to find a match by * validating the send or the body according to the parsers' * configuration. */ $parsers = Factory::getParsers(); foreach ($parsers as $parserName) { $parserClass = 'AbuseIO\\Parsers\\' . $parserName; // Parser is enabled, see if we can match it's sender_map or body_map if (config("parsers.{$parserName}.parser.enabled") === true) { // Check validity of the 'report_file' setting before we continue // If no report_file is used, continue w/o validation $report_file = config("parsers.{$parserName}.parser.report_file"); if ($report_file == null || (is_string($report_file) && isValidRegex($report_file)) ) { $isValidReport = true; } else { $isValidReport = false; Log::warning( 'AbuseIO\Parsers\Factory: ' . "The parser {$parserName} has an invalid value for 'report_file' (not a regex)." ); break; } // Check the sender address foreach (config("parsers.{$parserName}.parser.sender_map") as $senderMap) { if (isValidRegex($senderMap)) { if (preg_match($senderMap, $parsedMail->getHeader('from')) && $isValidReport) { return new $parserClass($parsedMail, $arfMail); } } else { Log::warning( 'AbuseIO\Parsers\Factory: ' . "The parser {$parserName} has an invalid value for 'sender_map' (not a regex)." ); } } // If no valid sender is found, check the body foreach (config("parsers.{$parserName}.parser.body_map") as $bodyMap) { if (isValidRegex($bodyMap)) { if (preg_match($bodyMap, $parsedMail->getMessageBody()) && $isValidReport) { return new $parserClass($parsedMail, $arfMail); } if ($arfMail !== false) { foreach ($arfMail as $mailPart) { if (preg_match($bodyMap, $mailPart)) { return new $parserClass($parsedMail, $arfMail); } } } } else { Log::warning( 'AbuseIO\Parsers\Factory: ' . "The parser {$parserName} has an invalid value for 'body_map' (not a regex)." ); } } } else { Log::info( 'AbuseIO\Parsers\Factory: ' . "The parser {$parserName} has been disabled and will not be used for this message." ); } } // No valid parsers found return false; }
php
public static function create($parsedMail, $arfMail) { /** * Loop through the parser list and try to find a match by * validating the send or the body according to the parsers' * configuration. */ $parsers = Factory::getParsers(); foreach ($parsers as $parserName) { $parserClass = 'AbuseIO\\Parsers\\' . $parserName; // Parser is enabled, see if we can match it's sender_map or body_map if (config("parsers.{$parserName}.parser.enabled") === true) { // Check validity of the 'report_file' setting before we continue // If no report_file is used, continue w/o validation $report_file = config("parsers.{$parserName}.parser.report_file"); if ($report_file == null || (is_string($report_file) && isValidRegex($report_file)) ) { $isValidReport = true; } else { $isValidReport = false; Log::warning( 'AbuseIO\Parsers\Factory: ' . "The parser {$parserName} has an invalid value for 'report_file' (not a regex)." ); break; } // Check the sender address foreach (config("parsers.{$parserName}.parser.sender_map") as $senderMap) { if (isValidRegex($senderMap)) { if (preg_match($senderMap, $parsedMail->getHeader('from')) && $isValidReport) { return new $parserClass($parsedMail, $arfMail); } } else { Log::warning( 'AbuseIO\Parsers\Factory: ' . "The parser {$parserName} has an invalid value for 'sender_map' (not a regex)." ); } } // If no valid sender is found, check the body foreach (config("parsers.{$parserName}.parser.body_map") as $bodyMap) { if (isValidRegex($bodyMap)) { if (preg_match($bodyMap, $parsedMail->getMessageBody()) && $isValidReport) { return new $parserClass($parsedMail, $arfMail); } if ($arfMail !== false) { foreach ($arfMail as $mailPart) { if (preg_match($bodyMap, $mailPart)) { return new $parserClass($parsedMail, $arfMail); } } } } else { Log::warning( 'AbuseIO\Parsers\Factory: ' . "The parser {$parserName} has an invalid value for 'body_map' (not a regex)." ); } } } else { Log::info( 'AbuseIO\Parsers\Factory: ' . "The parser {$parserName} has been disabled and will not be used for this message." ); } } // No valid parsers found return false; }
[ "public", "static", "function", "create", "(", "$", "parsedMail", ",", "$", "arfMail", ")", "{", "/**\n * Loop through the parser list and try to find a match by\n * validating the send or the body according to the parsers'\n * configuration.\n */", "$", "parsers", "=", "Factory", "::", "getParsers", "(", ")", ";", "foreach", "(", "$", "parsers", "as", "$", "parserName", ")", "{", "$", "parserClass", "=", "'AbuseIO\\\\Parsers\\\\'", ".", "$", "parserName", ";", "// Parser is enabled, see if we can match it's sender_map or body_map", "if", "(", "config", "(", "\"parsers.{$parserName}.parser.enabled\"", ")", "===", "true", ")", "{", "// Check validity of the 'report_file' setting before we continue", "// If no report_file is used, continue w/o validation", "$", "report_file", "=", "config", "(", "\"parsers.{$parserName}.parser.report_file\"", ")", ";", "if", "(", "$", "report_file", "==", "null", "||", "(", "is_string", "(", "$", "report_file", ")", "&&", "isValidRegex", "(", "$", "report_file", ")", ")", ")", "{", "$", "isValidReport", "=", "true", ";", "}", "else", "{", "$", "isValidReport", "=", "false", ";", "Log", "::", "warning", "(", "'AbuseIO\\Parsers\\Factory: '", ".", "\"The parser {$parserName} has an invalid value for 'report_file' (not a regex).\"", ")", ";", "break", ";", "}", "// Check the sender address", "foreach", "(", "config", "(", "\"parsers.{$parserName}.parser.sender_map\"", ")", "as", "$", "senderMap", ")", "{", "if", "(", "isValidRegex", "(", "$", "senderMap", ")", ")", "{", "if", "(", "preg_match", "(", "$", "senderMap", ",", "$", "parsedMail", "->", "getHeader", "(", "'from'", ")", ")", "&&", "$", "isValidReport", ")", "{", "return", "new", "$", "parserClass", "(", "$", "parsedMail", ",", "$", "arfMail", ")", ";", "}", "}", "else", "{", "Log", "::", "warning", "(", "'AbuseIO\\Parsers\\Factory: '", ".", "\"The parser {$parserName} has an invalid value for 'sender_map' (not a regex).\"", ")", ";", "}", "}", "// If no valid sender is found, check the body", "foreach", "(", "config", "(", "\"parsers.{$parserName}.parser.body_map\"", ")", "as", "$", "bodyMap", ")", "{", "if", "(", "isValidRegex", "(", "$", "bodyMap", ")", ")", "{", "if", "(", "preg_match", "(", "$", "bodyMap", ",", "$", "parsedMail", "->", "getMessageBody", "(", ")", ")", "&&", "$", "isValidReport", ")", "{", "return", "new", "$", "parserClass", "(", "$", "parsedMail", ",", "$", "arfMail", ")", ";", "}", "if", "(", "$", "arfMail", "!==", "false", ")", "{", "foreach", "(", "$", "arfMail", "as", "$", "mailPart", ")", "{", "if", "(", "preg_match", "(", "$", "bodyMap", ",", "$", "mailPart", ")", ")", "{", "return", "new", "$", "parserClass", "(", "$", "parsedMail", ",", "$", "arfMail", ")", ";", "}", "}", "}", "}", "else", "{", "Log", "::", "warning", "(", "'AbuseIO\\Parsers\\Factory: '", ".", "\"The parser {$parserName} has an invalid value for 'body_map' (not a regex).\"", ")", ";", "}", "}", "}", "else", "{", "Log", "::", "info", "(", "'AbuseIO\\Parsers\\Factory: '", ".", "\"The parser {$parserName} has been disabled and will not be used for this message.\"", ")", ";", "}", "}", "// No valid parsers found", "return", "false", ";", "}" ]
Create and return a Parser class and it's configuration @param \PhpMimeMailParser\Parser $parsedMail @param array $arfMail @return object parser
[ "Create", "and", "return", "a", "Parser", "class", "and", "it", "s", "configuration" ]
a77707df73908a3e9770f5bd8504fe444b5576b8
https://github.com/AbuseIO/parser-common/blob/a77707df73908a3e9770f5bd8504fe444b5576b8/src/Factory.php#L57-L135
13,824
dphn/ScContent
src/ScContent/Service/Installation/LayoutService.php
LayoutService.getRegions
public function getRegions($themeName) { $translator = $this->getTranslator(); $options = $this->getModuleOptions(); $theme = $options->getThemeByName($themeName); $map = []; if (! isset($theme['frontend']['regions']) || ! is_array($theme['frontend']['regions']) || empty($theme['frontend']['regions']) ) { return $map; } $regions = $theme['frontend']['regions']; $widgets = array_keys($options->getWidgets()); foreach ($regions as $regionName => $regionOptions) { if (isset($regionOptions['contains']) && is_array($regionOptions['contains']) ) { $container = $regionOptions['contains']; foreach ($container as $widget) { $map[$widget] = $regionName; } } } foreach ($widgets as $widget) { if (! array_key_exists($widget, $map)) { $map[$widget] = 'none'; } } return $map; }
php
public function getRegions($themeName) { $translator = $this->getTranslator(); $options = $this->getModuleOptions(); $theme = $options->getThemeByName($themeName); $map = []; if (! isset($theme['frontend']['regions']) || ! is_array($theme['frontend']['regions']) || empty($theme['frontend']['regions']) ) { return $map; } $regions = $theme['frontend']['regions']; $widgets = array_keys($options->getWidgets()); foreach ($regions as $regionName => $regionOptions) { if (isset($regionOptions['contains']) && is_array($regionOptions['contains']) ) { $container = $regionOptions['contains']; foreach ($container as $widget) { $map[$widget] = $regionName; } } } foreach ($widgets as $widget) { if (! array_key_exists($widget, $map)) { $map[$widget] = 'none'; } } return $map; }
[ "public", "function", "getRegions", "(", "$", "themeName", ")", "{", "$", "translator", "=", "$", "this", "->", "getTranslator", "(", ")", ";", "$", "options", "=", "$", "this", "->", "getModuleOptions", "(", ")", ";", "$", "theme", "=", "$", "options", "->", "getThemeByName", "(", "$", "themeName", ")", ";", "$", "map", "=", "[", "]", ";", "if", "(", "!", "isset", "(", "$", "theme", "[", "'frontend'", "]", "[", "'regions'", "]", ")", "||", "!", "is_array", "(", "$", "theme", "[", "'frontend'", "]", "[", "'regions'", "]", ")", "||", "empty", "(", "$", "theme", "[", "'frontend'", "]", "[", "'regions'", "]", ")", ")", "{", "return", "$", "map", ";", "}", "$", "regions", "=", "$", "theme", "[", "'frontend'", "]", "[", "'regions'", "]", ";", "$", "widgets", "=", "array_keys", "(", "$", "options", "->", "getWidgets", "(", ")", ")", ";", "foreach", "(", "$", "regions", "as", "$", "regionName", "=>", "$", "regionOptions", ")", "{", "if", "(", "isset", "(", "$", "regionOptions", "[", "'contains'", "]", ")", "&&", "is_array", "(", "$", "regionOptions", "[", "'contains'", "]", ")", ")", "{", "$", "container", "=", "$", "regionOptions", "[", "'contains'", "]", ";", "foreach", "(", "$", "container", "as", "$", "widget", ")", "{", "$", "map", "[", "$", "widget", "]", "=", "$", "regionName", ";", "}", "}", "}", "foreach", "(", "$", "widgets", "as", "$", "widget", ")", "{", "if", "(", "!", "array_key_exists", "(", "$", "widget", ",", "$", "map", ")", ")", "{", "$", "map", "[", "$", "widget", "]", "=", "'none'", ";", "}", "}", "return", "$", "map", ";", "}" ]
Get the existing regions from the module options. @param string $themeName @return array Regions <code>string[string]</code> <code>(string) region name [(string) widget name]</code>
[ "Get", "the", "existing", "regions", "from", "the", "module", "options", "." ]
9dd5732490c45fd788b96cedf7b3c7adfacb30d2
https://github.com/dphn/ScContent/blob/9dd5732490c45fd788b96cedf7b3c7adfacb30d2/src/ScContent/Service/Installation/LayoutService.php#L198-L230
13,825
DevGroup-ru/yii2-data-structure-tools
src/propertyStorage/AbstractPropertyStorage.php
AbstractPropertyStorage.getApplicablePropertyModelClassNames
protected static function getApplicablePropertyModelClassNames($id) { if (isset(static::$applicablePropertyModelClassNames[$id]) === false) { $subQuery = PropertyPropertyGroup::find() ->from(PropertyPropertyGroup::tableName() . ' ppg') ->select('pg.applicable_property_model_id') ->join('INNER JOIN', PropertyGroup::tableName() . ' pg', 'pg.id = ppg.property_group_id') ->where(['ppg.property_id' => $id]) ->createCommand()->getRawSql(); static::$applicablePropertyModelClassNames[$id] = (new Query()) ->select('class_name') ->from(ApplicablePropertyModels::tableName()) ->where('id IN (' . $subQuery . ')')->column(); } return static::$applicablePropertyModelClassNames[$id]; }
php
protected static function getApplicablePropertyModelClassNames($id) { if (isset(static::$applicablePropertyModelClassNames[$id]) === false) { $subQuery = PropertyPropertyGroup::find() ->from(PropertyPropertyGroup::tableName() . ' ppg') ->select('pg.applicable_property_model_id') ->join('INNER JOIN', PropertyGroup::tableName() . ' pg', 'pg.id = ppg.property_group_id') ->where(['ppg.property_id' => $id]) ->createCommand()->getRawSql(); static::$applicablePropertyModelClassNames[$id] = (new Query()) ->select('class_name') ->from(ApplicablePropertyModels::tableName()) ->where('id IN (' . $subQuery . ')')->column(); } return static::$applicablePropertyModelClassNames[$id]; }
[ "protected", "static", "function", "getApplicablePropertyModelClassNames", "(", "$", "id", ")", "{", "if", "(", "isset", "(", "static", "::", "$", "applicablePropertyModelClassNames", "[", "$", "id", "]", ")", "===", "false", ")", "{", "$", "subQuery", "=", "PropertyPropertyGroup", "::", "find", "(", ")", "->", "from", "(", "PropertyPropertyGroup", "::", "tableName", "(", ")", ".", "' ppg'", ")", "->", "select", "(", "'pg.applicable_property_model_id'", ")", "->", "join", "(", "'INNER JOIN'", ",", "PropertyGroup", "::", "tableName", "(", ")", ".", "' pg'", ",", "'pg.id = ppg.property_group_id'", ")", "->", "where", "(", "[", "'ppg.property_id'", "=>", "$", "id", "]", ")", "->", "createCommand", "(", ")", "->", "getRawSql", "(", ")", ";", "static", "::", "$", "applicablePropertyModelClassNames", "[", "$", "id", "]", "=", "(", "new", "Query", "(", ")", ")", "->", "select", "(", "'class_name'", ")", "->", "from", "(", "ApplicablePropertyModels", "::", "tableName", "(", ")", ")", "->", "where", "(", "'id IN ('", ".", "$", "subQuery", ".", "')'", ")", "->", "column", "(", ")", ";", "}", "return", "static", "::", "$", "applicablePropertyModelClassNames", "[", "$", "id", "]", ";", "}" ]
Get applicable property model class names by property id. @param int $id @return ActiveRecord[] | HasProperties[] | PropertiesTrait[]
[ "Get", "applicable", "property", "model", "class", "names", "by", "property", "id", "." ]
a5b24d7c0b24d4b0d58cacd91ec7fd876e979097
https://github.com/DevGroup-ru/yii2-data-structure-tools/blob/a5b24d7c0b24d4b0d58cacd91ec7fd876e979097/src/propertyStorage/AbstractPropertyStorage.php#L48-L63
13,826
phastlight/phastlight
src/Phastlight/System.php
System.import
public function import($name) { $object = null; if (!isset($this->modules[$name])) { if (isset($this->moduleMap[$name])) { $object_class = $this->moduleMap[$name]; $object = new $object_class(); $object->setSystem($this); $object->setEventLoop($this->eventLoop); $this->modules[$name] = $object; } } else{ $object = $this->modules[$name]; } return $object; }
php
public function import($name) { $object = null; if (!isset($this->modules[$name])) { if (isset($this->moduleMap[$name])) { $object_class = $this->moduleMap[$name]; $object = new $object_class(); $object->setSystem($this); $object->setEventLoop($this->eventLoop); $this->modules[$name] = $object; } } else{ $object = $this->modules[$name]; } return $object; }
[ "public", "function", "import", "(", "$", "name", ")", "{", "$", "object", "=", "null", ";", "if", "(", "!", "isset", "(", "$", "this", "->", "modules", "[", "$", "name", "]", ")", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "moduleMap", "[", "$", "name", "]", ")", ")", "{", "$", "object_class", "=", "$", "this", "->", "moduleMap", "[", "$", "name", "]", ";", "$", "object", "=", "new", "$", "object_class", "(", ")", ";", "$", "object", "->", "setSystem", "(", "$", "this", ")", ";", "$", "object", "->", "setEventLoop", "(", "$", "this", "->", "eventLoop", ")", ";", "$", "this", "->", "modules", "[", "$", "name", "]", "=", "$", "object", ";", "}", "}", "else", "{", "$", "object", "=", "$", "this", "->", "modules", "[", "$", "name", "]", ";", "}", "return", "$", "object", ";", "}" ]
import a module based on name, similar to node.js's require
[ "import", "a", "module", "based", "on", "name", "similar", "to", "node", ".", "js", "s", "require" ]
3fef01898fe56a0185511b56ec45ec44a75a74d9
https://github.com/phastlight/phastlight/blob/3fef01898fe56a0185511b56ec45ec44a75a74d9/src/Phastlight/System.php#L79-L97
13,827
PandaPlatform/framework
src/Panda/Localization/Helpers/LocaleHelper.php
LocaleHelper.getLocaleFallbackList
public static function getLocaleFallbackList($locale, $fallbackLocale = '') { // Check arguments if (empty($locale)) { throw new InvalidArgumentException(__METHOD__ . ': The given locale is empty'); } // Create a priority fallback list to check for different locale. // This list includes also generic language codes separated from locale in case // there is generic language fallback. // If the base language for current and fallback locale is the same, then the language code // goes in the end as final fallback. $fallbackList = []; // Get fallback for normal locale $fallbackList = array_merge($fallbackList, self::getFallbackList($locale)); // Add fallback locale, if different if ($fallbackLocale != $locale) { $fallbackList = array_merge($fallbackList, self::getFallbackList($fallbackLocale)); } return $fallbackList; }
php
public static function getLocaleFallbackList($locale, $fallbackLocale = '') { // Check arguments if (empty($locale)) { throw new InvalidArgumentException(__METHOD__ . ': The given locale is empty'); } // Create a priority fallback list to check for different locale. // This list includes also generic language codes separated from locale in case // there is generic language fallback. // If the base language for current and fallback locale is the same, then the language code // goes in the end as final fallback. $fallbackList = []; // Get fallback for normal locale $fallbackList = array_merge($fallbackList, self::getFallbackList($locale)); // Add fallback locale, if different if ($fallbackLocale != $locale) { $fallbackList = array_merge($fallbackList, self::getFallbackList($fallbackLocale)); } return $fallbackList; }
[ "public", "static", "function", "getLocaleFallbackList", "(", "$", "locale", ",", "$", "fallbackLocale", "=", "''", ")", "{", "// Check arguments", "if", "(", "empty", "(", "$", "locale", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "__METHOD__", ".", "': The given locale is empty'", ")", ";", "}", "// Create a priority fallback list to check for different locale.", "// This list includes also generic language codes separated from locale in case", "// there is generic language fallback.", "// If the base language for current and fallback locale is the same, then the language code", "// goes in the end as final fallback.", "$", "fallbackList", "=", "[", "]", ";", "// Get fallback for normal locale", "$", "fallbackList", "=", "array_merge", "(", "$", "fallbackList", ",", "self", "::", "getFallbackList", "(", "$", "locale", ")", ")", ";", "// Add fallback locale, if different", "if", "(", "$", "fallbackLocale", "!=", "$", "locale", ")", "{", "$", "fallbackList", "=", "array_merge", "(", "$", "fallbackList", ",", "self", "::", "getFallbackList", "(", "$", "fallbackLocale", ")", ")", ";", "}", "return", "$", "fallbackList", ";", "}" ]
Get a locale fallback list to check while translating. @param string $locale @param string $fallbackLocale @return array @throws InvalidArgumentException
[ "Get", "a", "locale", "fallback", "list", "to", "check", "while", "translating", "." ]
a78cf051b379896b5a4d5df620988e37a0e632f5
https://github.com/PandaPlatform/framework/blob/a78cf051b379896b5a4d5df620988e37a0e632f5/src/Panda/Localization/Helpers/LocaleHelper.php#L32-L55
13,828
nyeholt/silverstripe-simplewiki
thirdparty/htmlpurifier-4.0.0-lite/library/HTMLPurifier/Printer/HTMLDefinition.php
HTMLPurifier_Printer_HTMLDefinition.renderChildren
protected function renderChildren($def) { $context = new HTMLPurifier_Context(); $ret = ''; $ret .= $this->start('tr'); $elements = array(); $attr = array(); if (isset($def->elements)) { if ($def->type == 'strictblockquote') { $def->validateChildren(array(), $this->config, $context); } $elements = $def->elements; } if ($def->type == 'chameleon') { $attr['rowspan'] = 2; } elseif ($def->type == 'empty') { $elements = array(); } elseif ($def->type == 'table') { $elements = array_flip(array('col', 'caption', 'colgroup', 'thead', 'tfoot', 'tbody', 'tr')); } $ret .= $this->element('th', 'Allowed children', $attr); if ($def->type == 'chameleon') { $ret .= $this->element('td', '<em>Block</em>: ' . $this->escape($this->listifyTagLookup($def->block->elements)),0,0); $ret .= $this->end('tr'); $ret .= $this->start('tr'); $ret .= $this->element('td', '<em>Inline</em>: ' . $this->escape($this->listifyTagLookup($def->inline->elements)),0,0); } elseif ($def->type == 'custom') { $ret .= $this->element('td', '<em>'.ucfirst($def->type).'</em>: ' . $def->dtd_regex); } else { $ret .= $this->element('td', '<em>'.ucfirst($def->type).'</em>: ' . $this->escape($this->listifyTagLookup($elements)),0,0); } $ret .= $this->end('tr'); return $ret; }
php
protected function renderChildren($def) { $context = new HTMLPurifier_Context(); $ret = ''; $ret .= $this->start('tr'); $elements = array(); $attr = array(); if (isset($def->elements)) { if ($def->type == 'strictblockquote') { $def->validateChildren(array(), $this->config, $context); } $elements = $def->elements; } if ($def->type == 'chameleon') { $attr['rowspan'] = 2; } elseif ($def->type == 'empty') { $elements = array(); } elseif ($def->type == 'table') { $elements = array_flip(array('col', 'caption', 'colgroup', 'thead', 'tfoot', 'tbody', 'tr')); } $ret .= $this->element('th', 'Allowed children', $attr); if ($def->type == 'chameleon') { $ret .= $this->element('td', '<em>Block</em>: ' . $this->escape($this->listifyTagLookup($def->block->elements)),0,0); $ret .= $this->end('tr'); $ret .= $this->start('tr'); $ret .= $this->element('td', '<em>Inline</em>: ' . $this->escape($this->listifyTagLookup($def->inline->elements)),0,0); } elseif ($def->type == 'custom') { $ret .= $this->element('td', '<em>'.ucfirst($def->type).'</em>: ' . $def->dtd_regex); } else { $ret .= $this->element('td', '<em>'.ucfirst($def->type).'</em>: ' . $this->escape($this->listifyTagLookup($elements)),0,0); } $ret .= $this->end('tr'); return $ret; }
[ "protected", "function", "renderChildren", "(", "$", "def", ")", "{", "$", "context", "=", "new", "HTMLPurifier_Context", "(", ")", ";", "$", "ret", "=", "''", ";", "$", "ret", ".=", "$", "this", "->", "start", "(", "'tr'", ")", ";", "$", "elements", "=", "array", "(", ")", ";", "$", "attr", "=", "array", "(", ")", ";", "if", "(", "isset", "(", "$", "def", "->", "elements", ")", ")", "{", "if", "(", "$", "def", "->", "type", "==", "'strictblockquote'", ")", "{", "$", "def", "->", "validateChildren", "(", "array", "(", ")", ",", "$", "this", "->", "config", ",", "$", "context", ")", ";", "}", "$", "elements", "=", "$", "def", "->", "elements", ";", "}", "if", "(", "$", "def", "->", "type", "==", "'chameleon'", ")", "{", "$", "attr", "[", "'rowspan'", "]", "=", "2", ";", "}", "elseif", "(", "$", "def", "->", "type", "==", "'empty'", ")", "{", "$", "elements", "=", "array", "(", ")", ";", "}", "elseif", "(", "$", "def", "->", "type", "==", "'table'", ")", "{", "$", "elements", "=", "array_flip", "(", "array", "(", "'col'", ",", "'caption'", ",", "'colgroup'", ",", "'thead'", ",", "'tfoot'", ",", "'tbody'", ",", "'tr'", ")", ")", ";", "}", "$", "ret", ".=", "$", "this", "->", "element", "(", "'th'", ",", "'Allowed children'", ",", "$", "attr", ")", ";", "if", "(", "$", "def", "->", "type", "==", "'chameleon'", ")", "{", "$", "ret", ".=", "$", "this", "->", "element", "(", "'td'", ",", "'<em>Block</em>: '", ".", "$", "this", "->", "escape", "(", "$", "this", "->", "listifyTagLookup", "(", "$", "def", "->", "block", "->", "elements", ")", ")", ",", "0", ",", "0", ")", ";", "$", "ret", ".=", "$", "this", "->", "end", "(", "'tr'", ")", ";", "$", "ret", ".=", "$", "this", "->", "start", "(", "'tr'", ")", ";", "$", "ret", ".=", "$", "this", "->", "element", "(", "'td'", ",", "'<em>Inline</em>: '", ".", "$", "this", "->", "escape", "(", "$", "this", "->", "listifyTagLookup", "(", "$", "def", "->", "inline", "->", "elements", ")", ")", ",", "0", ",", "0", ")", ";", "}", "elseif", "(", "$", "def", "->", "type", "==", "'custom'", ")", "{", "$", "ret", ".=", "$", "this", "->", "element", "(", "'td'", ",", "'<em>'", ".", "ucfirst", "(", "$", "def", "->", "type", ")", ".", "'</em>: '", ".", "$", "def", "->", "dtd_regex", ")", ";", "}", "else", "{", "$", "ret", ".=", "$", "this", "->", "element", "(", "'td'", ",", "'<em>'", ".", "ucfirst", "(", "$", "def", "->", "type", ")", ".", "'</em>: '", ".", "$", "this", "->", "escape", "(", "$", "this", "->", "listifyTagLookup", "(", "$", "elements", ")", ")", ",", "0", ",", "0", ")", ";", "}", "$", "ret", ".=", "$", "this", "->", "end", "(", "'tr'", ")", ";", "return", "$", "ret", ";", "}" ]
Renders a row describing the allowed children of an element @param $def HTMLPurifier_ChildDef of pertinent element
[ "Renders", "a", "row", "describing", "the", "allowed", "children", "of", "an", "element" ]
ecffed0d75be1454901e1cb24633472b8f67c967
https://github.com/nyeholt/silverstripe-simplewiki/blob/ecffed0d75be1454901e1cb24633472b8f67c967/thirdparty/htmlpurifier-4.0.0-lite/library/HTMLPurifier/Printer/HTMLDefinition.php#L170-L215
13,829
nyeholt/silverstripe-simplewiki
thirdparty/htmlpurifier-4.0.0-lite/library/HTMLPurifier/Printer/HTMLDefinition.php
HTMLPurifier_Printer_HTMLDefinition.listifyTagLookup
protected function listifyTagLookup($array) { ksort($array); $list = array(); foreach ($array as $name => $discard) { if ($name !== '#PCDATA' && !isset($this->def->info[$name])) continue; $list[] = $name; } return $this->listify($list); }
php
protected function listifyTagLookup($array) { ksort($array); $list = array(); foreach ($array as $name => $discard) { if ($name !== '#PCDATA' && !isset($this->def->info[$name])) continue; $list[] = $name; } return $this->listify($list); }
[ "protected", "function", "listifyTagLookup", "(", "$", "array", ")", "{", "ksort", "(", "$", "array", ")", ";", "$", "list", "=", "array", "(", ")", ";", "foreach", "(", "$", "array", "as", "$", "name", "=>", "$", "discard", ")", "{", "if", "(", "$", "name", "!==", "'#PCDATA'", "&&", "!", "isset", "(", "$", "this", "->", "def", "->", "info", "[", "$", "name", "]", ")", ")", "continue", ";", "$", "list", "[", "]", "=", "$", "name", ";", "}", "return", "$", "this", "->", "listify", "(", "$", "list", ")", ";", "}" ]
Listifies a tag lookup table. @param $array Tag lookup array in form of array('tagname' => true)
[ "Listifies", "a", "tag", "lookup", "table", "." ]
ecffed0d75be1454901e1cb24633472b8f67c967
https://github.com/nyeholt/silverstripe-simplewiki/blob/ecffed0d75be1454901e1cb24633472b8f67c967/thirdparty/htmlpurifier-4.0.0-lite/library/HTMLPurifier/Printer/HTMLDefinition.php#L221-L229
13,830
nyeholt/silverstripe-simplewiki
thirdparty/htmlpurifier-4.0.0-lite/library/HTMLPurifier/Printer/HTMLDefinition.php
HTMLPurifier_Printer_HTMLDefinition.listifyAttr
protected function listifyAttr($array) { ksort($array); $list = array(); foreach ($array as $name => $obj) { if ($obj === false) continue; $list[] = "$name&nbsp;=&nbsp;<i>" . $this->getClass($obj, 'AttrDef_') . '</i>'; } return $this->listify($list); }
php
protected function listifyAttr($array) { ksort($array); $list = array(); foreach ($array as $name => $obj) { if ($obj === false) continue; $list[] = "$name&nbsp;=&nbsp;<i>" . $this->getClass($obj, 'AttrDef_') . '</i>'; } return $this->listify($list); }
[ "protected", "function", "listifyAttr", "(", "$", "array", ")", "{", "ksort", "(", "$", "array", ")", ";", "$", "list", "=", "array", "(", ")", ";", "foreach", "(", "$", "array", "as", "$", "name", "=>", "$", "obj", ")", "{", "if", "(", "$", "obj", "===", "false", ")", "continue", ";", "$", "list", "[", "]", "=", "\"$name&nbsp;=&nbsp;<i>\"", ".", "$", "this", "->", "getClass", "(", "$", "obj", ",", "'AttrDef_'", ")", ".", "'</i>'", ";", "}", "return", "$", "this", "->", "listify", "(", "$", "list", ")", ";", "}" ]
Listifies a hash of attributes to AttrDef classes @param $array Array hash in form of array('attrname' => HTMLPurifier_AttrDef)
[ "Listifies", "a", "hash", "of", "attributes", "to", "AttrDef", "classes" ]
ecffed0d75be1454901e1cb24633472b8f67c967
https://github.com/nyeholt/silverstripe-simplewiki/blob/ecffed0d75be1454901e1cb24633472b8f67c967/thirdparty/htmlpurifier-4.0.0-lite/library/HTMLPurifier/Printer/HTMLDefinition.php#L249-L257
13,831
Webiny/AnalyticsDb
src/Webiny/AnalyticsDb/LogEntry.php
LogEntry.addDimension
public function addDimension($name, $value, $increment = 1) { $dimension = new LogDimension($name, $value); $dimension->setIncrement($increment); $this->dimensions[] = $dimension; return $this; }
php
public function addDimension($name, $value, $increment = 1) { $dimension = new LogDimension($name, $value); $dimension->setIncrement($increment); $this->dimensions[] = $dimension; return $this; }
[ "public", "function", "addDimension", "(", "$", "name", ",", "$", "value", ",", "$", "increment", "=", "1", ")", "{", "$", "dimension", "=", "new", "LogDimension", "(", "$", "name", ",", "$", "value", ")", ";", "$", "dimension", "->", "setIncrement", "(", "$", "increment", ")", ";", "$", "this", "->", "dimensions", "[", "]", "=", "$", "dimension", ";", "return", "$", "this", ";", "}" ]
Add a dimension to the entry. @param string $name @param string $value @param int $increment @return $this
[ "Add", "a", "dimension", "to", "the", "entry", "." ]
e0b1e920643cd63071406520767243736004052e
https://github.com/Webiny/AnalyticsDb/blob/e0b1e920643cd63071406520767243736004052e/src/Webiny/AnalyticsDb/LogEntry.php#L118-L126
13,832
DevGroup-ru/yii2-data-structure-tools
src/searchOld/elastic/helpers/IndexHelper.php
IndexHelper.classToIndex
public static function classToIndex($className) { if (false === is_string($className)) { return ''; } $modelClass = strtolower($className); return StringHelper::basename($modelClass); }
php
public static function classToIndex($className) { if (false === is_string($className)) { return ''; } $modelClass = strtolower($className); return StringHelper::basename($modelClass); }
[ "public", "static", "function", "classToIndex", "(", "$", "className", ")", "{", "if", "(", "false", "===", "is_string", "(", "$", "className", ")", ")", "{", "return", "''", ";", "}", "$", "modelClass", "=", "strtolower", "(", "$", "className", ")", ";", "return", "StringHelper", "::", "basename", "(", "$", "modelClass", ")", ";", "}" ]
Builds index name according to given model class @param string $className @return string
[ "Builds", "index", "name", "according", "to", "given", "model", "class" ]
a5b24d7c0b24d4b0d58cacd91ec7fd876e979097
https://github.com/DevGroup-ru/yii2-data-structure-tools/blob/a5b24d7c0b24d4b0d58cacd91ec7fd876e979097/src/searchOld/elastic/helpers/IndexHelper.php#L23-L30
13,833
DevGroup-ru/yii2-data-structure-tools
src/searchOld/elastic/helpers/IndexHelper.php
IndexHelper.storageClassToType
public static function storageClassToType($storageClass) { if (false === is_string($storageClass)) { return ''; } $name = StringHelper::basename($storageClass); return Inflector::camel2id($name, '_'); }
php
public static function storageClassToType($storageClass) { if (false === is_string($storageClass)) { return ''; } $name = StringHelper::basename($storageClass); return Inflector::camel2id($name, '_'); }
[ "public", "static", "function", "storageClassToType", "(", "$", "storageClass", ")", "{", "if", "(", "false", "===", "is_string", "(", "$", "storageClass", ")", ")", "{", "return", "''", ";", "}", "$", "name", "=", "StringHelper", "::", "basename", "(", "$", "storageClass", ")", ";", "return", "Inflector", "::", "camel2id", "(", "$", "name", ",", "'_'", ")", ";", "}" ]
Builds index type according to given property storage class name @param $storageClass @return string
[ "Builds", "index", "type", "according", "to", "given", "property", "storage", "class", "name" ]
a5b24d7c0b24d4b0d58cacd91ec7fd876e979097
https://github.com/DevGroup-ru/yii2-data-structure-tools/blob/a5b24d7c0b24d4b0d58cacd91ec7fd876e979097/src/searchOld/elastic/helpers/IndexHelper.php#L38-L45
13,834
DevGroup-ru/yii2-data-structure-tools
src/searchOld/elastic/helpers/IndexHelper.php
IndexHelper.primaryKeysByCondition
public static function primaryKeysByCondition($client, $condition) { $primaryKeys = []; $count = $client->count($condition); $count = empty($count['count']) ? 10 : $count['count']; $condition['size'] = $count; $condition['_source'] = true; $res = $client->search($condition); if (false === empty($res['hits']['hits'])) { foreach ($res['hits']['hits'] as $doc) { if (false === isset($primaryKeys[$doc['_id']])) { $primaryKeys[$doc['_id']] = [$doc['_type']]; } else { if (false === in_array($doc['_type'], $primaryKeys[$doc['_id']])) { $primaryKeys[$doc['_id']][] = $doc['_type']; } } } } return $primaryKeys; }
php
public static function primaryKeysByCondition($client, $condition) { $primaryKeys = []; $count = $client->count($condition); $count = empty($count['count']) ? 10 : $count['count']; $condition['size'] = $count; $condition['_source'] = true; $res = $client->search($condition); if (false === empty($res['hits']['hits'])) { foreach ($res['hits']['hits'] as $doc) { if (false === isset($primaryKeys[$doc['_id']])) { $primaryKeys[$doc['_id']] = [$doc['_type']]; } else { if (false === in_array($doc['_type'], $primaryKeys[$doc['_id']])) { $primaryKeys[$doc['_id']][] = $doc['_type']; } } } } return $primaryKeys; }
[ "public", "static", "function", "primaryKeysByCondition", "(", "$", "client", ",", "$", "condition", ")", "{", "$", "primaryKeys", "=", "[", "]", ";", "$", "count", "=", "$", "client", "->", "count", "(", "$", "condition", ")", ";", "$", "count", "=", "empty", "(", "$", "count", "[", "'count'", "]", ")", "?", "10", ":", "$", "count", "[", "'count'", "]", ";", "$", "condition", "[", "'size'", "]", "=", "$", "count", ";", "$", "condition", "[", "'_source'", "]", "=", "true", ";", "$", "res", "=", "$", "client", "->", "search", "(", "$", "condition", ")", ";", "if", "(", "false", "===", "empty", "(", "$", "res", "[", "'hits'", "]", "[", "'hits'", "]", ")", ")", "{", "foreach", "(", "$", "res", "[", "'hits'", "]", "[", "'hits'", "]", "as", "$", "doc", ")", "{", "if", "(", "false", "===", "isset", "(", "$", "primaryKeys", "[", "$", "doc", "[", "'_id'", "]", "]", ")", ")", "{", "$", "primaryKeys", "[", "$", "doc", "[", "'_id'", "]", "]", "=", "[", "$", "doc", "[", "'_type'", "]", "]", ";", "}", "else", "{", "if", "(", "false", "===", "in_array", "(", "$", "doc", "[", "'_type'", "]", ",", "$", "primaryKeys", "[", "$", "doc", "[", "'_id'", "]", "]", ")", ")", "{", "$", "primaryKeys", "[", "$", "doc", "[", "'_id'", "]", "]", "[", "]", "=", "$", "doc", "[", "'_type'", "]", ";", "}", "}", "}", "}", "return", "$", "primaryKeys", ";", "}" ]
Performs fast scan for docs ids in elasticsearch indices @param Client $client @param array $condition query condition to find docs @return array
[ "Performs", "fast", "scan", "for", "docs", "ids", "in", "elasticsearch", "indices" ]
a5b24d7c0b24d4b0d58cacd91ec7fd876e979097
https://github.com/DevGroup-ru/yii2-data-structure-tools/blob/a5b24d7c0b24d4b0d58cacd91ec7fd876e979097/src/searchOld/elastic/helpers/IndexHelper.php#L54-L74
13,835
MissAllSunday/Ohara
src/Suki/Tools.php
Tools.checkScheme
public function checkScheme($url = '', $secure = false) { $parsed = []; $parsed = parse_url($url); $pos = strpos($url, '//'); // Perhaps this is a schema less url? parse_url should detect schema less urls .___. if (empty($parsed['scheme']) && strpos($url, '//') !== false) return $url; elseif (empty($parsed['scheme'])) return 'http'. ($secure ? 's' : '') .'://'. $url; else return $url; }
php
public function checkScheme($url = '', $secure = false) { $parsed = []; $parsed = parse_url($url); $pos = strpos($url, '//'); // Perhaps this is a schema less url? parse_url should detect schema less urls .___. if (empty($parsed['scheme']) && strpos($url, '//') !== false) return $url; elseif (empty($parsed['scheme'])) return 'http'. ($secure ? 's' : '') .'://'. $url; else return $url; }
[ "public", "function", "checkScheme", "(", "$", "url", "=", "''", ",", "$", "secure", "=", "false", ")", "{", "$", "parsed", "=", "[", "]", ";", "$", "parsed", "=", "parse_url", "(", "$", "url", ")", ";", "$", "pos", "=", "strpos", "(", "$", "url", ",", "'//'", ")", ";", "// Perhaps this is a schema less url? parse_url should detect schema less urls .___.", "if", "(", "empty", "(", "$", "parsed", "[", "'scheme'", "]", ")", "&&", "strpos", "(", "$", "url", ",", "'//'", ")", "!==", "false", ")", "return", "$", "url", ";", "elseif", "(", "empty", "(", "$", "parsed", "[", "'scheme'", "]", ")", ")", "return", "'http'", ".", "(", "$", "secure", "?", "'s'", ":", "''", ")", ".", "'://'", ".", "$", "url", ";", "else", "return", "$", "url", ";", "}" ]
Checks if a string contains a scheme. Adds one if necessary checks for schemaless urls. @param string $url The data to be converted, needs to be an array. @param boolean $secure If a scheme has to be added, check if https should be used. @access public @return string The passed string.
[ "Checks", "if", "a", "string", "contains", "a", "scheme", ".", "Adds", "one", "if", "necessary", "checks", "for", "schemaless", "urls", "." ]
7753500cde1d51a0d7b37593aeaf2fc05fefd903
https://github.com/MissAllSunday/Ohara/blob/7753500cde1d51a0d7b37593aeaf2fc05fefd903/src/Suki/Tools.php#L34-L49
13,836
MissAllSunday/Ohara
src/Suki/Tools.php
Tools.jsonResponse
public function jsonResponse($data = []) { global $db_show_debug; $json = ''; $result = false; // Defensive programming anyone? if (empty($data)) return false; // This is pretty simply, just encode the supplied data and be done with it. $json = json_encode($data); $result = json_last_error() == JSON_ERROR_NONE; if ($result) { // Don't need extra stuff... $db_show_debug = false; // Kill anything else ob_end_clean(); if ($this->_app->modSetting('CompressedOutput')) @ob_start('ob_gzhandler'); else ob_start(); // Set the header. header('Content-Type: application/json'); // Echo! echo $json; // Done obExit(false); } return $result; }
php
public function jsonResponse($data = []) { global $db_show_debug; $json = ''; $result = false; // Defensive programming anyone? if (empty($data)) return false; // This is pretty simply, just encode the supplied data and be done with it. $json = json_encode($data); $result = json_last_error() == JSON_ERROR_NONE; if ($result) { // Don't need extra stuff... $db_show_debug = false; // Kill anything else ob_end_clean(); if ($this->_app->modSetting('CompressedOutput')) @ob_start('ob_gzhandler'); else ob_start(); // Set the header. header('Content-Type: application/json'); // Echo! echo $json; // Done obExit(false); } return $result; }
[ "public", "function", "jsonResponse", "(", "$", "data", "=", "[", "]", ")", "{", "global", "$", "db_show_debug", ";", "$", "json", "=", "''", ";", "$", "result", "=", "false", ";", "// Defensive programming anyone?", "if", "(", "empty", "(", "$", "data", ")", ")", "return", "false", ";", "// This is pretty simply, just encode the supplied data and be done with it.", "$", "json", "=", "json_encode", "(", "$", "data", ")", ";", "$", "result", "=", "json_last_error", "(", ")", "==", "JSON_ERROR_NONE", ";", "if", "(", "$", "result", ")", "{", "// Don't need extra stuff...", "$", "db_show_debug", "=", "false", ";", "// Kill anything else", "ob_end_clean", "(", ")", ";", "if", "(", "$", "this", "->", "_app", "->", "modSetting", "(", "'CompressedOutput'", ")", ")", "@", "ob_start", "(", "'ob_gzhandler'", ")", ";", "else", "ob_start", "(", ")", ";", "// Set the header.", "header", "(", "'Content-Type: application/json'", ")", ";", "// Echo!", "echo", "$", "json", ";", "// Done", "obExit", "(", "false", ")", ";", "}", "return", "$", "result", ";", "}" ]
Outputs a json encoded string It assumes the data is a valid array. @param array $data The data to be converted, needs to be an array @access public @return boolean whether or not the data was encoded and outputted
[ "Outputs", "a", "json", "encoded", "string", "It", "assumes", "the", "data", "is", "a", "valid", "array", "." ]
7753500cde1d51a0d7b37593aeaf2fc05fefd903
https://github.com/MissAllSunday/Ohara/blob/7753500cde1d51a0d7b37593aeaf2fc05fefd903/src/Suki/Tools.php#L58-L99
13,837
MissAllSunday/Ohara
src/Suki/Tools.php
Tools.parser
public function parser($text, $replacements = []): string { global $context; if (empty($text) || empty($replacements) || !is_array($replacements)) return ''; // Split the replacements up into two arrays, for use with str_replace. $find = []; $replace = []; foreach ($replacements as $f => $r) { $find[] = '{' . $f . '}'; $replace[] = $r . ((strpos($f,'href') !== false) ? (';'. $context['session_var'] .'='. $context['session_id']) : ''); } // Do the variable replacements. return str_replace($find, $replace, $text); }
php
public function parser($text, $replacements = []): string { global $context; if (empty($text) || empty($replacements) || !is_array($replacements)) return ''; // Split the replacements up into two arrays, for use with str_replace. $find = []; $replace = []; foreach ($replacements as $f => $r) { $find[] = '{' . $f . '}'; $replace[] = $r . ((strpos($f,'href') !== false) ? (';'. $context['session_var'] .'='. $context['session_id']) : ''); } // Do the variable replacements. return str_replace($find, $replace, $text); }
[ "public", "function", "parser", "(", "$", "text", ",", "$", "replacements", "=", "[", "]", ")", ":", "string", "{", "global", "$", "context", ";", "if", "(", "empty", "(", "$", "text", ")", "||", "empty", "(", "$", "replacements", ")", "||", "!", "is_array", "(", "$", "replacements", ")", ")", "return", "''", ";", "// Split the replacements up into two arrays, for use with str_replace.", "$", "find", "=", "[", "]", ";", "$", "replace", "=", "[", "]", ";", "foreach", "(", "$", "replacements", "as", "$", "f", "=>", "$", "r", ")", "{", "$", "find", "[", "]", "=", "'{'", ".", "$", "f", ".", "'}'", ";", "$", "replace", "[", "]", "=", "$", "r", ".", "(", "(", "strpos", "(", "$", "f", ",", "'href'", ")", "!==", "false", ")", "?", "(", "';'", ".", "$", "context", "[", "'session_var'", "]", ".", "'='", ".", "$", "context", "[", "'session_id'", "]", ")", ":", "''", ")", ";", "}", "// Do the variable replacements.", "return", "str_replace", "(", "$", "find", ",", "$", "replace", ",", "$", "text", ")", ";", "}" ]
Parses and replace tokens by their given values. also automatically adds the session var for href tokens. @access public @param string $text The raw text. @param array $replacements a key => value array containing all tokens to be replaced. @return string
[ "Parses", "and", "replace", "tokens", "by", "their", "given", "values", ".", "also", "automatically", "adds", "the", "session", "var", "for", "href", "tokens", "." ]
7753500cde1d51a0d7b37593aeaf2fc05fefd903
https://github.com/MissAllSunday/Ohara/blob/7753500cde1d51a0d7b37593aeaf2fc05fefd903/src/Suki/Tools.php#L109-L128
13,838
MissAllSunday/Ohara
src/Suki/Tools.php
Tools.commaSeparated
public function commaSeparated($string, $type = 'alphanumeric', $delimiter = ',') { if (empty($string)) return false; // This is why we can't have nice things... $t = isset($this->_commaCases[$type]) ? $this->_commaCases[$type] : $this->_commaCases['alphanumeric']; return empty($string) ? false : implode($delimiter, array_filter(explode($delimiter, preg_replace( array( '/[^'. $t .',]/', '/(?<='. $delimiter .')'. $delimiter .'+/', '/^'. $delimiter .'+/', '/'. $delimiter .'+$/' ), '', $string )))); }
php
public function commaSeparated($string, $type = 'alphanumeric', $delimiter = ',') { if (empty($string)) return false; // This is why we can't have nice things... $t = isset($this->_commaCases[$type]) ? $this->_commaCases[$type] : $this->_commaCases['alphanumeric']; return empty($string) ? false : implode($delimiter, array_filter(explode($delimiter, preg_replace( array( '/[^'. $t .',]/', '/(?<='. $delimiter .')'. $delimiter .'+/', '/^'. $delimiter .'+/', '/'. $delimiter .'+$/' ), '', $string )))); }
[ "public", "function", "commaSeparated", "(", "$", "string", ",", "$", "type", "=", "'alphanumeric'", ",", "$", "delimiter", "=", "','", ")", "{", "if", "(", "empty", "(", "$", "string", ")", ")", "return", "false", ";", "// This is why we can't have nice things...", "$", "t", "=", "isset", "(", "$", "this", "->", "_commaCases", "[", "$", "type", "]", ")", "?", "$", "this", "->", "_commaCases", "[", "$", "type", "]", ":", "$", "this", "->", "_commaCases", "[", "'alphanumeric'", "]", ";", "return", "empty", "(", "$", "string", ")", "?", "false", ":", "implode", "(", "$", "delimiter", ",", "array_filter", "(", "explode", "(", "$", "delimiter", ",", "preg_replace", "(", "array", "(", "'/[^'", ".", "$", "t", ".", "',]/'", ",", "'/(?<='", ".", "$", "delimiter", ".", "')'", ".", "$", "delimiter", ".", "'+/'", ",", "'/^'", ".", "$", "delimiter", ".", "'+/'", ",", "'/'", ".", "$", "delimiter", ".", "'+$/'", ")", ",", "''", ",", "$", "string", ")", ")", ")", ")", ";", "}" ]
Checks and returns a comma separated string. @access public @param string $string The string to check and format @param string $type The type to check against. Accepts "numeric", "alpha" and "alphanumeric". @param string $delimiter Used for explode/imploding the string. @return string|bool
[ "Checks", "and", "returns", "a", "comma", "separated", "string", "." ]
7753500cde1d51a0d7b37593aeaf2fc05fefd903
https://github.com/MissAllSunday/Ohara/blob/7753500cde1d51a0d7b37593aeaf2fc05fefd903/src/Suki/Tools.php#L138-L154
13,839
MissAllSunday/Ohara
src/Suki/Tools.php
Tools.formatBytes
public function formatBytes($bytes, $showUnits = false, $log = 1024): string { $units = array('B', 'KB', 'MB', 'GB', 'TB'); $bytes = max($bytes, 0); $pow = floor(($bytes ? log($bytes) : 0) / log($log)); $pow = min($pow, count($units) - 1); $bytes /= (1 << (10 * $pow)); return round($bytes, 2) . ($showUnits ? ' ' . $units[$pow] : ''); }
php
public function formatBytes($bytes, $showUnits = false, $log = 1024): string { $units = array('B', 'KB', 'MB', 'GB', 'TB'); $bytes = max($bytes, 0); $pow = floor(($bytes ? log($bytes) : 0) / log($log)); $pow = min($pow, count($units) - 1); $bytes /= (1 << (10 * $pow)); return round($bytes, 2) . ($showUnits ? ' ' . $units[$pow] : ''); }
[ "public", "function", "formatBytes", "(", "$", "bytes", ",", "$", "showUnits", "=", "false", ",", "$", "log", "=", "1024", ")", ":", "string", "{", "$", "units", "=", "array", "(", "'B'", ",", "'KB'", ",", "'MB'", ",", "'GB'", ",", "'TB'", ")", ";", "$", "bytes", "=", "max", "(", "$", "bytes", ",", "0", ")", ";", "$", "pow", "=", "floor", "(", "(", "$", "bytes", "?", "log", "(", "$", "bytes", ")", ":", "0", ")", "/", "log", "(", "$", "log", ")", ")", ";", "$", "pow", "=", "min", "(", "$", "pow", ",", "count", "(", "$", "units", ")", "-", "1", ")", ";", "$", "bytes", "/=", "(", "1", "<<", "(", "10", "*", "$", "pow", ")", ")", ";", "return", "round", "(", "$", "bytes", ",", "2", ")", ".", "(", "$", "showUnits", "?", "' '", ".", "$", "units", "[", "$", "pow", "]", ":", "''", ")", ";", "}" ]
Returns a formatted string. @access public @param string|int $bytes A number of bytes. @param bool $showUnits To show the unit symbol or not. @param int $log the log used, either 1024 or 1000. @return string
[ "Returns", "a", "formatted", "string", "." ]
7753500cde1d51a0d7b37593aeaf2fc05fefd903
https://github.com/MissAllSunday/Ohara/blob/7753500cde1d51a0d7b37593aeaf2fc05fefd903/src/Suki/Tools.php#L164-L173
13,840
joomla-projects/jorobo
src/Tasks/JTask.php
JTask.determineSourceFolder
private function determineSourceFolder() { $this->sourceFolder = JPATH_BASE . "/" . $this->getJConfig()->source; if (!is_dir($this->sourceFolder)) { $this->say('Warning - Directory: ' . $this->sourceFolder . ' is not available'); } }
php
private function determineSourceFolder() { $this->sourceFolder = JPATH_BASE . "/" . $this->getJConfig()->source; if (!is_dir($this->sourceFolder)) { $this->say('Warning - Directory: ' . $this->sourceFolder . ' is not available'); } }
[ "private", "function", "determineSourceFolder", "(", ")", "{", "$", "this", "->", "sourceFolder", "=", "JPATH_BASE", ".", "\"/\"", ".", "$", "this", "->", "getJConfig", "(", ")", "->", "source", ";", "if", "(", "!", "is_dir", "(", "$", "this", "->", "sourceFolder", ")", ")", "{", "$", "this", "->", "say", "(", "'Warning - Directory: '", ".", "$", "this", "->", "sourceFolder", ".", "' is not available'", ")", ";", "}", "}" ]
Sets the source folder @return void @since 1.0
[ "Sets", "the", "source", "folder" ]
e72dd0ed15f387739f67cacdbc2c0bd1b427f317
https://github.com/joomla-projects/jorobo/blob/e72dd0ed15f387739f67cacdbc2c0bd1b427f317/src/Tasks/JTask.php#L167-L175
13,841
joomla-projects/jorobo
src/Tasks/JTask.php
JTask.determineOperatingSystem
private function determineOperatingSystem() { $this->os = strtoupper(substr(PHP_OS, 0, 3)); if ($this->os === 'WIN') { $this->fileExtension = '.exe'; } }
php
private function determineOperatingSystem() { $this->os = strtoupper(substr(PHP_OS, 0, 3)); if ($this->os === 'WIN') { $this->fileExtension = '.exe'; } }
[ "private", "function", "determineOperatingSystem", "(", ")", "{", "$", "this", "->", "os", "=", "strtoupper", "(", "substr", "(", "PHP_OS", ",", "0", ",", "3", ")", ")", ";", "if", "(", "$", "this", "->", "os", "===", "'WIN'", ")", "{", "$", "this", "->", "fileExtension", "=", "'.exe'", ";", "}", "}" ]
Sets the operating system @return void @since 1.0
[ "Sets", "the", "operating", "system" ]
e72dd0ed15f387739f67cacdbc2c0bd1b427f317
https://github.com/joomla-projects/jorobo/blob/e72dd0ed15f387739f67cacdbc2c0bd1b427f317/src/Tasks/JTask.php#L184-L192
13,842
pantera-digital/yii2-seo
controllers/PresetsController.php
PresetsController.actionCreate
public function actionCreate() { $model = new SeoPresets(); $model->loadDefaultValues(); if ($model->load(Yii::$app->request->post()) && $model->save()) { if(Yii::$app->request->post('action') === 'apply') { return $this->redirect(['update', 'id' => $model->id]); }else{ return $this->redirect(['view', 'id' => $model->id]); } } return $this->render('create', [ 'model' => $model, ]); }
php
public function actionCreate() { $model = new SeoPresets(); $model->loadDefaultValues(); if ($model->load(Yii::$app->request->post()) && $model->save()) { if(Yii::$app->request->post('action') === 'apply') { return $this->redirect(['update', 'id' => $model->id]); }else{ return $this->redirect(['view', 'id' => $model->id]); } } return $this->render('create', [ 'model' => $model, ]); }
[ "public", "function", "actionCreate", "(", ")", "{", "$", "model", "=", "new", "SeoPresets", "(", ")", ";", "$", "model", "->", "loadDefaultValues", "(", ")", ";", "if", "(", "$", "model", "->", "load", "(", "Yii", "::", "$", "app", "->", "request", "->", "post", "(", ")", ")", "&&", "$", "model", "->", "save", "(", ")", ")", "{", "if", "(", "Yii", "::", "$", "app", "->", "request", "->", "post", "(", "'action'", ")", "===", "'apply'", ")", "{", "return", "$", "this", "->", "redirect", "(", "[", "'update'", ",", "'id'", "=>", "$", "model", "->", "id", "]", ")", ";", "}", "else", "{", "return", "$", "this", "->", "redirect", "(", "[", "'view'", ",", "'id'", "=>", "$", "model", "->", "id", "]", ")", ";", "}", "}", "return", "$", "this", "->", "render", "(", "'create'", ",", "[", "'model'", "=>", "$", "model", ",", "]", ")", ";", "}" ]
Creates a new SeoPresets model. If creation is successful, the browser will be redirected to the 'view' page. @return mixed
[ "Creates", "a", "new", "SeoPresets", "model", ".", "If", "creation", "is", "successful", "the", "browser", "will", "be", "redirected", "to", "the", "view", "page", "." ]
7673224ef601bfbccc57c96e7413ceb43d8332b2
https://github.com/pantera-digital/yii2-seo/blob/7673224ef601bfbccc57c96e7413ceb43d8332b2/controllers/PresetsController.php#L80-L95
13,843
pantera-digital/yii2-seo
controllers/PresetsController.php
PresetsController.actionUpdate
public function actionUpdate($id) { $model = $this->findModel($id); $model->loadDefaultValues(); if ($model->load(Yii::$app->request->post()) && $model->save()) { if(Yii::$app->request->post('action') === 'apply') { return $this->redirect(['update', 'id' => $model->id]); }else{ return $this->redirect(['view', 'id' => $model->id]); } } return $this->render('update', [ 'model' => $model, ]); }
php
public function actionUpdate($id) { $model = $this->findModel($id); $model->loadDefaultValues(); if ($model->load(Yii::$app->request->post()) && $model->save()) { if(Yii::$app->request->post('action') === 'apply') { return $this->redirect(['update', 'id' => $model->id]); }else{ return $this->redirect(['view', 'id' => $model->id]); } } return $this->render('update', [ 'model' => $model, ]); }
[ "public", "function", "actionUpdate", "(", "$", "id", ")", "{", "$", "model", "=", "$", "this", "->", "findModel", "(", "$", "id", ")", ";", "$", "model", "->", "loadDefaultValues", "(", ")", ";", "if", "(", "$", "model", "->", "load", "(", "Yii", "::", "$", "app", "->", "request", "->", "post", "(", ")", ")", "&&", "$", "model", "->", "save", "(", ")", ")", "{", "if", "(", "Yii", "::", "$", "app", "->", "request", "->", "post", "(", "'action'", ")", "===", "'apply'", ")", "{", "return", "$", "this", "->", "redirect", "(", "[", "'update'", ",", "'id'", "=>", "$", "model", "->", "id", "]", ")", ";", "}", "else", "{", "return", "$", "this", "->", "redirect", "(", "[", "'view'", ",", "'id'", "=>", "$", "model", "->", "id", "]", ")", ";", "}", "}", "return", "$", "this", "->", "render", "(", "'update'", ",", "[", "'model'", "=>", "$", "model", ",", "]", ")", ";", "}" ]
Updates an existing SeoPresets model. If update is successful, the browser will be redirected to the 'view' page. @param integer $id @return mixed @throws NotFoundHttpException if the model cannot be found
[ "Updates", "an", "existing", "SeoPresets", "model", ".", "If", "update", "is", "successful", "the", "browser", "will", "be", "redirected", "to", "the", "view", "page", "." ]
7673224ef601bfbccc57c96e7413ceb43d8332b2
https://github.com/pantera-digital/yii2-seo/blob/7673224ef601bfbccc57c96e7413ceb43d8332b2/controllers/PresetsController.php#L104-L119
13,844
reinvanoyen/aegis
lib/Aegis/Parser.php
Parser.prepare
public function prepare(TokenStream $stream) :void { $this->root = $this->scope = new RootNode(); $this->stream = $stream; $this->lastTokenIndex = max(0, count($this->stream->getTokens()) - 1); $this->cursor = 0; }
php
public function prepare(TokenStream $stream) :void { $this->root = $this->scope = new RootNode(); $this->stream = $stream; $this->lastTokenIndex = max(0, count($this->stream->getTokens()) - 1); $this->cursor = 0; }
[ "public", "function", "prepare", "(", "TokenStream", "$", "stream", ")", ":", "void", "{", "$", "this", "->", "root", "=", "$", "this", "->", "scope", "=", "new", "RootNode", "(", ")", ";", "$", "this", "->", "stream", "=", "$", "stream", ";", "$", "this", "->", "lastTokenIndex", "=", "max", "(", "0", ",", "count", "(", "$", "this", "->", "stream", "->", "getTokens", "(", ")", ")", "-", "1", ")", ";", "$", "this", "->", "cursor", "=", "0", ";", "}" ]
Prepares the parser for parsing @param TokenStream $stream @return void
[ "Prepares", "the", "parser", "for", "parsing" ]
ecd831fd6f3ceb4fb20fb5af83483d73cad8e323
https://github.com/reinvanoyen/aegis/blob/ecd831fd6f3ceb4fb20fb5af83483d73cad8e323/lib/Aegis/Parser.php#L87-L93
13,845
reinvanoyen/aegis
lib/Aegis/Parser.php
Parser.parseOutsideTag
public function parseOutsideTag() : void { if (!count($this->stream->getTokens())) { return; } if ($this->accept(Token::T_TEXT)) { $this->insert(new TextNode($this->getCurrentToken()->getValue())); $this->advance(); } if ($this->skip(Token::T_OPENING_TAG)) { $this->parseStatement(); } }
php
public function parseOutsideTag() : void { if (!count($this->stream->getTokens())) { return; } if ($this->accept(Token::T_TEXT)) { $this->insert(new TextNode($this->getCurrentToken()->getValue())); $this->advance(); } if ($this->skip(Token::T_OPENING_TAG)) { $this->parseStatement(); } }
[ "public", "function", "parseOutsideTag", "(", ")", ":", "void", "{", "if", "(", "!", "count", "(", "$", "this", "->", "stream", "->", "getTokens", "(", ")", ")", ")", "{", "return", ";", "}", "if", "(", "$", "this", "->", "accept", "(", "Token", "::", "T_TEXT", ")", ")", "{", "$", "this", "->", "insert", "(", "new", "TextNode", "(", "$", "this", "->", "getCurrentToken", "(", ")", "->", "getValue", "(", ")", ")", ")", ";", "$", "this", "->", "advance", "(", ")", ";", "}", "if", "(", "$", "this", "->", "skip", "(", "Token", "::", "T_OPENING_TAG", ")", ")", "{", "$", "this", "->", "parseStatement", "(", ")", ";", "}", "}" ]
Parses outside of tags @return void
[ "Parses", "outside", "of", "tags" ]
ecd831fd6f3ceb4fb20fb5af83483d73cad8e323
https://github.com/reinvanoyen/aegis/blob/ecd831fd6f3ceb4fb20fb5af83483d73cad8e323/lib/Aegis/Parser.php#L100-L114
13,846
reinvanoyen/aegis
lib/Aegis/Parser.php
Parser.expect
public function expect(int $type, $value = null) : bool { if (!$this->accept($type, $value)) { $this->syntaxError('Expected '.Token::getStringRepresentation($type, $value).' got '.$this->getCurrentToken()); } return true; }
php
public function expect(int $type, $value = null) : bool { if (!$this->accept($type, $value)) { $this->syntaxError('Expected '.Token::getStringRepresentation($type, $value).' got '.$this->getCurrentToken()); } return true; }
[ "public", "function", "expect", "(", "int", "$", "type", ",", "$", "value", "=", "null", ")", ":", "bool", "{", "if", "(", "!", "$", "this", "->", "accept", "(", "$", "type", ",", "$", "value", ")", ")", "{", "$", "this", "->", "syntaxError", "(", "'Expected '", ".", "Token", "::", "getStringRepresentation", "(", "$", "type", ",", "$", "value", ")", ".", "' got '", ".", "$", "this", "->", "getCurrentToken", "(", ")", ")", ";", "}", "return", "true", ";", "}" ]
Expects the current token to be of given type and optionally has given value @param int $type @param null $value @return bool @throws ParseError
[ "Expects", "the", "current", "token", "to", "be", "of", "given", "type", "and", "optionally", "has", "given", "value" ]
ecd831fd6f3ceb4fb20fb5af83483d73cad8e323
https://github.com/reinvanoyen/aegis/blob/ecd831fd6f3ceb4fb20fb5af83483d73cad8e323/lib/Aegis/Parser.php#L151-L158
13,847
reinvanoyen/aegis
lib/Aegis/Parser.php
Parser.expectNext
public function expectNext(int $type, $value = null) : bool { if (!$this->acceptNext($type, $value)) { $this->syntaxError('Expected '.Token::getStringRepresentation($type, $value).' got '.$this->getNextToken()); } return true; }
php
public function expectNext(int $type, $value = null) : bool { if (!$this->acceptNext($type, $value)) { $this->syntaxError('Expected '.Token::getStringRepresentation($type, $value).' got '.$this->getNextToken()); } return true; }
[ "public", "function", "expectNext", "(", "int", "$", "type", ",", "$", "value", "=", "null", ")", ":", "bool", "{", "if", "(", "!", "$", "this", "->", "acceptNext", "(", "$", "type", ",", "$", "value", ")", ")", "{", "$", "this", "->", "syntaxError", "(", "'Expected '", ".", "Token", "::", "getStringRepresentation", "(", "$", "type", ",", "$", "value", ")", ".", "' got '", ".", "$", "this", "->", "getNextToken", "(", ")", ")", ";", "}", "return", "true", ";", "}" ]
Expects the next token to be of given type and optionally has given value @param int $type @param null $value @return bool @throws ParseError
[ "Expects", "the", "next", "token", "to", "be", "of", "given", "type", "and", "optionally", "has", "given", "value" ]
ecd831fd6f3ceb4fb20fb5af83483d73cad8e323
https://github.com/reinvanoyen/aegis/blob/ecd831fd6f3ceb4fb20fb5af83483d73cad8e323/lib/Aegis/Parser.php#L168-L175
13,848
reinvanoyen/aegis
lib/Aegis/Parser.php
Parser.skip
public function skip(int $type, $value = null) : bool { if ($this->accept($type, $value)) { $this->advance(); return true; } return false; }
php
public function skip(int $type, $value = null) : bool { if ($this->accept($type, $value)) { $this->advance(); return true; } return false; }
[ "public", "function", "skip", "(", "int", "$", "type", ",", "$", "value", "=", "null", ")", ":", "bool", "{", "if", "(", "$", "this", "->", "accept", "(", "$", "type", ",", "$", "value", ")", ")", "{", "$", "this", "->", "advance", "(", ")", ";", "return", "true", ";", "}", "return", "false", ";", "}" ]
Skips the current token if it's of given type and optionally has given value @param int $type @param null $value @return bool
[ "Skips", "the", "current", "token", "if", "it", "s", "of", "given", "type", "and", "optionally", "has", "given", "value" ]
ecd831fd6f3ceb4fb20fb5af83483d73cad8e323
https://github.com/reinvanoyen/aegis/blob/ecd831fd6f3ceb4fb20fb5af83483d73cad8e323/lib/Aegis/Parser.php#L184-L193
13,849
reinvanoyen/aegis
lib/Aegis/Parser.php
Parser.accept
public function accept(int $type, $value = null) : bool { if ($this->getCurrentToken()->getType() === $type) { if ($value) { if ($this->getCurrentToken()->getValue() === $value) { return true; } return false; } return true; } return false; }
php
public function accept(int $type, $value = null) : bool { if ($this->getCurrentToken()->getType() === $type) { if ($value) { if ($this->getCurrentToken()->getValue() === $value) { return true; } return false; } return true; } return false; }
[ "public", "function", "accept", "(", "int", "$", "type", ",", "$", "value", "=", "null", ")", ":", "bool", "{", "if", "(", "$", "this", "->", "getCurrentToken", "(", ")", "->", "getType", "(", ")", "===", "$", "type", ")", "{", "if", "(", "$", "value", ")", "{", "if", "(", "$", "this", "->", "getCurrentToken", "(", ")", "->", "getValue", "(", ")", "===", "$", "value", ")", "{", "return", "true", ";", "}", "return", "false", ";", "}", "return", "true", ";", "}", "return", "false", ";", "}" ]
Accepts the current token if it's of given type and optionally has given value @param int $type @param null $value @return bool
[ "Accepts", "the", "current", "token", "if", "it", "s", "of", "given", "type", "and", "optionally", "has", "given", "value" ]
ecd831fd6f3ceb4fb20fb5af83483d73cad8e323
https://github.com/reinvanoyen/aegis/blob/ecd831fd6f3ceb4fb20fb5af83483d73cad8e323/lib/Aegis/Parser.php#L202-L217
13,850
reinvanoyen/aegis
lib/Aegis/Parser.php
Parser.acceptNext
public function acceptNext(int $type, $value = null) : bool { if ($this->getNextToken()->getType() === $type) { if ($value) { if ($this->getNextToken()->getValue() === $value) { return true; } return false; } return true; } return false; }
php
public function acceptNext(int $type, $value = null) : bool { if ($this->getNextToken()->getType() === $type) { if ($value) { if ($this->getNextToken()->getValue() === $value) { return true; } return false; } return true; } return false; }
[ "public", "function", "acceptNext", "(", "int", "$", "type", ",", "$", "value", "=", "null", ")", ":", "bool", "{", "if", "(", "$", "this", "->", "getNextToken", "(", ")", "->", "getType", "(", ")", "===", "$", "type", ")", "{", "if", "(", "$", "value", ")", "{", "if", "(", "$", "this", "->", "getNextToken", "(", ")", "->", "getValue", "(", ")", "===", "$", "value", ")", "{", "return", "true", ";", "}", "return", "false", ";", "}", "return", "true", ";", "}", "return", "false", ";", "}" ]
Accepts the next token if it's of given type and optionally has given value @param int $type @param null $value @return bool
[ "Accepts", "the", "next", "token", "if", "it", "s", "of", "given", "type", "and", "optionally", "has", "given", "value" ]
ecd831fd6f3ceb4fb20fb5af83483d73cad8e323
https://github.com/reinvanoyen/aegis/blob/ecd831fd6f3ceb4fb20fb5af83483d73cad8e323/lib/Aegis/Parser.php#L226-L241
13,851
reinvanoyen/aegis
lib/Aegis/Parser.php
Parser.traverseDown
public function traverseDown() : void { try { $parent = $this->getScope()->getParent(); } catch (AegisError $e) { throw new ParseError($e->getMessage()); } $this->setScope($parent); }
php
public function traverseDown() : void { try { $parent = $this->getScope()->getParent(); } catch (AegisError $e) { throw new ParseError($e->getMessage()); } $this->setScope($parent); }
[ "public", "function", "traverseDown", "(", ")", ":", "void", "{", "try", "{", "$", "parent", "=", "$", "this", "->", "getScope", "(", ")", "->", "getParent", "(", ")", ";", "}", "catch", "(", "AegisError", "$", "e", ")", "{", "throw", "new", "ParseError", "(", "$", "e", "->", "getMessage", "(", ")", ")", ";", "}", "$", "this", "->", "setScope", "(", "$", "parent", ")", ";", "}" ]
Moves outside the current scope @return void @throws ParseError
[ "Moves", "outside", "the", "current", "scope" ]
ecd831fd6f3ceb4fb20fb5af83483d73cad8e323
https://github.com/reinvanoyen/aegis/blob/ecd831fd6f3ceb4fb20fb5af83483d73cad8e323/lib/Aegis/Parser.php#L320-L329
13,852
reinvanoyen/aegis
lib/Aegis/Parser.php
Parser.advance
public function advance() : void { if ($this->cursor < count($this->stream->getTokens()) - 1) { ++$this->cursor; } }
php
public function advance() : void { if ($this->cursor < count($this->stream->getTokens()) - 1) { ++$this->cursor; } }
[ "public", "function", "advance", "(", ")", ":", "void", "{", "if", "(", "$", "this", "->", "cursor", "<", "count", "(", "$", "this", "->", "stream", "->", "getTokens", "(", ")", ")", "-", "1", ")", "{", "++", "$", "this", "->", "cursor", ";", "}", "}" ]
Advances the cursor @return void
[ "Advances", "the", "cursor" ]
ecd831fd6f3ceb4fb20fb5af83483d73cad8e323
https://github.com/reinvanoyen/aegis/blob/ecd831fd6f3ceb4fb20fb5af83483d73cad8e323/lib/Aegis/Parser.php#L336-L341
13,853
reinvanoyen/aegis
lib/Aegis/Parser.php
Parser.wrap
public function wrap(Node $node) : void { $last = $this->scope->getLastChild(); // Get the last inserted node $this->scope->removeLastChild(); // Remove it $this->insert($node); $this->traverseUp(); $this->insert($last); }
php
public function wrap(Node $node) : void { $last = $this->scope->getLastChild(); // Get the last inserted node $this->scope->removeLastChild(); // Remove it $this->insert($node); $this->traverseUp(); $this->insert($last); }
[ "public", "function", "wrap", "(", "Node", "$", "node", ")", ":", "void", "{", "$", "last", "=", "$", "this", "->", "scope", "->", "getLastChild", "(", ")", ";", "// Get the last inserted node", "$", "this", "->", "scope", "->", "removeLastChild", "(", ")", ";", "// Remove it", "$", "this", "->", "insert", "(", "$", "node", ")", ";", "$", "this", "->", "traverseUp", "(", ")", ";", "$", "this", "->", "insert", "(", "$", "last", ")", ";", "}" ]
Wraps the last inserted node with the given node @param Node $node @return void
[ "Wraps", "the", "last", "inserted", "node", "with", "the", "given", "node" ]
ecd831fd6f3ceb4fb20fb5af83483d73cad8e323
https://github.com/reinvanoyen/aegis/blob/ecd831fd6f3ceb4fb20fb5af83483d73cad8e323/lib/Aegis/Parser.php#L359-L368
13,854
reinvanoyen/aegis
lib/Aegis/Parser.php
Parser.setAttribute
public function setAttribute() : void { $last = $this->scope->getLastChild(); // Get the last inserted node $this->scope->removeLastChild(); // Remove it $this->scope->setAttribute($last); }
php
public function setAttribute() : void { $last = $this->scope->getLastChild(); // Get the last inserted node $this->scope->removeLastChild(); // Remove it $this->scope->setAttribute($last); }
[ "public", "function", "setAttribute", "(", ")", ":", "void", "{", "$", "last", "=", "$", "this", "->", "scope", "->", "getLastChild", "(", ")", ";", "// Get the last inserted node", "$", "this", "->", "scope", "->", "removeLastChild", "(", ")", ";", "// Remove it", "$", "this", "->", "scope", "->", "setAttribute", "(", "$", "last", ")", ";", "}" ]
Sets the last inserted node as attribute @return void
[ "Sets", "the", "last", "inserted", "node", "as", "attribute" ]
ecd831fd6f3ceb4fb20fb5af83483d73cad8e323
https://github.com/reinvanoyen/aegis/blob/ecd831fd6f3ceb4fb20fb5af83483d73cad8e323/lib/Aegis/Parser.php#L375-L380
13,855
reinvanoyen/aegis
lib/Aegis/Parser.php
Parser.insert
public function insert(Node $node) : void { $node->setParent($this->scope); $this->scope->insert($node); }
php
public function insert(Node $node) : void { $node->setParent($this->scope); $this->scope->insert($node); }
[ "public", "function", "insert", "(", "Node", "$", "node", ")", ":", "void", "{", "$", "node", "->", "setParent", "(", "$", "this", "->", "scope", ")", ";", "$", "this", "->", "scope", "->", "insert", "(", "$", "node", ")", ";", "}" ]
Inserts the given node @param Node $node @return void
[ "Inserts", "the", "given", "node" ]
ecd831fd6f3ceb4fb20fb5af83483d73cad8e323
https://github.com/reinvanoyen/aegis/blob/ecd831fd6f3ceb4fb20fb5af83483d73cad8e323/lib/Aegis/Parser.php#L388-L392
13,856
mamuz/MamuzBlog
src/MamuzBlog/Controller/TagQueryController.php
TagQueryController.listAction
public function listAction() { $this->routeParam()->mapPageTo($this->queryService); $collection = $this->queryService->findUsedTags(); return $this->viewModelFactory()->createFor($collection); }
php
public function listAction() { $this->routeParam()->mapPageTo($this->queryService); $collection = $this->queryService->findUsedTags(); return $this->viewModelFactory()->createFor($collection); }
[ "public", "function", "listAction", "(", ")", "{", "$", "this", "->", "routeParam", "(", ")", "->", "mapPageTo", "(", "$", "this", "->", "queryService", ")", ";", "$", "collection", "=", "$", "this", "->", "queryService", "->", "findUsedTags", "(", ")", ";", "return", "$", "this", "->", "viewModelFactory", "(", ")", "->", "createFor", "(", "$", "collection", ")", ";", "}" ]
Tag list retrieval @return ModelInterface
[ "Tag", "list", "retrieval" ]
cb43be5c39031e3dcc939283e284824c4d07da38
https://github.com/mamuz/MamuzBlog/blob/cb43be5c39031e3dcc939283e284824c4d07da38/src/MamuzBlog/Controller/TagQueryController.php#L31-L37
13,857
sifophp/sifo-common-instance
controllers/locales/index.php
LocalesIndexController.build
public function build() { $this->setLayout( 'locales/index.tpl' ); $this->addModule( 'head', 'SharedHead' ); $this->addModule( 'footer', 'SharedFooter' ); $this->addModule( 'system_messages', 'SharedSystemMessages' ); $params = $this->getParams(); $action = \Sifo\Router::getReversalRoute( $params['path_parts'][0] ); $params = $this->getParams(); if ( $params['params'] !== false && in_array('saved-true', $params["params"])) { \Sifo\FlashMessages::set( 'File Saved OK.', \Sifo\FlashMessages::MSG_OK ); } if ( $params['params'] !== false && in_array('created-true', $params["params"])) { \Sifo\FlashMessages::set( 'File Created OK.', \Sifo\FlashMessages::MSG_OK ); } if ($this->getParsedParam( 'instance' ) !== false) { $this->assign('current_instance', $this->getParsedParam( 'instance' )); $this->assign('languages', $this->getLanguagesInstance($this->getParsedParam( 'instance' ))); //var_dump($this->getLanguagesInstance($this->getParsedParam( 'instance' ))); } if ($this->getParsedParam( 'language' ) !== false) { $this->assign('current_language', $this->getParsedParam( 'language' )); $temp = explode("_", $this->getParsedParam( 'language' )); if ( is_array( $temp)) { $this->assign('lang', $temp[1]); } } $instances = $this->getInstances(); $this->assign('instances', $instances); // For url with params generation: $this->assign( 'params', $this->getParam( 'parsed_params' ) ); $this->assign( 'params_definition', $this->getParamsDefinition() ); }
php
public function build() { $this->setLayout( 'locales/index.tpl' ); $this->addModule( 'head', 'SharedHead' ); $this->addModule( 'footer', 'SharedFooter' ); $this->addModule( 'system_messages', 'SharedSystemMessages' ); $params = $this->getParams(); $action = \Sifo\Router::getReversalRoute( $params['path_parts'][0] ); $params = $this->getParams(); if ( $params['params'] !== false && in_array('saved-true', $params["params"])) { \Sifo\FlashMessages::set( 'File Saved OK.', \Sifo\FlashMessages::MSG_OK ); } if ( $params['params'] !== false && in_array('created-true', $params["params"])) { \Sifo\FlashMessages::set( 'File Created OK.', \Sifo\FlashMessages::MSG_OK ); } if ($this->getParsedParam( 'instance' ) !== false) { $this->assign('current_instance', $this->getParsedParam( 'instance' )); $this->assign('languages', $this->getLanguagesInstance($this->getParsedParam( 'instance' ))); //var_dump($this->getLanguagesInstance($this->getParsedParam( 'instance' ))); } if ($this->getParsedParam( 'language' ) !== false) { $this->assign('current_language', $this->getParsedParam( 'language' )); $temp = explode("_", $this->getParsedParam( 'language' )); if ( is_array( $temp)) { $this->assign('lang', $temp[1]); } } $instances = $this->getInstances(); $this->assign('instances', $instances); // For url with params generation: $this->assign( 'params', $this->getParam( 'parsed_params' ) ); $this->assign( 'params_definition', $this->getParamsDefinition() ); }
[ "public", "function", "build", "(", ")", "{", "$", "this", "->", "setLayout", "(", "'locales/index.tpl'", ")", ";", "$", "this", "->", "addModule", "(", "'head'", ",", "'SharedHead'", ")", ";", "$", "this", "->", "addModule", "(", "'footer'", ",", "'SharedFooter'", ")", ";", "$", "this", "->", "addModule", "(", "'system_messages'", ",", "'SharedSystemMessages'", ")", ";", "$", "params", "=", "$", "this", "->", "getParams", "(", ")", ";", "$", "action", "=", "\\", "Sifo", "\\", "Router", "::", "getReversalRoute", "(", "$", "params", "[", "'path_parts'", "]", "[", "0", "]", ")", ";", "$", "params", "=", "$", "this", "->", "getParams", "(", ")", ";", "if", "(", "$", "params", "[", "'params'", "]", "!==", "false", "&&", "in_array", "(", "'saved-true'", ",", "$", "params", "[", "\"params\"", "]", ")", ")", "{", "\\", "Sifo", "\\", "FlashMessages", "::", "set", "(", "'File Saved OK.'", ",", "\\", "Sifo", "\\", "FlashMessages", "::", "MSG_OK", ")", ";", "}", "if", "(", "$", "params", "[", "'params'", "]", "!==", "false", "&&", "in_array", "(", "'created-true'", ",", "$", "params", "[", "\"params\"", "]", ")", ")", "{", "\\", "Sifo", "\\", "FlashMessages", "::", "set", "(", "'File Created OK.'", ",", "\\", "Sifo", "\\", "FlashMessages", "::", "MSG_OK", ")", ";", "}", "if", "(", "$", "this", "->", "getParsedParam", "(", "'instance'", ")", "!==", "false", ")", "{", "$", "this", "->", "assign", "(", "'current_instance'", ",", "$", "this", "->", "getParsedParam", "(", "'instance'", ")", ")", ";", "$", "this", "->", "assign", "(", "'languages'", ",", "$", "this", "->", "getLanguagesInstance", "(", "$", "this", "->", "getParsedParam", "(", "'instance'", ")", ")", ")", ";", "//var_dump($this->getLanguagesInstance($this->getParsedParam( 'instance' )));", "}", "if", "(", "$", "this", "->", "getParsedParam", "(", "'language'", ")", "!==", "false", ")", "{", "$", "this", "->", "assign", "(", "'current_language'", ",", "$", "this", "->", "getParsedParam", "(", "'language'", ")", ")", ";", "$", "temp", "=", "explode", "(", "\"_\"", ",", "$", "this", "->", "getParsedParam", "(", "'language'", ")", ")", ";", "if", "(", "is_array", "(", "$", "temp", ")", ")", "{", "$", "this", "->", "assign", "(", "'lang'", ",", "$", "temp", "[", "1", "]", ")", ";", "}", "}", "$", "instances", "=", "$", "this", "->", "getInstances", "(", ")", ";", "$", "this", "->", "assign", "(", "'instances'", ",", "$", "instances", ")", ";", "// For url with params generation:", "$", "this", "->", "assign", "(", "'params'", ",", "$", "this", "->", "getParam", "(", "'parsed_params'", ")", ")", ";", "$", "this", "->", "assign", "(", "'params_definition'", ",", "$", "this", "->", "getParamsDefinition", "(", ")", ")", ";", "}" ]
Main method controller. @return unknown_type
[ "Main", "method", "controller", "." ]
52d54ea3e565bd2bccd77e0b0a6a99b5cae3aff5
https://github.com/sifophp/sifo-common-instance/blob/52d54ea3e565bd2bccd77e0b0a6a99b5cae3aff5/controllers/locales/index.php#L18-L62
13,858
sifophp/sifo-common-instance
controllers/locales/index.php
LocalesIndexController.getLanguagesInstance
public function getLanguagesInstance($instance = null) { $languages = false; if ($instance != '') { $languages = $this->scanFiles(ROOT_PATH . '/instances/' . $instance . '/locale', false); if (is_array($languages) && count($languages) > 0) { $locales = array(); foreach ($languages as $index => $language) { require_once ROOT_PATH . '/instances/' . $instance . '/locale/' . $language["id"]; if (isset($translations)) { $locales[$language["id"]]["translations"] = $translations; unset($translations); } else { $locales[$language["id"]]["translations"] = null; } } $translation_keys = $this->getUniqueTranslationKeys($locales); if (is_array($translation_keys)) natcasesort($translation_keys); $this->assign("translation_keys", $translation_keys); if (is_array($translation_keys)) { $total_keys = count($translation_keys); foreach($locales as $language => $value) { $locales[$language]["total_keys"] = $total_keys; $locales[$language]["translated_keys"] = count($locales[$language]["translations"]); $locales[$language]["translated_percentage"] = number_format(($locales[$language]["translated_keys"] / $locales[$language]["total_keys"]) * 100, 2, ",", ".")."%"; } } } } return($locales); }
php
public function getLanguagesInstance($instance = null) { $languages = false; if ($instance != '') { $languages = $this->scanFiles(ROOT_PATH . '/instances/' . $instance . '/locale', false); if (is_array($languages) && count($languages) > 0) { $locales = array(); foreach ($languages as $index => $language) { require_once ROOT_PATH . '/instances/' . $instance . '/locale/' . $language["id"]; if (isset($translations)) { $locales[$language["id"]]["translations"] = $translations; unset($translations); } else { $locales[$language["id"]]["translations"] = null; } } $translation_keys = $this->getUniqueTranslationKeys($locales); if (is_array($translation_keys)) natcasesort($translation_keys); $this->assign("translation_keys", $translation_keys); if (is_array($translation_keys)) { $total_keys = count($translation_keys); foreach($locales as $language => $value) { $locales[$language]["total_keys"] = $total_keys; $locales[$language]["translated_keys"] = count($locales[$language]["translations"]); $locales[$language]["translated_percentage"] = number_format(($locales[$language]["translated_keys"] / $locales[$language]["total_keys"]) * 100, 2, ",", ".")."%"; } } } } return($locales); }
[ "public", "function", "getLanguagesInstance", "(", "$", "instance", "=", "null", ")", "{", "$", "languages", "=", "false", ";", "if", "(", "$", "instance", "!=", "''", ")", "{", "$", "languages", "=", "$", "this", "->", "scanFiles", "(", "ROOT_PATH", ".", "'/instances/'", ".", "$", "instance", ".", "'/locale'", ",", "false", ")", ";", "if", "(", "is_array", "(", "$", "languages", ")", "&&", "count", "(", "$", "languages", ")", ">", "0", ")", "{", "$", "locales", "=", "array", "(", ")", ";", "foreach", "(", "$", "languages", "as", "$", "index", "=>", "$", "language", ")", "{", "require_once", "ROOT_PATH", ".", "'/instances/'", ".", "$", "instance", ".", "'/locale/'", ".", "$", "language", "[", "\"id\"", "]", ";", "if", "(", "isset", "(", "$", "translations", ")", ")", "{", "$", "locales", "[", "$", "language", "[", "\"id\"", "]", "]", "[", "\"translations\"", "]", "=", "$", "translations", ";", "unset", "(", "$", "translations", ")", ";", "}", "else", "{", "$", "locales", "[", "$", "language", "[", "\"id\"", "]", "]", "[", "\"translations\"", "]", "=", "null", ";", "}", "}", "$", "translation_keys", "=", "$", "this", "->", "getUniqueTranslationKeys", "(", "$", "locales", ")", ";", "if", "(", "is_array", "(", "$", "translation_keys", ")", ")", "natcasesort", "(", "$", "translation_keys", ")", ";", "$", "this", "->", "assign", "(", "\"translation_keys\"", ",", "$", "translation_keys", ")", ";", "if", "(", "is_array", "(", "$", "translation_keys", ")", ")", "{", "$", "total_keys", "=", "count", "(", "$", "translation_keys", ")", ";", "foreach", "(", "$", "locales", "as", "$", "language", "=>", "$", "value", ")", "{", "$", "locales", "[", "$", "language", "]", "[", "\"total_keys\"", "]", "=", "$", "total_keys", ";", "$", "locales", "[", "$", "language", "]", "[", "\"translated_keys\"", "]", "=", "count", "(", "$", "locales", "[", "$", "language", "]", "[", "\"translations\"", "]", ")", ";", "$", "locales", "[", "$", "language", "]", "[", "\"translated_percentage\"", "]", "=", "number_format", "(", "(", "$", "locales", "[", "$", "language", "]", "[", "\"translated_keys\"", "]", "/", "$", "locales", "[", "$", "language", "]", "[", "\"total_keys\"", "]", ")", "*", "100", ",", "2", ",", "\",\"", ",", "\".\"", ")", ".", "\"%\"", ";", "}", "}", "}", "}", "return", "(", "$", "locales", ")", ";", "}" ]
Build a list with all of the languages of an instance @return array
[ "Build", "a", "list", "with", "all", "of", "the", "languages", "of", "an", "instance" ]
52d54ea3e565bd2bccd77e0b0a6a99b5cae3aff5
https://github.com/sifophp/sifo-common-instance/blob/52d54ea3e565bd2bccd77e0b0a6a99b5cae3aff5/controllers/locales/index.php#L78-L118
13,859
unimapper/unimapper
src/Query/Select.php
Select._mergeAssociated
private function _mergeAssociated( array $result, array $associated, $refKey, $colName ) { foreach ($result as $index => $item) { if (is_array($item)) { $refValue = $item[$refKey]; } else { $refValue = $item->{$refKey}; } if (isset($associated[$refValue])) { if (is_array($result[$index])) { $result[$index][$colName] = $associated[$refValue]; } else { $result[$index]->{$colName} = $associated[$refValue]; } } } return $result; }
php
private function _mergeAssociated( array $result, array $associated, $refKey, $colName ) { foreach ($result as $index => $item) { if (is_array($item)) { $refValue = $item[$refKey]; } else { $refValue = $item->{$refKey}; } if (isset($associated[$refValue])) { if (is_array($result[$index])) { $result[$index][$colName] = $associated[$refValue]; } else { $result[$index]->{$colName} = $associated[$refValue]; } } } return $result; }
[ "private", "function", "_mergeAssociated", "(", "array", "$", "result", ",", "array", "$", "associated", ",", "$", "refKey", ",", "$", "colName", ")", "{", "foreach", "(", "$", "result", "as", "$", "index", "=>", "$", "item", ")", "{", "if", "(", "is_array", "(", "$", "item", ")", ")", "{", "$", "refValue", "=", "$", "item", "[", "$", "refKey", "]", ";", "}", "else", "{", "$", "refValue", "=", "$", "item", "->", "{", "$", "refKey", "}", ";", "}", "if", "(", "isset", "(", "$", "associated", "[", "$", "refValue", "]", ")", ")", "{", "if", "(", "is_array", "(", "$", "result", "[", "$", "index", "]", ")", ")", "{", "$", "result", "[", "$", "index", "]", "[", "$", "colName", "]", "=", "$", "associated", "[", "$", "refValue", "]", ";", "}", "else", "{", "$", "result", "[", "$", "index", "]", "->", "{", "$", "colName", "}", "=", "$", "associated", "[", "$", "refValue", "]", ";", "}", "}", "}", "return", "$", "result", ";", "}" ]
Merge associated data with result @param array $result @param array $associated @param string $refKey @param string $colName @return array
[ "Merge", "associated", "data", "with", "result" ]
a63b39f38a790fec7e852c8ef1e4c31653e689f7
https://github.com/unimapper/unimapper/blob/a63b39f38a790fec7e852c8ef1e4c31653e689f7/src/Query/Select.php#L150-L174
13,860
unimapper/unimapper
src/Query/Select.php
Select._getQueryChecksum
private function _getQueryChecksum() { return md5( serialize( [ "name" => $this->getName(), "entity" => Convention::classToName( $this->reflection->getClassName(), Convention::ENTITY_MASK ), "limit" => $this->limit, "offset" => $this->offset, "selection" => $this->selection, "orderBy" => $this->orderBy, "adapterAssociations" => array_keys($this->adapterAssociations), "remoteAssociations" => array_keys($this->remoteAssociations), "conditions" => $this->filter ] ) ); }
php
private function _getQueryChecksum() { return md5( serialize( [ "name" => $this->getName(), "entity" => Convention::classToName( $this->reflection->getClassName(), Convention::ENTITY_MASK ), "limit" => $this->limit, "offset" => $this->offset, "selection" => $this->selection, "orderBy" => $this->orderBy, "adapterAssociations" => array_keys($this->adapterAssociations), "remoteAssociations" => array_keys($this->remoteAssociations), "conditions" => $this->filter ] ) ); }
[ "private", "function", "_getQueryChecksum", "(", ")", "{", "return", "md5", "(", "serialize", "(", "[", "\"name\"", "=>", "$", "this", "->", "getName", "(", ")", ",", "\"entity\"", "=>", "Convention", "::", "classToName", "(", "$", "this", "->", "reflection", "->", "getClassName", "(", ")", ",", "Convention", "::", "ENTITY_MASK", ")", ",", "\"limit\"", "=>", "$", "this", "->", "limit", ",", "\"offset\"", "=>", "$", "this", "->", "offset", ",", "\"selection\"", "=>", "$", "this", "->", "selection", ",", "\"orderBy\"", "=>", "$", "this", "->", "orderBy", ",", "\"adapterAssociations\"", "=>", "array_keys", "(", "$", "this", "->", "adapterAssociations", ")", ",", "\"remoteAssociations\"", "=>", "array_keys", "(", "$", "this", "->", "remoteAssociations", ")", ",", "\"conditions\"", "=>", "$", "this", "->", "filter", "]", ")", ")", ";", "}" ]
Get a unique query checksum @return integer
[ "Get", "a", "unique", "query", "checksum" ]
a63b39f38a790fec7e852c8ef1e4c31653e689f7
https://github.com/unimapper/unimapper/blob/a63b39f38a790fec7e852c8ef1e4c31653e689f7/src/Query/Select.php#L181-L200
13,861
keboola/juicer
Client/RestClient.php
RestClient.getRequestConfig
protected function getRequestConfig(array $config) : array { if (!empty($this->defaultRequestOptions)) { $config = array_replace_recursive($this->defaultRequestOptions, $config); } return $config; }
php
protected function getRequestConfig(array $config) : array { if (!empty($this->defaultRequestOptions)) { $config = array_replace_recursive($this->defaultRequestOptions, $config); } return $config; }
[ "protected", "function", "getRequestConfig", "(", "array", "$", "config", ")", ":", "array", "{", "if", "(", "!", "empty", "(", "$", "this", "->", "defaultRequestOptions", ")", ")", "{", "$", "config", "=", "array_replace_recursive", "(", "$", "this", "->", "defaultRequestOptions", ",", "$", "config", ")", ";", "}", "return", "$", "config", ";", "}" ]
Update request config with default options @param array $config @return array
[ "Update", "request", "config", "with", "default", "options" ]
780e7900ccd23082ed234cc2c51b279a4223e9f5
https://github.com/keboola/juicer/blob/780e7900ccd23082ed234cc2c51b279a4223e9f5/Client/RestClient.php#L83-L90
13,862
keboola/juicer
Client/RestClient.php
RestClient.createBackoff
private static function createBackoff(array $options, LoggerInterface $logger) { $headerName = isset($options['http']['retryHeader']) ? $options['http']['retryHeader'] : 'Retry-After'; $httpRetryCodes = isset($options['http']['codes']) ? $options['http']['codes'] : [500, 502, 503, 504, 408, 420, 429]; $maxRetries = isset($options['maxRetries']) ? (int) $options['maxRetries']: 10; $curlRetryCodes = isset($options['curl']['codes']) ? $options['curl']['codes'] : [ CURLE_OPERATION_TIMEOUTED, CURLE_COULDNT_RESOLVE_HOST, CURLE_COULDNT_CONNECT, CURLE_SSL_CONNECT_ERROR, CURLE_GOT_NOTHING, CURLE_RECV_ERROR ]; return new RetrySubscriber([ 'filter' => RetrySubscriber::createChainFilter([ RetrySubscriber::createStatusFilter($httpRetryCodes), RetrySubscriber::createCurlFilter($curlRetryCodes) ]), 'max' => $maxRetries, 'delay' => function ($retries, AbstractTransferEvent $event) use ($headerName, $logger) { $delay = self::getRetryDelay($retries, $event, $headerName); $errData = [ "http_code" => !empty($event->getTransferInfo()['http_code']) ? $event->getTransferInfo()['http_code'] : null, "body" => is_null($event->getResponse()) ? null : (string) $event->getResponse()->getBody(), "url" => !empty($event->getTransferInfo()['url']) ? $event->getTransferInfo()['url'] : $event->getRequest()->getUrl(), ]; if ($event instanceof ErrorEvent) { $errData["message"] = $event->getException()->getMessage(); } $logger->debug("Http request failed, retrying in {$delay}s", $errData); // ms > s return 1000 * $delay; } ]); }
php
private static function createBackoff(array $options, LoggerInterface $logger) { $headerName = isset($options['http']['retryHeader']) ? $options['http']['retryHeader'] : 'Retry-After'; $httpRetryCodes = isset($options['http']['codes']) ? $options['http']['codes'] : [500, 502, 503, 504, 408, 420, 429]; $maxRetries = isset($options['maxRetries']) ? (int) $options['maxRetries']: 10; $curlRetryCodes = isset($options['curl']['codes']) ? $options['curl']['codes'] : [ CURLE_OPERATION_TIMEOUTED, CURLE_COULDNT_RESOLVE_HOST, CURLE_COULDNT_CONNECT, CURLE_SSL_CONNECT_ERROR, CURLE_GOT_NOTHING, CURLE_RECV_ERROR ]; return new RetrySubscriber([ 'filter' => RetrySubscriber::createChainFilter([ RetrySubscriber::createStatusFilter($httpRetryCodes), RetrySubscriber::createCurlFilter($curlRetryCodes) ]), 'max' => $maxRetries, 'delay' => function ($retries, AbstractTransferEvent $event) use ($headerName, $logger) { $delay = self::getRetryDelay($retries, $event, $headerName); $errData = [ "http_code" => !empty($event->getTransferInfo()['http_code']) ? $event->getTransferInfo()['http_code'] : null, "body" => is_null($event->getResponse()) ? null : (string) $event->getResponse()->getBody(), "url" => !empty($event->getTransferInfo()['url']) ? $event->getTransferInfo()['url'] : $event->getRequest()->getUrl(), ]; if ($event instanceof ErrorEvent) { $errData["message"] = $event->getException()->getMessage(); } $logger->debug("Http request failed, retrying in {$delay}s", $errData); // ms > s return 1000 * $delay; } ]); }
[ "private", "static", "function", "createBackoff", "(", "array", "$", "options", ",", "LoggerInterface", "$", "logger", ")", "{", "$", "headerName", "=", "isset", "(", "$", "options", "[", "'http'", "]", "[", "'retryHeader'", "]", ")", "?", "$", "options", "[", "'http'", "]", "[", "'retryHeader'", "]", ":", "'Retry-After'", ";", "$", "httpRetryCodes", "=", "isset", "(", "$", "options", "[", "'http'", "]", "[", "'codes'", "]", ")", "?", "$", "options", "[", "'http'", "]", "[", "'codes'", "]", ":", "[", "500", ",", "502", ",", "503", ",", "504", ",", "408", ",", "420", ",", "429", "]", ";", "$", "maxRetries", "=", "isset", "(", "$", "options", "[", "'maxRetries'", "]", ")", "?", "(", "int", ")", "$", "options", "[", "'maxRetries'", "]", ":", "10", ";", "$", "curlRetryCodes", "=", "isset", "(", "$", "options", "[", "'curl'", "]", "[", "'codes'", "]", ")", "?", "$", "options", "[", "'curl'", "]", "[", "'codes'", "]", ":", "[", "CURLE_OPERATION_TIMEOUTED", ",", "CURLE_COULDNT_RESOLVE_HOST", ",", "CURLE_COULDNT_CONNECT", ",", "CURLE_SSL_CONNECT_ERROR", ",", "CURLE_GOT_NOTHING", ",", "CURLE_RECV_ERROR", "]", ";", "return", "new", "RetrySubscriber", "(", "[", "'filter'", "=>", "RetrySubscriber", "::", "createChainFilter", "(", "[", "RetrySubscriber", "::", "createStatusFilter", "(", "$", "httpRetryCodes", ")", ",", "RetrySubscriber", "::", "createCurlFilter", "(", "$", "curlRetryCodes", ")", "]", ")", ",", "'max'", "=>", "$", "maxRetries", ",", "'delay'", "=>", "function", "(", "$", "retries", ",", "AbstractTransferEvent", "$", "event", ")", "use", "(", "$", "headerName", ",", "$", "logger", ")", "{", "$", "delay", "=", "self", "::", "getRetryDelay", "(", "$", "retries", ",", "$", "event", ",", "$", "headerName", ")", ";", "$", "errData", "=", "[", "\"http_code\"", "=>", "!", "empty", "(", "$", "event", "->", "getTransferInfo", "(", ")", "[", "'http_code'", "]", ")", "?", "$", "event", "->", "getTransferInfo", "(", ")", "[", "'http_code'", "]", ":", "null", ",", "\"body\"", "=>", "is_null", "(", "$", "event", "->", "getResponse", "(", ")", ")", "?", "null", ":", "(", "string", ")", "$", "event", "->", "getResponse", "(", ")", "->", "getBody", "(", ")", ",", "\"url\"", "=>", "!", "empty", "(", "$", "event", "->", "getTransferInfo", "(", ")", "[", "'url'", "]", ")", "?", "$", "event", "->", "getTransferInfo", "(", ")", "[", "'url'", "]", ":", "$", "event", "->", "getRequest", "(", ")", "->", "getUrl", "(", ")", ",", "]", ";", "if", "(", "$", "event", "instanceof", "ErrorEvent", ")", "{", "$", "errData", "[", "\"message\"", "]", "=", "$", "event", "->", "getException", "(", ")", "->", "getMessage", "(", ")", ";", "}", "$", "logger", "->", "debug", "(", "\"Http request failed, retrying in {$delay}s\"", ",", "$", "errData", ")", ";", "// ms > s", "return", "1000", "*", "$", "delay", ";", "}", "]", ")", ";", "}" ]
Create exponential backoff for GuzzleClient options - maxRetries: (integer) max retries count - http - retryHeader (string) header containing retry time header - codes (array) list of status codes to retry on - curl - codes (array) list of error codes to retry on @param array $options @param LoggerInterface $logger @return RetrySubscriber
[ "Create", "exponential", "backoff", "for", "GuzzleClient" ]
780e7900ccd23082ed234cc2c51b279a4223e9f5
https://github.com/keboola/juicer/blob/780e7900ccd23082ed234cc2c51b279a4223e9f5/Client/RestClient.php#L268-L306
13,863
gorkalaucirica/HipchatAPIv2Client
Model/Webhook.php
Webhook.toJson
public function toJson() { $json = array(); $json['id'] = $this->id; $json['url'] = $this->url; $json['pattern'] = $this->pattern; $json['event'] = $this->event; $json['name'] = $this->name; $json['links'] = $this->links; return $json; }
php
public function toJson() { $json = array(); $json['id'] = $this->id; $json['url'] = $this->url; $json['pattern'] = $this->pattern; $json['event'] = $this->event; $json['name'] = $this->name; $json['links'] = $this->links; return $json; }
[ "public", "function", "toJson", "(", ")", "{", "$", "json", "=", "array", "(", ")", ";", "$", "json", "[", "'id'", "]", "=", "$", "this", "->", "id", ";", "$", "json", "[", "'url'", "]", "=", "$", "this", "->", "url", ";", "$", "json", "[", "'pattern'", "]", "=", "$", "this", "->", "pattern", ";", "$", "json", "[", "'event'", "]", "=", "$", "this", "->", "event", ";", "$", "json", "[", "'name'", "]", "=", "$", "this", "->", "name", ";", "$", "json", "[", "'links'", "]", "=", "$", "this", "->", "links", ";", "return", "$", "json", ";", "}" ]
Serializes Webhook object @return array
[ "Serializes", "Webhook", "object" ]
eef9c91d5efe5ae9cad27c503601ffff089c9547
https://github.com/gorkalaucirica/HipchatAPIv2Client/blob/eef9c91d5efe5ae9cad27c503601ffff089c9547/Model/Webhook.php#L79-L90
13,864
activecollab/user
src/UserInterface/FormatNameImplementation.php
FormatNameImplementation.formatName
public function formatName($format = UserInterface::NAME_FULL) { $first_name = $this->getFirstName(); $last_name = $this->getLastName(); if (empty($first_name) && empty($last_name)) { list($first_name, $last_name) = $this->getFirstAndLastNameFromEmail(); } if ($format == UserInterface::NAME_FULL) { return trim($first_name . ' ' . $last_name); } else { if ($format == UserInterface::NAME_SHORT_LAST_NAME) { return $this->getLastName() ? trim($this->getFirstName() . ' ' . mb_substr($this->getLastName(), 0, 1) . '.') : $this->getFirstName(); } elseif ($format == UserInterface::NAME_SHORT_FIRST_NAME) { return $this->getFirstName() ? trim(mb_substr($this->getFirstName(), 0, 1) . '.' . ' ' . $this->getLastName()) : $this->getLastName(); } else { return mb_substr($first_name, 0, 1) . mb_substr($last_name, 0, 1); } } }
php
public function formatName($format = UserInterface::NAME_FULL) { $first_name = $this->getFirstName(); $last_name = $this->getLastName(); if (empty($first_name) && empty($last_name)) { list($first_name, $last_name) = $this->getFirstAndLastNameFromEmail(); } if ($format == UserInterface::NAME_FULL) { return trim($first_name . ' ' . $last_name); } else { if ($format == UserInterface::NAME_SHORT_LAST_NAME) { return $this->getLastName() ? trim($this->getFirstName() . ' ' . mb_substr($this->getLastName(), 0, 1) . '.') : $this->getFirstName(); } elseif ($format == UserInterface::NAME_SHORT_FIRST_NAME) { return $this->getFirstName() ? trim(mb_substr($this->getFirstName(), 0, 1) . '.' . ' ' . $this->getLastName()) : $this->getLastName(); } else { return mb_substr($first_name, 0, 1) . mb_substr($last_name, 0, 1); } } }
[ "public", "function", "formatName", "(", "$", "format", "=", "UserInterface", "::", "NAME_FULL", ")", "{", "$", "first_name", "=", "$", "this", "->", "getFirstName", "(", ")", ";", "$", "last_name", "=", "$", "this", "->", "getLastName", "(", ")", ";", "if", "(", "empty", "(", "$", "first_name", ")", "&&", "empty", "(", "$", "last_name", ")", ")", "{", "list", "(", "$", "first_name", ",", "$", "last_name", ")", "=", "$", "this", "->", "getFirstAndLastNameFromEmail", "(", ")", ";", "}", "if", "(", "$", "format", "==", "UserInterface", "::", "NAME_FULL", ")", "{", "return", "trim", "(", "$", "first_name", ".", "' '", ".", "$", "last_name", ")", ";", "}", "else", "{", "if", "(", "$", "format", "==", "UserInterface", "::", "NAME_SHORT_LAST_NAME", ")", "{", "return", "$", "this", "->", "getLastName", "(", ")", "?", "trim", "(", "$", "this", "->", "getFirstName", "(", ")", ".", "' '", ".", "mb_substr", "(", "$", "this", "->", "getLastName", "(", ")", ",", "0", ",", "1", ")", ".", "'.'", ")", ":", "$", "this", "->", "getFirstName", "(", ")", ";", "}", "elseif", "(", "$", "format", "==", "UserInterface", "::", "NAME_SHORT_FIRST_NAME", ")", "{", "return", "$", "this", "->", "getFirstName", "(", ")", "?", "trim", "(", "mb_substr", "(", "$", "this", "->", "getFirstName", "(", ")", ",", "0", ",", "1", ")", ".", "'.'", ".", "' '", ".", "$", "this", "->", "getLastName", "(", ")", ")", ":", "$", "this", "->", "getLastName", "(", ")", ";", "}", "else", "{", "return", "mb_substr", "(", "$", "first_name", ",", "0", ",", "1", ")", ".", "mb_substr", "(", "$", "last_name", ",", "0", ",", "1", ")", ";", "}", "}", "}" ]
Return display name of this user. @param string $format @return string
[ "Return", "display", "name", "of", "this", "user", "." ]
f54b858eb9016fbca32090e624eccb0354e93d8f
https://github.com/activecollab/user/blob/f54b858eb9016fbca32090e624eccb0354e93d8f/src/UserInterface/FormatNameImplementation.php#L24-L44
13,865
activecollab/user
src/UserInterface/FormatNameImplementation.php
FormatNameImplementation.getFirstAndLastNameFromEmail
public function getFirstAndLastNameFromEmail() { $exploded_full_name = explode(' ', str_replace(['.', '-', '_'], [' ', ' ', ' '], substr($this->getEmail(), 0, strpos($this->getEmail(), '@')))); if (count($exploded_full_name) === 1) { $first_name = mb_strtoupper(mb_substr($exploded_full_name[0], 0, 1)) . mb_substr($exploded_full_name[0], 1); $last_name = ''; } else { $full_name = []; foreach ($exploded_full_name as $k) { $full_name[] = mb_strtoupper(mb_substr($k, 0, 1)) . mb_substr($k, 1); } $first_name = array_shift($full_name); $last_name = implode(' ', $full_name); } return [$first_name, $last_name]; }
php
public function getFirstAndLastNameFromEmail() { $exploded_full_name = explode(' ', str_replace(['.', '-', '_'], [' ', ' ', ' '], substr($this->getEmail(), 0, strpos($this->getEmail(), '@')))); if (count($exploded_full_name) === 1) { $first_name = mb_strtoupper(mb_substr($exploded_full_name[0], 0, 1)) . mb_substr($exploded_full_name[0], 1); $last_name = ''; } else { $full_name = []; foreach ($exploded_full_name as $k) { $full_name[] = mb_strtoupper(mb_substr($k, 0, 1)) . mb_substr($k, 1); } $first_name = array_shift($full_name); $last_name = implode(' ', $full_name); } return [$first_name, $last_name]; }
[ "public", "function", "getFirstAndLastNameFromEmail", "(", ")", "{", "$", "exploded_full_name", "=", "explode", "(", "' '", ",", "str_replace", "(", "[", "'.'", ",", "'-'", ",", "'_'", "]", ",", "[", "' '", ",", "' '", ",", "' '", "]", ",", "substr", "(", "$", "this", "->", "getEmail", "(", ")", ",", "0", ",", "strpos", "(", "$", "this", "->", "getEmail", "(", ")", ",", "'@'", ")", ")", ")", ")", ";", "if", "(", "count", "(", "$", "exploded_full_name", ")", "===", "1", ")", "{", "$", "first_name", "=", "mb_strtoupper", "(", "mb_substr", "(", "$", "exploded_full_name", "[", "0", "]", ",", "0", ",", "1", ")", ")", ".", "mb_substr", "(", "$", "exploded_full_name", "[", "0", "]", ",", "1", ")", ";", "$", "last_name", "=", "''", ";", "}", "else", "{", "$", "full_name", "=", "[", "]", ";", "foreach", "(", "$", "exploded_full_name", "as", "$", "k", ")", "{", "$", "full_name", "[", "]", "=", "mb_strtoupper", "(", "mb_substr", "(", "$", "k", ",", "0", ",", "1", ")", ")", ".", "mb_substr", "(", "$", "k", ",", "1", ")", ";", "}", "$", "first_name", "=", "array_shift", "(", "$", "full_name", ")", ";", "$", "last_name", "=", "implode", "(", "' '", ",", "$", "full_name", ")", ";", "}", "return", "[", "$", "first_name", ",", "$", "last_name", "]", ";", "}" ]
Try to get first and last name from email address. @return array
[ "Try", "to", "get", "first", "and", "last", "name", "from", "email", "address", "." ]
f54b858eb9016fbca32090e624eccb0354e93d8f
https://github.com/activecollab/user/blob/f54b858eb9016fbca32090e624eccb0354e93d8f/src/UserInterface/FormatNameImplementation.php#L51-L70
13,866
transfer-framework/transfer
src/Transfer/Console/Command/Manifest/DescribeCommand.php
DescribeCommand.describeManifest
private function describeManifest(ManifestInterface $manifest, OutputInterface $output) { $builder = new ProcedureBuilder(); $manifest->configureProcedureBuilder($builder); $output->writeln(sprintf("Manifest description for <info>%s</info>\n", $manifest->getName())); $output->writeln("<fg=blue;options=bold>PROCEDURE CONFIGURATION</fg=blue;options=bold>\n"); $this->describeProcedure($builder->getProcedure(), $output); }
php
private function describeManifest(ManifestInterface $manifest, OutputInterface $output) { $builder = new ProcedureBuilder(); $manifest->configureProcedureBuilder($builder); $output->writeln(sprintf("Manifest description for <info>%s</info>\n", $manifest->getName())); $output->writeln("<fg=blue;options=bold>PROCEDURE CONFIGURATION</fg=blue;options=bold>\n"); $this->describeProcedure($builder->getProcedure(), $output); }
[ "private", "function", "describeManifest", "(", "ManifestInterface", "$", "manifest", ",", "OutputInterface", "$", "output", ")", "{", "$", "builder", "=", "new", "ProcedureBuilder", "(", ")", ";", "$", "manifest", "->", "configureProcedureBuilder", "(", "$", "builder", ")", ";", "$", "output", "->", "writeln", "(", "sprintf", "(", "\"Manifest description for <info>%s</info>\\n\"", ",", "$", "manifest", "->", "getName", "(", ")", ")", ")", ";", "$", "output", "->", "writeln", "(", "\"<fg=blue;options=bold>PROCEDURE CONFIGURATION</fg=blue;options=bold>\\n\"", ")", ";", "$", "this", "->", "describeProcedure", "(", "$", "builder", "->", "getProcedure", "(", ")", ",", "$", "output", ")", ";", "}" ]
Describes a manifest. @param ManifestInterface $manifest Manifest @param OutputInterface $output Output
[ "Describes", "a", "manifest", "." ]
9225ae068d5924982f14ad4446b15f75384a058a
https://github.com/transfer-framework/transfer/blob/9225ae068d5924982f14ad4446b15f75384a058a/src/Transfer/Console/Command/Manifest/DescribeCommand.php#L60-L69
13,867
transfer-framework/transfer
src/Transfer/Console/Command/Manifest/DescribeCommand.php
DescribeCommand.describeProcedure
private function describeProcedure(Procedure $procedure, OutputInterface $output, $depth = 0) { $output->writeln(sprintf('%sProcedure <info>%s</info>', str_repeat(' ', $depth), $procedure->getName())); $this->describeComponents($procedure->getSources(), 'SOURCES', $output, $depth); $this->describeComponents($procedure->getWorkers(), 'WORKERS', $output, $depth); $this->describeComponents($procedure->getTargets(), 'TARGETS', $output, $depth); $this->describeChildProcedures($procedure->getChildren(), $output, $depth); $output->write("\n"); }
php
private function describeProcedure(Procedure $procedure, OutputInterface $output, $depth = 0) { $output->writeln(sprintf('%sProcedure <info>%s</info>', str_repeat(' ', $depth), $procedure->getName())); $this->describeComponents($procedure->getSources(), 'SOURCES', $output, $depth); $this->describeComponents($procedure->getWorkers(), 'WORKERS', $output, $depth); $this->describeComponents($procedure->getTargets(), 'TARGETS', $output, $depth); $this->describeChildProcedures($procedure->getChildren(), $output, $depth); $output->write("\n"); }
[ "private", "function", "describeProcedure", "(", "Procedure", "$", "procedure", ",", "OutputInterface", "$", "output", ",", "$", "depth", "=", "0", ")", "{", "$", "output", "->", "writeln", "(", "sprintf", "(", "'%sProcedure <info>%s</info>'", ",", "str_repeat", "(", "' '", ",", "$", "depth", ")", ",", "$", "procedure", "->", "getName", "(", ")", ")", ")", ";", "$", "this", "->", "describeComponents", "(", "$", "procedure", "->", "getSources", "(", ")", ",", "'SOURCES'", ",", "$", "output", ",", "$", "depth", ")", ";", "$", "this", "->", "describeComponents", "(", "$", "procedure", "->", "getWorkers", "(", ")", ",", "'WORKERS'", ",", "$", "output", ",", "$", "depth", ")", ";", "$", "this", "->", "describeComponents", "(", "$", "procedure", "->", "getTargets", "(", ")", ",", "'TARGETS'", ",", "$", "output", ",", "$", "depth", ")", ";", "$", "this", "->", "describeChildProcedures", "(", "$", "procedure", "->", "getChildren", "(", ")", ",", "$", "output", ",", "$", "depth", ")", ";", "$", "output", "->", "write", "(", "\"\\n\"", ")", ";", "}" ]
Describes a procedure. @param Procedure $procedure Procedure @param OutputInterface $output Console output handle @param int $depth Current depth
[ "Describes", "a", "procedure", "." ]
9225ae068d5924982f14ad4446b15f75384a058a
https://github.com/transfer-framework/transfer/blob/9225ae068d5924982f14ad4446b15f75384a058a/src/Transfer/Console/Command/Manifest/DescribeCommand.php#L78-L88
13,868
transfer-framework/transfer
src/Transfer/Console/Command/Manifest/DescribeCommand.php
DescribeCommand.describeChildProcedures
private function describeChildProcedures($children, $output, $depth) { if (is_array($children)) { $output->writeln(sprintf('%s<comment>SUB-PROCEDURES</comment>', str_repeat(' ', $depth))); foreach ($children as $child) { $this->describeProcedure($child, $output, $depth + 2); $output->writeln(''); } } }
php
private function describeChildProcedures($children, $output, $depth) { if (is_array($children)) { $output->writeln(sprintf('%s<comment>SUB-PROCEDURES</comment>', str_repeat(' ', $depth))); foreach ($children as $child) { $this->describeProcedure($child, $output, $depth + 2); $output->writeln(''); } } }
[ "private", "function", "describeChildProcedures", "(", "$", "children", ",", "$", "output", ",", "$", "depth", ")", "{", "if", "(", "is_array", "(", "$", "children", ")", ")", "{", "$", "output", "->", "writeln", "(", "sprintf", "(", "'%s<comment>SUB-PROCEDURES</comment>'", ",", "str_repeat", "(", "' '", ",", "$", "depth", ")", ")", ")", ";", "foreach", "(", "$", "children", "as", "$", "child", ")", "{", "$", "this", "->", "describeProcedure", "(", "$", "child", ",", "$", "output", ",", "$", "depth", "+", "2", ")", ";", "$", "output", "->", "writeln", "(", "''", ")", ";", "}", "}", "}" ]
Describes child procedures. @param array $children Procedure children @param OutputInterface $output Console output handle @param int $depth Current depth
[ "Describes", "child", "procedures", "." ]
9225ae068d5924982f14ad4446b15f75384a058a
https://github.com/transfer-framework/transfer/blob/9225ae068d5924982f14ad4446b15f75384a058a/src/Transfer/Console/Command/Manifest/DescribeCommand.php#L97-L107
13,869
transfer-framework/transfer
src/Transfer/Console/Command/Manifest/DescribeCommand.php
DescribeCommand.describeComponents
private function describeComponents($components, $name, OutputInterface $output, $depth = 0) { if (is_array($components)) { $output->writeln(sprintf('%s<comment>%s</comment>', str_repeat(' ', $depth), $name)); foreach ($components as $component) { $output->writeln(sprintf( '%s%s', str_repeat(' ', $depth + 4), is_object($component) ? get_class($component) : get_class($component[0]) )); } } }
php
private function describeComponents($components, $name, OutputInterface $output, $depth = 0) { if (is_array($components)) { $output->writeln(sprintf('%s<comment>%s</comment>', str_repeat(' ', $depth), $name)); foreach ($components as $component) { $output->writeln(sprintf( '%s%s', str_repeat(' ', $depth + 4), is_object($component) ? get_class($component) : get_class($component[0]) )); } } }
[ "private", "function", "describeComponents", "(", "$", "components", ",", "$", "name", ",", "OutputInterface", "$", "output", ",", "$", "depth", "=", "0", ")", "{", "if", "(", "is_array", "(", "$", "components", ")", ")", "{", "$", "output", "->", "writeln", "(", "sprintf", "(", "'%s<comment>%s</comment>'", ",", "str_repeat", "(", "' '", ",", "$", "depth", ")", ",", "$", "name", ")", ")", ";", "foreach", "(", "$", "components", "as", "$", "component", ")", "{", "$", "output", "->", "writeln", "(", "sprintf", "(", "'%s%s'", ",", "str_repeat", "(", "' '", ",", "$", "depth", "+", "4", ")", ",", "is_object", "(", "$", "component", ")", "?", "get_class", "(", "$", "component", ")", ":", "get_class", "(", "$", "component", "[", "0", "]", ")", ")", ")", ";", "}", "}", "}" ]
Describes components. @param array $components Components @param string $name Component type @param OutputInterface $output Console output handle @param int $depth Current depth
[ "Describes", "components", "." ]
9225ae068d5924982f14ad4446b15f75384a058a
https://github.com/transfer-framework/transfer/blob/9225ae068d5924982f14ad4446b15f75384a058a/src/Transfer/Console/Command/Manifest/DescribeCommand.php#L117-L130
13,870
nyeholt/silverstripe-simplewiki
code/formatters/SimpleWikiFormatter.php
SimpleWikiFormatter.analyseSavedContent
public function analyseSavedContent($wikiPage) { $newPages = $this->parseNewPagesFrom($wikiPage->Content); foreach ($newPages as $pageTitle) { $trimmedTitle = trim($pageTitle); // need to trim the title before doing the search $page = DataObject::get_one('WikiPage', '"SiteTree"."Title" = \'' . Convert::raw2sql($trimmedTitle) . '\''); if (!$page) { // it's a new page, so create that $page = new WikiPage(); $page->Title = $trimmedTitle; $page->MenuTitle = $trimmedTitle; $page->ParentID = $wikiPage->ID; $page->write(); // publish if we're on autopublish if (WikiPage::$auto_publish) { $page->doPublish(); } } $replacement = '<a href="[sitetree_link id=' . $page->ID . ']">' . $pageTitle . '</a>'; $wikiPage->Content = str_replace('[[' . $pageTitle . ']]', $replacement, $wikiPage->Content); } }
php
public function analyseSavedContent($wikiPage) { $newPages = $this->parseNewPagesFrom($wikiPage->Content); foreach ($newPages as $pageTitle) { $trimmedTitle = trim($pageTitle); // need to trim the title before doing the search $page = DataObject::get_one('WikiPage', '"SiteTree"."Title" = \'' . Convert::raw2sql($trimmedTitle) . '\''); if (!$page) { // it's a new page, so create that $page = new WikiPage(); $page->Title = $trimmedTitle; $page->MenuTitle = $trimmedTitle; $page->ParentID = $wikiPage->ID; $page->write(); // publish if we're on autopublish if (WikiPage::$auto_publish) { $page->doPublish(); } } $replacement = '<a href="[sitetree_link id=' . $page->ID . ']">' . $pageTitle . '</a>'; $wikiPage->Content = str_replace('[[' . $pageTitle . ']]', $replacement, $wikiPage->Content); } }
[ "public", "function", "analyseSavedContent", "(", "$", "wikiPage", ")", "{", "$", "newPages", "=", "$", "this", "->", "parseNewPagesFrom", "(", "$", "wikiPage", "->", "Content", ")", ";", "foreach", "(", "$", "newPages", "as", "$", "pageTitle", ")", "{", "$", "trimmedTitle", "=", "trim", "(", "$", "pageTitle", ")", ";", "// need to trim the title before doing the search", "$", "page", "=", "DataObject", "::", "get_one", "(", "'WikiPage'", ",", "'\"SiteTree\".\"Title\" = \\''", ".", "Convert", "::", "raw2sql", "(", "$", "trimmedTitle", ")", ".", "'\\''", ")", ";", "if", "(", "!", "$", "page", ")", "{", "// it's a new page, so create that", "$", "page", "=", "new", "WikiPage", "(", ")", ";", "$", "page", "->", "Title", "=", "$", "trimmedTitle", ";", "$", "page", "->", "MenuTitle", "=", "$", "trimmedTitle", ";", "$", "page", "->", "ParentID", "=", "$", "wikiPage", "->", "ID", ";", "$", "page", "->", "write", "(", ")", ";", "// publish if we're on autopublish", "if", "(", "WikiPage", "::", "$", "auto_publish", ")", "{", "$", "page", "->", "doPublish", "(", ")", ";", "}", "}", "$", "replacement", "=", "'<a href=\"[sitetree_link id='", ".", "$", "page", "->", "ID", ".", "']\">'", ".", "$", "pageTitle", ".", "'</a>'", ";", "$", "wikiPage", "->", "Content", "=", "str_replace", "(", "'[['", ".", "$", "pageTitle", ".", "']]'", ",", "$", "replacement", ",", "$", "wikiPage", "->", "Content", ")", ";", "}", "}" ]
Analyse content just after it's saved. This is useful for creating new pages etc where referenced by particular formatting
[ "Analyse", "content", "just", "after", "it", "s", "saved", ".", "This", "is", "useful", "for", "creating", "new", "pages", "etc", "where", "referenced", "by", "particular", "formatting" ]
ecffed0d75be1454901e1cb24633472b8f67c967
https://github.com/nyeholt/silverstripe-simplewiki/blob/ecffed0d75be1454901e1cb24633472b8f67c967/code/formatters/SimpleWikiFormatter.php#L14-L40
13,871
nyeholt/silverstripe-simplewiki
code/formatters/SimpleWikiFormatter.php
SimpleWikiFormatter.parseNewPagesFrom
public function parseNewPagesFrom($content) { $pages = array(); if (preg_match_all('/\[\[([\w\s_.-]+)\]\]/', $content, $matches)) { // exit(print_r($matches)); foreach ($matches[1] as $pageTitle) { $pages[] = $pageTitle; } } return $pages; }
php
public function parseNewPagesFrom($content) { $pages = array(); if (preg_match_all('/\[\[([\w\s_.-]+)\]\]/', $content, $matches)) { // exit(print_r($matches)); foreach ($matches[1] as $pageTitle) { $pages[] = $pageTitle; } } return $pages; }
[ "public", "function", "parseNewPagesFrom", "(", "$", "content", ")", "{", "$", "pages", "=", "array", "(", ")", ";", "if", "(", "preg_match_all", "(", "'/\\[\\[([\\w\\s_.-]+)\\]\\]/'", ",", "$", "content", ",", "$", "matches", ")", ")", "{", "// exit(print_r($matches));", "foreach", "(", "$", "matches", "[", "1", "]", "as", "$", "pageTitle", ")", "{", "$", "pages", "[", "]", "=", "$", "pageTitle", ";", "}", "}", "return", "$", "pages", ";", "}" ]
Separated into a separate method for testing @param String $content @return array
[ "Separated", "into", "a", "separate", "method", "for", "testing" ]
ecffed0d75be1454901e1cb24633472b8f67c967
https://github.com/nyeholt/silverstripe-simplewiki/blob/ecffed0d75be1454901e1cb24633472b8f67c967/code/formatters/SimpleWikiFormatter.php#L49-L59
13,872
sebastiansulinski/laravel-pagination
src/Pagination/Select.php
Select.getSelect
protected function getSelect() { $html = '<select>'; if (is_array($this->window['all'])) { $html .= $this->getOptionLinks($this->window['all']); } $html .= '</select>'; return $html; }
php
protected function getSelect() { $html = '<select>'; if (is_array($this->window['all'])) { $html .= $this->getOptionLinks($this->window['all']); } $html .= '</select>'; return $html; }
[ "protected", "function", "getSelect", "(", ")", "{", "$", "html", "=", "'<select>'", ";", "if", "(", "is_array", "(", "$", "this", "->", "window", "[", "'all'", "]", ")", ")", "{", "$", "html", ".=", "$", "this", "->", "getOptionLinks", "(", "$", "this", "->", "window", "[", "'all'", "]", ")", ";", "}", "$", "html", ".=", "'</select>'", ";", "return", "$", "html", ";", "}" ]
Get the select tag with options for the URLs in the given array. @return string
[ "Get", "the", "select", "tag", "with", "options", "for", "the", "URLs", "in", "the", "given", "array", "." ]
fdd1e6e437c908ce360e72c1f99eb0142a35e8f2
https://github.com/sebastiansulinski/laravel-pagination/blob/fdd1e6e437c908ce360e72c1f99eb0142a35e8f2/src/Pagination/Select.php#L106-L117
13,873
sebastiansulinski/laravel-pagination
src/Pagination/Select.php
Select.getOptionLinks
protected function getOptionLinks(array $urls) { $html = ''; foreach ($urls as $page => $url) { $html .= $this->getOption($url, $page); } return $html; }
php
protected function getOptionLinks(array $urls) { $html = ''; foreach ($urls as $page => $url) { $html .= $this->getOption($url, $page); } return $html; }
[ "protected", "function", "getOptionLinks", "(", "array", "$", "urls", ")", "{", "$", "html", "=", "''", ";", "foreach", "(", "$", "urls", "as", "$", "page", "=>", "$", "url", ")", "{", "$", "html", ".=", "$", "this", "->", "getOption", "(", "$", "url", ",", "$", "page", ")", ";", "}", "return", "$", "html", ";", "}" ]
Get option tags with links for the URLs in the given array. @param array $urls @return string
[ "Get", "option", "tags", "with", "links", "for", "the", "URLs", "in", "the", "given", "array", "." ]
fdd1e6e437c908ce360e72c1f99eb0142a35e8f2
https://github.com/sebastiansulinski/laravel-pagination/blob/fdd1e6e437c908ce360e72c1f99eb0142a35e8f2/src/Pagination/Select.php#L125-L134
13,874
sebastiansulinski/laravel-pagination
src/Pagination/Select.php
Select.getOption
protected function getOption($url, $page) { if ($page == $this->paginator->currentPage()) { return $this->getActiveOption($page); } return $this->getAvailableOption($url, $page); }
php
protected function getOption($url, $page) { if ($page == $this->paginator->currentPage()) { return $this->getActiveOption($page); } return $this->getAvailableOption($url, $page); }
[ "protected", "function", "getOption", "(", "$", "url", ",", "$", "page", ")", "{", "if", "(", "$", "page", "==", "$", "this", "->", "paginator", "->", "currentPage", "(", ")", ")", "{", "return", "$", "this", "->", "getActiveOption", "(", "$", "page", ")", ";", "}", "return", "$", "this", "->", "getAvailableOption", "(", "$", "url", ",", "$", "page", ")", ";", "}" ]
Get html option tag. @param string $url @param int $page @return string
[ "Get", "html", "option", "tag", "." ]
fdd1e6e437c908ce360e72c1f99eb0142a35e8f2
https://github.com/sebastiansulinski/laravel-pagination/blob/fdd1e6e437c908ce360e72c1f99eb0142a35e8f2/src/Pagination/Select.php#L143-L150
13,875
ptlis/conneg
src/Parser/FieldParser.php
FieldParser.parseBundle
private function parseBundle(array $tokenBundle, $serverField, $fromField) { $pref = null; try { list($variantTokenList, $paramTokenList) = $this->splitVariantAndParamTokens($tokenBundle, $fromField); $paramBundleList = $this->bundleTokens($paramTokenList, Tokens::PARAMS_SEPARATOR); $this->validateParamBundleList($paramBundleList, $serverField); $pref = $this->createPreference($variantTokenList, $paramBundleList, $serverField, $fromField); } catch (InvalidVariantException $e) { if ($serverField) { throw $e; } } return $pref; }
php
private function parseBundle(array $tokenBundle, $serverField, $fromField) { $pref = null; try { list($variantTokenList, $paramTokenList) = $this->splitVariantAndParamTokens($tokenBundle, $fromField); $paramBundleList = $this->bundleTokens($paramTokenList, Tokens::PARAMS_SEPARATOR); $this->validateParamBundleList($paramBundleList, $serverField); $pref = $this->createPreference($variantTokenList, $paramBundleList, $serverField, $fromField); } catch (InvalidVariantException $e) { if ($serverField) { throw $e; } } return $pref; }
[ "private", "function", "parseBundle", "(", "array", "$", "tokenBundle", ",", "$", "serverField", ",", "$", "fromField", ")", "{", "$", "pref", "=", "null", ";", "try", "{", "list", "(", "$", "variantTokenList", ",", "$", "paramTokenList", ")", "=", "$", "this", "->", "splitVariantAndParamTokens", "(", "$", "tokenBundle", ",", "$", "fromField", ")", ";", "$", "paramBundleList", "=", "$", "this", "->", "bundleTokens", "(", "$", "paramTokenList", ",", "Tokens", "::", "PARAMS_SEPARATOR", ")", ";", "$", "this", "->", "validateParamBundleList", "(", "$", "paramBundleList", ",", "$", "serverField", ")", ";", "$", "pref", "=", "$", "this", "->", "createPreference", "(", "$", "variantTokenList", ",", "$", "paramBundleList", ",", "$", "serverField", ",", "$", "fromField", ")", ";", "}", "catch", "(", "InvalidVariantException", "$", "e", ")", "{", "if", "(", "$", "serverField", ")", "{", "throw", "$", "e", ";", "}", "}", "return", "$", "pref", ";", "}" ]
Accepts tokens for a single variant and returns the Preference value object encapsulating that data. @throws InvalidVariantException @param array<string> $tokenBundle @param bool $serverField @param string $fromField @return null|PreferenceInterface
[ "Accepts", "tokens", "for", "a", "single", "variant", "and", "returns", "the", "Preference", "value", "object", "encapsulating", "that", "data", "." ]
04afb568f368ecdd81c13277006c4be041ccb58b
https://github.com/ptlis/conneg/blob/04afb568f368ecdd81c13277006c4be041ccb58b/src/Parser/FieldParser.php#L81-L99
13,876
ptlis/conneg
src/Parser/FieldParser.php
FieldParser.splitVariantAndParamTokens
private function splitVariantAndParamTokens(array $tokenBundle, $fromField) { if (PreferenceInterface::MIME === $fromField) { $this->validateBundleMimeVariant($tokenBundle); $variantTokenList = array_slice($tokenBundle, 0, 3); $paramTokenList = array_slice($tokenBundle, 3); } else { $variantTokenList = array_slice($tokenBundle, 0, 1); $paramTokenList = array_slice($tokenBundle, 1); } return array($variantTokenList, $paramTokenList); }
php
private function splitVariantAndParamTokens(array $tokenBundle, $fromField) { if (PreferenceInterface::MIME === $fromField) { $this->validateBundleMimeVariant($tokenBundle); $variantTokenList = array_slice($tokenBundle, 0, 3); $paramTokenList = array_slice($tokenBundle, 3); } else { $variantTokenList = array_slice($tokenBundle, 0, 1); $paramTokenList = array_slice($tokenBundle, 1); } return array($variantTokenList, $paramTokenList); }
[ "private", "function", "splitVariantAndParamTokens", "(", "array", "$", "tokenBundle", ",", "$", "fromField", ")", "{", "if", "(", "PreferenceInterface", "::", "MIME", "===", "$", "fromField", ")", "{", "$", "this", "->", "validateBundleMimeVariant", "(", "$", "tokenBundle", ")", ";", "$", "variantTokenList", "=", "array_slice", "(", "$", "tokenBundle", ",", "0", ",", "3", ")", ";", "$", "paramTokenList", "=", "array_slice", "(", "$", "tokenBundle", ",", "3", ")", ";", "}", "else", "{", "$", "variantTokenList", "=", "array_slice", "(", "$", "tokenBundle", ",", "0", ",", "1", ")", ";", "$", "paramTokenList", "=", "array_slice", "(", "$", "tokenBundle", ",", "1", ")", ";", "}", "return", "array", "(", "$", "variantTokenList", ",", "$", "paramTokenList", ")", ";", "}" ]
Splits the token list into variant & parameter arrays. @throws InvalidVariantException @param array<string> $tokenBundle @param string $fromField @return string[][]
[ "Splits", "the", "token", "list", "into", "variant", "&", "parameter", "arrays", "." ]
04afb568f368ecdd81c13277006c4be041ccb58b
https://github.com/ptlis/conneg/blob/04afb568f368ecdd81c13277006c4be041ccb58b/src/Parser/FieldParser.php#L111-L123
13,877
ptlis/conneg
src/Parser/FieldParser.php
FieldParser.createPreference
private function createPreference(array $variantTokenList, array $paramBundleList, $serverField, $fromField) { $builder = $this->getBuilder($fromField) ->setFromField($fromField) ->setFromServer($serverField) ->setVariant(implode('', $variantTokenList)); // Look for quality factor, discarding accept-extens foreach ($paramBundleList as $paramBundle) { // Correct format for quality factor if ($this->isQualityFactor($paramBundle)) { $builder = $builder->setQualityFactor($paramBundle[2]); break; } } return $builder->get(); }
php
private function createPreference(array $variantTokenList, array $paramBundleList, $serverField, $fromField) { $builder = $this->getBuilder($fromField) ->setFromField($fromField) ->setFromServer($serverField) ->setVariant(implode('', $variantTokenList)); // Look for quality factor, discarding accept-extens foreach ($paramBundleList as $paramBundle) { // Correct format for quality factor if ($this->isQualityFactor($paramBundle)) { $builder = $builder->setQualityFactor($paramBundle[2]); break; } } return $builder->get(); }
[ "private", "function", "createPreference", "(", "array", "$", "variantTokenList", ",", "array", "$", "paramBundleList", ",", "$", "serverField", ",", "$", "fromField", ")", "{", "$", "builder", "=", "$", "this", "->", "getBuilder", "(", "$", "fromField", ")", "->", "setFromField", "(", "$", "fromField", ")", "->", "setFromServer", "(", "$", "serverField", ")", "->", "setVariant", "(", "implode", "(", "''", ",", "$", "variantTokenList", ")", ")", ";", "// Look for quality factor, discarding accept-extens", "foreach", "(", "$", "paramBundleList", "as", "$", "paramBundle", ")", "{", "// Correct format for quality factor", "if", "(", "$", "this", "->", "isQualityFactor", "(", "$", "paramBundle", ")", ")", "{", "$", "builder", "=", "$", "builder", "->", "setQualityFactor", "(", "$", "paramBundle", "[", "2", "]", ")", ";", "break", ";", "}", "}", "return", "$", "builder", "->", "get", "(", ")", ";", "}" ]
Accepts the bundled tokens for variant & parameter data and builds the Preference value object. @param array<string> $variantTokenList @param array<array<string>> $paramBundleList @param bool $serverField @param string $fromField @return PreferenceInterface
[ "Accepts", "the", "bundled", "tokens", "for", "variant", "&", "parameter", "data", "and", "builds", "the", "Preference", "value", "object", "." ]
04afb568f368ecdd81c13277006c4be041ccb58b
https://github.com/ptlis/conneg/blob/04afb568f368ecdd81c13277006c4be041ccb58b/src/Parser/FieldParser.php#L135-L152
13,878
ptlis/conneg
src/Parser/FieldParser.php
FieldParser.bundleTokens
private function bundleTokens(array $tokenList, $targetToken) { $bundleList = array(); $bundle = array(); foreach ($tokenList as $token) { // On token match add the bundle to list & re-initialize empty bundle if ($targetToken === $token) { $bundleList[] = $bundle; $bundle = array(); // Otherwise collect tokens } else { $bundle[] = $token; } } // Handle trailing type $bundleList[] = $bundle; // Remove empty types $bundleList = array_filter($bundleList); return $bundleList; }
php
private function bundleTokens(array $tokenList, $targetToken) { $bundleList = array(); $bundle = array(); foreach ($tokenList as $token) { // On token match add the bundle to list & re-initialize empty bundle if ($targetToken === $token) { $bundleList[] = $bundle; $bundle = array(); // Otherwise collect tokens } else { $bundle[] = $token; } } // Handle trailing type $bundleList[] = $bundle; // Remove empty types $bundleList = array_filter($bundleList); return $bundleList; }
[ "private", "function", "bundleTokens", "(", "array", "$", "tokenList", ",", "$", "targetToken", ")", "{", "$", "bundleList", "=", "array", "(", ")", ";", "$", "bundle", "=", "array", "(", ")", ";", "foreach", "(", "$", "tokenList", "as", "$", "token", ")", "{", "// On token match add the bundle to list & re-initialize empty bundle", "if", "(", "$", "targetToken", "===", "$", "token", ")", "{", "$", "bundleList", "[", "]", "=", "$", "bundle", ";", "$", "bundle", "=", "array", "(", ")", ";", "// Otherwise collect tokens", "}", "else", "{", "$", "bundle", "[", "]", "=", "$", "token", ";", "}", "}", "// Handle trailing type", "$", "bundleList", "[", "]", "=", "$", "bundle", ";", "// Remove empty types", "$", "bundleList", "=", "array_filter", "(", "$", "bundleList", ")", ";", "return", "$", "bundleList", ";", "}" ]
Splits token list up into one bundle per variant for later processing. @param array<string> $tokenList @param string $targetToken The token to split the list up by. @return array<array<string>> an array of arrays - the child array contains the tokens for a single variant.
[ "Splits", "token", "list", "up", "into", "one", "bundle", "per", "variant", "for", "later", "processing", "." ]
04afb568f368ecdd81c13277006c4be041ccb58b
https://github.com/ptlis/conneg/blob/04afb568f368ecdd81c13277006c4be041ccb58b/src/Parser/FieldParser.php#L176-L200
13,879
ptlis/conneg
src/Parser/FieldParser.php
FieldParser.validateBundleMimeVariant
private function validateBundleMimeVariant(array $bundle) { if (count($bundle) < 3 // Too few items in bundle || Tokens::MIME_SEPARATOR !== $bundle[1] // Invalid separator || Tokens::isSeparator($bundle[0], true) // Invalid type || Tokens::isSeparator($bundle[2], true) // Invalid subtype ) { throw new InvalidVariantException( '"' . implode('', $bundle) . '" is not a valid mime type' ); } }
php
private function validateBundleMimeVariant(array $bundle) { if (count($bundle) < 3 // Too few items in bundle || Tokens::MIME_SEPARATOR !== $bundle[1] // Invalid separator || Tokens::isSeparator($bundle[0], true) // Invalid type || Tokens::isSeparator($bundle[2], true) // Invalid subtype ) { throw new InvalidVariantException( '"' . implode('', $bundle) . '" is not a valid mime type' ); } }
[ "private", "function", "validateBundleMimeVariant", "(", "array", "$", "bundle", ")", "{", "if", "(", "count", "(", "$", "bundle", ")", "<", "3", "// Too few items in bundle", "||", "Tokens", "::", "MIME_SEPARATOR", "!==", "$", "bundle", "[", "1", "]", "// Invalid separator", "||", "Tokens", "::", "isSeparator", "(", "$", "bundle", "[", "0", "]", ",", "true", ")", "// Invalid type", "||", "Tokens", "::", "isSeparator", "(", "$", "bundle", "[", "2", "]", ",", "true", ")", "// Invalid subtype", ")", "{", "throw", "new", "InvalidVariantException", "(", "'\"'", ".", "implode", "(", "''", ",", "$", "bundle", ")", ".", "'\" is not a valid mime type'", ")", ";", "}", "}" ]
Checks to see if the bundle is valid for a mime type, if an anomaly is detected then an exception is thrown. @throws InvalidVariantException @param array<string> $bundle
[ "Checks", "to", "see", "if", "the", "bundle", "is", "valid", "for", "a", "mime", "type", "if", "an", "anomaly", "is", "detected", "then", "an", "exception", "is", "thrown", "." ]
04afb568f368ecdd81c13277006c4be041ccb58b
https://github.com/ptlis/conneg/blob/04afb568f368ecdd81c13277006c4be041ccb58b/src/Parser/FieldParser.php#L209-L220
13,880
ptlis/conneg
src/Parser/FieldParser.php
FieldParser.validateParamBundleList
private function validateParamBundleList(array $paramBundleList, $serverField) { foreach ($paramBundleList as $paramBundle) { try { $this->validateParamBundle($paramBundle); } catch (InvalidVariantException $e) { // Rethrow exception only if the field was provided by the server if ($serverField) { throw $e; } } } }
php
private function validateParamBundleList(array $paramBundleList, $serverField) { foreach ($paramBundleList as $paramBundle) { try { $this->validateParamBundle($paramBundle); } catch (InvalidVariantException $e) { // Rethrow exception only if the field was provided by the server if ($serverField) { throw $e; } } } }
[ "private", "function", "validateParamBundleList", "(", "array", "$", "paramBundleList", ",", "$", "serverField", ")", "{", "foreach", "(", "$", "paramBundleList", "as", "$", "paramBundle", ")", "{", "try", "{", "$", "this", "->", "validateParamBundle", "(", "$", "paramBundle", ")", ";", "}", "catch", "(", "InvalidVariantException", "$", "e", ")", "{", "// Rethrow exception only if the field was provided by the server", "if", "(", "$", "serverField", ")", "{", "throw", "$", "e", ";", "}", "}", "}", "}" ]
Checks to see if the parameters are correctly formed, if an anomaly is detected then an exception is thrown. @throws InvalidVariantException @param array<array<string>> $paramBundleList @param bool $serverField If true the field came from the server & we error on malformed data otherwise we suppress errors for client preferences.
[ "Checks", "to", "see", "if", "the", "parameters", "are", "correctly", "formed", "if", "an", "anomaly", "is", "detected", "then", "an", "exception", "is", "thrown", "." ]
04afb568f368ecdd81c13277006c4be041ccb58b
https://github.com/ptlis/conneg/blob/04afb568f368ecdd81c13277006c4be041ccb58b/src/Parser/FieldParser.php#L231-L243
13,881
TypistTech/cloudflare-wp-api
src/Api.php
Api.request
protected function request($path, array $data = null, $method = null) { $authError = $this->authenticationError(); if (null !== $authError) { return $authError; } $url = 'https://api.cloudflare.com/client/v4/' . $path; $args = $this->prepareRequestArguments($data, $method); $response = wp_remote_request($url, $args); if (is_wp_error($response)) { return $response; } return $this->decode($response); }
php
protected function request($path, array $data = null, $method = null) { $authError = $this->authenticationError(); if (null !== $authError) { return $authError; } $url = 'https://api.cloudflare.com/client/v4/' . $path; $args = $this->prepareRequestArguments($data, $method); $response = wp_remote_request($url, $args); if (is_wp_error($response)) { return $response; } return $this->decode($response); }
[ "protected", "function", "request", "(", "$", "path", ",", "array", "$", "data", "=", "null", ",", "$", "method", "=", "null", ")", "{", "$", "authError", "=", "$", "this", "->", "authenticationError", "(", ")", ";", "if", "(", "null", "!==", "$", "authError", ")", "{", "return", "$", "authError", ";", "}", "$", "url", "=", "'https://api.cloudflare.com/client/v4/'", ".", "$", "path", ";", "$", "args", "=", "$", "this", "->", "prepareRequestArguments", "(", "$", "data", ",", "$", "method", ")", ";", "$", "response", "=", "wp_remote_request", "(", "$", "url", ",", "$", "args", ")", ";", "if", "(", "is_wp_error", "(", "$", "response", ")", ")", "{", "return", "$", "response", ";", "}", "return", "$", "this", "->", "decode", "(", "$", "response", ")", ";", "}" ]
API call method for sending requests via wp_remote_request. @param string $path Path of the endpoint. @param array|null $data Data to be sent along with the request. @param string|null $method Type of method that should be used ('GET', 'POST', 'PUT', 'DELETE', 'PATCH'). @return array|WP_Error
[ "API", "call", "method", "for", "sending", "requests", "via", "wp_remote_request", "." ]
e25f1f0d7cec1dc54e3b0fc4fc770742299fc98b
https://github.com/TypistTech/cloudflare-wp-api/blob/e25f1f0d7cec1dc54e3b0fc4fc770742299fc98b/src/Api.php#L34-L51
13,882
TypistTech/cloudflare-wp-api
src/Api.php
Api.authenticationError
private function authenticationError() { if (empty($this->email) || empty($this->auth_key)) { return new WP_Error('authentication-error', 'Authentication information must be provided'); } if (! is_email($this->email)) { return new WP_Error('authentication-error', 'Email is not valid'); } return null; }
php
private function authenticationError() { if (empty($this->email) || empty($this->auth_key)) { return new WP_Error('authentication-error', 'Authentication information must be provided'); } if (! is_email($this->email)) { return new WP_Error('authentication-error', 'Email is not valid'); } return null; }
[ "private", "function", "authenticationError", "(", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "email", ")", "||", "empty", "(", "$", "this", "->", "auth_key", ")", ")", "{", "return", "new", "WP_Error", "(", "'authentication-error'", ",", "'Authentication information must be provided'", ")", ";", "}", "if", "(", "!", "is_email", "(", "$", "this", "->", "email", ")", ")", "{", "return", "new", "WP_Error", "(", "'authentication-error'", ",", "'Email is not valid'", ")", ";", "}", "return", "null", ";", "}" ]
Return WP Error if this object does not contain necessary info to perform API requests. @return null|WP_Error
[ "Return", "WP", "Error", "if", "this", "object", "does", "not", "contain", "necessary", "info", "to", "perform", "API", "requests", "." ]
e25f1f0d7cec1dc54e3b0fc4fc770742299fc98b
https://github.com/TypistTech/cloudflare-wp-api/blob/e25f1f0d7cec1dc54e3b0fc4fc770742299fc98b/src/Api.php#L58-L69
13,883
TypistTech/cloudflare-wp-api
src/Api.php
Api.prepareRequestArguments
private function prepareRequestArguments(array $data = null, string $method = null): array { $data = $data ?? []; $method = $method ?? 'GET'; // Removes null entries. $data = array_filter($data, function ($val) { return (null !== $val); }); $headers = [ 'Content-Type' => 'application/json', 'X-Auth-Email' => $this->email, 'X-Auth-Key' => $this->auth_key, ]; $args = [ 'body' => wp_json_encode($data), 'headers' => $headers, 'method' => strtoupper($method), 'timeout' => 15, ]; return $args; }
php
private function prepareRequestArguments(array $data = null, string $method = null): array { $data = $data ?? []; $method = $method ?? 'GET'; // Removes null entries. $data = array_filter($data, function ($val) { return (null !== $val); }); $headers = [ 'Content-Type' => 'application/json', 'X-Auth-Email' => $this->email, 'X-Auth-Key' => $this->auth_key, ]; $args = [ 'body' => wp_json_encode($data), 'headers' => $headers, 'method' => strtoupper($method), 'timeout' => 15, ]; return $args; }
[ "private", "function", "prepareRequestArguments", "(", "array", "$", "data", "=", "null", ",", "string", "$", "method", "=", "null", ")", ":", "array", "{", "$", "data", "=", "$", "data", "??", "[", "]", ";", "$", "method", "=", "$", "method", "??", "'GET'", ";", "// Removes null entries.", "$", "data", "=", "array_filter", "(", "$", "data", ",", "function", "(", "$", "val", ")", "{", "return", "(", "null", "!==", "$", "val", ")", ";", "}", ")", ";", "$", "headers", "=", "[", "'Content-Type'", "=>", "'application/json'", ",", "'X-Auth-Email'", "=>", "$", "this", "->", "email", ",", "'X-Auth-Key'", "=>", "$", "this", "->", "auth_key", ",", "]", ";", "$", "args", "=", "[", "'body'", "=>", "wp_json_encode", "(", "$", "data", ")", ",", "'headers'", "=>", "$", "headers", ",", "'method'", "=>", "strtoupper", "(", "$", "method", ")", ",", "'timeout'", "=>", "15", ",", "]", ";", "return", "$", "args", ";", "}" ]
Prepare arguments for wp_remote_request. @param array|null $data Data to be sent along with the request. @param string|null $method Type of method that should be used ('GET', 'POST', 'PUT', 'DELETE', 'PATCH'). @return array
[ "Prepare", "arguments", "for", "wp_remote_request", "." ]
e25f1f0d7cec1dc54e3b0fc4fc770742299fc98b
https://github.com/TypistTech/cloudflare-wp-api/blob/e25f1f0d7cec1dc54e3b0fc4fc770742299fc98b/src/Api.php#L79-L103
13,884
TypistTech/cloudflare-wp-api
src/Api.php
Api.decode
private function decode(array $response) { $decodedBody = json_decode($response['body'], true); if (null === $decodedBody) { return new WP_Error('decode-error', 'Unable to decode response body', $response); } if (true !== $decodedBody['success']) { return $this->wpErrorFor($decodedBody['errors'], $response); } return $response; }
php
private function decode(array $response) { $decodedBody = json_decode($response['body'], true); if (null === $decodedBody) { return new WP_Error('decode-error', 'Unable to decode response body', $response); } if (true !== $decodedBody['success']) { return $this->wpErrorFor($decodedBody['errors'], $response); } return $response; }
[ "private", "function", "decode", "(", "array", "$", "response", ")", "{", "$", "decodedBody", "=", "json_decode", "(", "$", "response", "[", "'body'", "]", ",", "true", ")", ";", "if", "(", "null", "===", "$", "decodedBody", ")", "{", "return", "new", "WP_Error", "(", "'decode-error'", ",", "'Unable to decode response body'", ",", "$", "response", ")", ";", "}", "if", "(", "true", "!==", "$", "decodedBody", "[", "'success'", "]", ")", "{", "return", "$", "this", "->", "wpErrorFor", "(", "$", "decodedBody", "[", "'errors'", "]", ",", "$", "response", ")", ";", "}", "return", "$", "response", ";", "}" ]
Decode Cloudflare response. @param array $response The response from Cloudflare. @return array|WP_Error
[ "Decode", "Cloudflare", "response", "." ]
e25f1f0d7cec1dc54e3b0fc4fc770742299fc98b
https://github.com/TypistTech/cloudflare-wp-api/blob/e25f1f0d7cec1dc54e3b0fc4fc770742299fc98b/src/Api.php#L112-L125
13,885
TypistTech/cloudflare-wp-api
src/Api.php
Api.wpErrorFor
private function wpErrorFor(array $errors, array $response): WP_Error { $wpError = new WP_Error; foreach ($errors as $error) { $wpError->add($error['code'], $error['message'], $response); } return $wpError; }
php
private function wpErrorFor(array $errors, array $response): WP_Error { $wpError = new WP_Error; foreach ($errors as $error) { $wpError->add($error['code'], $error['message'], $response); } return $wpError; }
[ "private", "function", "wpErrorFor", "(", "array", "$", "errors", ",", "array", "$", "response", ")", ":", "WP_Error", "{", "$", "wpError", "=", "new", "WP_Error", ";", "foreach", "(", "$", "errors", "as", "$", "error", ")", "{", "$", "wpError", "->", "add", "(", "$", "error", "[", "'code'", "]", ",", "$", "error", "[", "'message'", "]", ",", "$", "response", ")", ";", "}", "return", "$", "wpError", ";", "}" ]
Decode Cloudflare error messages to WP Error. @param array $errors The error messages from Cloudflare. @param array $response The full response from Cloudflare. @return WP_Error
[ "Decode", "Cloudflare", "error", "messages", "to", "WP", "Error", "." ]
e25f1f0d7cec1dc54e3b0fc4fc770742299fc98b
https://github.com/TypistTech/cloudflare-wp-api/blob/e25f1f0d7cec1dc54e3b0fc4fc770742299fc98b/src/Api.php#L135-L143
13,886
dekuan/delib
src/CEnv.php
CEnv.GetEnvType
static function GetEnvType() { // // RETURN - environment type // 0 - production // 1 - pre-production // 2 - development // 3 - local // 4 - test // if ( ! is_array( $_SERVER ) || ! array_key_exists( 'SERVER_NAME', $_SERVER ) || ! is_string( $_SERVER[ 'SERVER_NAME' ] ) || empty( $_SERVER[ 'SERVER_NAME' ] ) ) { return self::ENV_UNKNOWN; } // ... $nRet = self::ENV_PRODUCTION; // ... $sServerName = strtolower( trim( $_SERVER[ 'SERVER_NAME' ] ) ); $sRootDomain = strtolower( trim( self::ROOT_DOMAIN ) ); if ( 0 == strcasecmp( $sServerName, $sRootDomain ) ) { // production $nRet = self::ENV_PRODUCTION; } else if ( strstr( $sServerName, sprintf( "-pre.%s", $sRootDomain ) ) ) { // pre-production $nRet = self::ENV_PRE_PRODUCTION; } else if ( strstr( $sServerName, sprintf( "-dev.%s", $sRootDomain ) ) ) { // development $nRet = self::ENV_DEVELOPMENT; } else if ( strstr( $sServerName, sprintf( "-loc.%s", $sRootDomain ) ) ) { // local $nRet = self::ENV_LOCAL; } else if ( strstr( $sServerName, sprintf( "-test.%s", $sRootDomain ) ) ) { // test $nRet = self::ENV_TEST; } else { // test for production $sNeedle = sprintf( ".%s", $sRootDomain ); $nRightPos = strlen( $sServerName ) - strlen( $sNeedle ) - 1; $nSearchPos = strrpos( $sServerName, $sNeedle ); if ( $nRightPos > 0 && $nRightPos === $nSearchPos ) { // production $nRet = self::ENV_PRODUCTION; } } return $nRet; }
php
static function GetEnvType() { // // RETURN - environment type // 0 - production // 1 - pre-production // 2 - development // 3 - local // 4 - test // if ( ! is_array( $_SERVER ) || ! array_key_exists( 'SERVER_NAME', $_SERVER ) || ! is_string( $_SERVER[ 'SERVER_NAME' ] ) || empty( $_SERVER[ 'SERVER_NAME' ] ) ) { return self::ENV_UNKNOWN; } // ... $nRet = self::ENV_PRODUCTION; // ... $sServerName = strtolower( trim( $_SERVER[ 'SERVER_NAME' ] ) ); $sRootDomain = strtolower( trim( self::ROOT_DOMAIN ) ); if ( 0 == strcasecmp( $sServerName, $sRootDomain ) ) { // production $nRet = self::ENV_PRODUCTION; } else if ( strstr( $sServerName, sprintf( "-pre.%s", $sRootDomain ) ) ) { // pre-production $nRet = self::ENV_PRE_PRODUCTION; } else if ( strstr( $sServerName, sprintf( "-dev.%s", $sRootDomain ) ) ) { // development $nRet = self::ENV_DEVELOPMENT; } else if ( strstr( $sServerName, sprintf( "-loc.%s", $sRootDomain ) ) ) { // local $nRet = self::ENV_LOCAL; } else if ( strstr( $sServerName, sprintf( "-test.%s", $sRootDomain ) ) ) { // test $nRet = self::ENV_TEST; } else { // test for production $sNeedle = sprintf( ".%s", $sRootDomain ); $nRightPos = strlen( $sServerName ) - strlen( $sNeedle ) - 1; $nSearchPos = strrpos( $sServerName, $sNeedle ); if ( $nRightPos > 0 && $nRightPos === $nSearchPos ) { // production $nRet = self::ENV_PRODUCTION; } } return $nRet; }
[ "static", "function", "GetEnvType", "(", ")", "{", "//", "//\tRETURN\t- environment type", "//\t\t0\t- production", "//\t\t1\t- pre-production", "//\t\t2\t- development", "//\t\t3\t- local", "//\t\t4\t- test", "//", "if", "(", "!", "is_array", "(", "$", "_SERVER", ")", "||", "!", "array_key_exists", "(", "'SERVER_NAME'", ",", "$", "_SERVER", ")", "||", "!", "is_string", "(", "$", "_SERVER", "[", "'SERVER_NAME'", "]", ")", "||", "empty", "(", "$", "_SERVER", "[", "'SERVER_NAME'", "]", ")", ")", "{", "return", "self", "::", "ENV_UNKNOWN", ";", "}", "//\t...", "$", "nRet", "=", "self", "::", "ENV_PRODUCTION", ";", "//\t...", "$", "sServerName", "=", "strtolower", "(", "trim", "(", "$", "_SERVER", "[", "'SERVER_NAME'", "]", ")", ")", ";", "$", "sRootDomain", "=", "strtolower", "(", "trim", "(", "self", "::", "ROOT_DOMAIN", ")", ")", ";", "if", "(", "0", "==", "strcasecmp", "(", "$", "sServerName", ",", "$", "sRootDomain", ")", ")", "{", "//\tproduction", "$", "nRet", "=", "self", "::", "ENV_PRODUCTION", ";", "}", "else", "if", "(", "strstr", "(", "$", "sServerName", ",", "sprintf", "(", "\"-pre.%s\"", ",", "$", "sRootDomain", ")", ")", ")", "{", "//\tpre-production", "$", "nRet", "=", "self", "::", "ENV_PRE_PRODUCTION", ";", "}", "else", "if", "(", "strstr", "(", "$", "sServerName", ",", "sprintf", "(", "\"-dev.%s\"", ",", "$", "sRootDomain", ")", ")", ")", "{", "//\tdevelopment", "$", "nRet", "=", "self", "::", "ENV_DEVELOPMENT", ";", "}", "else", "if", "(", "strstr", "(", "$", "sServerName", ",", "sprintf", "(", "\"-loc.%s\"", ",", "$", "sRootDomain", ")", ")", ")", "{", "//\tlocal", "$", "nRet", "=", "self", "::", "ENV_LOCAL", ";", "}", "else", "if", "(", "strstr", "(", "$", "sServerName", ",", "sprintf", "(", "\"-test.%s\"", ",", "$", "sRootDomain", ")", ")", ")", "{", "//\ttest", "$", "nRet", "=", "self", "::", "ENV_TEST", ";", "}", "else", "{", "//\ttest for production", "$", "sNeedle", "=", "sprintf", "(", "\".%s\"", ",", "$", "sRootDomain", ")", ";", "$", "nRightPos", "=", "strlen", "(", "$", "sServerName", ")", "-", "strlen", "(", "$", "sNeedle", ")", "-", "1", ";", "$", "nSearchPos", "=", "strrpos", "(", "$", "sServerName", ",", "$", "sNeedle", ")", ";", "if", "(", "$", "nRightPos", ">", "0", "&&", "$", "nRightPos", "===", "$", "nSearchPos", ")", "{", "//\tproduction", "$", "nRet", "=", "self", "::", "ENV_PRODUCTION", ";", "}", "}", "return", "$", "nRet", ";", "}" ]
get environment type @return int
[ "get", "environment", "type" ]
a0b82c5f1eb0cf7379eac3670ebf362787a7c6f8
https://github.com/dekuan/delib/blob/a0b82c5f1eb0cf7379eac3670ebf362787a7c6f8/src/CEnv.php#L27-L92
13,887
dekuan/delib
src/CEnv.php
CEnv.IsSecureHttp
static function IsSecureHttp() { return ( CLib::IsArrayWithKeys( $_SERVER, 'HTTPS' ) && CLib::IsExistingString( $_SERVER[ 'HTTPS' ] ) && ( 0 == strcasecmp( 'ON', $_SERVER[ 'HTTPS' ] ) || 0 == strcasecmp( '1', $_SERVER[ 'HTTPS' ] ) ) ); }
php
static function IsSecureHttp() { return ( CLib::IsArrayWithKeys( $_SERVER, 'HTTPS' ) && CLib::IsExistingString( $_SERVER[ 'HTTPS' ] ) && ( 0 == strcasecmp( 'ON', $_SERVER[ 'HTTPS' ] ) || 0 == strcasecmp( '1', $_SERVER[ 'HTTPS' ] ) ) ); }
[ "static", "function", "IsSecureHttp", "(", ")", "{", "return", "(", "CLib", "::", "IsArrayWithKeys", "(", "$", "_SERVER", ",", "'HTTPS'", ")", "&&", "CLib", "::", "IsExistingString", "(", "$", "_SERVER", "[", "'HTTPS'", "]", ")", "&&", "(", "0", "==", "strcasecmp", "(", "'ON'", ",", "$", "_SERVER", "[", "'HTTPS'", "]", ")", "||", "0", "==", "strcasecmp", "(", "'1'", ",", "$", "_SERVER", "[", "'HTTPS'", "]", ")", ")", ")", ";", "}" ]
detect if the protocol of current request is secure @return boolean
[ "detect", "if", "the", "protocol", "of", "current", "request", "is", "secure" ]
a0b82c5f1eb0cf7379eac3670ebf362787a7c6f8
https://github.com/dekuan/delib/blob/a0b82c5f1eb0cf7379eac3670ebf362787a7c6f8/src/CEnv.php#L99-L107
13,888
christophe-brachet/aspi-framework
src/Framework/Form/Element/RadioSet.php
RadioSet.setRadioAttribute
public function setRadioAttribute($a, $v) { foreach ($this->radios as $radio) { $radio->setAttribute($a, $v); if ($a == 'tabindex') { $v++; } } return $this; }
php
public function setRadioAttribute($a, $v) { foreach ($this->radios as $radio) { $radio->setAttribute($a, $v); if ($a == 'tabindex') { $v++; } } return $this; }
[ "public", "function", "setRadioAttribute", "(", "$", "a", ",", "$", "v", ")", "{", "foreach", "(", "$", "this", "->", "radios", "as", "$", "radio", ")", "{", "$", "radio", "->", "setAttribute", "(", "$", "a", ",", "$", "v", ")", ";", "if", "(", "$", "a", "==", "'tabindex'", ")", "{", "$", "v", "++", ";", "}", "}", "return", "$", "this", ";", "}" ]
Set an attribute for the input radio elements @param string $a @param string $v @return Child
[ "Set", "an", "attribute", "for", "the", "input", "radio", "elements" ]
17a36c8a8582e0b8d8bff7087590c09a9bd4af1e
https://github.com/christophe-brachet/aspi-framework/blob/17a36c8a8582e0b8d8bff7087590c09a9bd4af1e/src/Framework/Form/Element/RadioSet.php#L96-L105
13,889
christophe-brachet/aspi-framework
src/Framework/Form/Element/RadioSet.php
RadioSet.setRadioAttributes
public function setRadioAttributes(array $a) { foreach ($this->radios as $radio) { $radio->setAttributes($a); if (isset($a['tabindex'])) { $a['tabindex']++; } } return $this; }
php
public function setRadioAttributes(array $a) { foreach ($this->radios as $radio) { $radio->setAttributes($a); if (isset($a['tabindex'])) { $a['tabindex']++; } } return $this; }
[ "public", "function", "setRadioAttributes", "(", "array", "$", "a", ")", "{", "foreach", "(", "$", "this", "->", "radios", "as", "$", "radio", ")", "{", "$", "radio", "->", "setAttributes", "(", "$", "a", ")", ";", "if", "(", "isset", "(", "$", "a", "[", "'tabindex'", "]", ")", ")", "{", "$", "a", "[", "'tabindex'", "]", "++", ";", "}", "}", "return", "$", "this", ";", "}" ]
Set an attribute or attributes for the input radio elements @param array $a @return Child
[ "Set", "an", "attribute", "or", "attributes", "for", "the", "input", "radio", "elements" ]
17a36c8a8582e0b8d8bff7087590c09a9bd4af1e
https://github.com/christophe-brachet/aspi-framework/blob/17a36c8a8582e0b8d8bff7087590c09a9bd4af1e/src/Framework/Form/Element/RadioSet.php#L112-L121
13,890
christophe-brachet/aspi-framework
src/Framework/Form/Element/RadioSet.php
RadioSet.setValue
public function setValue($value) { $this->checked = $value; if ((null !== $this->checked) && ($this->hasChildren())) { foreach ($this->childNodes as $child) { if ($child instanceof Input\Radio) { if ($child->getValue() == $this->checked) { $child->check(); } else { $child->uncheck(); } } } } return $this; }
php
public function setValue($value) { $this->checked = $value; if ((null !== $this->checked) && ($this->hasChildren())) { foreach ($this->childNodes as $child) { if ($child instanceof Input\Radio) { if ($child->getValue() == $this->checked) { $child->check(); } else { $child->uncheck(); } } } } return $this; }
[ "public", "function", "setValue", "(", "$", "value", ")", "{", "$", "this", "->", "checked", "=", "$", "value", ";", "if", "(", "(", "null", "!==", "$", "this", "->", "checked", ")", "&&", "(", "$", "this", "->", "hasChildren", "(", ")", ")", ")", "{", "foreach", "(", "$", "this", "->", "childNodes", "as", "$", "child", ")", "{", "if", "(", "$", "child", "instanceof", "Input", "\\", "Radio", ")", "{", "if", "(", "$", "child", "->", "getValue", "(", ")", "==", "$", "this", "->", "checked", ")", "{", "$", "child", "->", "check", "(", ")", ";", "}", "else", "{", "$", "child", "->", "uncheck", "(", ")", ";", "}", "}", "}", "}", "return", "$", "this", ";", "}" ]
Set the checked value of the radio form elements @param mixed $value @return RadioSet
[ "Set", "the", "checked", "value", "of", "the", "radio", "form", "elements" ]
17a36c8a8582e0b8d8bff7087590c09a9bd4af1e
https://github.com/christophe-brachet/aspi-framework/blob/17a36c8a8582e0b8d8bff7087590c09a9bd4af1e/src/Framework/Form/Element/RadioSet.php#L128-L143
13,891
markwatkinson/luminous
src/Luminous/Scanners/ErlangScanner.php
ErlangScanner.buildBasedIntRegex
public static function buildBasedIntRegex($base) { assert(2 <= $base && $base <= 16); $regex = '/(?i:[0-'; if ($base <= 10) { $regex .= (string)$base-1; } else { $regex .= '9a-' . strtolower(dechex($base-1)); } $regex .= '])+/'; return $regex; }
php
public static function buildBasedIntRegex($base) { assert(2 <= $base && $base <= 16); $regex = '/(?i:[0-'; if ($base <= 10) { $regex .= (string)$base-1; } else { $regex .= '9a-' . strtolower(dechex($base-1)); } $regex .= '])+/'; return $regex; }
[ "public", "static", "function", "buildBasedIntRegex", "(", "$", "base", ")", "{", "assert", "(", "2", "<=", "$", "base", "&&", "$", "base", "<=", "16", ")", ";", "$", "regex", "=", "'/(?i:[0-'", ";", "if", "(", "$", "base", "<=", "10", ")", "{", "$", "regex", ".=", "(", "string", ")", "$", "base", "-", "1", ";", "}", "else", "{", "$", "regex", ".=", "'9a-'", ".", "strtolower", "(", "dechex", "(", "$", "base", "-", "1", ")", ")", ";", "}", "$", "regex", ".=", "'])+/'", ";", "return", "$", "regex", ";", "}" ]
in the given base
[ "in", "the", "given", "base" ]
4adc18f414534abe986133d6d38e8e9787d32e69
https://github.com/markwatkinson/luminous/blob/4adc18f414534abe986133d6d38e8e9787d32e69/src/Luminous/Scanners/ErlangScanner.php#L31-L42
13,892
transfer-framework/transfer
src/Transfer/Processor/EventSubscriber/Logger.php
Logger.logPreProcedureEvent
public function logPreProcedureEvent(Events\PreProcedureEvent $event) { $procedure = $event->getProcedure(); $this->logger->info(sprintf('Starting procedure "%s"...', $procedure->getName())); }
php
public function logPreProcedureEvent(Events\PreProcedureEvent $event) { $procedure = $event->getProcedure(); $this->logger->info(sprintf('Starting procedure "%s"...', $procedure->getName())); }
[ "public", "function", "logPreProcedureEvent", "(", "Events", "\\", "PreProcedureEvent", "$", "event", ")", "{", "$", "procedure", "=", "$", "event", "->", "getProcedure", "(", ")", ";", "$", "this", "->", "logger", "->", "info", "(", "sprintf", "(", "'Starting procedure \"%s\"...'", ",", "$", "procedure", "->", "getName", "(", ")", ")", ")", ";", "}" ]
Logs pre procedure event. @param Events\PreProcedureEvent $event
[ "Logs", "pre", "procedure", "event", "." ]
9225ae068d5924982f14ad4446b15f75384a058a
https://github.com/transfer-framework/transfer/blob/9225ae068d5924982f14ad4446b15f75384a058a/src/Transfer/Processor/EventSubscriber/Logger.php#L75-L80
13,893
transfer-framework/transfer
src/Transfer/Processor/EventSubscriber/Logger.php
Logger.logPostProcedureEvent
public function logPostProcedureEvent(Events\PostProcedureEvent $event) { $procedure = $event->getProcedure(); $this->logger->info(sprintf('Finished procedure "%s"', $procedure->getName())); }
php
public function logPostProcedureEvent(Events\PostProcedureEvent $event) { $procedure = $event->getProcedure(); $this->logger->info(sprintf('Finished procedure "%s"', $procedure->getName())); }
[ "public", "function", "logPostProcedureEvent", "(", "Events", "\\", "PostProcedureEvent", "$", "event", ")", "{", "$", "procedure", "=", "$", "event", "->", "getProcedure", "(", ")", ";", "$", "this", "->", "logger", "->", "info", "(", "sprintf", "(", "'Finished procedure \"%s\"'", ",", "$", "procedure", "->", "getName", "(", ")", ")", ")", ";", "}" ]
Logs post procedure event. @param Events\PostProcedureEvent $event
[ "Logs", "post", "procedure", "event", "." ]
9225ae068d5924982f14ad4446b15f75384a058a
https://github.com/transfer-framework/transfer/blob/9225ae068d5924982f14ad4446b15f75384a058a/src/Transfer/Processor/EventSubscriber/Logger.php#L87-L92
13,894
transfer-framework/transfer
src/Transfer/Processor/EventSubscriber/Logger.php
Logger.logPostAdapterReceiveEvent
public function logPostAdapterReceiveEvent(Events\PostAdapterReceiveEvent $event) { $source = $event->getSourceAdapter(); $this->logger->info(sprintf('Received data from adapter "%s"', get_class($source))); }
php
public function logPostAdapterReceiveEvent(Events\PostAdapterReceiveEvent $event) { $source = $event->getSourceAdapter(); $this->logger->info(sprintf('Received data from adapter "%s"', get_class($source))); }
[ "public", "function", "logPostAdapterReceiveEvent", "(", "Events", "\\", "PostAdapterReceiveEvent", "$", "event", ")", "{", "$", "source", "=", "$", "event", "->", "getSourceAdapter", "(", ")", ";", "$", "this", "->", "logger", "->", "info", "(", "sprintf", "(", "'Received data from adapter \"%s\"'", ",", "get_class", "(", "$", "source", ")", ")", ")", ";", "}" ]
Logs post adapter receive. @param Events\PostAdapterReceiveEvent $event
[ "Logs", "post", "adapter", "receive", "." ]
9225ae068d5924982f14ad4446b15f75384a058a
https://github.com/transfer-framework/transfer/blob/9225ae068d5924982f14ad4446b15f75384a058a/src/Transfer/Processor/EventSubscriber/Logger.php#L107-L112
13,895
transfer-framework/transfer
src/Transfer/Processor/EventSubscriber/Logger.php
Logger.logPostWorkerEvent
public function logPostWorkerEvent(Events\PostWorkerEvent $event) { $worker = $event->getWorker(); $this->logger->info(sprintf('Worked an object with "%s"', get_class($worker))); }
php
public function logPostWorkerEvent(Events\PostWorkerEvent $event) { $worker = $event->getWorker(); $this->logger->info(sprintf('Worked an object with "%s"', get_class($worker))); }
[ "public", "function", "logPostWorkerEvent", "(", "Events", "\\", "PostWorkerEvent", "$", "event", ")", "{", "$", "worker", "=", "$", "event", "->", "getWorker", "(", ")", ";", "$", "this", "->", "logger", "->", "info", "(", "sprintf", "(", "'Worked an object with \"%s\"'", ",", "get_class", "(", "$", "worker", ")", ")", ")", ";", "}" ]
Logs post worker event. @param Events\PostWorkerEvent $event
[ "Logs", "post", "worker", "event", "." ]
9225ae068d5924982f14ad4446b15f75384a058a
https://github.com/transfer-framework/transfer/blob/9225ae068d5924982f14ad4446b15f75384a058a/src/Transfer/Processor/EventSubscriber/Logger.php#L127-L132
13,896
transfer-framework/transfer
src/Transfer/Processor/EventSubscriber/Logger.php
Logger.logPostAdapterSendEvent
public function logPostAdapterSendEvent(Events\PostAdapterSendEvent $event) { $target = $event->getTargetAdapter(); $this->logger->info(sprintf('Objects sent to adapter "%s"', get_class($target))); }
php
public function logPostAdapterSendEvent(Events\PostAdapterSendEvent $event) { $target = $event->getTargetAdapter(); $this->logger->info(sprintf('Objects sent to adapter "%s"', get_class($target))); }
[ "public", "function", "logPostAdapterSendEvent", "(", "Events", "\\", "PostAdapterSendEvent", "$", "event", ")", "{", "$", "target", "=", "$", "event", "->", "getTargetAdapter", "(", ")", ";", "$", "this", "->", "logger", "->", "info", "(", "sprintf", "(", "'Objects sent to adapter \"%s\"'", ",", "get_class", "(", "$", "target", ")", ")", ")", ";", "}" ]
Logs post adapter send event. @param Events\PostAdapterSendEvent $event
[ "Logs", "post", "adapter", "send", "event", "." ]
9225ae068d5924982f14ad4446b15f75384a058a
https://github.com/transfer-framework/transfer/blob/9225ae068d5924982f14ad4446b15f75384a058a/src/Transfer/Processor/EventSubscriber/Logger.php#L147-L152
13,897
Stratadox/ImmutableCollection
src/CannotAlterCollection.php
CannotAlterCollection.byOverWriting
public static function byOverWriting(Collection $collection, int $index): NotAllowed { return new static(sprintf( 'Cannot write to the immutable collection `%s`. ' . '(Tried writing to position %d).', get_class($collection), $index )); }
php
public static function byOverWriting(Collection $collection, int $index): NotAllowed { return new static(sprintf( 'Cannot write to the immutable collection `%s`. ' . '(Tried writing to position %d).', get_class($collection), $index )); }
[ "public", "static", "function", "byOverWriting", "(", "Collection", "$", "collection", ",", "int", "$", "index", ")", ":", "NotAllowed", "{", "return", "new", "static", "(", "sprintf", "(", "'Cannot write to the immutable collection `%s`. '", ".", "'(Tried writing to position %d).'", ",", "get_class", "(", "$", "collection", ")", ",", "$", "index", ")", ")", ";", "}" ]
Indicates that this write operation is not allowed. @param Collection $collection The collection that may not be mutated. @param int $index The index that will not be overwritten. @return NotAllowed The exception object.
[ "Indicates", "that", "this", "write", "operation", "is", "not", "allowed", "." ]
eac441bc1762eefda6da25354b4e8f91f48bd733
https://github.com/Stratadox/ImmutableCollection/blob/eac441bc1762eefda6da25354b4e8f91f48bd733/src/CannotAlterCollection.php#L57-L65
13,898
Stratadox/ImmutableCollection
src/CannotAlterCollection.php
CannotAlterCollection.byRemoving
public static function byRemoving(Collection $collection, int $index): NotAllowed { return new static(sprintf( 'Cannot alter the immutable collection `%s`. ' . '(Tried to unset position %d).', get_class($collection), $index )); }
php
public static function byRemoving(Collection $collection, int $index): NotAllowed { return new static(sprintf( 'Cannot alter the immutable collection `%s`. ' . '(Tried to unset position %d).', get_class($collection), $index )); }
[ "public", "static", "function", "byRemoving", "(", "Collection", "$", "collection", ",", "int", "$", "index", ")", ":", "NotAllowed", "{", "return", "new", "static", "(", "sprintf", "(", "'Cannot alter the immutable collection `%s`. '", ".", "'(Tried to unset position %d).'", ",", "get_class", "(", "$", "collection", ")", ",", "$", "index", ")", ")", ";", "}" ]
Indicates that this unset operation is not allowed. @param Collection $collection The collection that may not be mutated. @param int $index The index that will not be removed. @return NotAllowed The exception object.
[ "Indicates", "that", "this", "unset", "operation", "is", "not", "allowed", "." ]
eac441bc1762eefda6da25354b4e8f91f48bd733
https://github.com/Stratadox/ImmutableCollection/blob/eac441bc1762eefda6da25354b4e8f91f48bd733/src/CannotAlterCollection.php#L74-L82
13,899
Stratadox/ImmutableCollection
src/CannotAlterCollection.php
CannotAlterCollection.byResizingTo
public static function byResizingTo(Collection $collection, int $size): NotAllowed { return new static(sprintf( 'Cannot directly resize the immutable collection `%s`. ' . '(Tried to resize from %d to %d).', get_class($collection), count($collection), $size )); }
php
public static function byResizingTo(Collection $collection, int $size): NotAllowed { return new static(sprintf( 'Cannot directly resize the immutable collection `%s`. ' . '(Tried to resize from %d to %d).', get_class($collection), count($collection), $size )); }
[ "public", "static", "function", "byResizingTo", "(", "Collection", "$", "collection", ",", "int", "$", "size", ")", ":", "NotAllowed", "{", "return", "new", "static", "(", "sprintf", "(", "'Cannot directly resize the immutable collection `%s`. '", ".", "'(Tried to resize from %d to %d).'", ",", "get_class", "(", "$", "collection", ")", ",", "count", "(", "$", "collection", ")", ",", "$", "size", ")", ")", ";", "}" ]
Indicates that this resize operation is not allowed. @param Collection $collection The collection that may not be mutated. @param int $size The size that will not be assigned. @return NotAllowed The exception object.
[ "Indicates", "that", "this", "resize", "operation", "is", "not", "allowed", "." ]
eac441bc1762eefda6da25354b4e8f91f48bd733
https://github.com/Stratadox/ImmutableCollection/blob/eac441bc1762eefda6da25354b4e8f91f48bd733/src/CannotAlterCollection.php#L91-L100