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
partition
stringclasses
1 value
mothership-gmbh/state_machine
src/WorkflowAbstract.php
WorkflowAbstract.setInitialState
public function setInitialState() { foreach ($this->states as $status) { if ($status->getType() == StatusInterface::TYPE_INITIAL) { $this->currentStatus = $status; return; } } throw new WorkflowException('No initial state found for the workflow', 90, NULL); }
php
public function setInitialState() { foreach ($this->states as $status) { if ($status->getType() == StatusInterface::TYPE_INITIAL) { $this->currentStatus = $status; return; } } throw new WorkflowException('No initial state found for the workflow', 90, NULL); }
[ "public", "function", "setInitialState", "(", ")", "{", "foreach", "(", "$", "this", "->", "states", "as", "$", "status", ")", "{", "if", "(", "$", "status", "->", "getType", "(", ")", "==", "StatusInterface", "::", "TYPE_INITIAL", ")", "{", "$", "this...
Set the initial state @return void
[ "Set", "the", "initial", "state" ]
317ee68bb4e64a18a176f4e0c93a5c9c71946f71
https://github.com/mothership-gmbh/state_machine/blob/317ee68bb4e64a18a176f4e0c93a5c9c71946f71/src/WorkflowAbstract.php#L158-L168
train
mothership-gmbh/state_machine
src/WorkflowAbstract.php
WorkflowAbstract.getStatus
public function getStatus($name) { foreach ($this->states as $status) { if ($status->getName() == $name) { return $status; } } throw new WorkflowException('No status found with the name ' . $name, 70, NULL); }
php
public function getStatus($name) { foreach ($this->states as $status) { if ($status->getName() == $name) { return $status; } } throw new WorkflowException('No status found with the name ' . $name, 70, NULL); }
[ "public", "function", "getStatus", "(", "$", "name", ")", "{", "foreach", "(", "$", "this", "->", "states", "as", "$", "status", ")", "{", "if", "(", "$", "status", "->", "getName", "(", ")", "==", "$", "name", ")", "{", "return", "$", "status", ...
Get the status of the workflow by its name. @param $name @return \Mothership\StateMachine\StatusInterface WorkflowException @throws WorkflowException
[ "Get", "the", "status", "of", "the", "workflow", "by", "its", "name", "." ]
317ee68bb4e64a18a176f4e0c93a5c9c71946f71
https://github.com/mothership-gmbh/state_machine/blob/317ee68bb4e64a18a176f4e0c93a5c9c71946f71/src/WorkflowAbstract.php#L201-L209
train
mothership-gmbh/state_machine
src/WorkflowAbstract.php
WorkflowAbstract.addToLog
protected function addToLog($state, $return = NULL) { $data['name'] = $state; if (NULL !== $return) { $data['return'] = $return; } $this->log[] = $data; }
php
protected function addToLog($state, $return = NULL) { $data['name'] = $state; if (NULL !== $return) { $data['return'] = $return; } $this->log[] = $data; }
[ "protected", "function", "addToLog", "(", "$", "state", ",", "$", "return", "=", "NULL", ")", "{", "$", "data", "[", "'name'", "]", "=", "$", "state", ";", "if", "(", "NULL", "!==", "$", "return", ")", "{", "$", "data", "[", "'return'", "]", "=",...
The log will create. @param $state @param null $return @return mixed
[ "The", "log", "will", "create", "." ]
317ee68bb4e64a18a176f4e0c93a5c9c71946f71
https://github.com/mothership-gmbh/state_machine/blob/317ee68bb4e64a18a176f4e0c93a5c9c71946f71/src/WorkflowAbstract.php#L219-L227
train
mothership-gmbh/state_machine
src/WorkflowAbstract.php
WorkflowAbstract.run
public function run($args = [], $saveLog = false) { /** * The state machine must be able to re run the same processes again. */ $this->reset(); // just store the arguments for external logic $this->args = $args; $continueExecution = true; $nextState = $this->currentStatus; /** * Based on the initial state, the algorithm * will try to execute each method until the * final state is reached */ while (true === $continueExecution) { if ($nextState->getType() == StatusInterface::TYPE_FINAL) { $continueExecution = false; } /* * Every workflow class has methods, which names are equal to the state names in the * configuration file. By executing the methods, a return value can be given. This * depends on your graph logic. * * However the return value will be seen as a condition for the NEXT state * transition evaluation. */ try { $this->executeMethod('preDispatch'); $condition = $this->executeMethod($nextState->getName()); $this->executeMethod('postDispatch'); } catch (\Exception $e) { if (method_exists($this, 'exception')) { call_user_func([$this, 'exception'], [$e]); $nextState = $this->getNextStateFrom('exception'); $this->setState($nextState); continue; } else { throw $e; } } if (true === $saveLog) { $this->addToLog($nextState->getName(), $condition); } /** * Mark the execution to be stopped when the next state * is StatusInterface::TYPE_FINAL. */ if (false === $continueExecution) { continue; } $nextState = $this->getNextStateFrom($nextState->getName(), $condition); /** * Overwrite the current state. This does not affect * the application logic but will be used for debugging purpose to be able * to inspect the current state machine */ $this->setState($nextState); } if (true === $saveLog) { return $this->log; } }
php
public function run($args = [], $saveLog = false) { /** * The state machine must be able to re run the same processes again. */ $this->reset(); // just store the arguments for external logic $this->args = $args; $continueExecution = true; $nextState = $this->currentStatus; /** * Based on the initial state, the algorithm * will try to execute each method until the * final state is reached */ while (true === $continueExecution) { if ($nextState->getType() == StatusInterface::TYPE_FINAL) { $continueExecution = false; } /* * Every workflow class has methods, which names are equal to the state names in the * configuration file. By executing the methods, a return value can be given. This * depends on your graph logic. * * However the return value will be seen as a condition for the NEXT state * transition evaluation. */ try { $this->executeMethod('preDispatch'); $condition = $this->executeMethod($nextState->getName()); $this->executeMethod('postDispatch'); } catch (\Exception $e) { if (method_exists($this, 'exception')) { call_user_func([$this, 'exception'], [$e]); $nextState = $this->getNextStateFrom('exception'); $this->setState($nextState); continue; } else { throw $e; } } if (true === $saveLog) { $this->addToLog($nextState->getName(), $condition); } /** * Mark the execution to be stopped when the next state * is StatusInterface::TYPE_FINAL. */ if (false === $continueExecution) { continue; } $nextState = $this->getNextStateFrom($nextState->getName(), $condition); /** * Overwrite the current state. This does not affect * the application logic but will be used for debugging purpose to be able * to inspect the current state machine */ $this->setState($nextState); } if (true === $saveLog) { return $this->log; } }
[ "public", "function", "run", "(", "$", "args", "=", "[", "]", ",", "$", "saveLog", "=", "false", ")", "{", "/**\n * The state machine must be able to re run the same processes again.\n */", "$", "this", "->", "reset", "(", ")", ";", "// just store the ...
The main method, which processes the state machine. @param mixed $args You might pass external logic @param bool $saveLog If enabled, then all processed states will be stored and can be processed in the acceptance method later for debugging purpose @throws \Exception @return void|mixed
[ "The", "main", "method", "which", "processes", "the", "state", "machine", "." ]
317ee68bb4e64a18a176f4e0c93a5c9c71946f71
https://github.com/mothership-gmbh/state_machine/blob/317ee68bb4e64a18a176f4e0c93a5c9c71946f71/src/WorkflowAbstract.php#L251-L325
train
mothership-gmbh/state_machine
src/WorkflowAbstract.php
WorkflowAbstract.executeMethod
private function executeMethod($method, $args = []) { if (method_exists($this, $method)) { return call_user_func_array([$this, $method], $args); } }
php
private function executeMethod($method, $args = []) { if (method_exists($this, $method)) { return call_user_func_array([$this, $method], $args); } }
[ "private", "function", "executeMethod", "(", "$", "method", ",", "$", "args", "=", "[", "]", ")", "{", "if", "(", "method_exists", "(", "$", "this", ",", "$", "method", ")", ")", "{", "return", "call_user_func_array", "(", "[", "$", "this", ",", "$",...
Helper method for executing. @param string $method @®eturn void
[ "Helper", "method", "for", "executing", "." ]
317ee68bb4e64a18a176f4e0c93a5c9c71946f71
https://github.com/mothership-gmbh/state_machine/blob/317ee68bb4e64a18a176f4e0c93a5c9c71946f71/src/WorkflowAbstract.php#L334-L339
train
mothership-gmbh/state_machine
src/WorkflowAbstract.php
WorkflowAbstract.getStatusIndex
private function getStatusIndex($statusname) { $status_count = count($this->states); for ($i = 0; $i < $status_count; ++$i) { if ($this->states[$i]->getName() == $statusname) { return $i; } } }
php
private function getStatusIndex($statusname) { $status_count = count($this->states); for ($i = 0; $i < $status_count; ++$i) { if ($this->states[$i]->getName() == $statusname) { return $i; } } }
[ "private", "function", "getStatusIndex", "(", "$", "statusname", ")", "{", "$", "status_count", "=", "count", "(", "$", "this", "->", "states", ")", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "$", "status_count", ";", "++", "$", "i", ...
Get the position of a state. @param $statusname @return int
[ "Get", "the", "position", "of", "a", "state", "." ]
317ee68bb4e64a18a176f4e0c93a5c9c71946f71
https://github.com/mothership-gmbh/state_machine/blob/317ee68bb4e64a18a176f4e0c93a5c9c71946f71/src/WorkflowAbstract.php#L391-L399
train
silverstripe/silverstripe-securityreport
src/MemberReportExtension.php
MemberReportExtension.getLastLoggedIn
public function getLastLoggedIn() { $lastTime = LoginAttempt::get() ->filter([ 'MemberID' => $this->owner->ID, 'Status' => 'Success', ]) ->sort('Created', 'DESC') ->first(); if ($lastTime) { return $lastTime->dbObject('Created')->format(DBDatetime::ISO_DATETIME); } return _t(__CLASS__ . '.NEVER', 'Never'); }
php
public function getLastLoggedIn() { $lastTime = LoginAttempt::get() ->filter([ 'MemberID' => $this->owner->ID, 'Status' => 'Success', ]) ->sort('Created', 'DESC') ->first(); if ($lastTime) { return $lastTime->dbObject('Created')->format(DBDatetime::ISO_DATETIME); } return _t(__CLASS__ . '.NEVER', 'Never'); }
[ "public", "function", "getLastLoggedIn", "(", ")", "{", "$", "lastTime", "=", "LoginAttempt", "::", "get", "(", ")", "->", "filter", "(", "[", "'MemberID'", "=>", "$", "this", "->", "owner", "->", "ID", ",", "'Status'", "=>", "'Success'", ",", "]", ")"...
Retrieves the most recent successful LoginAttempt @return DBDatetime|string
[ "Retrieves", "the", "most", "recent", "successful", "LoginAttempt" ]
38ee887986edf878f40a8dfa7df5c37df42a5dee
https://github.com/silverstripe/silverstripe-securityreport/blob/38ee887986edf878f40a8dfa7df5c37df42a5dee/src/MemberReportExtension.php#L33-L47
train
silverstripe/silverstripe-securityreport
src/MemberReportExtension.php
MemberReportExtension.getGroupsDescription
public function getGroupsDescription() { if (class_exists(Subsite::class)) { Subsite::disable_subsite_filter(true); } // Get the member's groups, if any $groups = $this->owner->Groups(); if ($groups->Count()) { // Collect the group names $groupNames = array(); foreach ($groups as $group) { /** @var Group $group */ $groupNames[] = html_entity_decode($group->getTreeTitle()); } // return a csv string of the group names, sans-markup $result = preg_replace("#</?[^>]>#", '', implode(', ', $groupNames)); } else { // If no groups then return a status label $result = _t(__CLASS__ . '.NOGROUPS', 'Not in a Security Group'); } if (class_exists(Subsite::class)) { Subsite::disable_subsite_filter(false); } return $result; }
php
public function getGroupsDescription() { if (class_exists(Subsite::class)) { Subsite::disable_subsite_filter(true); } // Get the member's groups, if any $groups = $this->owner->Groups(); if ($groups->Count()) { // Collect the group names $groupNames = array(); foreach ($groups as $group) { /** @var Group $group */ $groupNames[] = html_entity_decode($group->getTreeTitle()); } // return a csv string of the group names, sans-markup $result = preg_replace("#</?[^>]>#", '', implode(', ', $groupNames)); } else { // If no groups then return a status label $result = _t(__CLASS__ . '.NOGROUPS', 'Not in a Security Group'); } if (class_exists(Subsite::class)) { Subsite::disable_subsite_filter(false); } return $result; }
[ "public", "function", "getGroupsDescription", "(", ")", "{", "if", "(", "class_exists", "(", "Subsite", "::", "class", ")", ")", "{", "Subsite", "::", "disable_subsite_filter", "(", "true", ")", ";", "}", "// Get the member's groups, if any", "$", "groups", "=",...
Builds a comma separated list of member group names for a given Member. @return string
[ "Builds", "a", "comma", "separated", "list", "of", "member", "group", "names", "for", "a", "given", "Member", "." ]
38ee887986edf878f40a8dfa7df5c37df42a5dee
https://github.com/silverstripe/silverstripe-securityreport/blob/38ee887986edf878f40a8dfa7df5c37df42a5dee/src/MemberReportExtension.php#L54-L80
train
silverstripe/silverstripe-securityreport
src/MemberReportExtension.php
MemberReportExtension.getPermissionsDescription
public function getPermissionsDescription() { if (class_exists(Subsite::class)) { Subsite::disable_subsite_filter(true); } $permissionsUsr = Permission::permissions_for_member($this->owner->ID); $permissionsSrc = Permission::get_codes(true); sort($permissionsUsr); $permissionNames = array(); foreach ($permissionsUsr as $code) { $code = strtoupper($code); foreach ($permissionsSrc as $k => $v) { if (isset($v[$code])) { $name = empty($v[$code]['name']) ? _t(__CLASS__ . '.UNKNOWN', 'Unknown') : $v[$code]['name']; $permissionNames[] = $name; } } } $result = $permissionNames ? implode(', ', $permissionNames) : _t(__CLASS__ . '.NOPERMISSIONS', 'No Permissions'); if (class_exists(Subsite::class)) { Subsite::disable_subsite_filter(false); } return $result; }
php
public function getPermissionsDescription() { if (class_exists(Subsite::class)) { Subsite::disable_subsite_filter(true); } $permissionsUsr = Permission::permissions_for_member($this->owner->ID); $permissionsSrc = Permission::get_codes(true); sort($permissionsUsr); $permissionNames = array(); foreach ($permissionsUsr as $code) { $code = strtoupper($code); foreach ($permissionsSrc as $k => $v) { if (isset($v[$code])) { $name = empty($v[$code]['name']) ? _t(__CLASS__ . '.UNKNOWN', 'Unknown') : $v[$code]['name']; $permissionNames[] = $name; } } } $result = $permissionNames ? implode(', ', $permissionNames) : _t(__CLASS__ . '.NOPERMISSIONS', 'No Permissions'); if (class_exists(Subsite::class)) { Subsite::disable_subsite_filter(false); } return $result; }
[ "public", "function", "getPermissionsDescription", "(", ")", "{", "if", "(", "class_exists", "(", "Subsite", "::", "class", ")", ")", "{", "Subsite", "::", "disable_subsite_filter", "(", "true", ")", ";", "}", "$", "permissionsUsr", "=", "Permission", "::", ...
Builds a comma separated list of human-readbale permissions for a given Member. @return string
[ "Builds", "a", "comma", "separated", "list", "of", "human", "-", "readbale", "permissions", "for", "a", "given", "Member", "." ]
38ee887986edf878f40a8dfa7df5c37df42a5dee
https://github.com/silverstripe/silverstripe-securityreport/blob/38ee887986edf878f40a8dfa7df5c37df42a5dee/src/MemberReportExtension.php#L87-L118
train
SaftIng/Saft
src/Saft/Addition/EasyRdf/Data/SerializerFactoryEasyRdf.php
SerializerFactoryEasyRdf.createSerializerFor
public function createSerializerFor($serialization) { $serializer = new SerializerEasyRdf($serialization); if (in_array($serialization, $serializer->getSupportedSerializations())) { return $serializer; } else { throw new \Exception( 'No serializer for requested serialization available: '.$serialization.'. '. 'Supported serializations are: '.implode(', ', $this->getSupportedSerializations()) ); } }
php
public function createSerializerFor($serialization) { $serializer = new SerializerEasyRdf($serialization); if (in_array($serialization, $serializer->getSupportedSerializations())) { return $serializer; } else { throw new \Exception( 'No serializer for requested serialization available: '.$serialization.'. '. 'Supported serializations are: '.implode(', ', $this->getSupportedSerializations()) ); } }
[ "public", "function", "createSerializerFor", "(", "$", "serialization", ")", "{", "$", "serializer", "=", "new", "SerializerEasyRdf", "(", "$", "serialization", ")", ";", "if", "(", "in_array", "(", "$", "serialization", ",", "$", "serializer", "->", "getSuppo...
Creates a Serializer instance for a given serialization, if available. @param string $serialization The serialization you need a serializer for. In case it is not available, an exception will be thrown. @return Parser suitable serializer for the requested serialization @throws \Exception if serializer for requested serialization is not available
[ "Creates", "a", "Serializer", "instance", "for", "a", "given", "serialization", "if", "available", "." ]
ac2d9aed53da6ab3bb5ea05165644027df5248e8
https://github.com/SaftIng/Saft/blob/ac2d9aed53da6ab3bb5ea05165644027df5248e8/src/Saft/Addition/EasyRdf/Data/SerializerFactoryEasyRdf.php#L29-L41
train
webeweb/core-library
src/Argument/StringHelper.php
StringHelper.parseArray
public static function parseArray(array $values) { // Initialize the output. $output = []; // Handle each value. foreach ($values as $key => $value) { // Check if the value is null. if (null === $value) { continue; } // Check if the value is an array. if (true === is_array($value)) { $buffer = trim(implode(" ", $value)); } else { $buffer = trim($value); } // Check if the buffer is not empty. if ("" !== $buffer) { $output[] = $key . "=\"" . preg_replace("/\s+/", " ", $buffer) . "\""; } } // Concatenates all attributes. return implode(" ", $output); }
php
public static function parseArray(array $values) { // Initialize the output. $output = []; // Handle each value. foreach ($values as $key => $value) { // Check if the value is null. if (null === $value) { continue; } // Check if the value is an array. if (true === is_array($value)) { $buffer = trim(implode(" ", $value)); } else { $buffer = trim($value); } // Check if the buffer is not empty. if ("" !== $buffer) { $output[] = $key . "=\"" . preg_replace("/\s+/", " ", $buffer) . "\""; } } // Concatenates all attributes. return implode(" ", $output); }
[ "public", "static", "function", "parseArray", "(", "array", "$", "values", ")", "{", "// Initialize the output.", "$", "output", "=", "[", "]", ";", "// Handle each value.", "foreach", "(", "$", "values", "as", "$", "key", "=>", "$", "value", ")", "{", "//...
Parse an array. @param array $values The array. @return string Returns the array converted into key="value".
[ "Parse", "an", "array", "." ]
bd454a47f6a28fbf6029635ee77ed01c9995cf60
https://github.com/webeweb/core-library/blob/bd454a47f6a28fbf6029635ee77ed01c9995cf60/src/Argument/StringHelper.php#L44-L72
train
BerliozFramework/Berlioz
src/Services/FlashBag.php
FlashBag.get
public function get(string $type): array { if (isset($this->messages[$type])) { $messages = $this->messages[$type]; // Clear messages $this->clear($type); return $messages; } else { return []; } }
php
public function get(string $type): array { if (isset($this->messages[$type])) { $messages = $this->messages[$type]; // Clear messages $this->clear($type); return $messages; } else { return []; } }
[ "public", "function", "get", "(", "string", "$", "type", ")", ":", "array", "{", "if", "(", "isset", "(", "$", "this", "->", "messages", "[", "$", "type", "]", ")", ")", "{", "$", "messages", "=", "$", "this", "->", "messages", "[", "$", "type", ...
Get all messages for given type and clear flash bag of them. @param string $type Type of message @return string[] List of messages
[ "Get", "all", "messages", "for", "given", "type", "and", "clear", "flash", "bag", "of", "them", "." ]
cd5f28f93fdff254b9a123a30dad275e5bbfd78c
https://github.com/BerliozFramework/Berlioz/blob/cd5f28f93fdff254b9a123a30dad275e5bbfd78c/src/Services/FlashBag.php#L110-L122
train
BerliozFramework/Berlioz
src/Services/FlashBag.php
FlashBag.clear
public function clear(string $type = null): FlashBag { if (is_null($type)) { $this->messages = []; } else { if (isset($this->messages[$type])) { unset($this->messages[$type]); } } // Save into session $this->saveToSession(); return $this; }
php
public function clear(string $type = null): FlashBag { if (is_null($type)) { $this->messages = []; } else { if (isset($this->messages[$type])) { unset($this->messages[$type]); } } // Save into session $this->saveToSession(); return $this; }
[ "public", "function", "clear", "(", "string", "$", "type", "=", "null", ")", ":", "FlashBag", "{", "if", "(", "is_null", "(", "$", "type", ")", ")", "{", "$", "this", "->", "messages", "=", "[", "]", ";", "}", "else", "{", "if", "(", "isset", "...
Clear messages in flash bag. @param string $type Type of message @return static
[ "Clear", "messages", "in", "flash", "bag", "." ]
cd5f28f93fdff254b9a123a30dad275e5bbfd78c
https://github.com/BerliozFramework/Berlioz/blob/cd5f28f93fdff254b9a123a30dad275e5bbfd78c/src/Services/FlashBag.php#L153-L167
train
webeweb/core-library
src/ThirdParty/SkiData/Parser/AbstractParser.php
AbstractParser.decodeDate
protected function decodeDate($str) { $date = DateTime::createFromFormat("!" . self::DATE_FORMAT, $str); return false === $date ? null : $date; }
php
protected function decodeDate($str) { $date = DateTime::createFromFormat("!" . self::DATE_FORMAT, $str); return false === $date ? null : $date; }
[ "protected", "function", "decodeDate", "(", "$", "str", ")", "{", "$", "date", "=", "DateTime", "::", "createFromFormat", "(", "\"!\"", ".", "self", "::", "DATE_FORMAT", ",", "$", "str", ")", ";", "return", "false", "===", "$", "date", "?", "null", ":"...
Decode a date string. @param string $str The string. @return DateTime Returns the decoded string into DateTime.
[ "Decode", "a", "date", "string", "." ]
bd454a47f6a28fbf6029635ee77ed01c9995cf60
https://github.com/webeweb/core-library/blob/bd454a47f6a28fbf6029635ee77ed01c9995cf60/src/ThirdParty/SkiData/Parser/AbstractParser.php#L49-L52
train
webeweb/core-library
src/ThirdParty/SkiData/Parser/AbstractParser.php
AbstractParser.decodeDateTime
protected function decodeDateTime($str) { $date = DateTime::createFromFormat(self::DATETIME_FORMAT, $str); return false === $date ? null : $date; }
php
protected function decodeDateTime($str) { $date = DateTime::createFromFormat(self::DATETIME_FORMAT, $str); return false === $date ? null : $date; }
[ "protected", "function", "decodeDateTime", "(", "$", "str", ")", "{", "$", "date", "=", "DateTime", "::", "createFromFormat", "(", "self", "::", "DATETIME_FORMAT", ",", "$", "str", ")", ";", "return", "false", "===", "$", "date", "?", "null", ":", "$", ...
Decode a datetime string. @param string $str The string. @return DateTime Returns the decoded string into DateTime.
[ "Decode", "a", "datetime", "string", "." ]
bd454a47f6a28fbf6029635ee77ed01c9995cf60
https://github.com/webeweb/core-library/blob/bd454a47f6a28fbf6029635ee77ed01c9995cf60/src/ThirdParty/SkiData/Parser/AbstractParser.php#L60-L63
train
webeweb/core-library
src/ThirdParty/SkiData/Parser/AbstractParser.php
AbstractParser.encodeDate
protected function encodeDate(DateTime $value = null) { return null === $value ? "" : $value->format(self::DATE_FORMAT); }
php
protected function encodeDate(DateTime $value = null) { return null === $value ? "" : $value->format(self::DATE_FORMAT); }
[ "protected", "function", "encodeDate", "(", "DateTime", "$", "value", "=", "null", ")", "{", "return", "null", "===", "$", "value", "?", "\"\"", ":", "$", "value", "->", "format", "(", "self", "::", "DATE_FORMAT", ")", ";", "}" ]
Encode a date value. @param DateTime $value The value. @return string Returns the encoded datetime value.
[ "Encode", "a", "date", "value", "." ]
bd454a47f6a28fbf6029635ee77ed01c9995cf60
https://github.com/webeweb/core-library/blob/bd454a47f6a28fbf6029635ee77ed01c9995cf60/src/ThirdParty/SkiData/Parser/AbstractParser.php#L91-L93
train
webeweb/core-library
src/ThirdParty/SkiData/Parser/AbstractParser.php
AbstractParser.encodeDateTime
protected function encodeDateTime(DateTime $value = null) { return null === $value ? "" : $value->format(self::DATETIME_FORMAT); }
php
protected function encodeDateTime(DateTime $value = null) { return null === $value ? "" : $value->format(self::DATETIME_FORMAT); }
[ "protected", "function", "encodeDateTime", "(", "DateTime", "$", "value", "=", "null", ")", "{", "return", "null", "===", "$", "value", "?", "\"\"", ":", "$", "value", "->", "format", "(", "self", "::", "DATETIME_FORMAT", ")", ";", "}" ]
Encode a datetime value. @param DateTime $value The value. @return string Returns the encoded datetime value.
[ "Encode", "a", "datetime", "value", "." ]
bd454a47f6a28fbf6029635ee77ed01c9995cf60
https://github.com/webeweb/core-library/blob/bd454a47f6a28fbf6029635ee77ed01c9995cf60/src/ThirdParty/SkiData/Parser/AbstractParser.php#L101-L103
train
webeweb/core-library
src/ThirdParty/SkiData/Parser/AbstractParser.php
AbstractParser.encodeInteger
protected function encodeInteger($value, $length) { $format = "%'.0" . $length . "d"; $output = null === $value ? "" : sprintf($format, $value); if ($length < strlen($output)) { throw new TooLongDataException($value, $length); } return $output; }
php
protected function encodeInteger($value, $length) { $format = "%'.0" . $length . "d"; $output = null === $value ? "" : sprintf($format, $value); if ($length < strlen($output)) { throw new TooLongDataException($value, $length); } return $output; }
[ "protected", "function", "encodeInteger", "(", "$", "value", ",", "$", "length", ")", "{", "$", "format", "=", "\"%'.0\"", ".", "$", "length", ".", "\"d\"", ";", "$", "output", "=", "null", "===", "$", "value", "?", "\"\"", ":", "sprintf", "(", "$", ...
Encode an integer value. @param int $value The value. @param int $length The length. @return string Returns the encoded integer. @throws TooLongDataException Throws a too long data exception if the value exceeds the length.
[ "Encode", "an", "integer", "value", "." ]
bd454a47f6a28fbf6029635ee77ed01c9995cf60
https://github.com/webeweb/core-library/blob/bd454a47f6a28fbf6029635ee77ed01c9995cf60/src/ThirdParty/SkiData/Parser/AbstractParser.php#L113-L120
train
webeweb/core-library
src/ThirdParty/SkiData/Parser/AbstractParser.php
AbstractParser.encodeString
protected function encodeString($value, $length = -1) { if (-1 !== $length && $length < strlen($value)) { throw new TooLongDataException($value, $length); } return "\"" . substr($value, 0, (-1 === $length ? strlen($value) : $length)) . "\""; }
php
protected function encodeString($value, $length = -1) { if (-1 !== $length && $length < strlen($value)) { throw new TooLongDataException($value, $length); } return "\"" . substr($value, 0, (-1 === $length ? strlen($value) : $length)) . "\""; }
[ "protected", "function", "encodeString", "(", "$", "value", ",", "$", "length", "=", "-", "1", ")", "{", "if", "(", "-", "1", "!==", "$", "length", "&&", "$", "length", "<", "strlen", "(", "$", "value", ")", ")", "{", "throw", "new", "TooLongDataEx...
Encode a string value. @param string $value The value. @param int $length The length. @return string Returns the encoded string. @throws TooLongDataException Throws a too long data exception if the value exceeds the length.
[ "Encode", "a", "string", "value", "." ]
bd454a47f6a28fbf6029635ee77ed01c9995cf60
https://github.com/webeweb/core-library/blob/bd454a47f6a28fbf6029635ee77ed01c9995cf60/src/ThirdParty/SkiData/Parser/AbstractParser.php#L130-L135
train
hypeJunction/hypeApps
classes/hypeJunction/Filestore/CoverHandler.php
CoverHandler.getIconSizes
protected static function getIconSizes($entity, $icon_sizes = array()) { $type = $entity->getType(); $subtype = $entity->getSubtype(); $defaults = array( 'master' => array( 'h' => 370, 'w' => 1000, 'upscale' => true, 'square' => false, ) ); if (is_array($icon_sizes)) { $icon_sizes = array_merge($defaults, $icon_sizes); } else { $icon_sizes = $defaults; } return elgg_trigger_plugin_hook('entity:cover:sizes', $type, array( 'entity' => $entity, 'subtype' => $subtype, ), $icon_sizes); }
php
protected static function getIconSizes($entity, $icon_sizes = array()) { $type = $entity->getType(); $subtype = $entity->getSubtype(); $defaults = array( 'master' => array( 'h' => 370, 'w' => 1000, 'upscale' => true, 'square' => false, ) ); if (is_array($icon_sizes)) { $icon_sizes = array_merge($defaults, $icon_sizes); } else { $icon_sizes = $defaults; } return elgg_trigger_plugin_hook('entity:cover:sizes', $type, array( 'entity' => $entity, 'subtype' => $subtype, ), $icon_sizes); }
[ "protected", "static", "function", "getIconSizes", "(", "$", "entity", ",", "$", "icon_sizes", "=", "array", "(", ")", ")", "{", "$", "type", "=", "$", "entity", "->", "getType", "(", ")", ";", "$", "subtype", "=", "$", "entity", "->", "getSubtype", ...
Get cover size config @param ElggEntity $entity Entity whose icons are being handled @param array $icon_sizes An array of predefined icon sizes @return array
[ "Get", "cover", "size", "config" ]
704a0aa57e817aa38bb9e40ad3710ba69d52e44c
https://github.com/hypeJunction/hypeApps/blob/704a0aa57e817aa38bb9e40ad3710ba69d52e44c/classes/hypeJunction/Filestore/CoverHandler.php#L22-L46
train
SaftIng/Saft
src/Saft/Addition/EasyRdf/Data/ParserEasyRdf.php
ParserEasyRdf.rdfPhpToStatementIterator
protected function rdfPhpToStatementIterator(array $rdfPhp) { $statements = []; // go through all subjects foreach ($rdfPhp as $subject => $predicates) { // predicates associated with the subject foreach ($predicates as $property => $objects) { // object(s) foreach ($objects as $object) { /* * Create subject node */ if (true === $this->RdfHelpers->simpleCheckURI($subject)) { $s = $this->nodeFactory->createNamedNode($subject); } elseif (true === $this->RdfHelpers->simpleCheckBlankNodeId($subject)) { $s = $this->nodeFactory->createBlankNode($subject); } else { // should not be possible, because EasyRdf is able to check for invalid subjects. throw new \Exception('Only URIs and blank nodes are allowed as subjects.'); } /* * Create predicate node */ if (true === $this->RdfHelpers->simpleCheckURI($property)) { $p = $this->nodeFactory->createNamedNode($property); } elseif (true === $this->RdfHelpers->simpleCheckBlankNodeId($property)) { $p = $this->nodeFactory->createBlankNode($property); } else { // should not be possible, because EasyRdf is able to check for invalid predicates. throw new \Exception('Only URIs and blank nodes are allowed as predicates.'); } /* * Create object node */ // URI if ($this->RdfHelpers->simpleCheckURI($object['value'])) { $o = $this->nodeFactory->createNamedNode($object['value']); // datatype set } elseif (isset($object['datatype'])) { $o = $this->nodeFactory->createLiteral($object['value'], $object['datatype']); // lang set } elseif (isset($object['lang'])) { $o = $this->nodeFactory->createLiteral( $object['value'], 'http://www.w3.org/1999/02/22-rdf-syntax-ns#langString', $object['lang'] ); // if no information about the object was provided, assume its a simple string } else { $o = $this->nodeFactory->createLiteral($object['value']); } // build and add statement $statements[] = $this->statementFactory->createStatement($s, $p, $o); } } } return $this->statementIteratorFactory->createStatementIteratorFromArray($statements); }
php
protected function rdfPhpToStatementIterator(array $rdfPhp) { $statements = []; // go through all subjects foreach ($rdfPhp as $subject => $predicates) { // predicates associated with the subject foreach ($predicates as $property => $objects) { // object(s) foreach ($objects as $object) { /* * Create subject node */ if (true === $this->RdfHelpers->simpleCheckURI($subject)) { $s = $this->nodeFactory->createNamedNode($subject); } elseif (true === $this->RdfHelpers->simpleCheckBlankNodeId($subject)) { $s = $this->nodeFactory->createBlankNode($subject); } else { // should not be possible, because EasyRdf is able to check for invalid subjects. throw new \Exception('Only URIs and blank nodes are allowed as subjects.'); } /* * Create predicate node */ if (true === $this->RdfHelpers->simpleCheckURI($property)) { $p = $this->nodeFactory->createNamedNode($property); } elseif (true === $this->RdfHelpers->simpleCheckBlankNodeId($property)) { $p = $this->nodeFactory->createBlankNode($property); } else { // should not be possible, because EasyRdf is able to check for invalid predicates. throw new \Exception('Only URIs and blank nodes are allowed as predicates.'); } /* * Create object node */ // URI if ($this->RdfHelpers->simpleCheckURI($object['value'])) { $o = $this->nodeFactory->createNamedNode($object['value']); // datatype set } elseif (isset($object['datatype'])) { $o = $this->nodeFactory->createLiteral($object['value'], $object['datatype']); // lang set } elseif (isset($object['lang'])) { $o = $this->nodeFactory->createLiteral( $object['value'], 'http://www.w3.org/1999/02/22-rdf-syntax-ns#langString', $object['lang'] ); // if no information about the object was provided, assume its a simple string } else { $o = $this->nodeFactory->createLiteral($object['value']); } // build and add statement $statements[] = $this->statementFactory->createStatement($s, $p, $o); } } } return $this->statementIteratorFactory->createStatementIteratorFromArray($statements); }
[ "protected", "function", "rdfPhpToStatementIterator", "(", "array", "$", "rdfPhp", ")", "{", "$", "statements", "=", "[", "]", ";", "// go through all subjects", "foreach", "(", "$", "rdfPhp", "as", "$", "subject", "=>", "$", "predicates", ")", "{", "// predic...
Transforms a statement array given by EasyRdf to a Saft StatementIterator instance. @param array $rdfPhp RDF data structured as array. It structure looks like: array( $subject => array( $predicate => array ( // object information 'datatype' => ..., 'lang' => ..., 'value' => ... ) ) ) @return StatementIterator @throws \Exception if a non-URI or non-BlankNode is used at subject position @throws \Exception if a non-URI or non-BlankNode is used at predicate position
[ "Transforms", "a", "statement", "array", "given", "by", "EasyRdf", "to", "a", "Saft", "StatementIterator", "instance", "." ]
ac2d9aed53da6ab3bb5ea05165644027df5248e8
https://github.com/SaftIng/Saft/blob/ac2d9aed53da6ab3bb5ea05165644027df5248e8/src/Saft/Addition/EasyRdf/Data/ParserEasyRdf.php#L174-L238
train
shopgate/cart-integration-magento2-base
src/Helper/Shipping/Carrier/TableRate.php
TableRate.getTableRateCollection
public function getTableRateCollection($storeId = null) { return $this->tableRateCollection->setWebsiteFilter($this->storeManager->getStore($storeId)->getWebsiteId()); }
php
public function getTableRateCollection($storeId = null) { return $this->tableRateCollection->setWebsiteFilter($this->storeManager->getStore($storeId)->getWebsiteId()); }
[ "public", "function", "getTableRateCollection", "(", "$", "storeId", "=", "null", ")", "{", "return", "$", "this", "->", "tableRateCollection", "->", "setWebsiteFilter", "(", "$", "this", "->", "storeManager", "->", "getStore", "(", "$", "storeId", ")", "->", ...
Retrieve the table rate collection filtered by store's website @param null|string|int $storeId - will use this store's website to pull the collection @return Collection
[ "Retrieve", "the", "table", "rate", "collection", "filtered", "by", "store", "s", "website" ]
e7f8dec935aa9b23cd5b434484bc45033e62d270
https://github.com/shopgate/cart-integration-magento2-base/blob/e7f8dec935aa9b23cd5b434484bc45033e62d270/src/Helper/Shipping/Carrier/TableRate.php#L59-L62
train
hypeJunction/hypeApps
classes/hypeJunction/Apps/Plugin.php
Plugin.init
public function init() { elgg_register_plugin_hook_handler('entity:icon:url', 'all', new Handlers\EntityIconUrlHook()); elgg_register_plugin_hook_handler('graph:properties', 'all', new Handlers\PropertiesHook()); elgg_register_plugin_hook_handler('graph:properties', 'user', new Handlers\UserPropertiesHook()); elgg_register_plugin_hook_handler('graph:properties', 'group', new Handlers\GroupPropertiesHook()); elgg_register_plugin_hook_handler('graph:properties', 'site', new Handlers\SitePropertiesHook()); elgg_register_plugin_hook_handler('graph:properties', 'object', new Handlers\ObjectPropertiesHook()); elgg_register_plugin_hook_handler('graph:properties', 'object:blog', new Handlers\BlogPropertiesHook()); elgg_register_plugin_hook_handler('graph:properties', 'object:file', new Handlers\FilePropertiesHook()); elgg_register_plugin_hook_handler('graph:properties', 'object:messages', new Handlers\MessagePropertiesHook()); elgg_register_plugin_hook_handler('graph:properties', 'metadata', new Handlers\ExtenderPropertiesHook()); elgg_register_plugin_hook_handler('graph:properties', 'annotation', new Handlers\ExtenderPropertiesHook()); elgg_register_plugin_hook_handler('graph:properties', 'relationship', new Handlers\RelationshipPropertiesHook()); elgg_register_plugin_hook_handler('graph:properties', 'river:item', new Handlers\RiverPropertiesHook()); }
php
public function init() { elgg_register_plugin_hook_handler('entity:icon:url', 'all', new Handlers\EntityIconUrlHook()); elgg_register_plugin_hook_handler('graph:properties', 'all', new Handlers\PropertiesHook()); elgg_register_plugin_hook_handler('graph:properties', 'user', new Handlers\UserPropertiesHook()); elgg_register_plugin_hook_handler('graph:properties', 'group', new Handlers\GroupPropertiesHook()); elgg_register_plugin_hook_handler('graph:properties', 'site', new Handlers\SitePropertiesHook()); elgg_register_plugin_hook_handler('graph:properties', 'object', new Handlers\ObjectPropertiesHook()); elgg_register_plugin_hook_handler('graph:properties', 'object:blog', new Handlers\BlogPropertiesHook()); elgg_register_plugin_hook_handler('graph:properties', 'object:file', new Handlers\FilePropertiesHook()); elgg_register_plugin_hook_handler('graph:properties', 'object:messages', new Handlers\MessagePropertiesHook()); elgg_register_plugin_hook_handler('graph:properties', 'metadata', new Handlers\ExtenderPropertiesHook()); elgg_register_plugin_hook_handler('graph:properties', 'annotation', new Handlers\ExtenderPropertiesHook()); elgg_register_plugin_hook_handler('graph:properties', 'relationship', new Handlers\RelationshipPropertiesHook()); elgg_register_plugin_hook_handler('graph:properties', 'river:item', new Handlers\RiverPropertiesHook()); }
[ "public", "function", "init", "(", ")", "{", "elgg_register_plugin_hook_handler", "(", "'entity:icon:url'", ",", "'all'", ",", "new", "Handlers", "\\", "EntityIconUrlHook", "(", ")", ")", ";", "elgg_register_plugin_hook_handler", "(", "'graph:properties'", ",", "'all'...
'init','system' callback
[ "init", "system", "callback" ]
704a0aa57e817aa38bb9e40ad3710ba69d52e44c
https://github.com/hypeJunction/hypeApps/blob/704a0aa57e817aa38bb9e40ad3710ba69d52e44c/classes/hypeJunction/Apps/Plugin.php#L71-L90
train
shopgate/cart-integration-magento2-base
src/Helper/Quote/Coupon.php
Coupon.setCoupon
public function setCoupon() { foreach ($this->cart->getExternalCoupons() as $coupon) { $this->setCouponToQuote($coupon); } return $this->quote; }
php
public function setCoupon() { foreach ($this->cart->getExternalCoupons() as $coupon) { $this->setCouponToQuote($coupon); } return $this->quote; }
[ "public", "function", "setCoupon", "(", ")", "{", "foreach", "(", "$", "this", "->", "cart", "->", "getExternalCoupons", "(", ")", "as", "$", "coupon", ")", "{", "$", "this", "->", "setCouponToQuote", "(", "$", "coupon", ")", ";", "}", "return", "$", ...
Sets coupon to quote @return Quote
[ "Sets", "coupon", "to", "quote" ]
e7f8dec935aa9b23cd5b434484bc45033e62d270
https://github.com/shopgate/cart-integration-magento2-base/blob/e7f8dec935aa9b23cd5b434484bc45033e62d270/src/Helper/Quote/Coupon.php#L70-L77
train
hypeJunction/hypeApps
classes/hypeJunction/Controllers/Actions.php
Actions.parseActionName
public function parseActionName() { $uri = trim(get_input('__elgg_uri', ''), '/'); $segments = explode('/', $uri); $handler = array_shift($segments); if ($handler == 'action') { return implode('/', $segments); } return $uri; }
php
public function parseActionName() { $uri = trim(get_input('__elgg_uri', ''), '/'); $segments = explode('/', $uri); $handler = array_shift($segments); if ($handler == 'action') { return implode('/', $segments); } return $uri; }
[ "public", "function", "parseActionName", "(", ")", "{", "$", "uri", "=", "trim", "(", "get_input", "(", "'__elgg_uri'", ",", "''", ")", ",", "'/'", ")", ";", "$", "segments", "=", "explode", "(", "'/'", ",", "$", "uri", ")", ";", "$", "handler", "=...
Parses action name @return string
[ "Parses", "action", "name" ]
704a0aa57e817aa38bb9e40ad3710ba69d52e44c
https://github.com/hypeJunction/hypeApps/blob/704a0aa57e817aa38bb9e40ad3710ba69d52e44c/classes/hypeJunction/Controllers/Actions.php#L87-L95
train
shopgate/cart-integration-magento2-base
src/Model/Shopgate/Extended/Base.php
Base.getItemsWithUnhandledErrors
public function getItemsWithUnhandledErrors() { $list = []; foreach ($this->getItems() as $item) { if ($item->hasUnhandledError()) { $list[] = $item; } } return $list; }
php
public function getItemsWithUnhandledErrors() { $list = []; foreach ($this->getItems() as $item) { if ($item->hasUnhandledError()) { $list[] = $item; } } return $list; }
[ "public", "function", "getItemsWithUnhandledErrors", "(", ")", "{", "$", "list", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "getItems", "(", ")", "as", "$", "item", ")", "{", "if", "(", "$", "item", "->", "hasUnhandledError", "(", ")", ")...
Returns cart items with errors @return OrderItem[]
[ "Returns", "cart", "items", "with", "errors" ]
e7f8dec935aa9b23cd5b434484bc45033e62d270
https://github.com/shopgate/cart-integration-magento2-base/blob/e7f8dec935aa9b23cd5b434484bc45033e62d270/src/Model/Shopgate/Extended/Base.php#L60-L70
train
shopgate/cart-integration-magento2-base
src/Model/Shopgate/Extended/Base.php
Base.setItems
public function setItems($list) { if (!is_array($list)) { $this->items = null; return; } $items = []; foreach ($list as $index => $element) { if ((!is_object($element) || !($element instanceof \ShopgateOrderItem)) && !is_array($element)) { unset($list[$index]); continue; } if ($element instanceof \ShopgateOrderItem) { $element = $element->toArray(); } $item = $this->itemFactory->create(); $item->loadArray($element); $items[$item->getItemNumber()] = $item; } $this->items = $items; }
php
public function setItems($list) { if (!is_array($list)) { $this->items = null; return; } $items = []; foreach ($list as $index => $element) { if ((!is_object($element) || !($element instanceof \ShopgateOrderItem)) && !is_array($element)) { unset($list[$index]); continue; } if ($element instanceof \ShopgateOrderItem) { $element = $element->toArray(); } $item = $this->itemFactory->create(); $item->loadArray($element); $items[$item->getItemNumber()] = $item; } $this->items = $items; }
[ "public", "function", "setItems", "(", "$", "list", ")", "{", "if", "(", "!", "is_array", "(", "$", "list", ")", ")", "{", "$", "this", "->", "items", "=", "null", ";", "return", ";", "}", "$", "items", "=", "[", "]", ";", "foreach", "(", "$", ...
Rewrite of the original just to swap out the objects into our custom item classes @param OrderItem[] | null $list
[ "Rewrite", "of", "the", "original", "just", "to", "swap", "out", "the", "objects", "into", "our", "custom", "item", "classes" ]
e7f8dec935aa9b23cd5b434484bc45033e62d270
https://github.com/shopgate/cart-integration-magento2-base/blob/e7f8dec935aa9b23cd5b434484bc45033e62d270/src/Model/Shopgate/Extended/Base.php#L87-L112
train
shopgate/cart-integration-magento2-base
src/Model/Shopgate/Extended/Base.php
Base.customFieldsToArray
public function customFieldsToArray() { $result = []; foreach ($this->getCustomFields() as $field) { $result[$field->getInternalFieldName()] = $field->getValue(); } return $result; }
php
public function customFieldsToArray() { $result = []; foreach ($this->getCustomFields() as $field) { $result[$field->getInternalFieldName()] = $field->getValue(); } return $result; }
[ "public", "function", "customFieldsToArray", "(", ")", "{", "$", "result", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "getCustomFields", "(", ")", "as", "$", "field", ")", "{", "$", "result", "[", "$", "field", "->", "getInternalFieldName", ...
Returns fields in array format ready for magento import @return array
[ "Returns", "fields", "in", "array", "format", "ready", "for", "magento", "import" ]
e7f8dec935aa9b23cd5b434484bc45033e62d270
https://github.com/shopgate/cart-integration-magento2-base/blob/e7f8dec935aa9b23cd5b434484bc45033e62d270/src/Model/Shopgate/Extended/Base.php#L271-L279
train
hypeJunction/hypeApps
classes/hypeJunction/Data/Property.php
Property.toArray
public function toArray() { return array_filter(array( 'name' => $this->getAttributeName(), 'required' => $this->required, 'type' => $this->type, 'enum' => $this->getEnumOptions(), 'default' => $this->default, )); }
php
public function toArray() { return array_filter(array( 'name' => $this->getAttributeName(), 'required' => $this->required, 'type' => $this->type, 'enum' => $this->getEnumOptions(), 'default' => $this->default, )); }
[ "public", "function", "toArray", "(", ")", "{", "return", "array_filter", "(", "array", "(", "'name'", "=>", "$", "this", "->", "getAttributeName", "(", ")", ",", "'required'", "=>", "$", "this", "->", "required", ",", "'type'", "=>", "$", "this", "->", ...
Exports property to an array @return array
[ "Exports", "property", "to", "an", "array" ]
704a0aa57e817aa38bb9e40ad3710ba69d52e44c
https://github.com/hypeJunction/hypeApps/blob/704a0aa57e817aa38bb9e40ad3710ba69d52e44c/classes/hypeJunction/Data/Property.php#L353-L361
train
ARCANEDEV/Notify
src/NotifyServiceProvider.php
NotifyServiceProvider.registerNotifyService
private function registerNotifyService() { $this->singleton(Contracts\Notify::class, function ($app) { /** @var \Illuminate\Config\Repository $config */ $config = $app['config']; return new Notify( $app[Contracts\SessionStore::class], $config->get('notify.session.prefix', 'notifier') ); }); }
php
private function registerNotifyService() { $this->singleton(Contracts\Notify::class, function ($app) { /** @var \Illuminate\Config\Repository $config */ $config = $app['config']; return new Notify( $app[Contracts\SessionStore::class], $config->get('notify.session.prefix', 'notifier') ); }); }
[ "private", "function", "registerNotifyService", "(", ")", "{", "$", "this", "->", "singleton", "(", "Contracts", "\\", "Notify", "::", "class", ",", "function", "(", "$", "app", ")", "{", "/** @var \\Illuminate\\Config\\Repository $config */", "$", "config", "=...
Register the Notify service.
[ "Register", "the", "Notify", "service", "." ]
86fb23220637417e562b3c0fa1d53c4d1d97ad46
https://github.com/ARCANEDEV/Notify/blob/86fb23220637417e562b3c0fa1d53c4d1d97ad46/src/NotifyServiceProvider.php#L88-L99
train
SaftIng/Saft
src/Saft/Rdf/AbstractStatement.php
AbstractStatement.isConcrete
public function isConcrete() { if ($this->isQuad() && !$this->getGraph()->isConcrete()) { return false; } return $this->getSubject()->isConcrete() && $this->getPredicate()->isConcrete() && $this->getObject()->isConcrete(); }
php
public function isConcrete() { if ($this->isQuad() && !$this->getGraph()->isConcrete()) { return false; } return $this->getSubject()->isConcrete() && $this->getPredicate()->isConcrete() && $this->getObject()->isConcrete(); }
[ "public", "function", "isConcrete", "(", ")", "{", "if", "(", "$", "this", "->", "isQuad", "(", ")", "&&", "!", "$", "this", "->", "getGraph", "(", ")", "->", "isConcrete", "(", ")", ")", "{", "return", "false", ";", "}", "return", "$", "this", "...
Returns true if neither subject, predicate, object nor, if available, graph, are patterns. @return bool true, if if neither subject, predicate, object nor, if available, graph, are patterns, false otherwise @api @since 0.1
[ "Returns", "true", "if", "neither", "subject", "predicate", "object", "nor", "if", "available", "graph", "are", "patterns", "." ]
ac2d9aed53da6ab3bb5ea05165644027df5248e8
https://github.com/SaftIng/Saft/blob/ac2d9aed53da6ab3bb5ea05165644027df5248e8/src/Saft/Rdf/AbstractStatement.php#L32-L41
train
SaftIng/Saft
src/Saft/Rdf/AbstractStatement.php
AbstractStatement.toNQuads
public function toNQuads() { if ($this->isConcrete()) { if ($this->isQuad()) { return $this->getSubject()->toNQuads().' '. $this->getPredicate()->toNQuads().' '. $this->getObject()->toNQuads().' '. $this->getGraph()->toNQuads().' .'; } else { return $this->getSubject()->toNQuads().' '. $this->getPredicate()->toNQuads().' '. $this->getObject()->toNQuads().' .'; } } else { throw new \Exception('A Statement has to be concrete in N-Quads.'); } }
php
public function toNQuads() { if ($this->isConcrete()) { if ($this->isQuad()) { return $this->getSubject()->toNQuads().' '. $this->getPredicate()->toNQuads().' '. $this->getObject()->toNQuads().' '. $this->getGraph()->toNQuads().' .'; } else { return $this->getSubject()->toNQuads().' '. $this->getPredicate()->toNQuads().' '. $this->getObject()->toNQuads().' .'; } } else { throw new \Exception('A Statement has to be concrete in N-Quads.'); } }
[ "public", "function", "toNQuads", "(", ")", "{", "if", "(", "$", "this", "->", "isConcrete", "(", ")", ")", "{", "if", "(", "$", "this", "->", "isQuad", "(", ")", ")", "{", "return", "$", "this", "->", "getSubject", "(", ")", "->", "toNQuads", "(...
Transforms content of the Statement to n-quads form. @return string N-Quads string containing subject, predicate, object and graph, if available @throws \Exception if this instance is a non-concrete statement @api @since 0.1
[ "Transforms", "content", "of", "the", "Statement", "to", "n", "-", "quads", "form", "." ]
ac2d9aed53da6ab3bb5ea05165644027df5248e8
https://github.com/SaftIng/Saft/blob/ac2d9aed53da6ab3bb5ea05165644027df5248e8/src/Saft/Rdf/AbstractStatement.php#L69-L85
train
SaftIng/Saft
src/Saft/Rdf/AbstractStatement.php
AbstractStatement.toNTriples
public function toNTriples() { if ($this->isConcrete()) { return $this->getSubject()->toNQuads().' '. $this->getPredicate()->toNQuads().' '. $this->getObject()->toNQuads().' .'; } else { throw new \Exception('A Statement has to be concrete in N-Triples.'); } }
php
public function toNTriples() { if ($this->isConcrete()) { return $this->getSubject()->toNQuads().' '. $this->getPredicate()->toNQuads().' '. $this->getObject()->toNQuads().' .'; } else { throw new \Exception('A Statement has to be concrete in N-Triples.'); } }
[ "public", "function", "toNTriples", "(", ")", "{", "if", "(", "$", "this", "->", "isConcrete", "(", ")", ")", "{", "return", "$", "this", "->", "getSubject", "(", ")", "->", "toNQuads", "(", ")", ".", "' '", ".", "$", "this", "->", "getPredicate", ...
Transforms content of the Statement to n-triples form. @return string N-triples string, containing subject, predicate and object @throws \Exception if this instance is a non-concrete statement @api @since 0.1
[ "Transforms", "content", "of", "the", "Statement", "to", "n", "-", "triples", "form", "." ]
ac2d9aed53da6ab3bb5ea05165644027df5248e8
https://github.com/SaftIng/Saft/blob/ac2d9aed53da6ab3bb5ea05165644027df5248e8/src/Saft/Rdf/AbstractStatement.php#L98-L107
train
SaftIng/Saft
src/Saft/Rdf/AbstractStatement.php
AbstractStatement.equals
public function equals(Statement $toTest) { if ($toTest instanceof Statement && $this->getSubject()->equals($toTest->getSubject()) && $this->getPredicate()->equals($toTest->getPredicate()) && $this->getObject()->equals($toTest->getObject()) ) { if ($this->isQuad() && $toTest->isQuad() && $this->getGraph()->equals($toTest->getGraph())) { return true; } elseif ($this->isTriple() && $toTest->isTriple()) { return true; } } return false; }
php
public function equals(Statement $toTest) { if ($toTest instanceof Statement && $this->getSubject()->equals($toTest->getSubject()) && $this->getPredicate()->equals($toTest->getPredicate()) && $this->getObject()->equals($toTest->getObject()) ) { if ($this->isQuad() && $toTest->isQuad() && $this->getGraph()->equals($toTest->getGraph())) { return true; } elseif ($this->isTriple() && $toTest->isTriple()) { return true; } } return false; }
[ "public", "function", "equals", "(", "Statement", "$", "toTest", ")", "{", "if", "(", "$", "toTest", "instanceof", "Statement", "&&", "$", "this", "->", "getSubject", "(", ")", "->", "equals", "(", "$", "toTest", "->", "getSubject", "(", ")", ")", "&&"...
Checks if a given statement is equal to this instance. @param Statement $toTest statement to check this instance against @return bool true, if this instance is equal to the given instance, false otherwise @api @since 0.1
[ "Checks", "if", "a", "given", "statement", "is", "equal", "to", "this", "instance", "." ]
ac2d9aed53da6ab3bb5ea05165644027df5248e8
https://github.com/SaftIng/Saft/blob/ac2d9aed53da6ab3bb5ea05165644027df5248e8/src/Saft/Rdf/AbstractStatement.php#L140-L155
train
SaftIng/Saft
src/Saft/Rdf/AbstractStatement.php
AbstractStatement.matches
public function matches(Statement $toTest) { if ($this->isConcrete() && $this->equals($toTest)) { return true; } if ($toTest instanceof Statement && $this->getSubject()->matches($toTest->getSubject()) && $this->getPredicate()->matches($toTest->getPredicate()) && $this->getObject()->matches($toTest->getObject()) ) { if ($this->isQuad() && $toTest->isQuad() && $this->getGraph()->matches($toTest->getGraph())) { return true; } elseif ($this->isQuad() && $this->getGraph()->isPattern()) { /* * This case also matches the default graph i.e. if the graph is set to a variable it also matches the * defaultgraph */ return true; } elseif ($this->isTriple() && $toTest->isTriple()) { return true; } /* * TODO What should happen if $this->isTriple() is true, should this pattern match any $quad? * This is the same descission, as, if the default graph should contain the union of all graphs! * * As I understand the situation with SPARQL it doesn't give a descission for this, but in the case that * named graphs are included in a query only using FROM NAMED the default graph is empty per definiton. * {@url http://www.w3.org/TR/2013/REC-sparql11-query-20130321/#rdfDataset} */ } return false; }
php
public function matches(Statement $toTest) { if ($this->isConcrete() && $this->equals($toTest)) { return true; } if ($toTest instanceof Statement && $this->getSubject()->matches($toTest->getSubject()) && $this->getPredicate()->matches($toTest->getPredicate()) && $this->getObject()->matches($toTest->getObject()) ) { if ($this->isQuad() && $toTest->isQuad() && $this->getGraph()->matches($toTest->getGraph())) { return true; } elseif ($this->isQuad() && $this->getGraph()->isPattern()) { /* * This case also matches the default graph i.e. if the graph is set to a variable it also matches the * defaultgraph */ return true; } elseif ($this->isTriple() && $toTest->isTriple()) { return true; } /* * TODO What should happen if $this->isTriple() is true, should this pattern match any $quad? * This is the same descission, as, if the default graph should contain the union of all graphs! * * As I understand the situation with SPARQL it doesn't give a descission for this, but in the case that * named graphs are included in a query only using FROM NAMED the default graph is empty per definiton. * {@url http://www.w3.org/TR/2013/REC-sparql11-query-20130321/#rdfDataset} */ } return false; }
[ "public", "function", "matches", "(", "Statement", "$", "toTest", ")", "{", "if", "(", "$", "this", "->", "isConcrete", "(", ")", "&&", "$", "this", "->", "equals", "(", "$", "toTest", ")", ")", "{", "return", "true", ";", "}", "if", "(", "$", "t...
Checks if this instance matches a given instance. @param Statement $toTest statement instance to check for a match @return bool true, if this instance matches a given Statement instance, false otherwise @api @since 0.1
[ "Checks", "if", "this", "instance", "matches", "a", "given", "instance", "." ]
ac2d9aed53da6ab3bb5ea05165644027df5248e8
https://github.com/SaftIng/Saft/blob/ac2d9aed53da6ab3bb5ea05165644027df5248e8/src/Saft/Rdf/AbstractStatement.php#L168-L201
train
liues1992/php-protobuf-generator
src/Gary/Protobuf/Generator/CommentStringBuffer.php
CommentStringBuffer.append
public function append($line, $newline = true, $indentOffset = 0) { $line = trim($line); if (strlen($line) > 0) { parent::append( self::COMMENT_LINE_PREFIX . ' ' . $line, $newline, $indentOffset ); } else { parent::append( self::COMMENT_LINE_PREFIX, $newline, $indentOffset ); } return $this; }
php
public function append($line, $newline = true, $indentOffset = 0) { $line = trim($line); if (strlen($line) > 0) { parent::append( self::COMMENT_LINE_PREFIX . ' ' . $line, $newline, $indentOffset ); } else { parent::append( self::COMMENT_LINE_PREFIX, $newline, $indentOffset ); } return $this; }
[ "public", "function", "append", "(", "$", "line", ",", "$", "newline", "=", "true", ",", "$", "indentOffset", "=", "0", ")", "{", "$", "line", "=", "trim", "(", "$", "line", ")", ";", "if", "(", "strlen", "(", "$", "line", ")", ">", "0", ")", ...
Appends new comment line to block @param string $line Lines to append @param bool $newline True to append extra line at the end @param int $indentOffset Ident offset @return CommentStringBuffer
[ "Appends", "new", "comment", "line", "to", "block" ]
0bae264906b9e8fd989784e482e09bd0aa649991
https://github.com/liues1992/php-protobuf-generator/blob/0bae264906b9e8fd989784e482e09bd0aa649991/src/Gary/Protobuf/Generator/CommentStringBuffer.php#L52-L65
train
Raphhh/trex-reflection
src/TypeReflection.php
TypeReflection.getStandardizedType
public function getStandardizedType() { foreach ($this->getStandardizedTypes() as $standardizedType) { if ($this->is($standardizedType)) { return $standardizedType; } } return self::UNKNOWN_TYPE; }
php
public function getStandardizedType() { foreach ($this->getStandardizedTypes() as $standardizedType) { if ($this->is($standardizedType)) { return $standardizedType; } } return self::UNKNOWN_TYPE; }
[ "public", "function", "getStandardizedType", "(", ")", "{", "foreach", "(", "$", "this", "->", "getStandardizedTypes", "(", ")", "as", "$", "standardizedType", ")", "{", "if", "(", "$", "this", "->", "is", "(", "$", "standardizedType", ")", ")", "{", "re...
Depending on the type, returns a standardized type, a constant value of XXX_TYPE. Note that if the type is a class name, object type is returned. @return string
[ "Depending", "on", "the", "type", "returns", "a", "standardized", "type", "a", "constant", "value", "of", "XXX_TYPE", ".", "Note", "that", "if", "the", "type", "is", "a", "class", "name", "object", "type", "is", "returned", "." ]
a3c36d498b58f0648b91e95d44ffea0548ae44cd
https://github.com/Raphhh/trex-reflection/blob/a3c36d498b58f0648b91e95d44ffea0548ae44cd/src/TypeReflection.php#L165-L173
train
Raphhh/trex-reflection
src/TypeReflection.php
TypeReflection.getTypeMapping
private function getTypeMapping($standardizeType) { if(!isset($this->getTypeMappingList()[$standardizeType])){ throw new InvalidArgumentException(sprintf( '$standardizeType not valid. Should be on of the values: %s. "%s" given.', json_encode($this->getStandardizedTypes()), $standardizeType )); } return $this->getTypeMappingList()[$standardizeType]; }
php
private function getTypeMapping($standardizeType) { if(!isset($this->getTypeMappingList()[$standardizeType])){ throw new InvalidArgumentException(sprintf( '$standardizeType not valid. Should be on of the values: %s. "%s" given.', json_encode($this->getStandardizedTypes()), $standardizeType )); } return $this->getTypeMappingList()[$standardizeType]; }
[ "private", "function", "getTypeMapping", "(", "$", "standardizeType", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "getTypeMappingList", "(", ")", "[", "$", "standardizeType", "]", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(",...
Returns a type mapping. @param string $standardizeType @return array
[ "Returns", "a", "type", "mapping", "." ]
a3c36d498b58f0648b91e95d44ffea0548ae44cd
https://github.com/Raphhh/trex-reflection/blob/a3c36d498b58f0648b91e95d44ffea0548ae44cd/src/TypeReflection.php#L395-L405
train
BerliozFramework/Berlioz
src/Entity/Collection.php
Collection.shuffle
public function shuffle(): Collection { // Get keys and shuffle $keys = array_keys($this->list); shuffle($keys); // Attribute shuffle keys to theirs values $newList = []; foreach ($keys as $key) { $newList[$key] = $this->list[$key]; } // Update list $this->list = $newList; return $this; }
php
public function shuffle(): Collection { // Get keys and shuffle $keys = array_keys($this->list); shuffle($keys); // Attribute shuffle keys to theirs values $newList = []; foreach ($keys as $key) { $newList[$key] = $this->list[$key]; } // Update list $this->list = $newList; return $this; }
[ "public", "function", "shuffle", "(", ")", ":", "Collection", "{", "// Get keys and shuffle", "$", "keys", "=", "array_keys", "(", "$", "this", "->", "list", ")", ";", "shuffle", "(", "$", "keys", ")", ";", "// Attribute shuffle keys to theirs values", "$", "n...
Shuffle list and preserve keys. @return static
[ "Shuffle", "list", "and", "preserve", "keys", "." ]
cd5f28f93fdff254b9a123a30dad275e5bbfd78c
https://github.com/BerliozFramework/Berlioz/blob/cd5f28f93fdff254b9a123a30dad275e5bbfd78c/src/Entity/Collection.php#L157-L173
train
BerliozFramework/Berlioz
src/Entity/Collection.php
Collection.offsetSet
public function offsetSet($offset, $value): void { if ($this->isValidEntity($value)) { if (is_null($offset) || mb_strlen($offset) == 0) { $this->list[] = $value; } else { $this->list[$offset] = $value; } } else { throw new \InvalidArgumentException(sprintf('This collection does\'t accept this entity "%s"', gettype($value))); } }
php
public function offsetSet($offset, $value): void { if ($this->isValidEntity($value)) { if (is_null($offset) || mb_strlen($offset) == 0) { $this->list[] = $value; } else { $this->list[$offset] = $value; } } else { throw new \InvalidArgumentException(sprintf('This collection does\'t accept this entity "%s"', gettype($value))); } }
[ "public", "function", "offsetSet", "(", "$", "offset", ",", "$", "value", ")", ":", "void", "{", "if", "(", "$", "this", "->", "isValidEntity", "(", "$", "value", ")", ")", "{", "if", "(", "is_null", "(", "$", "offset", ")", "||", "mb_strlen", "(",...
Assign a value to the specified offset. @param mixed $offset The offset to assign the value to @param mixed $value The value to set @see \ArrayAccess @throws \InvalidArgumentException if entity isn't accepted
[ "Assign", "a", "value", "to", "the", "specified", "offset", "." ]
cd5f28f93fdff254b9a123a30dad275e5bbfd78c
https://github.com/BerliozFramework/Berlioz/blob/cd5f28f93fdff254b9a123a30dad275e5bbfd78c/src/Entity/Collection.php#L230-L241
train
BerliozFramework/Berlioz
src/Entity/Collection.php
Collection.isValidEntity
public function isValidEntity($mixed): bool { if (empty($this->entityClasses)) { return true; } else { if (is_object($mixed)) { foreach ($this->entityClasses as $entityClass) { if (is_a($mixed, $entityClass, true)) { return true; } } } } return false; }
php
public function isValidEntity($mixed): bool { if (empty($this->entityClasses)) { return true; } else { if (is_object($mixed)) { foreach ($this->entityClasses as $entityClass) { if (is_a($mixed, $entityClass, true)) { return true; } } } } return false; }
[ "public", "function", "isValidEntity", "(", "$", "mixed", ")", ":", "bool", "{", "if", "(", "empty", "(", "$", "this", "->", "entityClasses", ")", ")", "{", "return", "true", ";", "}", "else", "{", "if", "(", "is_object", "(", "$", "mixed", ")", ")...
Check if element is valid for the list. @param mixed $mixed Element to check @return bool
[ "Check", "if", "element", "is", "valid", "for", "the", "list", "." ]
cd5f28f93fdff254b9a123a30dad275e5bbfd78c
https://github.com/BerliozFramework/Berlioz/blob/cd5f28f93fdff254b9a123a30dad275e5bbfd78c/src/Entity/Collection.php#L317-L332
train
BerliozFramework/Berlioz
src/Entity/Collection.php
Collection.mergeWith
public function mergeWith(Collection $collection): Collection { $calledClass = get_called_class(); if ($collection instanceof $calledClass) { foreach ($collection as $key => $object) { $this[$key] = $object; } } else { throw new \InvalidArgumentException(sprintf('%s::mergeWith() method require an same type of Collection.', get_class($this))); } return $this; }
php
public function mergeWith(Collection $collection): Collection { $calledClass = get_called_class(); if ($collection instanceof $calledClass) { foreach ($collection as $key => $object) { $this[$key] = $object; } } else { throw new \InvalidArgumentException(sprintf('%s::mergeWith() method require an same type of Collection.', get_class($this))); } return $this; }
[ "public", "function", "mergeWith", "(", "Collection", "$", "collection", ")", ":", "Collection", "{", "$", "calledClass", "=", "get_called_class", "(", ")", ";", "if", "(", "$", "collection", "instanceof", "$", "calledClass", ")", "{", "foreach", "(", "$", ...
Merge another Collection with this. @param \Berlioz\Core\Entity\Collection $collection Collection to merge @return static @throws \InvalidArgumentException if not the same Collection class
[ "Merge", "another", "Collection", "with", "this", "." ]
cd5f28f93fdff254b9a123a30dad275e5bbfd78c
https://github.com/BerliozFramework/Berlioz/blob/cd5f28f93fdff254b9a123a30dad275e5bbfd78c/src/Entity/Collection.php#L342-L355
train
shopgate/cart-integration-magento2-base
src/Model/Observer/AddAppOnlySalesRuleCondition.php
AddAppOnlySalesRuleCondition.execute
public function execute(\Magento\Framework\Event\Observer $observer) { $additional = $observer->getAdditional(); $conditions = (array) $additional->getConditions(); $conditions = array_merge_recursive($conditions, [$this->getShopgateCondition()]); $additional->setConditions($conditions); return $this; }
php
public function execute(\Magento\Framework\Event\Observer $observer) { $additional = $observer->getAdditional(); $conditions = (array) $additional->getConditions(); $conditions = array_merge_recursive($conditions, [$this->getShopgateCondition()]); $additional->setConditions($conditions); return $this; }
[ "public", "function", "execute", "(", "\\", "Magento", "\\", "Framework", "\\", "Event", "\\", "Observer", "$", "observer", ")", "{", "$", "additional", "=", "$", "observer", "->", "getAdditional", "(", ")", ";", "$", "conditions", "=", "(", "array", ")"...
Execute observer. @param \Magento\Framework\Event\Observer $observer @return $this
[ "Execute", "observer", "." ]
e7f8dec935aa9b23cd5b434484bc45033e62d270
https://github.com/shopgate/cart-integration-magento2-base/blob/e7f8dec935aa9b23cd5b434484bc45033e62d270/src/Model/Observer/AddAppOnlySalesRuleCondition.php#L37-L45
train
SaftIng/Saft
src/Saft/Sparql/Query/AbstractQuery.php
AbstractQuery.determineEntityType
public function determineEntityType($entity) { // remove braces at the beginning (only if $entity looks like <http://...>) if ('<' == substr($entity, 0, 1)) { $entity = str_replace(['>', '<'], '', $entity); } // checks if $entity is an URL if (true === $this->rdfHelpers->simpleCheckURI($entity)) { return 'uri'; // checks if ^^< is in $entity OR if $entity is surrounded by quotation marks } elseif (false !== strpos($entity, '"^^<') || ('"' == substr($entity, 0, 1) && '"' == substr($entity, strlen($entity) - 1, 1))) { return 'typed-literal'; // blank node } elseif (false !== strpos($entity, '_:')) { return 'blanknode'; // checks if $entity is an URL, which was written with prefix, such as rdfs:label } elseif (false !== strpos($entity, ':')) { return 'uri'; // checks if "@ is in $entity } elseif (false !== strpos($entity, '"@')) { return 'literal'; // checks if $entity is a string; only strings can be a variable } elseif (true === is_string($entity)) { return 'var'; // unknown type } else { return null; } }
php
public function determineEntityType($entity) { // remove braces at the beginning (only if $entity looks like <http://...>) if ('<' == substr($entity, 0, 1)) { $entity = str_replace(['>', '<'], '', $entity); } // checks if $entity is an URL if (true === $this->rdfHelpers->simpleCheckURI($entity)) { return 'uri'; // checks if ^^< is in $entity OR if $entity is surrounded by quotation marks } elseif (false !== strpos($entity, '"^^<') || ('"' == substr($entity, 0, 1) && '"' == substr($entity, strlen($entity) - 1, 1))) { return 'typed-literal'; // blank node } elseif (false !== strpos($entity, '_:')) { return 'blanknode'; // checks if $entity is an URL, which was written with prefix, such as rdfs:label } elseif (false !== strpos($entity, ':')) { return 'uri'; // checks if "@ is in $entity } elseif (false !== strpos($entity, '"@')) { return 'literal'; // checks if $entity is a string; only strings can be a variable } elseif (true === is_string($entity)) { return 'var'; // unknown type } else { return null; } }
[ "public", "function", "determineEntityType", "(", "$", "entity", ")", "{", "// remove braces at the beginning (only if $entity looks like <http://...>)", "if", "(", "'<'", "==", "substr", "(", "$", "entity", ",", "0", ",", "1", ")", ")", "{", "$", "entity", "=", ...
Determines type of a entity. @param string $entity entity string @return string|null Returns either literal, typed-literal, uri or var. Returns null if it couldnt be determined.
[ "Determines", "type", "of", "a", "entity", "." ]
ac2d9aed53da6ab3bb5ea05165644027df5248e8
https://github.com/SaftIng/Saft/blob/ac2d9aed53da6ab3bb5ea05165644027df5248e8/src/Saft/Sparql/Query/AbstractQuery.php#L115-L151
train
SaftIng/Saft
src/Saft/Sparql/Query/AbstractQuery.php
AbstractQuery.determineObjectDatatype
public function determineObjectDatatype($objectString) { $datatype = null; // checks if ^^< is in $objectString $arrowPos = strpos($objectString, '"^^<'); // checks if $objectString starts with " and contains "^^< if ('"' === substr($objectString, 0, 1) && false !== $arrowPos) { // extract datatype URI $datatype = substr($objectString, $arrowPos + 4); return substr($datatype, 0, strlen($datatype) - 1); // checks for surrounding ", without ^^< } elseif ('"' == substr($objectString, 0, 1) && '"' == substr($objectString, strlen($objectString) - 1, 1)) { // if we land here, there are surrounding quotation marks, but no datatype return 'http://www.w3.org/2001/XMLSchema#string'; // malformed string, return null as datatype } else { return null; } }
php
public function determineObjectDatatype($objectString) { $datatype = null; // checks if ^^< is in $objectString $arrowPos = strpos($objectString, '"^^<'); // checks if $objectString starts with " and contains "^^< if ('"' === substr($objectString, 0, 1) && false !== $arrowPos) { // extract datatype URI $datatype = substr($objectString, $arrowPos + 4); return substr($datatype, 0, strlen($datatype) - 1); // checks for surrounding ", without ^^< } elseif ('"' == substr($objectString, 0, 1) && '"' == substr($objectString, strlen($objectString) - 1, 1)) { // if we land here, there are surrounding quotation marks, but no datatype return 'http://www.w3.org/2001/XMLSchema#string'; // malformed string, return null as datatype } else { return null; } }
[ "public", "function", "determineObjectDatatype", "(", "$", "objectString", ")", "{", "$", "datatype", "=", "null", ";", "// checks if ^^< is in $objectString", "$", "arrowPos", "=", "strpos", "(", "$", "objectString", ",", "'\"^^<'", ")", ";", "// checks if $objectS...
Determines SPARQL datatype of a given string, usually of an object value. @param string $objectString Object value, incl. datatype information. @return string|null Returns datatype of object, e.g. http://www.w3.org/2001/XMLSchema#string. Returns null if datatype couldnt be determined.
[ "Determines", "SPARQL", "datatype", "of", "a", "given", "string", "usually", "of", "an", "object", "value", "." ]
ac2d9aed53da6ab3bb5ea05165644027df5248e8
https://github.com/SaftIng/Saft/blob/ac2d9aed53da6ab3bb5ea05165644027df5248e8/src/Saft/Sparql/Query/AbstractQuery.php#L161-L185
train
SaftIng/Saft
src/Saft/Sparql/Query/AbstractQuery.php
AbstractQuery.extractNamespacesFromQuery
public function extractNamespacesFromQuery($query) { preg_match_all('/\<([a-zA-Z\\\.\/\-\#\:0-9]+)\>/', $query, $matches); $uris = []; // only use URI until the last occurence of one of these chars: # / foreach ($matches[1] as $match) { $hashPos = strrpos($match, '#'); // check for last # if (false !== $hashPos) { $uri = substr($match, 0, $hashPos + 1); } else { if (7 < strlen($match)) { $slashPos = strrpos($match, '/', 7); // check for last / if (false !== $slashPos) { $uri = substr($match, 0, $slashPos + 1); } else { continue; } } else { continue; } } $uris[$uri] = $uri; } $uris = array_values($uris); $prefixes = []; $uriSet = false; $prefixNumber = 0; foreach ($uris as $uri) { $uriSet = false; // go through common namespaces and try to find according prefix for // current URI foreach ($this->commonNamespaces as $prefix => $_uri) { if ($uri == $_uri) { $prefixes[$prefix] = $uri; $uriSet = true; break; } } // in case, it couldnt find according prefix, generate one if (false === $uriSet) { $prefixes['ns-'.$prefixNumber++] = $uri; } } return $prefixes; }
php
public function extractNamespacesFromQuery($query) { preg_match_all('/\<([a-zA-Z\\\.\/\-\#\:0-9]+)\>/', $query, $matches); $uris = []; // only use URI until the last occurence of one of these chars: # / foreach ($matches[1] as $match) { $hashPos = strrpos($match, '#'); // check for last # if (false !== $hashPos) { $uri = substr($match, 0, $hashPos + 1); } else { if (7 < strlen($match)) { $slashPos = strrpos($match, '/', 7); // check for last / if (false !== $slashPos) { $uri = substr($match, 0, $slashPos + 1); } else { continue; } } else { continue; } } $uris[$uri] = $uri; } $uris = array_values($uris); $prefixes = []; $uriSet = false; $prefixNumber = 0; foreach ($uris as $uri) { $uriSet = false; // go through common namespaces and try to find according prefix for // current URI foreach ($this->commonNamespaces as $prefix => $_uri) { if ($uri == $_uri) { $prefixes[$prefix] = $uri; $uriSet = true; break; } } // in case, it couldnt find according prefix, generate one if (false === $uriSet) { $prefixes['ns-'.$prefixNumber++] = $uri; } } return $prefixes; }
[ "public", "function", "extractNamespacesFromQuery", "(", "$", "query", ")", "{", "preg_match_all", "(", "'/\\<([a-zA-Z\\\\\\.\\/\\-\\#\\:0-9]+)\\>/'", ",", "$", "query", ",", "$", "matches", ")", ";", "$", "uris", "=", "[", "]", ";", "// only use URI until the last ...
Extracts prefixes from a given query. @param string $query query to get prefixes from @return array list of extracted prefixes
[ "Extracts", "prefixes", "from", "a", "given", "query", "." ]
ac2d9aed53da6ab3bb5ea05165644027df5248e8
https://github.com/SaftIng/Saft/blob/ac2d9aed53da6ab3bb5ea05165644027df5248e8/src/Saft/Sparql/Query/AbstractQuery.php#L460-L514
train
SaftIng/Saft
src/Saft/Sparql/Query/AbstractQuery.php
AbstractQuery.extractPrefixesFromQuery
public function extractPrefixesFromQuery($query) { preg_match_all('/PREFIX\s+([a-z0-9]+)\:\s*\<([a-z0-9\:\/\.\#\-]+)\>/', $query, $matches); $prefixes = []; foreach ($matches[1] as $index => $key) { $prefixes[$key] = $matches[2][$index]; } return $prefixes; }
php
public function extractPrefixesFromQuery($query) { preg_match_all('/PREFIX\s+([a-z0-9]+)\:\s*\<([a-z0-9\:\/\.\#\-]+)\>/', $query, $matches); $prefixes = []; foreach ($matches[1] as $index => $key) { $prefixes[$key] = $matches[2][$index]; } return $prefixes; }
[ "public", "function", "extractPrefixesFromQuery", "(", "$", "query", ")", "{", "preg_match_all", "(", "'/PREFIX\\s+([a-z0-9]+)\\:\\s*\\<([a-z0-9\\:\\/\\.\\#\\-]+)\\>/'", ",", "$", "query", ",", "$", "matches", ")", ";", "$", "prefixes", "=", "[", "]", ";", "foreach"...
Extracts prefixes from the prologue part of the given query. @param string $query query to get prologue prefixes from @return array list of extracted prefixes
[ "Extracts", "prefixes", "from", "the", "prologue", "part", "of", "the", "given", "query", "." ]
ac2d9aed53da6ab3bb5ea05165644027df5248e8
https://github.com/SaftIng/Saft/blob/ac2d9aed53da6ab3bb5ea05165644027df5248e8/src/Saft/Sparql/Query/AbstractQuery.php#L523-L534
train
SaftIng/Saft
src/Saft/Sparql/Query/AbstractQuery.php
AbstractQuery.extractQuads
public function extractQuads($query) { $quads = []; /** * Matches the following pattern: Graph <http://uri/> { ?s ?p ?o } * Whereas ?s ?p ?o stands for any triple, so also for an URI. It also matches multi line strings * which have { and triple on different lines. */ $result = preg_match_all('/GRAPH\s*\<(.*?)\>\s*\{\n*\s*(.*?)\s*\n*\}/si', $query, $matches); // if no errors occour and graphs and triple where found if (false !== $result && true === isset($matches[1]) && true === isset($matches[2])) { foreach ($matches[1] as $key => $graph) { // parse according triple string, for instance: <http://saft/test/s1> dc:p1 <http://saft/test/o1> // and extract S, P and O. $triplePattern = $this->extractTriplePattern($matches[2][$key]); // TODO Handle case that more than one triple pattern was found if (0 == count($triplePattern)) { throw new \Exception('Quad related part of the query is invalid: '.$matches[2][$key]); } $quad = $triplePattern[0]; $quad['g'] = $graph; $quad['g_type'] = 'uri'; $quads[] = $quad; } } return $quads; }
php
public function extractQuads($query) { $quads = []; /** * Matches the following pattern: Graph <http://uri/> { ?s ?p ?o } * Whereas ?s ?p ?o stands for any triple, so also for an URI. It also matches multi line strings * which have { and triple on different lines. */ $result = preg_match_all('/GRAPH\s*\<(.*?)\>\s*\{\n*\s*(.*?)\s*\n*\}/si', $query, $matches); // if no errors occour and graphs and triple where found if (false !== $result && true === isset($matches[1]) && true === isset($matches[2])) { foreach ($matches[1] as $key => $graph) { // parse according triple string, for instance: <http://saft/test/s1> dc:p1 <http://saft/test/o1> // and extract S, P and O. $triplePattern = $this->extractTriplePattern($matches[2][$key]); // TODO Handle case that more than one triple pattern was found if (0 == count($triplePattern)) { throw new \Exception('Quad related part of the query is invalid: '.$matches[2][$key]); } $quad = $triplePattern[0]; $quad['g'] = $graph; $quad['g_type'] = 'uri'; $quads[] = $quad; } } return $quads; }
[ "public", "function", "extractQuads", "(", "$", "query", ")", "{", "$", "quads", "=", "[", "]", ";", "/**\n * Matches the following pattern: Graph <http://uri/> { ?s ?p ?o }\n * Whereas ?s ?p ?o stands for any triple, so also for an URI. It also matches multi line strings...
Extracts quads from query, if available. @param string $query @return array
[ "Extracts", "quads", "from", "query", "if", "available", "." ]
ac2d9aed53da6ab3bb5ea05165644027df5248e8
https://github.com/SaftIng/Saft/blob/ac2d9aed53da6ab3bb5ea05165644027df5248e8/src/Saft/Sparql/Query/AbstractQuery.php#L543-L578
train
SaftIng/Saft
src/Saft/Sparql/Query/AbstractQuery.php
AbstractQuery.replacePrefixWithUri
public function replacePrefixWithUri($prefixedString, $prefixes) { // check for qname. a qname was given if a : was found, but no < and > if (false !== strpos($prefixedString, ':') && false === strpos($prefixedString, '<') && false === strpos($prefixedString, '>')) { // prefix is the part before the : $prefix = substr($prefixedString, 0, strpos($prefixedString, ':')); // if a prefix if (true === isset($prefixes[$prefix])) { $prefixedString = str_replace($prefix.':', $prefixes[$prefix], $prefixedString); } } return $prefixedString; }
php
public function replacePrefixWithUri($prefixedString, $prefixes) { // check for qname. a qname was given if a : was found, but no < and > if (false !== strpos($prefixedString, ':') && false === strpos($prefixedString, '<') && false === strpos($prefixedString, '>')) { // prefix is the part before the : $prefix = substr($prefixedString, 0, strpos($prefixedString, ':')); // if a prefix if (true === isset($prefixes[$prefix])) { $prefixedString = str_replace($prefix.':', $prefixes[$prefix], $prefixedString); } } return $prefixedString; }
[ "public", "function", "replacePrefixWithUri", "(", "$", "prefixedString", ",", "$", "prefixes", ")", "{", "// check for qname. a qname was given if a : was found, but no < and >", "if", "(", "false", "!==", "strpos", "(", "$", "prefixedString", ",", "':'", ")", "&&", ...
Replaces the prefix in a string with the original URI. @param string $prefixedString string to adapt @param array $prefixes array containing prefixes as keys and according URI as value @return string
[ "Replaces", "the", "prefix", "in", "a", "string", "with", "the", "original", "URI", "." ]
ac2d9aed53da6ab3bb5ea05165644027df5248e8
https://github.com/SaftIng/Saft/blob/ac2d9aed53da6ab3bb5ea05165644027df5248e8/src/Saft/Sparql/Query/AbstractQuery.php#L754-L769
train
milesj/transit
src/Transit/Transit.php
Transit.importFromLocal
public function importFromLocal($overwrite = true, $delete = false) { $path = $this->_data; $file = new File($path); $target = $this->findDestination($file, $overwrite); if (copy($path, $target)) { if ($delete) { $file->delete(); } $this->_file = new File($target); return true; } throw new IoException(sprintf('Failed to copy %s to new location', $file->basename())); }
php
public function importFromLocal($overwrite = true, $delete = false) { $path = $this->_data; $file = new File($path); $target = $this->findDestination($file, $overwrite); if (copy($path, $target)) { if ($delete) { $file->delete(); } $this->_file = new File($target); return true; } throw new IoException(sprintf('Failed to copy %s to new location', $file->basename())); }
[ "public", "function", "importFromLocal", "(", "$", "overwrite", "=", "true", ",", "$", "delete", "=", "false", ")", "{", "$", "path", "=", "$", "this", "->", "_data", ";", "$", "file", "=", "new", "File", "(", "$", "path", ")", ";", "$", "target", ...
Copy a local file to the temp directory and return a File object. @param bool $overwrite @param bool $delete @return bool @throws \Transit\Exception\IoException
[ "Copy", "a", "local", "file", "to", "the", "temp", "directory", "and", "return", "a", "File", "object", "." ]
2454f464e26cd1aa9c900c0535fceb731562c2e5
https://github.com/milesj/transit/blob/2454f464e26cd1aa9c900c0535fceb731562c2e5/src/Transit/Transit.php#L207-L223
train
milesj/transit
src/Transit/Transit.php
Transit.importFromRemote
public function importFromRemote($overwrite = true, array $options = array()) { if (!function_exists('curl_init')) { throw new RuntimeException('The cURL module is required for remote file importing'); } $url = $this->_data; $name = pathinfo(parse_url($url, PHP_URL_PATH), PATHINFO_BASENAME); if (!$name) { $name = md5(microtime(true)); } $options = $options + array( CURLOPT_RETURNTRANSFER => true, CURLOPT_FOLLOWLOCATION => true, CURLOPT_FAILONERROR => true, CURLOPT_SSL_VERIFYPEER => false ); // Fetch the remote file $curl = curl_init($url); curl_setopt_array($curl, $options); $response = curl_exec($curl); $error = curl_error($curl); curl_close($curl); // Save the file locally if (!$error) { $target = $this->findDestination($name, $overwrite); if (file_put_contents($target, $response)) { $this->_file = new File($target); return true; } } throw new IoException(sprintf('Failed to import %s from remote location: %s', $name, $error)); }
php
public function importFromRemote($overwrite = true, array $options = array()) { if (!function_exists('curl_init')) { throw new RuntimeException('The cURL module is required for remote file importing'); } $url = $this->_data; $name = pathinfo(parse_url($url, PHP_URL_PATH), PATHINFO_BASENAME); if (!$name) { $name = md5(microtime(true)); } $options = $options + array( CURLOPT_RETURNTRANSFER => true, CURLOPT_FOLLOWLOCATION => true, CURLOPT_FAILONERROR => true, CURLOPT_SSL_VERIFYPEER => false ); // Fetch the remote file $curl = curl_init($url); curl_setopt_array($curl, $options); $response = curl_exec($curl); $error = curl_error($curl); curl_close($curl); // Save the file locally if (!$error) { $target = $this->findDestination($name, $overwrite); if (file_put_contents($target, $response)) { $this->_file = new File($target); return true; } } throw new IoException(sprintf('Failed to import %s from remote location: %s', $name, $error)); }
[ "public", "function", "importFromRemote", "(", "$", "overwrite", "=", "true", ",", "array", "$", "options", "=", "array", "(", ")", ")", "{", "if", "(", "!", "function_exists", "(", "'curl_init'", ")", ")", "{", "throw", "new", "RuntimeException", "(", "...
Copy a remote file to the temp directory and return a File object. @param bool $overwrite @param array $options @return bool @throws \Transit\Exception\IoException @throws \RuntimeException
[ "Copy", "a", "remote", "file", "to", "the", "temp", "directory", "and", "return", "a", "File", "object", "." ]
2454f464e26cd1aa9c900c0535fceb731562c2e5
https://github.com/milesj/transit/blob/2454f464e26cd1aa9c900c0535fceb731562c2e5/src/Transit/Transit.php#L234-L272
train
milesj/transit
src/Transit/Transit.php
Transit.importFromStream
public function importFromStream($overwrite = true) { $target = $this->findDestination($this->_data, $overwrite); $input = fopen('php://input', 'r'); $output = fopen($target, 'w'); $size = stream_copy_to_stream($input, $output); fclose($input); fclose($output); if ($size <= 0) { @unlink($target); throw new IoException('No file detected in input stream'); } $this->_file = new File($target); return $size; }
php
public function importFromStream($overwrite = true) { $target = $this->findDestination($this->_data, $overwrite); $input = fopen('php://input', 'r'); $output = fopen($target, 'w'); $size = stream_copy_to_stream($input, $output); fclose($input); fclose($output); if ($size <= 0) { @unlink($target); throw new IoException('No file detected in input stream'); } $this->_file = new File($target); return $size; }
[ "public", "function", "importFromStream", "(", "$", "overwrite", "=", "true", ")", "{", "$", "target", "=", "$", "this", "->", "findDestination", "(", "$", "this", "->", "_data", ",", "$", "overwrite", ")", ";", "$", "input", "=", "fopen", "(", "'php:/...
Copy a file from the input stream into the temp directory and return a File object. Primarily used for Javascript AJAX file uploads. @param bool $overwrite @return bool @throws \Transit\Exception\IoException
[ "Copy", "a", "file", "from", "the", "input", "stream", "into", "the", "temp", "directory", "and", "return", "a", "File", "object", ".", "Primarily", "used", "for", "Javascript", "AJAX", "file", "uploads", "." ]
2454f464e26cd1aa9c900c0535fceb731562c2e5
https://github.com/milesj/transit/blob/2454f464e26cd1aa9c900c0535fceb731562c2e5/src/Transit/Transit.php#L282-L301
train
milesj/transit
src/Transit/Transit.php
Transit.rollback
public function rollback() { if ($files = $this->getAllFiles()) { foreach ($files as $file) { if ($file instanceof File) { $file->delete(); } } } $this->_file = null; $this->_files = array(); return $this; }
php
public function rollback() { if ($files = $this->getAllFiles()) { foreach ($files as $file) { if ($file instanceof File) { $file->delete(); } } } $this->_file = null; $this->_files = array(); return $this; }
[ "public", "function", "rollback", "(", ")", "{", "if", "(", "$", "files", "=", "$", "this", "->", "getAllFiles", "(", ")", ")", "{", "foreach", "(", "$", "files", "as", "$", "file", ")", "{", "if", "(", "$", "file", "instanceof", "File", ")", "{"...
Rollback and delete all uploaded and transformed files. @return \Transit\Transit
[ "Rollback", "and", "delete", "all", "uploaded", "and", "transformed", "files", "." ]
2454f464e26cd1aa9c900c0535fceb731562c2e5
https://github.com/milesj/transit/blob/2454f464e26cd1aa9c900c0535fceb731562c2e5/src/Transit/Transit.php#L308-L321
train
milesj/transit
src/Transit/Transit.php
Transit.setDirectory
public function setDirectory($path) { if (substr($path, -1) !== '/') { $path .= '/'; } if (!file_exists($path)) { mkdir($path, 0777, true); } else if (!is_writable($path)) { chmod($path, 0777); } $this->_directory = $path; return $this; }
php
public function setDirectory($path) { if (substr($path, -1) !== '/') { $path .= '/'; } if (!file_exists($path)) { mkdir($path, 0777, true); } else if (!is_writable($path)) { chmod($path, 0777); } $this->_directory = $path; return $this; }
[ "public", "function", "setDirectory", "(", "$", "path", ")", "{", "if", "(", "substr", "(", "$", "path", ",", "-", "1", ")", "!==", "'/'", ")", "{", "$", "path", ".=", "'/'", ";", "}", "if", "(", "!", "file_exists", "(", "$", "path", ")", ")", ...
Set the temporary directory and create it if it does not exist. @param string $path @return \Transit\Transit
[ "Set", "the", "temporary", "directory", "and", "create", "it", "if", "it", "does", "not", "exist", "." ]
2454f464e26cd1aa9c900c0535fceb731562c2e5
https://github.com/milesj/transit/blob/2454f464e26cd1aa9c900c0535fceb731562c2e5/src/Transit/Transit.php#L329-L344
train
milesj/transit
src/Transit/Transit.php
Transit.transform
public function transform() { $originalFile = $this->getOriginalFile(); $transformedFiles = array(); $error = null; if (!$originalFile) { throw new IoException('No original file detected'); } // Apply transformations to original if ($this->_selfTransformers) { foreach ($this->_selfTransformers as $transformer) { try { $originalFile = $transformer->transform($originalFile, true); } catch (Exception $e) { $error = $e->getMessage(); break; } } $originalFile->reset(); } // Create transformed files based off original if ($this->_transformers && !$error) { foreach ($this->_transformers as $transformer) { try { $transformedFiles[] = $transformer->transform($originalFile, false); } catch (Exception $e) { $error = $e->getMessage(); break; } } } $this->_file = $originalFile; $this->_files = $transformedFiles; // Throw error and rollback if ($error) { $this->rollback(); throw new TransformationException($error); } return true; }
php
public function transform() { $originalFile = $this->getOriginalFile(); $transformedFiles = array(); $error = null; if (!$originalFile) { throw new IoException('No original file detected'); } // Apply transformations to original if ($this->_selfTransformers) { foreach ($this->_selfTransformers as $transformer) { try { $originalFile = $transformer->transform($originalFile, true); } catch (Exception $e) { $error = $e->getMessage(); break; } } $originalFile->reset(); } // Create transformed files based off original if ($this->_transformers && !$error) { foreach ($this->_transformers as $transformer) { try { $transformedFiles[] = $transformer->transform($originalFile, false); } catch (Exception $e) { $error = $e->getMessage(); break; } } } $this->_file = $originalFile; $this->_files = $transformedFiles; // Throw error and rollback if ($error) { $this->rollback(); throw new TransformationException($error); } return true; }
[ "public", "function", "transform", "(", ")", "{", "$", "originalFile", "=", "$", "this", "->", "getOriginalFile", "(", ")", ";", "$", "transformedFiles", "=", "array", "(", ")", ";", "$", "error", "=", "null", ";", "if", "(", "!", "$", "originalFile", ...
Apply transformations to the original file and generate new transformed files. @return bool @throws \Transit\Exception\IoException @throws \Transit\Exception\TransformationException
[ "Apply", "transformations", "to", "the", "original", "file", "and", "generate", "new", "transformed", "files", "." ]
2454f464e26cd1aa9c900c0535fceb731562c2e5
https://github.com/milesj/transit/blob/2454f464e26cd1aa9c900c0535fceb731562c2e5/src/Transit/Transit.php#L377-L425
train
milesj/transit
src/Transit/Transit.php
Transit.transport
public function transport(array $config = array()) { if (!$this->_transporter) { throw new InvalidArgumentException('No Transporter has been defined'); } $localFiles = $this->getAllFiles(); $transportedFiles = array(); $error = null; if (!$localFiles) { throw new IoException('No files to transport'); } foreach ($localFiles as $i => $file) { try { $tempConfig = $config; if (isset($tempConfig[$i])) { $tempConfig = array_merge($tempConfig, $tempConfig[$i]); } $transportedFiles[] = $this->getTransporter()->transport($file, $tempConfig); } catch (Exception $e) { $error = $e->getMessage(); break; } } // Throw error and rollback if ($error) { $this->rollback(); if ($transportedFiles) { foreach ($transportedFiles as $path) { $this->getTransporter()->delete($path); } } throw new TransportationException($error); } return $transportedFiles; }
php
public function transport(array $config = array()) { if (!$this->_transporter) { throw new InvalidArgumentException('No Transporter has been defined'); } $localFiles = $this->getAllFiles(); $transportedFiles = array(); $error = null; if (!$localFiles) { throw new IoException('No files to transport'); } foreach ($localFiles as $i => $file) { try { $tempConfig = $config; if (isset($tempConfig[$i])) { $tempConfig = array_merge($tempConfig, $tempConfig[$i]); } $transportedFiles[] = $this->getTransporter()->transport($file, $tempConfig); } catch (Exception $e) { $error = $e->getMessage(); break; } } // Throw error and rollback if ($error) { $this->rollback(); if ($transportedFiles) { foreach ($transportedFiles as $path) { $this->getTransporter()->delete($path); } } throw new TransportationException($error); } return $transportedFiles; }
[ "public", "function", "transport", "(", "array", "$", "config", "=", "array", "(", ")", ")", "{", "if", "(", "!", "$", "this", "->", "_transporter", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'No Transporter has been defined'", ")", ";", "}"...
Transport the file using the Transporter object. An array of configuration can be passed to override the transporter configuration. If the configuration is numerically indexed, individual file overrides can be set. @param array $config @return array @throws \Transit\Exception\IoException @throws \Transit\Exception\TransportationException @throws \InvalidArgumentException
[ "Transport", "the", "file", "using", "the", "Transporter", "object", ".", "An", "array", "of", "configuration", "can", "be", "passed", "to", "override", "the", "transporter", "configuration", ".", "If", "the", "configuration", "is", "numerically", "indexed", "in...
2454f464e26cd1aa9c900c0535fceb731562c2e5
https://github.com/milesj/transit/blob/2454f464e26cd1aa9c900c0535fceb731562c2e5/src/Transit/Transit.php#L438-L481
train
milesj/transit
src/Transit/Transit.php
Transit.upload
public function upload($overwrite = false) { $data = $this->_data; if (empty($data['tmp_name'])) { throw new ValidationException('Invalid file detected for upload'); } // Check upload errors if ($data['error'] > 0 || !$this->_isUploadedFile($data['tmp_name'])) { switch ($data['error']) { case UPLOAD_ERR_INI_SIZE: case UPLOAD_ERR_FORM_SIZE: $error = 'File exceeds the maximum file size'; break; case UPLOAD_ERR_PARTIAL: $error = 'File was only partially uploaded'; break; case UPLOAD_ERR_NO_FILE: $error = 'No file was found for upload'; break; default: $error = 'File failed to upload'; break; } throw new ValidationException($error); } // Validate rules if ($validator = $this->getValidator()) { $validator ->setFile(new File($data)) ->validate(); } // Upload the file $target = $this->findDestination($data['name'], $overwrite); if ($this->_moveUploadedFile($data['tmp_name'], $target)) { $data['name'] = basename($target); $data['tmp_name'] = $target; $this->_file = new File($data); return true; } throw new ValidationException('An unknown error has occurred'); }
php
public function upload($overwrite = false) { $data = $this->_data; if (empty($data['tmp_name'])) { throw new ValidationException('Invalid file detected for upload'); } // Check upload errors if ($data['error'] > 0 || !$this->_isUploadedFile($data['tmp_name'])) { switch ($data['error']) { case UPLOAD_ERR_INI_SIZE: case UPLOAD_ERR_FORM_SIZE: $error = 'File exceeds the maximum file size'; break; case UPLOAD_ERR_PARTIAL: $error = 'File was only partially uploaded'; break; case UPLOAD_ERR_NO_FILE: $error = 'No file was found for upload'; break; default: $error = 'File failed to upload'; break; } throw new ValidationException($error); } // Validate rules if ($validator = $this->getValidator()) { $validator ->setFile(new File($data)) ->validate(); } // Upload the file $target = $this->findDestination($data['name'], $overwrite); if ($this->_moveUploadedFile($data['tmp_name'], $target)) { $data['name'] = basename($target); $data['tmp_name'] = $target; $this->_file = new File($data); return true; } throw new ValidationException('An unknown error has occurred'); }
[ "public", "function", "upload", "(", "$", "overwrite", "=", "false", ")", "{", "$", "data", "=", "$", "this", "->", "_data", ";", "if", "(", "empty", "(", "$", "data", "[", "'tmp_name'", "]", ")", ")", "{", "throw", "new", "ValidationException", "(",...
Upload the file to the target directory. @param bool $overwrite @return bool @throws \Transit\Exception\ValidationException
[ "Upload", "the", "file", "to", "the", "target", "directory", "." ]
2454f464e26cd1aa9c900c0535fceb731562c2e5
https://github.com/milesj/transit/blob/2454f464e26cd1aa9c900c0535fceb731562c2e5/src/Transit/Transit.php#L490-L538
train
inpsyde/inpsyde-validator
src/ArrayValue.php
ArrayValue.add_validator_by_key
public function add_validator_by_key( ValidatorInterface $validator, $key ) { if ( ! is_scalar( $key ) ) { throw new Exception\InvalidArgumentException( 'key should be a scalar value.' ); } $key = (string) $key; if ( ! isset ( $this->validators_by_key[ $key ] ) ) { $this->validators_by_key[ $key ] = [ ]; } $this->validators_by_key[ $key ][] = $validator; return $this; }
php
public function add_validator_by_key( ValidatorInterface $validator, $key ) { if ( ! is_scalar( $key ) ) { throw new Exception\InvalidArgumentException( 'key should be a scalar value.' ); } $key = (string) $key; if ( ! isset ( $this->validators_by_key[ $key ] ) ) { $this->validators_by_key[ $key ] = [ ]; } $this->validators_by_key[ $key ][] = $validator; return $this; }
[ "public", "function", "add_validator_by_key", "(", "ValidatorInterface", "$", "validator", ",", "$", "key", ")", "{", "if", "(", "!", "is_scalar", "(", "$", "key", ")", ")", "{", "throw", "new", "Exception", "\\", "InvalidArgumentException", "(", "'key should ...
Adding a validator grouped by array key. @throws Exception\InvalidArgumentException if type of $key is not scalar. @param ValidatorInterface $validator @param $key @return ArrayValue @deprecated Please use DataValidator::add_validator_by_key() instead
[ "Adding", "a", "validator", "grouped", "by", "array", "key", "." ]
dcc57f705f142071a1764204bb469eee0bb5015d
https://github.com/inpsyde/inpsyde-validator/blob/dcc57f705f142071a1764204bb469eee0bb5015d/src/ArrayValue.php#L87-L102
train
inpsyde/inpsyde-validator
src/ArrayValue.php
ArrayValue.validate
private function validate( $values ) { $is_valid = TRUE; foreach ( $values as $key => $value ) { if ( ! is_scalar( $value ) ) { continue; } foreach ( $this->validators as $validator ) { $is_valid = $validator->is_valid( $value ); if ( ! $is_valid ) { $this->error_messages[ $key ] = $validator->get_error_messages(); break; } } if ( ! $is_valid ) { break; } } return $is_valid; }
php
private function validate( $values ) { $is_valid = TRUE; foreach ( $values as $key => $value ) { if ( ! is_scalar( $value ) ) { continue; } foreach ( $this->validators as $validator ) { $is_valid = $validator->is_valid( $value ); if ( ! $is_valid ) { $this->error_messages[ $key ] = $validator->get_error_messages(); break; } } if ( ! $is_valid ) { break; } } return $is_valid; }
[ "private", "function", "validate", "(", "$", "values", ")", "{", "$", "is_valid", "=", "TRUE", ";", "foreach", "(", "$", "values", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "!", "is_scalar", "(", "$", "value", ")", ")", "{", "con...
Validates all values. @param $values @return bool TRUE|FALSE
[ "Validates", "all", "values", "." ]
dcc57f705f142071a1764204bb469eee0bb5015d
https://github.com/inpsyde/inpsyde-validator/blob/dcc57f705f142071a1764204bb469eee0bb5015d/src/ArrayValue.php#L149-L174
train
inpsyde/inpsyde-validator
src/ArrayValue.php
ArrayValue.validate_by_key
protected function validate_by_key( $values ) { $is_valid = TRUE; if ( count( $this->validators_by_key ) < 1 ) { return $is_valid; } foreach ( $values as $key => $value ) { if ( ! is_scalar( $value ) || ! isset( $this->validators_by_key[ $key ] ) ) { continue; } /** @var $validators ValidatorInterface[] */ $validators = $this->validators_by_key[ $key ]; foreach ( $validators as $validator ) { $is_valid = $validator->is_valid( $value ); if ( ! $is_valid ) { $this->error_messages[ $key ] = $validator->get_error_messages(); break; } } if ( ! $is_valid ) { break; } } return $is_valid; }
php
protected function validate_by_key( $values ) { $is_valid = TRUE; if ( count( $this->validators_by_key ) < 1 ) { return $is_valid; } foreach ( $values as $key => $value ) { if ( ! is_scalar( $value ) || ! isset( $this->validators_by_key[ $key ] ) ) { continue; } /** @var $validators ValidatorInterface[] */ $validators = $this->validators_by_key[ $key ]; foreach ( $validators as $validator ) { $is_valid = $validator->is_valid( $value ); if ( ! $is_valid ) { $this->error_messages[ $key ] = $validator->get_error_messages(); break; } } if ( ! $is_valid ) { break; } } return $is_valid; }
[ "protected", "function", "validate_by_key", "(", "$", "values", ")", "{", "$", "is_valid", "=", "TRUE", ";", "if", "(", "count", "(", "$", "this", "->", "validators_by_key", ")", "<", "1", ")", "{", "return", "$", "is_valid", ";", "}", "foreach", "(", ...
Validates all values by array-key. TODO: Add option to validate recursive through an array with RecursiveArrayIterator. @param mixed $values @return bool TRUE|FALSE @deprecated
[ "Validates", "all", "values", "by", "array", "-", "key", "." ]
dcc57f705f142071a1764204bb469eee0bb5015d
https://github.com/inpsyde/inpsyde-validator/blob/dcc57f705f142071a1764204bb469eee0bb5015d/src/ArrayValue.php#L187-L218
train
gentlecat/steam-locomotive
src/Tsukanov/SteamLocomotive/Core/Tools/User.php
User.convertToCommunityId
public function convertToCommunityId($id) { switch (self::getTypeOfId($id)) { case USER_ID_TYPE_COMMUNITY: return $id; case USER_ID_TYPE_VANITY: $api_interface = new ISteamUser(); return $api_interface->ResolveVanityURL($id); case USER_ID_TYPE_STEAM: return self::steamIdToCommunityId($id); default: return FALSE; } }
php
public function convertToCommunityId($id) { switch (self::getTypeOfId($id)) { case USER_ID_TYPE_COMMUNITY: return $id; case USER_ID_TYPE_VANITY: $api_interface = new ISteamUser(); return $api_interface->ResolveVanityURL($id); case USER_ID_TYPE_STEAM: return self::steamIdToCommunityId($id); default: return FALSE; } }
[ "public", "function", "convertToCommunityId", "(", "$", "id", ")", "{", "switch", "(", "self", "::", "getTypeOfId", "(", "$", "id", ")", ")", "{", "case", "USER_ID_TYPE_COMMUNITY", ":", "return", "$", "id", ";", "case", "USER_ID_TYPE_VANITY", ":", "$", "ap...
Converts User ID into Community ID @param mixed $id User ID @return bool|null|string Returns Community ID or FALSE if supplied ID cannot be converted
[ "Converts", "User", "ID", "into", "Community", "ID" ]
4251567f39a675bca856a950ed45daa699130e1b
https://github.com/gentlecat/steam-locomotive/blob/4251567f39a675bca856a950ed45daa699130e1b/src/Tsukanov/SteamLocomotive/Core/Tools/User.php#L19-L32
train
gentlecat/steam-locomotive
src/Tsukanov/SteamLocomotive/Core/Tools/User.php
User.getTypeOfId
public function getTypeOfId($id) { if (self::validateUserId($id, USER_ID_TYPE_COMMUNITY)) return USER_ID_TYPE_COMMUNITY; if (self::validateUserId($id, USER_ID_TYPE_STEAM)) return USER_ID_TYPE_STEAM; if (self::validateUserId($id, USER_ID_TYPE_VANITY)) return USER_ID_TYPE_VANITY; return FALSE; }
php
public function getTypeOfId($id) { if (self::validateUserId($id, USER_ID_TYPE_COMMUNITY)) return USER_ID_TYPE_COMMUNITY; if (self::validateUserId($id, USER_ID_TYPE_STEAM)) return USER_ID_TYPE_STEAM; if (self::validateUserId($id, USER_ID_TYPE_VANITY)) return USER_ID_TYPE_VANITY; return FALSE; }
[ "public", "function", "getTypeOfId", "(", "$", "id", ")", "{", "if", "(", "self", "::", "validateUserId", "(", "$", "id", ",", "USER_ID_TYPE_COMMUNITY", ")", ")", "return", "USER_ID_TYPE_COMMUNITY", ";", "if", "(", "self", "::", "validateUserId", "(", "$", ...
Returns type of supplied ID @param mixed $id User ID @return bool|string Returns type of ID or FALSE if not determined
[ "Returns", "type", "of", "supplied", "ID" ]
4251567f39a675bca856a950ed45daa699130e1b
https://github.com/gentlecat/steam-locomotive/blob/4251567f39a675bca856a950ed45daa699130e1b/src/Tsukanov/SteamLocomotive/Core/Tools/User.php#L39-L45
train
gentlecat/steam-locomotive
src/Tsukanov/SteamLocomotive/Core/Tools/User.php
User.communityIdToSteamId
public function communityIdToSteamId($community_id, $is_short = FALSE) { $temp = intval($community_id) - 76561197960265728; $odd_id = $temp % 2; $temp = floor($temp / 2); if ($is_short) { return $odd_id . ':' . $temp; } else { return 'STEAM_0:' . $odd_id . ':' . $temp; } }
php
public function communityIdToSteamId($community_id, $is_short = FALSE) { $temp = intval($community_id) - 76561197960265728; $odd_id = $temp % 2; $temp = floor($temp / 2); if ($is_short) { return $odd_id . ':' . $temp; } else { return 'STEAM_0:' . $odd_id . ':' . $temp; } }
[ "public", "function", "communityIdToSteamId", "(", "$", "community_id", ",", "$", "is_short", "=", "FALSE", ")", "{", "$", "temp", "=", "intval", "(", "$", "community_id", ")", "-", "76561197960265728", ";", "$", "odd_id", "=", "$", "temp", "%", "2", ";"...
Converts Community ID to Steam ID @param int $community_id Community ID @param bool $is_short Is short Steam ID required @return string Steam ID @throws WrongIDException
[ "Converts", "Community", "ID", "to", "Steam", "ID" ]
4251567f39a675bca856a950ed45daa699130e1b
https://github.com/gentlecat/steam-locomotive/blob/4251567f39a675bca856a950ed45daa699130e1b/src/Tsukanov/SteamLocomotive/Core/Tools/User.php#L100-L110
train
PHPSnippets/CircularArray
src/CircularArray.php
CircularArray.fromArray
public static function fromArray($array, $save_indexes = true) { $circular = new self(count($array)); foreach ($array as $key => $value) { $circular[$key] = $value; } return $circular; }
php
public static function fromArray($array, $save_indexes = true) { $circular = new self(count($array)); foreach ($array as $key => $value) { $circular[$key] = $value; } return $circular; }
[ "public", "static", "function", "fromArray", "(", "$", "array", ",", "$", "save_indexes", "=", "true", ")", "{", "$", "circular", "=", "new", "self", "(", "count", "(", "$", "array", ")", ")", ";", "foreach", "(", "$", "array", "as", "$", "key", "=...
Convert a simple array to fixed circular array @param array $array @param boolean $save_indexes @return FixedCircularArray
[ "Convert", "a", "simple", "array", "to", "fixed", "circular", "array" ]
ced508492a55dad4c3fae515260f5461c30d35fc
https://github.com/PHPSnippets/CircularArray/blob/ced508492a55dad4c3fae515260f5461c30d35fc/src/CircularArray.php#L42-L51
train
webeweb/core-library
src/Model/Organizer/TimeSlotHelper.php
TimeSlotHelper.contains
public static function contains(TimeSlot $a, TimeSlot $b) { $c1 = DateTimeHelper::isBetween($b->getStartDate(), $a->getStartDate(), $a->getEndDate()); $c2 = DateTimeHelper::isBetween($b->getEndDate(), $a->getStartDate(), $a->getEndDate()); return $c1 && $c2; }
php
public static function contains(TimeSlot $a, TimeSlot $b) { $c1 = DateTimeHelper::isBetween($b->getStartDate(), $a->getStartDate(), $a->getEndDate()); $c2 = DateTimeHelper::isBetween($b->getEndDate(), $a->getStartDate(), $a->getEndDate()); return $c1 && $c2; }
[ "public", "static", "function", "contains", "(", "TimeSlot", "$", "a", ",", "TimeSlot", "$", "b", ")", "{", "$", "c1", "=", "DateTimeHelper", "::", "isBetween", "(", "$", "b", "->", "getStartDate", "(", ")", ",", "$", "a", "->", "getStartDate", "(", ...
Determines if a time slot A contains a time slot b. @param TimeSlot $a The time slot A. @param TimeSlot $b The time slot B. @return bool Returns true in case of success, false otherwise.
[ "Determines", "if", "a", "time", "slot", "A", "contains", "a", "time", "slot", "b", "." ]
bd454a47f6a28fbf6029635ee77ed01c9995cf60
https://github.com/webeweb/core-library/blob/bd454a47f6a28fbf6029635ee77ed01c9995cf60/src/Model/Organizer/TimeSlotHelper.php#L32-L36
train
webeweb/core-library
src/Model/Organizer/TimeSlotHelper.php
TimeSlotHelper.equals
public static function equals(TimeSlot $a, TimeSlot $b) { // Compare the start dates. if (false === DateTimeHelper::equals($a->getStartDate(), $b->getStartDate())) { return false; } // Compare the end dates. if (false === DateTimeHelper::equals($a->getEndDate(), $b->getEndDate())) { return false; } // Compare the time slots count. if (count($a->getTimeSlots()) !== count($b->getTimeSlots())) { return false; } // Handle each time slot. for ($i = count($a->getTimeSlots()) - 1; 0 <= $i; --$i) { if (false === static::equals($a->getTimeSlots()[$i], $b->getTimeSlots()[$i])) { return false; } } // return true; }
php
public static function equals(TimeSlot $a, TimeSlot $b) { // Compare the start dates. if (false === DateTimeHelper::equals($a->getStartDate(), $b->getStartDate())) { return false; } // Compare the end dates. if (false === DateTimeHelper::equals($a->getEndDate(), $b->getEndDate())) { return false; } // Compare the time slots count. if (count($a->getTimeSlots()) !== count($b->getTimeSlots())) { return false; } // Handle each time slot. for ($i = count($a->getTimeSlots()) - 1; 0 <= $i; --$i) { if (false === static::equals($a->getTimeSlots()[$i], $b->getTimeSlots()[$i])) { return false; } } // return true; }
[ "public", "static", "function", "equals", "(", "TimeSlot", "$", "a", ",", "TimeSlot", "$", "b", ")", "{", "// Compare the start dates.", "if", "(", "false", "===", "DateTimeHelper", "::", "equals", "(", "$", "a", "->", "getStartDate", "(", ")", ",", "$", ...
Determines if two time slots are equals. @param TimeSlot $a The time slot A. @param TimeSlot $b The time slot B. @return bool Returns true in case of success, false otherwise.
[ "Determines", "if", "two", "time", "slots", "are", "equals", "." ]
bd454a47f6a28fbf6029635ee77ed01c9995cf60
https://github.com/webeweb/core-library/blob/bd454a47f6a28fbf6029635ee77ed01c9995cf60/src/Model/Organizer/TimeSlotHelper.php#L45-L71
train
webeweb/core-library
src/Model/Organizer/TimeSlotHelper.php
TimeSlotHelper.fullJoin
public static function fullJoin(TimeSlot $a, TimeSlot $b) { // Has full join ? if (false === static::hasFullJoin($a, $b)) { return null; } // Initialize the date/times. $startDate = DateTimeHelper::getSmaller($a->getStartDate(), $b->getStartDate()); $endDate = DateTimeHelper::getGreater($a->getEndDate(), $b->getEndDate()); // Return the time slot. return new TimeSlot(clone $startDate, clone $endDate); }
php
public static function fullJoin(TimeSlot $a, TimeSlot $b) { // Has full join ? if (false === static::hasFullJoin($a, $b)) { return null; } // Initialize the date/times. $startDate = DateTimeHelper::getSmaller($a->getStartDate(), $b->getStartDate()); $endDate = DateTimeHelper::getGreater($a->getEndDate(), $b->getEndDate()); // Return the time slot. return new TimeSlot(clone $startDate, clone $endDate); }
[ "public", "static", "function", "fullJoin", "(", "TimeSlot", "$", "a", ",", "TimeSlot", "$", "b", ")", "{", "// Has full join ?", "if", "(", "false", "===", "static", "::", "hasFullJoin", "(", "$", "a", ",", "$", "b", ")", ")", "{", "return", "null", ...
Full join two time slots. @param TimeSlot $a The time slot A. @param TimeSlot $b The time slot B. @return TimeSlot|null Returns a time slot in case of success, null otherwise.
[ "Full", "join", "two", "time", "slots", "." ]
bd454a47f6a28fbf6029635ee77ed01c9995cf60
https://github.com/webeweb/core-library/blob/bd454a47f6a28fbf6029635ee77ed01c9995cf60/src/Model/Organizer/TimeSlotHelper.php#L80-L93
train
webeweb/core-library
src/Model/Organizer/TimeSlotHelper.php
TimeSlotHelper.fullJoinWithout
public static function fullJoinWithout(TimeSlot $a, TimeSlot $b) { // Initialize the time slots. $leftJoins = static::leftJoinWithout($a, $b); $rightJoins = static::rightJoinWithout($a, $b); // Check the time slots. if (null === $leftJoins && null === $rightJoins) { return null; } if (null === $leftJoins) { return $rightJoins; } if (null === $rightJoins) { return $leftJoins; } // Return the time slots. return static::sort(array_merge($leftJoins, $rightJoins)); }
php
public static function fullJoinWithout(TimeSlot $a, TimeSlot $b) { // Initialize the time slots. $leftJoins = static::leftJoinWithout($a, $b); $rightJoins = static::rightJoinWithout($a, $b); // Check the time slots. if (null === $leftJoins && null === $rightJoins) { return null; } if (null === $leftJoins) { return $rightJoins; } if (null === $rightJoins) { return $leftJoins; } // Return the time slots. return static::sort(array_merge($leftJoins, $rightJoins)); }
[ "public", "static", "function", "fullJoinWithout", "(", "TimeSlot", "$", "a", ",", "TimeSlot", "$", "b", ")", "{", "// Initialize the time slots.", "$", "leftJoins", "=", "static", "::", "leftJoinWithout", "(", "$", "a", ",", "$", "b", ")", ";", "$", "righ...
Full join two time slots without time slots intersection. @param TimeSlot $a The time slot A. @param TimeSlot $b The time slot B. @return TimeSlot[] Returns the time slots in case of success, null otherwise.
[ "Full", "join", "two", "time", "slots", "without", "time", "slots", "intersection", "." ]
bd454a47f6a28fbf6029635ee77ed01c9995cf60
https://github.com/webeweb/core-library/blob/bd454a47f6a28fbf6029635ee77ed01c9995cf60/src/Model/Organizer/TimeSlotHelper.php#L102-L121
train
webeweb/core-library
src/Model/Organizer/TimeSlotHelper.php
TimeSlotHelper.hasInnerJoin
public static function hasInnerJoin(TimeSlot $a, TimeSlot $b) { $c1 = DateTimeHelper::isBetween($b->getStartDate(), $a->getStartDate(), $a->getEndDate()); $c2 = DateTimeHelper::isBetween($b->getEndDate(), $a->getStartDate(), $a->getEndDate()); $c3 = DateTimeHelper::isBetween($a->getStartDate(), $b->getStartDate(), $b->getEndDate()); $c4 = DateTimeHelper::isBetween($a->getEndDate(), $b->getStartDate(), $b->getEndDate()); return $c1 || $c2 || $c3 || $c4; }
php
public static function hasInnerJoin(TimeSlot $a, TimeSlot $b) { $c1 = DateTimeHelper::isBetween($b->getStartDate(), $a->getStartDate(), $a->getEndDate()); $c2 = DateTimeHelper::isBetween($b->getEndDate(), $a->getStartDate(), $a->getEndDate()); $c3 = DateTimeHelper::isBetween($a->getStartDate(), $b->getStartDate(), $b->getEndDate()); $c4 = DateTimeHelper::isBetween($a->getEndDate(), $b->getStartDate(), $b->getEndDate()); return $c1 || $c2 || $c3 || $c4; }
[ "public", "static", "function", "hasInnerJoin", "(", "TimeSlot", "$", "a", ",", "TimeSlot", "$", "b", ")", "{", "$", "c1", "=", "DateTimeHelper", "::", "isBetween", "(", "$", "b", "->", "getStartDate", "(", ")", ",", "$", "a", "->", "getStartDate", "("...
Determines if a time slot A has an inner join with time slot B. @param TimeSlot $a The time slot A. @param TimeSlot $b The time slot B. @return bool Returns true in case of success, false otherwise.
[ "Determines", "if", "a", "time", "slot", "A", "has", "an", "inner", "join", "with", "time", "slot", "B", "." ]
bd454a47f6a28fbf6029635ee77ed01c9995cf60
https://github.com/webeweb/core-library/blob/bd454a47f6a28fbf6029635ee77ed01c9995cf60/src/Model/Organizer/TimeSlotHelper.php#L155-L161
train
webeweb/core-library
src/Model/Organizer/TimeSlotHelper.php
TimeSlotHelper.innerJoin
public static function innerJoin(TimeSlot $a, TimeSlot $b) { // Has inner join ? if (false === static::hasInnerJoin($a, $b)) { return null; } // Initialize the date/times. $startDate = DateTimeHelper::getGreater($a->getStartDate(), $b->getStartDate()); $endDate = DateTimeHelper::getSmaller($a->getEndDate(), $b->getEndDate()); // Return the time slot. return new TimeSlot(clone $startDate, clone $endDate); }
php
public static function innerJoin(TimeSlot $a, TimeSlot $b) { // Has inner join ? if (false === static::hasInnerJoin($a, $b)) { return null; } // Initialize the date/times. $startDate = DateTimeHelper::getGreater($a->getStartDate(), $b->getStartDate()); $endDate = DateTimeHelper::getSmaller($a->getEndDate(), $b->getEndDate()); // Return the time slot. return new TimeSlot(clone $startDate, clone $endDate); }
[ "public", "static", "function", "innerJoin", "(", "TimeSlot", "$", "a", ",", "TimeSlot", "$", "b", ")", "{", "// Has inner join ?", "if", "(", "false", "===", "static", "::", "hasInnerJoin", "(", "$", "a", ",", "$", "b", ")", ")", "{", "return", "null"...
Inner join two time slots. @param TimeSlot $a The time slot A. @param TimeSlot $b The time slot B. @return TimeSlot|null Returns a time slot in case of success, null otherwise.
[ "Inner", "join", "two", "time", "slots", "." ]
bd454a47f6a28fbf6029635ee77ed01c9995cf60
https://github.com/webeweb/core-library/blob/bd454a47f6a28fbf6029635ee77ed01c9995cf60/src/Model/Organizer/TimeSlotHelper.php#L170-L183
train
webeweb/core-library
src/Model/Organizer/TimeSlotHelper.php
TimeSlotHelper.leftJoin
public static function leftJoin(TimeSlot $a, TimeSlot $b) { // Has inner join ? if (false === static::hasInnerJoin($a, $b)) { return null; } // Return the time slot. return new TimeSlot(clone $a->getStartDate(), clone $a->getEndDate()); }
php
public static function leftJoin(TimeSlot $a, TimeSlot $b) { // Has inner join ? if (false === static::hasInnerJoin($a, $b)) { return null; } // Return the time slot. return new TimeSlot(clone $a->getStartDate(), clone $a->getEndDate()); }
[ "public", "static", "function", "leftJoin", "(", "TimeSlot", "$", "a", ",", "TimeSlot", "$", "b", ")", "{", "// Has inner join ?", "if", "(", "false", "===", "static", "::", "hasInnerJoin", "(", "$", "a", ",", "$", "b", ")", ")", "{", "return", "null",...
Left join two time slots. @param TimeSlot $a The time slot A. @param TimeSlot $b The time slot B. @return TimeSlot Returns the time slot in case of success, null otherwise.
[ "Left", "join", "two", "time", "slots", "." ]
bd454a47f6a28fbf6029635ee77ed01c9995cf60
https://github.com/webeweb/core-library/blob/bd454a47f6a28fbf6029635ee77ed01c9995cf60/src/Model/Organizer/TimeSlotHelper.php#L192-L201
train
webeweb/core-library
src/Model/Organizer/TimeSlotHelper.php
TimeSlotHelper.leftJoinWithout
public static function leftJoinWithout(TimeSlot $a, TimeSlot $b) { // Has inner join ? if (false === static::hasInnerJoin($a, $b) || true === static::contains($b, $a)) { return null; } // Contains ? if (true === static::contains($a, $b)) { return static::sort([ new TimeSlot(clone $a->getStartDate(), clone $b->getStartDate()), new TimeSlot(clone $b->getEndDate(), clone $a->getEndDate()), ]); } // Initialize the date/times. $startDate = true === DateTimeHelper::isLessThan($a->getStartDate(), $b->getStartDate()) ? $a->getStartDate() : $b->getEndDate(); $endDate = true === DateTimeHelper::isGreaterThan($a->getEndDate(), $b->getEndDate()) ? $a->getEndDate() : $b->getStartDate(); // Return the time slots. return [ new TimeSlot(clone $startDate, clone $endDate), ]; }
php
public static function leftJoinWithout(TimeSlot $a, TimeSlot $b) { // Has inner join ? if (false === static::hasInnerJoin($a, $b) || true === static::contains($b, $a)) { return null; } // Contains ? if (true === static::contains($a, $b)) { return static::sort([ new TimeSlot(clone $a->getStartDate(), clone $b->getStartDate()), new TimeSlot(clone $b->getEndDate(), clone $a->getEndDate()), ]); } // Initialize the date/times. $startDate = true === DateTimeHelper::isLessThan($a->getStartDate(), $b->getStartDate()) ? $a->getStartDate() : $b->getEndDate(); $endDate = true === DateTimeHelper::isGreaterThan($a->getEndDate(), $b->getEndDate()) ? $a->getEndDate() : $b->getStartDate(); // Return the time slots. return [ new TimeSlot(clone $startDate, clone $endDate), ]; }
[ "public", "static", "function", "leftJoinWithout", "(", "TimeSlot", "$", "a", ",", "TimeSlot", "$", "b", ")", "{", "// Has inner join ?", "if", "(", "false", "===", "static", "::", "hasInnerJoin", "(", "$", "a", ",", "$", "b", ")", "||", "true", "===", ...
Left join two time slots without time slot B intersection. @param TimeSlot $a The time slot A. @param TimeSlot $b The time slot B. @return TimeSlot[] Returns the time slots in case of success, null otherwise.
[ "Left", "join", "two", "time", "slots", "without", "time", "slot", "B", "intersection", "." ]
bd454a47f6a28fbf6029635ee77ed01c9995cf60
https://github.com/webeweb/core-library/blob/bd454a47f6a28fbf6029635ee77ed01c9995cf60/src/Model/Organizer/TimeSlotHelper.php#L210-L233
train
webeweb/core-library
src/Model/Organizer/TimeSlotHelper.php
TimeSlotHelper.sort
public static function sort(array $timeSlots) { // Initialize a Qucik sort. $sorter = new QuickSort($timeSlots, new TimeSlotFunctor()); $sorter->sort(); // Return the time slots. return $sorter->getValues(); }
php
public static function sort(array $timeSlots) { // Initialize a Qucik sort. $sorter = new QuickSort($timeSlots, new TimeSlotFunctor()); $sorter->sort(); // Return the time slots. return $sorter->getValues(); }
[ "public", "static", "function", "sort", "(", "array", "$", "timeSlots", ")", "{", "// Initialize a Qucik sort.", "$", "sorter", "=", "new", "QuickSort", "(", "$", "timeSlots", ",", "new", "TimeSlotFunctor", "(", ")", ")", ";", "$", "sorter", "->", "sort", ...
Sort time slots. @param TimeSlot[] $timeSlots The time slots. @return TimeSlot[] Returns the sorted time slots.
[ "Sort", "time", "slots", "." ]
bd454a47f6a28fbf6029635ee77ed01c9995cf60
https://github.com/webeweb/core-library/blob/bd454a47f6a28fbf6029635ee77ed01c9995cf60/src/Model/Organizer/TimeSlotHelper.php#L304-L312
train
silverstripe/silverstripe-securityreport
src/UserSecurityReport.php
UserSecurityReport.columns
public function columns() { $columns = self::config()->columns; if (!Security::config()->get('login_recording')) { unset($columns['LastLoggedIn']); } return $columns; }
php
public function columns() { $columns = self::config()->columns; if (!Security::config()->get('login_recording')) { unset($columns['LastLoggedIn']); } return $columns; }
[ "public", "function", "columns", "(", ")", "{", "$", "columns", "=", "self", "::", "config", "(", ")", "->", "columns", ";", "if", "(", "!", "Security", "::", "config", "(", ")", "->", "get", "(", "'login_recording'", ")", ")", "{", "unset", "(", "...
Returns the column names of the report @return array
[ "Returns", "the", "column", "names", "of", "the", "report" ]
38ee887986edf878f40a8dfa7df5c37df42a5dee
https://github.com/silverstripe/silverstripe-securityreport/blob/38ee887986edf878f40a8dfa7df5c37df42a5dee/src/UserSecurityReport.php#L73-L80
train
p3ym4n/laravel-asset-manager
Asset.php
Asset.addAsset
public function addAsset(array $Asset) { if (isset($Asset['name']) && ! array_key_exists($Asset['name'], $this->holder)) { $this->holder[$Asset['name']] = $Asset; } }
php
public function addAsset(array $Asset) { if (isset($Asset['name']) && ! array_key_exists($Asset['name'], $this->holder)) { $this->holder[$Asset['name']] = $Asset; } }
[ "public", "function", "addAsset", "(", "array", "$", "Asset", ")", "{", "if", "(", "isset", "(", "$", "Asset", "[", "'name'", "]", ")", "&&", "!", "array_key_exists", "(", "$", "Asset", "[", "'name'", "]", ",", "$", "this", "->", "holder", ")", ")"...
adds the asset to the main holder @param array $Asset
[ "adds", "the", "asset", "to", "the", "main", "holder" ]
cd51fd2226e1e97c9d0ee75f1e062089082c33b2
https://github.com/p3ym4n/laravel-asset-manager/blob/cd51fd2226e1e97c9d0ee75f1e062089082c33b2/Asset.php#L26-L30
train
p3ym4n/laravel-asset-manager
Asset.php
Asset.delAsset
public function delAsset(array $Asset) { if (isset($Asset['name']) && array_key_exists($Asset['name'], $this->holder)) { unset($this->holder[$Asset['name']]); } }
php
public function delAsset(array $Asset) { if (isset($Asset['name']) && array_key_exists($Asset['name'], $this->holder)) { unset($this->holder[$Asset['name']]); } }
[ "public", "function", "delAsset", "(", "array", "$", "Asset", ")", "{", "if", "(", "isset", "(", "$", "Asset", "[", "'name'", "]", ")", "&&", "array_key_exists", "(", "$", "Asset", "[", "'name'", "]", ",", "$", "this", "->", "holder", ")", ")", "{"...
delete the asset from the main holder @param array $Asset
[ "delete", "the", "asset", "from", "the", "main", "holder" ]
cd51fd2226e1e97c9d0ee75f1e062089082c33b2
https://github.com/p3ym4n/laravel-asset-manager/blob/cd51fd2226e1e97c9d0ee75f1e062089082c33b2/Asset.php#L37-L41
train
p3ym4n/laravel-asset-manager
Asset.php
Asset.addCss
public function addCss($link) { if ( ! empty($link)) { if ( ! is_array($link)) { $link = [$link]; } $this->css = array_merge($this->css, $link); } }
php
public function addCss($link) { if ( ! empty($link)) { if ( ! is_array($link)) { $link = [$link]; } $this->css = array_merge($this->css, $link); } }
[ "public", "function", "addCss", "(", "$", "link", ")", "{", "if", "(", "!", "empty", "(", "$", "link", ")", ")", "{", "if", "(", "!", "is_array", "(", "$", "link", ")", ")", "{", "$", "link", "=", "[", "$", "link", "]", ";", "}", "$", "this...
adds css to the css list @param $link
[ "adds", "css", "to", "the", "css", "list" ]
cd51fd2226e1e97c9d0ee75f1e062089082c33b2
https://github.com/p3ym4n/laravel-asset-manager/blob/cd51fd2226e1e97c9d0ee75f1e062089082c33b2/Asset.php#L48-L55
train
p3ym4n/laravel-asset-manager
Asset.php
Asset.addJs
public function addJs($link) { if ( ! empty($link)) { if ( ! is_array($link)) { $link = [$link]; } $this->js = array_merge($this->js, $link); } }
php
public function addJs($link) { if ( ! empty($link)) { if ( ! is_array($link)) { $link = [$link]; } $this->js = array_merge($this->js, $link); } }
[ "public", "function", "addJs", "(", "$", "link", ")", "{", "if", "(", "!", "empty", "(", "$", "link", ")", ")", "{", "if", "(", "!", "is_array", "(", "$", "link", ")", ")", "{", "$", "link", "=", "[", "$", "link", "]", ";", "}", "$", "this"...
adds js to the js list @param $link
[ "adds", "js", "to", "the", "js", "list" ]
cd51fd2226e1e97c9d0ee75f1e062089082c33b2
https://github.com/p3ym4n/laravel-asset-manager/blob/cd51fd2226e1e97c9d0ee75f1e062089082c33b2/Asset.php#L62-L70
train
p3ym4n/laravel-asset-manager
Asset.php
Asset.delCss
public function delCss($link) { if ( ! empty($link)) { if ( ! is_array($link)) { $link = [$link]; } if ( ! isset($this->obsolete['css'])) { $this->obsolete['css'] = []; } $this->obsolete['css'] = array_merge($this->obsolete['css'], $link); } }
php
public function delCss($link) { if ( ! empty($link)) { if ( ! is_array($link)) { $link = [$link]; } if ( ! isset($this->obsolete['css'])) { $this->obsolete['css'] = []; } $this->obsolete['css'] = array_merge($this->obsolete['css'], $link); } }
[ "public", "function", "delCss", "(", "$", "link", ")", "{", "if", "(", "!", "empty", "(", "$", "link", ")", ")", "{", "if", "(", "!", "is_array", "(", "$", "link", ")", ")", "{", "$", "link", "=", "[", "$", "link", "]", ";", "}", "if", "(",...
deleted css from the css list @param $link
[ "deleted", "css", "from", "the", "css", "list" ]
cd51fd2226e1e97c9d0ee75f1e062089082c33b2
https://github.com/p3ym4n/laravel-asset-manager/blob/cd51fd2226e1e97c9d0ee75f1e062089082c33b2/Asset.php#L77-L87
train
p3ym4n/laravel-asset-manager
Asset.php
Asset.delJs
public function delJs($link) { if ( ! empty($link)) { if ( ! is_array($link)) { $link = [$link]; } if ( ! isset($this->obsolete['js'])) { $this->obsolete['js'] = []; } $this->obsolete['js'] = array_merge($this->obsolete['js'], $link); } }
php
public function delJs($link) { if ( ! empty($link)) { if ( ! is_array($link)) { $link = [$link]; } if ( ! isset($this->obsolete['js'])) { $this->obsolete['js'] = []; } $this->obsolete['js'] = array_merge($this->obsolete['js'], $link); } }
[ "public", "function", "delJs", "(", "$", "link", ")", "{", "if", "(", "!", "empty", "(", "$", "link", ")", ")", "{", "if", "(", "!", "is_array", "(", "$", "link", ")", ")", "{", "$", "link", "=", "[", "$", "link", "]", ";", "}", "if", "(", ...
deletes js from the js list @param $link
[ "deletes", "js", "from", "the", "js", "list" ]
cd51fd2226e1e97c9d0ee75f1e062089082c33b2
https://github.com/p3ym4n/laravel-asset-manager/blob/cd51fd2226e1e97c9d0ee75f1e062089082c33b2/Asset.php#L94-L104
train
p3ym4n/laravel-asset-manager
Asset.php
Asset.addScriptBefore
private function addScriptBefore($script) { $script = trim($script); if ($script != '') { if (strpos($this->script, $script) === false) { $this->script = " {$script} {$this->script}"; } } }
php
private function addScriptBefore($script) { $script = trim($script); if ($script != '') { if (strpos($this->script, $script) === false) { $this->script = " {$script} {$this->script}"; } } }
[ "private", "function", "addScriptBefore", "(", "$", "script", ")", "{", "$", "script", "=", "trim", "(", "$", "script", ")", ";", "if", "(", "$", "script", "!=", "''", ")", "{", "if", "(", "strpos", "(", "$", "this", "->", "script", ",", "$", "sc...
this method add the init script into the first of scripts @param $script
[ "this", "method", "add", "the", "init", "script", "into", "the", "first", "of", "scripts" ]
cd51fd2226e1e97c9d0ee75f1e062089082c33b2
https://github.com/p3ym4n/laravel-asset-manager/blob/cd51fd2226e1e97c9d0ee75f1e062089082c33b2/Asset.php#L141-L150
train
p3ym4n/laravel-asset-manager
Asset.php
Asset.reset
public function reset() { $this->script = ''; $this->style = ''; $this->js = []; $this->css = []; $this->obsolete = []; $this->holder = []; $this->run = false; }
php
public function reset() { $this->script = ''; $this->style = ''; $this->js = []; $this->css = []; $this->obsolete = []; $this->holder = []; $this->run = false; }
[ "public", "function", "reset", "(", ")", "{", "$", "this", "->", "script", "=", "''", ";", "$", "this", "->", "style", "=", "''", ";", "$", "this", "->", "js", "=", "[", "]", ";", "$", "this", "->", "css", "=", "[", "]", ";", "$", "this", "...
removes all the added style , scripts & assets
[ "removes", "all", "the", "added", "style", "scripts", "&", "assets" ]
cd51fd2226e1e97c9d0ee75f1e062089082c33b2
https://github.com/p3ym4n/laravel-asset-manager/blob/cd51fd2226e1e97c9d0ee75f1e062089082c33b2/Asset.php#L189-L197
train
p3ym4n/laravel-asset-manager
Asset.php
Asset.runCopy
private function runCopy() { if ( ! $this->run) { foreach ($this->holder as $name => $contents) { //checking the copy index if (array_key_exists('copy', $contents)) { //forceCopy flag check if ( ! array_key_exists('forceCopy', $contents)) { $contents['forceCopy'] = false; } //chmod flag check if ( ! array_key_exists('chmod', $contents)) { $contents['chmod'] = 0777; } //iterating foreach ($contents['copy'] as $from => $to) { $this->copy($from, $to, $contents['forceCopy'], $contents['chmod']); } } //some scripts have to initialized before they call statements if (array_key_exists('script', $contents)) { $this->addScriptBefore($contents['script']); } if (array_key_exists('style', $contents)) { $this->addStyle($contents['style']); } if (array_key_exists('css', $contents)) { $this->addCss($contents['css']); } if (array_key_exists('js', $contents)) { $this->addJs($contents['js']); } } //all css if (array_key_exists('css', $this->obsolete)) { $this->css = array_diff($this->css, $this->obsolete['css']); } $this->css = array_unique($this->css); //all js if (array_key_exists('js', $this->obsolete)) { $this->js = array_diff($this->js, $this->obsolete['js']); } $this->js = array_unique($this->js); //all scripts if (array_key_exists('script', $this->obsolete)) { $this->script = str_replace($this->obsolete['script'], '', $this->script); } //all styles if (array_key_exists('style', $this->obsolete)) { $this->style = str_replace($this->obsolete['style'], '', $this->style); } //the copy has been executed! $this->run = true; } }
php
private function runCopy() { if ( ! $this->run) { foreach ($this->holder as $name => $contents) { //checking the copy index if (array_key_exists('copy', $contents)) { //forceCopy flag check if ( ! array_key_exists('forceCopy', $contents)) { $contents['forceCopy'] = false; } //chmod flag check if ( ! array_key_exists('chmod', $contents)) { $contents['chmod'] = 0777; } //iterating foreach ($contents['copy'] as $from => $to) { $this->copy($from, $to, $contents['forceCopy'], $contents['chmod']); } } //some scripts have to initialized before they call statements if (array_key_exists('script', $contents)) { $this->addScriptBefore($contents['script']); } if (array_key_exists('style', $contents)) { $this->addStyle($contents['style']); } if (array_key_exists('css', $contents)) { $this->addCss($contents['css']); } if (array_key_exists('js', $contents)) { $this->addJs($contents['js']); } } //all css if (array_key_exists('css', $this->obsolete)) { $this->css = array_diff($this->css, $this->obsolete['css']); } $this->css = array_unique($this->css); //all js if (array_key_exists('js', $this->obsolete)) { $this->js = array_diff($this->js, $this->obsolete['js']); } $this->js = array_unique($this->js); //all scripts if (array_key_exists('script', $this->obsolete)) { $this->script = str_replace($this->obsolete['script'], '', $this->script); } //all styles if (array_key_exists('style', $this->obsolete)) { $this->style = str_replace($this->obsolete['style'], '', $this->style); } //the copy has been executed! $this->run = true; } }
[ "private", "function", "runCopy", "(", ")", "{", "if", "(", "!", "$", "this", "->", "run", ")", "{", "foreach", "(", "$", "this", "->", "holder", "as", "$", "name", "=>", "$", "contents", ")", "{", "//checking the copy index", "if", "(", "array_key_exi...
does all the copying and making the last cleaned arrays for use this method run only once per request
[ "does", "all", "the", "copying", "and", "making", "the", "last", "cleaned", "arrays", "for", "use", "this", "method", "run", "only", "once", "per", "request" ]
cd51fd2226e1e97c9d0ee75f1e062089082c33b2
https://github.com/p3ym4n/laravel-asset-manager/blob/cd51fd2226e1e97c9d0ee75f1e062089082c33b2/Asset.php#L251-L316
train
inc2734/wp-github-theme-updater
src/Bootstrap.php
Bootstrap._pre_set_site_transient_update_themes
public function _pre_set_site_transient_update_themes( $transient ) { $current = wp_get_theme( $this->theme_name ); $api_data = $this->_get_transient_api_data(); if ( is_wp_error( $api_data ) ) { $this->_set_notice_error_about_github_api(); return $transient; } if ( ! isset( $api_data->tag_name ) ) { return $transient; } if ( ! $this->_should_update( $current['Version'], $api_data->tag_name ) ) { return $transient; } $package = $this->_get_zip_url( $api_data ); $http_status_code = $this->_get_http_status_code( $package ); if ( ! $package || ! in_array( $http_status_code, [ 200, 302 ] ) ) { error_log( 'Inc2734_WP_GitHub_Theme_Updater error. zip url not found. ' . $http_status_code . ' ' . $package ); return $transient; } $transient->response[ $this->theme_name ] = [ 'theme' => $this->theme_name, 'new_version' => $api_data->tag_name, 'url' => ( ! empty( $this->fields['homepage'] ) ) ? $this->fields['homepage'] : '', 'package' => $package, ]; return $transient; }
php
public function _pre_set_site_transient_update_themes( $transient ) { $current = wp_get_theme( $this->theme_name ); $api_data = $this->_get_transient_api_data(); if ( is_wp_error( $api_data ) ) { $this->_set_notice_error_about_github_api(); return $transient; } if ( ! isset( $api_data->tag_name ) ) { return $transient; } if ( ! $this->_should_update( $current['Version'], $api_data->tag_name ) ) { return $transient; } $package = $this->_get_zip_url( $api_data ); $http_status_code = $this->_get_http_status_code( $package ); if ( ! $package || ! in_array( $http_status_code, [ 200, 302 ] ) ) { error_log( 'Inc2734_WP_GitHub_Theme_Updater error. zip url not found. ' . $http_status_code . ' ' . $package ); return $transient; } $transient->response[ $this->theme_name ] = [ 'theme' => $this->theme_name, 'new_version' => $api_data->tag_name, 'url' => ( ! empty( $this->fields['homepage'] ) ) ? $this->fields['homepage'] : '', 'package' => $package, ]; return $transient; }
[ "public", "function", "_pre_set_site_transient_update_themes", "(", "$", "transient", ")", "{", "$", "current", "=", "wp_get_theme", "(", "$", "this", "->", "theme_name", ")", ";", "$", "api_data", "=", "$", "this", "->", "_get_transient_api_data", "(", ")", "...
Overwirte site_transient_update_themes from GitHub API @param false|array $transient @return false|array
[ "Overwirte", "site_transient_update_themes", "from", "GitHub", "API" ]
f9727530f2d62b2bf0ca909704d9b9b790d4e9a5
https://github.com/inc2734/wp-github-theme-updater/blob/f9727530f2d62b2bf0ca909704d9b9b790d4e9a5/src/Bootstrap.php#L65-L97
train
inc2734/wp-github-theme-updater
src/Bootstrap.php
Bootstrap._set_notice_error_about_github_api
protected function _set_notice_error_about_github_api() { $api_data = $this->_get_transient_api_data(); if ( ! is_wp_error( $api_data ) ) { return; } add_action( 'admin_notices', function() use ( $api_data ) { ?> <div class="notice notice-error"> <p> <?php echo esc_html( $api_data->get_error_message() ); ?> </p> </div> <?php } ); }
php
protected function _set_notice_error_about_github_api() { $api_data = $this->_get_transient_api_data(); if ( ! is_wp_error( $api_data ) ) { return; } add_action( 'admin_notices', function() use ( $api_data ) { ?> <div class="notice notice-error"> <p> <?php echo esc_html( $api_data->get_error_message() ); ?> </p> </div> <?php } ); }
[ "protected", "function", "_set_notice_error_about_github_api", "(", ")", "{", "$", "api_data", "=", "$", "this", "->", "_get_transient_api_data", "(", ")", ";", "if", "(", "!", "is_wp_error", "(", "$", "api_data", ")", ")", "{", "return", ";", "}", "add_acti...
Set notice error about GitHub API using admin_notice hook @return void
[ "Set", "notice", "error", "about", "GitHub", "API", "using", "admin_notice", "hook" ]
f9727530f2d62b2bf0ca909704d9b9b790d4e9a5
https://github.com/inc2734/wp-github-theme-updater/blob/f9727530f2d62b2bf0ca909704d9b9b790d4e9a5/src/Bootstrap.php#L120-L138
train
inc2734/wp-github-theme-updater
src/Bootstrap.php
Bootstrap._get_zip_url
protected function _get_zip_url( $remote ) { $url = false; if ( ! empty( $remote->assets ) && is_array( $remote->assets ) ) { if ( ! empty( $remote->assets[0] ) && is_object( $remote->assets[0] ) ) { if ( ! empty( $remote->assets[0]->browser_download_url ) ) { $url = $remote->assets[0]->browser_download_url; } } } $tag_name = isset( $remote->tag_name ) ? $remote->tag_name : null; if ( ! $url && $tag_name ) { $url = sprintf( 'https://github.com/%1$s/%2$s/archive/%3$s.zip', $this->user_name, $this->repository, $tag_name ); } return apply_filters( sprintf( 'inc2734_github_theme_updater_zip_url_%1$s/%2$s', $this->user_name, $this->repository ), $url, $this->user_name, $this->repository, $tag_name ); }
php
protected function _get_zip_url( $remote ) { $url = false; if ( ! empty( $remote->assets ) && is_array( $remote->assets ) ) { if ( ! empty( $remote->assets[0] ) && is_object( $remote->assets[0] ) ) { if ( ! empty( $remote->assets[0]->browser_download_url ) ) { $url = $remote->assets[0]->browser_download_url; } } } $tag_name = isset( $remote->tag_name ) ? $remote->tag_name : null; if ( ! $url && $tag_name ) { $url = sprintf( 'https://github.com/%1$s/%2$s/archive/%3$s.zip', $this->user_name, $this->repository, $tag_name ); } return apply_filters( sprintf( 'inc2734_github_theme_updater_zip_url_%1$s/%2$s', $this->user_name, $this->repository ), $url, $this->user_name, $this->repository, $tag_name ); }
[ "protected", "function", "_get_zip_url", "(", "$", "remote", ")", "{", "$", "url", "=", "false", ";", "if", "(", "!", "empty", "(", "$", "remote", "->", "assets", ")", "&&", "is_array", "(", "$", "remote", "->", "assets", ")", ")", "{", "if", "(", ...
Return URL of new zip file @param object $remote Data from GitHub API @return string
[ "Return", "URL", "of", "new", "zip", "file" ]
f9727530f2d62b2bf0ca909704d9b9b790d4e9a5
https://github.com/inc2734/wp-github-theme-updater/blob/f9727530f2d62b2bf0ca909704d9b9b790d4e9a5/src/Bootstrap.php#L146-L179
train
inc2734/wp-github-theme-updater
src/Bootstrap.php
Bootstrap._get_transient_api_data
protected function _get_transient_api_data() { $transient_name = sprintf( 'wp_github_theme_updater_%1$s', $this->theme_name ); $transient = get_transient( $transient_name ); if ( false !== $transient ) { return $transient; } $api_data = $this->_get_github_api_data(); set_transient( $transient_name, $api_data, 60 * 5 ); return $api_data; }
php
protected function _get_transient_api_data() { $transient_name = sprintf( 'wp_github_theme_updater_%1$s', $this->theme_name ); $transient = get_transient( $transient_name ); if ( false !== $transient ) { return $transient; } $api_data = $this->_get_github_api_data(); set_transient( $transient_name, $api_data, 60 * 5 ); return $api_data; }
[ "protected", "function", "_get_transient_api_data", "(", ")", "{", "$", "transient_name", "=", "sprintf", "(", "'wp_github_theme_updater_%1$s'", ",", "$", "this", "->", "theme_name", ")", ";", "$", "transient", "=", "get_transient", "(", "$", "transient_name", ")"...
Return the data from the Transient API or GitHub API. @return object|WP_Error
[ "Return", "the", "data", "from", "the", "Transient", "API", "or", "GitHub", "API", "." ]
f9727530f2d62b2bf0ca909704d9b9b790d4e9a5
https://github.com/inc2734/wp-github-theme-updater/blob/f9727530f2d62b2bf0ca909704d9b9b790d4e9a5/src/Bootstrap.php#L186-L197
train
inc2734/wp-github-theme-updater
src/Bootstrap.php
Bootstrap._get_github_api_data
protected function _get_github_api_data() { $response = $this->_request_github_api(); if ( is_wp_error( $response ) ) { return $response; } $response_code = wp_remote_retrieve_response_code( $response ); $body = json_decode( wp_remote_retrieve_body( $response ) ); if ( 200 == $response_code ) { return $body; } return new \WP_Error( $response_code, 'Inc2734_WP_GitHub_Theme_Updater error. ' . $body->message ); }
php
protected function _get_github_api_data() { $response = $this->_request_github_api(); if ( is_wp_error( $response ) ) { return $response; } $response_code = wp_remote_retrieve_response_code( $response ); $body = json_decode( wp_remote_retrieve_body( $response ) ); if ( 200 == $response_code ) { return $body; } return new \WP_Error( $response_code, 'Inc2734_WP_GitHub_Theme_Updater error. ' . $body->message ); }
[ "protected", "function", "_get_github_api_data", "(", ")", "{", "$", "response", "=", "$", "this", "->", "_request_github_api", "(", ")", ";", "if", "(", "is_wp_error", "(", "$", "response", ")", ")", "{", "return", "$", "response", ";", "}", "$", "respo...
Return the data from the GitHub API. @return object|WP_Error
[ "Return", "the", "data", "from", "the", "GitHub", "API", "." ]
f9727530f2d62b2bf0ca909704d9b9b790d4e9a5
https://github.com/inc2734/wp-github-theme-updater/blob/f9727530f2d62b2bf0ca909704d9b9b790d4e9a5/src/Bootstrap.php#L204-L221
train
inc2734/wp-github-theme-updater
src/Bootstrap.php
Bootstrap._request_github_api
protected function _request_github_api() { global $wp_version; $url = sprintf( 'https://api.github.com/repos/%1$s/%2$s/releases/latest', $this->user_name, $this->repository ); return wp_remote_get( apply_filters( sprintf( 'inc2734_github_theme_updater_request_url_%1$s/%2$s', $this->user_name, $this->repository ), $url, $this->user_name, $this->repository ), [ 'user-agent' => 'WordPress/' . $wp_version, 'headers' => [ 'Accept-Encoding' => '', ], ] ); }
php
protected function _request_github_api() { global $wp_version; $url = sprintf( 'https://api.github.com/repos/%1$s/%2$s/releases/latest', $this->user_name, $this->repository ); return wp_remote_get( apply_filters( sprintf( 'inc2734_github_theme_updater_request_url_%1$s/%2$s', $this->user_name, $this->repository ), $url, $this->user_name, $this->repository ), [ 'user-agent' => 'WordPress/' . $wp_version, 'headers' => [ 'Accept-Encoding' => '', ], ] ); }
[ "protected", "function", "_request_github_api", "(", ")", "{", "global", "$", "wp_version", ";", "$", "url", "=", "sprintf", "(", "'https://api.github.com/repos/%1$s/%2$s/releases/latest'", ",", "$", "this", "->", "user_name", ",", "$", "this", "->", "repository", ...
Get request to GitHub API @return json|WP_Error
[ "Get", "request", "to", "GitHub", "API" ]
f9727530f2d62b2bf0ca909704d9b9b790d4e9a5
https://github.com/inc2734/wp-github-theme-updater/blob/f9727530f2d62b2bf0ca909704d9b9b790d4e9a5/src/Bootstrap.php#L228-L255
train
inc2734/wp-github-theme-updater
src/Bootstrap.php
Bootstrap._should_update
protected function _should_update( $current_version, $remote_version ) { return version_compare( $this->_sanitize_version( $current_version ), $this->_sanitize_version( $remote_version ), '<' ); }
php
protected function _should_update( $current_version, $remote_version ) { return version_compare( $this->_sanitize_version( $current_version ), $this->_sanitize_version( $remote_version ), '<' ); }
[ "protected", "function", "_should_update", "(", "$", "current_version", ",", "$", "remote_version", ")", "{", "return", "version_compare", "(", "$", "this", "->", "_sanitize_version", "(", "$", "current_version", ")", ",", "$", "this", "->", "_sanitize_version", ...
If remote version is newer, return true @param string $current_version @param string $remote_version @return bool
[ "If", "remote", "version", "is", "newer", "return", "true" ]
f9727530f2d62b2bf0ca909704d9b9b790d4e9a5
https://github.com/inc2734/wp-github-theme-updater/blob/f9727530f2d62b2bf0ca909704d9b9b790d4e9a5/src/Bootstrap.php#L275-L281
train
orchestral/notifier
src/Handlers/Orchestra.php
Orchestra.isUsingQueue
protected function isUsingQueue() { // It impossible to get either the email is sent out straight away // when the mailer is only push to queue, in this case we should // assume that sending is successful when using queue. $queue = false; $driver = 'mail'; if ($this->memory instanceof Provider) { $queue = $this->memory->get('email.queue', false); $driver = $this->memory->get('email.driver'); } return $queue || \in_array($driver, ['mailgun', 'mandrill', 'log']); }
php
protected function isUsingQueue() { // It impossible to get either the email is sent out straight away // when the mailer is only push to queue, in this case we should // assume that sending is successful when using queue. $queue = false; $driver = 'mail'; if ($this->memory instanceof Provider) { $queue = $this->memory->get('email.queue', false); $driver = $this->memory->get('email.driver'); } return $queue || \in_array($driver, ['mailgun', 'mandrill', 'log']); }
[ "protected", "function", "isUsingQueue", "(", ")", "{", "// It impossible to get either the email is sent out straight away", "// when the mailer is only push to queue, in this case we should", "// assume that sending is successful when using queue.", "$", "queue", "=", "false", ";", "$"...
Determine if mailer using queue. @return bool
[ "Determine", "if", "mailer", "using", "queue", "." ]
a0036f924c51ead67f3e339cd2688163876f3b59
https://github.com/orchestral/notifier/blob/a0036f924c51ead67f3e339cd2688163876f3b59/src/Handlers/Orchestra.php#L68-L83
train
shopgate/cart-integration-magento2-base
src/Helper/Shipping/Main.php
Main.getMageShippingCountries
public function getMageShippingCountries($storeId = null) { return $this ->countryCollection ->loadByStore($this->storeManager->getStore($storeId)) ->getColumnValues('country_id'); }
php
public function getMageShippingCountries($storeId = null) { return $this ->countryCollection ->loadByStore($this->storeManager->getStore($storeId)) ->getColumnValues('country_id'); }
[ "public", "function", "getMageShippingCountries", "(", "$", "storeId", "=", "null", ")", "{", "return", "$", "this", "->", "countryCollection", "->", "loadByStore", "(", "$", "this", "->", "storeManager", "->", "getStore", "(", "$", "storeId", ")", ")", "->"...
Retrieves magento's allowed shipping countries @param null|string|int $storeId - store ID of which to get the ship countries @return mixed
[ "Retrieves", "magento", "s", "allowed", "shipping", "countries" ]
e7f8dec935aa9b23cd5b434484bc45033e62d270
https://github.com/shopgate/cart-integration-magento2-base/blob/e7f8dec935aa9b23cd5b434484bc45033e62d270/src/Helper/Shipping/Main.php#L52-L58
train
shopgate/cart-integration-magento2-base
src/Helper/Shipping/Main.php
Main.getActiveCarriers
public function getActiveCarriers($storeId = null) { return $this->carrierConfig->getActiveCarriers($this->storeManager->getStore($storeId)); }
php
public function getActiveCarriers($storeId = null) { return $this->carrierConfig->getActiveCarriers($this->storeManager->getStore($storeId)); }
[ "public", "function", "getActiveCarriers", "(", "$", "storeId", "=", "null", ")", "{", "return", "$", "this", "->", "carrierConfig", "->", "getActiveCarriers", "(", "$", "this", "->", "storeManager", "->", "getStore", "(", "$", "storeId", ")", ")", ";", "}...
Retrieves all carriers that are currently set to active in magento @param null|string|int $storeId - store ID of which to get the carriers @return mixed
[ "Retrieves", "all", "carriers", "that", "are", "currently", "set", "to", "active", "in", "magento" ]
e7f8dec935aa9b23cd5b434484bc45033e62d270
https://github.com/shopgate/cart-integration-magento2-base/blob/e7f8dec935aa9b23cd5b434484bc45033e62d270/src/Helper/Shipping/Main.php#L68-L71
train
liues1992/php-protobuf-generator
src/Gary/Protobuf/Internal/FieldDescriptor.php
FieldDescriptor.getPhpType
public function getPhpType() { if (isset(self::$_phpTypesByProtobufType[$this->getType()])) { return self::$_phpTypesByProtobufType[$this->getType()]; } else { return null; } }
php
public function getPhpType() { if (isset(self::$_phpTypesByProtobufType[$this->getType()])) { return self::$_phpTypesByProtobufType[$this->getType()]; } else { return null; } }
[ "public", "function", "getPhpType", "(", ")", "{", "if", "(", "isset", "(", "self", "::", "$", "_phpTypesByProtobufType", "[", "$", "this", "->", "getType", "(", ")", "]", ")", ")", "{", "return", "self", "::", "$", "_phpTypesByProtobufType", "[", "$", ...
Returns PHP type @return string|null
[ "Returns", "PHP", "type" ]
0bae264906b9e8fd989784e482e09bd0aa649991
https://github.com/liues1992/php-protobuf-generator/blob/0bae264906b9e8fd989784e482e09bd0aa649991/src/Gary/Protobuf/Internal/FieldDescriptor.php#L132-L139
train
milesj/transit
src/Transit/Transporter/Aws/GlacierTransporter.php
GlacierTransporter.delete
public function delete($id) { $config = $this->getConfig(); try { $this->getClient()->deleteArchive(array_filter(array( 'vaultName' => $config['vault'], 'accountId' => $config['accountId'], 'archiveId' => $id ))); } catch (GlacierException $e) { return false; } return true; }
php
public function delete($id) { $config = $this->getConfig(); try { $this->getClient()->deleteArchive(array_filter(array( 'vaultName' => $config['vault'], 'accountId' => $config['accountId'], 'archiveId' => $id ))); } catch (GlacierException $e) { return false; } return true; }
[ "public", "function", "delete", "(", "$", "id", ")", "{", "$", "config", "=", "$", "this", "->", "getConfig", "(", ")", ";", "try", "{", "$", "this", "->", "getClient", "(", ")", "->", "deleteArchive", "(", "array_filter", "(", "array", "(", "'vaultN...
Delete a file from Amazon Glacier using the archive ID. @param string $id @return bool
[ "Delete", "a", "file", "from", "Amazon", "Glacier", "using", "the", "archive", "ID", "." ]
2454f464e26cd1aa9c900c0535fceb731562c2e5
https://github.com/milesj/transit/blob/2454f464e26cd1aa9c900c0535fceb731562c2e5/src/Transit/Transporter/Aws/GlacierTransporter.php#L74-L88
train
milesj/transit
src/Transit/Transporter/Aws/GlacierTransporter.php
GlacierTransporter.transport
public function transport(File $file, array $config = array()) { $config = $config + $this->getConfig(); $response = null; // If larger then 100MB, split upload into parts if ($file->size() >= (100 * Size::MB)) { $uploader = UploadBuilder::newInstance() ->setClient($this->getClient()) ->setSource($file->path()) ->setVaultName($config['vault']) ->setAccountId($config['accountId'] ?: '-') ->setPartSize(10 * Size::MB) ->build(); try { $response = $uploader->upload(); } catch (MultipartUploadException $e) { $uploader->abort(); } } else { $response = $this->getClient()->uploadArchive(array_filter(array( 'vaultName' => $config['vault'], 'accountId' => $config['accountId'], 'body' => EntityBody::factory(fopen($file->path(), 'r')), ))); } // Return archive ID if successful if ($response) { $config['removeLocal'] && $file->delete(); return $response->getPath('archiveId'); } throw new TransportationException(sprintf('Failed to transport %s to Amazon Glacier', $file->basename())); }
php
public function transport(File $file, array $config = array()) { $config = $config + $this->getConfig(); $response = null; // If larger then 100MB, split upload into parts if ($file->size() >= (100 * Size::MB)) { $uploader = UploadBuilder::newInstance() ->setClient($this->getClient()) ->setSource($file->path()) ->setVaultName($config['vault']) ->setAccountId($config['accountId'] ?: '-') ->setPartSize(10 * Size::MB) ->build(); try { $response = $uploader->upload(); } catch (MultipartUploadException $e) { $uploader->abort(); } } else { $response = $this->getClient()->uploadArchive(array_filter(array( 'vaultName' => $config['vault'], 'accountId' => $config['accountId'], 'body' => EntityBody::factory(fopen($file->path(), 'r')), ))); } // Return archive ID if successful if ($response) { $config['removeLocal'] && $file->delete(); return $response->getPath('archiveId'); } throw new TransportationException(sprintf('Failed to transport %s to Amazon Glacier', $file->basename())); }
[ "public", "function", "transport", "(", "File", "$", "file", ",", "array", "$", "config", "=", "array", "(", ")", ")", "{", "$", "config", "=", "$", "config", "+", "$", "this", "->", "getConfig", "(", ")", ";", "$", "response", "=", "null", ";", ...
Transport the file to Amazon Glacier and return the archive ID. @uses Aws\Glacier\GlacierClient @uses Aws\Glacier\Model\MultipartUpload\UploadBuilder @uses Guzzle\Http\EntityBody @param \Transit\File $file @param array $config @return string @throws \Transit\Exception\TransportationException
[ "Transport", "the", "file", "to", "Amazon", "Glacier", "and", "return", "the", "archive", "ID", "." ]
2454f464e26cd1aa9c900c0535fceb731562c2e5
https://github.com/milesj/transit/blob/2454f464e26cd1aa9c900c0535fceb731562c2e5/src/Transit/Transporter/Aws/GlacierTransporter.php#L102-L138
train
camspiers/silverstripe-loggerbridge
src/Camspiers/LoggerBridge/LoggerBridge.php
LoggerBridge.preRequest
public function preRequest( \SS_HTTPRequest $request, \Session $session, \DataModel $model ) { $this->registerGlobalHandlers(); return true; }
php
public function preRequest( \SS_HTTPRequest $request, \Session $session, \DataModel $model ) { $this->registerGlobalHandlers(); return true; }
[ "public", "function", "preRequest", "(", "\\", "SS_HTTPRequest", "$", "request", ",", "\\", "Session", "$", "session", ",", "\\", "DataModel", "$", "model", ")", "{", "$", "this", "->", "registerGlobalHandlers", "(", ")", ";", "return", "true", ";", "}" ]
This hook function is executed from RequestProcessor before the request starts @param \SS_HTTPRequest $request @param \Session $session @param \DataModel $model @return bool @SuppressWarnings("unused")
[ "This", "hook", "function", "is", "executed", "from", "RequestProcessor", "before", "the", "request", "starts" ]
16891556ff2e9eb7c2f94e42106044fb28bde33d
https://github.com/camspiers/silverstripe-loggerbridge/blob/16891556ff2e9eb7c2f94e42106044fb28bde33d/src/Camspiers/LoggerBridge/LoggerBridge.php#L315-L323
train
camspiers/silverstripe-loggerbridge
src/Camspiers/LoggerBridge/LoggerBridge.php
LoggerBridge.postRequest
public function postRequest( \SS_HTTPRequest $request, \SS_HTTPResponse $response, \DataModel $model ) { $this->deregisterGlobalHandlers(); return true; }
php
public function postRequest( \SS_HTTPRequest $request, \SS_HTTPResponse $response, \DataModel $model ) { $this->deregisterGlobalHandlers(); return true; }
[ "public", "function", "postRequest", "(", "\\", "SS_HTTPRequest", "$", "request", ",", "\\", "SS_HTTPResponse", "$", "response", ",", "\\", "DataModel", "$", "model", ")", "{", "$", "this", "->", "deregisterGlobalHandlers", "(", ")", ";", "return", "true", "...
This hook function is executed from RequestProcessor after the request ends @param \SS_HTTPRequest $request @param \SS_HTTPResponse $response @param \DataModel $model @return bool @SuppressWarnings("unused")
[ "This", "hook", "function", "is", "executed", "from", "RequestProcessor", "after", "the", "request", "ends" ]
16891556ff2e9eb7c2f94e42106044fb28bde33d
https://github.com/camspiers/silverstripe-loggerbridge/blob/16891556ff2e9eb7c2f94e42106044fb28bde33d/src/Camspiers/LoggerBridge/LoggerBridge.php#L333-L341
train
camspiers/silverstripe-loggerbridge
src/Camspiers/LoggerBridge/LoggerBridge.php
LoggerBridge.registerGlobalHandlers
public function registerGlobalHandlers() { if (!$this->registered) { // Store the previous error handler if there was any $this->registerErrorHandler(); // Store the previous exception handler if there was any $this->registerExceptionHandler(); // If the shutdown function hasn't been registered register it if ($this->registered === null) { $this->registerFatalErrorHandler(); // If suhosin is relevant then decrease the memory_limit by the reserveMemory amount // otherwise we should be able to increase the memory by our reserveMemory amount without worry if ($this->isSuhosinRelevant()) { $this->ensureSuhosinMemory(); } } $this->registered = true; } }
php
public function registerGlobalHandlers() { if (!$this->registered) { // Store the previous error handler if there was any $this->registerErrorHandler(); // Store the previous exception handler if there was any $this->registerExceptionHandler(); // If the shutdown function hasn't been registered register it if ($this->registered === null) { $this->registerFatalErrorHandler(); // If suhosin is relevant then decrease the memory_limit by the reserveMemory amount // otherwise we should be able to increase the memory by our reserveMemory amount without worry if ($this->isSuhosinRelevant()) { $this->ensureSuhosinMemory(); } } $this->registered = true; } }
[ "public", "function", "registerGlobalHandlers", "(", ")", "{", "if", "(", "!", "$", "this", "->", "registered", ")", "{", "// Store the previous error handler if there was any", "$", "this", "->", "registerErrorHandler", "(", ")", ";", "// Store the previous exception h...
Registers global error handlers
[ "Registers", "global", "error", "handlers" ]
16891556ff2e9eb7c2f94e42106044fb28bde33d
https://github.com/camspiers/silverstripe-loggerbridge/blob/16891556ff2e9eb7c2f94e42106044fb28bde33d/src/Camspiers/LoggerBridge/LoggerBridge.php#L346-L364
train
camspiers/silverstripe-loggerbridge
src/Camspiers/LoggerBridge/LoggerBridge.php
LoggerBridge.deregisterGlobalHandlers
public function deregisterGlobalHandlers() { if ($this->registered) { // Restore the previous error handler if available set_error_handler( is_callable($this->errorHandler) ? $this->errorHandler : function () { } ); // Restore the previous exception handler if available set_exception_handler( is_callable($this->exceptionHandler) ? $this->exceptionHandler : function () { } ); $this->registered = false; } }
php
public function deregisterGlobalHandlers() { if ($this->registered) { // Restore the previous error handler if available set_error_handler( is_callable($this->errorHandler) ? $this->errorHandler : function () { } ); // Restore the previous exception handler if available set_exception_handler( is_callable($this->exceptionHandler) ? $this->exceptionHandler : function () { } ); $this->registered = false; } }
[ "public", "function", "deregisterGlobalHandlers", "(", ")", "{", "if", "(", "$", "this", "->", "registered", ")", "{", "// Restore the previous error handler if available", "set_error_handler", "(", "is_callable", "(", "$", "this", "->", "errorHandler", ")", "?", "$...
Removes handlers we have added, and restores others if possible
[ "Removes", "handlers", "we", "have", "added", "and", "restores", "others", "if", "possible" ]
16891556ff2e9eb7c2f94e42106044fb28bde33d
https://github.com/camspiers/silverstripe-loggerbridge/blob/16891556ff2e9eb7c2f94e42106044fb28bde33d/src/Camspiers/LoggerBridge/LoggerBridge.php#L369-L382
train