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
fusonic/linq
src/Fusonic/Linq/Helper/Set.php
Set.find
private function find($value, $add = false) { $hash = self::hash($value); if(array_key_exists($hash, $this->objects)) { return true; } else if($add) { $this->objects[$hash] = $value; } return false; }
php
private function find($value, $add = false) { $hash = self::hash($value); if(array_key_exists($hash, $this->objects)) { return true; } else if($add) { $this->objects[$hash] = $value; } return false; }
[ "private", "function", "find", "(", "$", "value", ",", "$", "add", "=", "false", ")", "{", "$", "hash", "=", "self", "::", "hash", "(", "$", "value", ")", ";", "if", "(", "array_key_exists", "(", "$", "hash", ",", "$", "this", "->", "objects", ")", ")", "{", "return", "true", ";", "}", "else", "if", "(", "$", "add", ")", "{", "$", "this", "->", "objects", "[", "$", "hash", "]", "=", "$", "value", ";", "}", "return", "false", ";", "}" ]
Finds the given value and returns true if it was found. Otherwise return false.
[ "Finds", "the", "given", "value", "and", "returns", "true", "if", "it", "was", "found", ".", "Otherwise", "return", "false", "." ]
065bfd32674875c9b5df25d29bfe4aa3b073c88f
https://github.com/fusonic/linq/blob/065bfd32674875c9b5df25d29bfe4aa3b073c88f/src/Fusonic/Linq/Helper/Set.php#L54-L64
train
OXIDprojects/oxid-console
src/Command/GenerateModuleCommand.php
GenerateModuleCommand._generateModule
protected function _generateModule($oScaffold) { $oSmarty = $this->_getSmarty(); $oSmarty->assign('oScaffold', $oScaffold); if ($oScaffold->sVendor) { $this->_generateVendorDir($oScaffold->sVendor); } $sModuleDir = $this->_getModuleDir($oScaffold->sVendor, $oScaffold->sModuleName); $this->_copyAndParseDir( $this->_sTemplatesDir, $sModuleDir, array( '_prefix_' => strtolower($oScaffold->sVendor . $oScaffold->sModuleName) ) ); }
php
protected function _generateModule($oScaffold) { $oSmarty = $this->_getSmarty(); $oSmarty->assign('oScaffold', $oScaffold); if ($oScaffold->sVendor) { $this->_generateVendorDir($oScaffold->sVendor); } $sModuleDir = $this->_getModuleDir($oScaffold->sVendor, $oScaffold->sModuleName); $this->_copyAndParseDir( $this->_sTemplatesDir, $sModuleDir, array( '_prefix_' => strtolower($oScaffold->sVendor . $oScaffold->sModuleName) ) ); }
[ "protected", "function", "_generateModule", "(", "$", "oScaffold", ")", "{", "$", "oSmarty", "=", "$", "this", "->", "_getSmarty", "(", ")", ";", "$", "oSmarty", "->", "assign", "(", "'oScaffold'", ",", "$", "oScaffold", ")", ";", "if", "(", "$", "oScaffold", "->", "sVendor", ")", "{", "$", "this", "->", "_generateVendorDir", "(", "$", "oScaffold", "->", "sVendor", ")", ";", "}", "$", "sModuleDir", "=", "$", "this", "->", "_getModuleDir", "(", "$", "oScaffold", "->", "sVendor", ",", "$", "oScaffold", "->", "sModuleName", ")", ";", "$", "this", "->", "_copyAndParseDir", "(", "$", "this", "->", "_sTemplatesDir", ",", "$", "sModuleDir", ",", "array", "(", "'_prefix_'", "=>", "strtolower", "(", "$", "oScaffold", "->", "sVendor", ".", "$", "oScaffold", "->", "sModuleName", ")", ")", ")", ";", "}" ]
Generate module from scaffold object @param object $oScaffold
[ "Generate", "module", "from", "scaffold", "object" ]
476fa3b1ddd01fb3d4566258fbad941d75ba8a5a
https://github.com/OXIDprojects/oxid-console/blob/476fa3b1ddd01fb3d4566258fbad941d75ba8a5a/src/Command/GenerateModuleCommand.php#L86-L101
train
OXIDprojects/oxid-console
src/Command/GenerateModuleCommand.php
GenerateModuleCommand._copyAndParseDir
protected function _copyAndParseDir($sFrom, $sTo, array $aNameMap = array()) { $oFileInfos = new \RecursiveIteratorIterator( new \RecursiveDirectoryIterator($sFrom, \RecursiveDirectoryIterator::SKIP_DOTS) ); if (!file_exists($sTo)) { mkdir($sTo); } foreach ($oFileInfos as $oFileInfo) { $sFilePath = (string)$oFileInfo; $aReplace = array( 'search' => array_merge(array($sFrom), array_keys($aNameMap)), 'replace' => array_merge(array($sTo), array_values($aNameMap)) ); $sNewPath = str_replace($aReplace['search'], $aReplace['replace'], $sFilePath); $this->_copyAndParseFile($sFilePath, $sNewPath); } }
php
protected function _copyAndParseDir($sFrom, $sTo, array $aNameMap = array()) { $oFileInfos = new \RecursiveIteratorIterator( new \RecursiveDirectoryIterator($sFrom, \RecursiveDirectoryIterator::SKIP_DOTS) ); if (!file_exists($sTo)) { mkdir($sTo); } foreach ($oFileInfos as $oFileInfo) { $sFilePath = (string)$oFileInfo; $aReplace = array( 'search' => array_merge(array($sFrom), array_keys($aNameMap)), 'replace' => array_merge(array($sTo), array_values($aNameMap)) ); $sNewPath = str_replace($aReplace['search'], $aReplace['replace'], $sFilePath); $this->_copyAndParseFile($sFilePath, $sNewPath); } }
[ "protected", "function", "_copyAndParseDir", "(", "$", "sFrom", ",", "$", "sTo", ",", "array", "$", "aNameMap", "=", "array", "(", ")", ")", "{", "$", "oFileInfos", "=", "new", "\\", "RecursiveIteratorIterator", "(", "new", "\\", "RecursiveDirectoryIterator", "(", "$", "sFrom", ",", "\\", "RecursiveDirectoryIterator", "::", "SKIP_DOTS", ")", ")", ";", "if", "(", "!", "file_exists", "(", "$", "sTo", ")", ")", "{", "mkdir", "(", "$", "sTo", ")", ";", "}", "foreach", "(", "$", "oFileInfos", "as", "$", "oFileInfo", ")", "{", "$", "sFilePath", "=", "(", "string", ")", "$", "oFileInfo", ";", "$", "aReplace", "=", "array", "(", "'search'", "=>", "array_merge", "(", "array", "(", "$", "sFrom", ")", ",", "array_keys", "(", "$", "aNameMap", ")", ")", ",", "'replace'", "=>", "array_merge", "(", "array", "(", "$", "sTo", ")", ",", "array_values", "(", "$", "aNameMap", ")", ")", ")", ";", "$", "sNewPath", "=", "str_replace", "(", "$", "aReplace", "[", "'search'", "]", ",", "$", "aReplace", "[", "'replace'", "]", ",", "$", "sFilePath", ")", ";", "$", "this", "->", "_copyAndParseFile", "(", "$", "sFilePath", ",", "$", "sNewPath", ")", ";", "}", "}" ]
Copies files from directory, parses all files and puts parsed content to another directory @param string $sFrom Directory from @param string $sTo Directory to @param array $aNameMap What should be changed in file name?
[ "Copies", "files", "from", "directory", "parses", "all", "files", "and", "puts", "parsed", "content", "to", "another", "directory" ]
476fa3b1ddd01fb3d4566258fbad941d75ba8a5a
https://github.com/OXIDprojects/oxid-console/blob/476fa3b1ddd01fb3d4566258fbad941d75ba8a5a/src/Command/GenerateModuleCommand.php#L111-L130
train
OXIDprojects/oxid-console
src/Command/GenerateModuleCommand.php
GenerateModuleCommand._copyAndParseFile
protected function _copyAndParseFile($sFrom, $sTo) { $this->_createMissingFolders($sTo); $sTo = preg_replace('/\.tpl$/', '', $sTo); if (preg_match('/\.tpl$/', $sFrom)) { $oSmarty = $this->_getSmarty(); $sContent = $oSmarty->fetch($sFrom); } else { $sContent = file_get_contents($sFrom); } file_put_contents($sTo, $sContent); }
php
protected function _copyAndParseFile($sFrom, $sTo) { $this->_createMissingFolders($sTo); $sTo = preg_replace('/\.tpl$/', '', $sTo); if (preg_match('/\.tpl$/', $sFrom)) { $oSmarty = $this->_getSmarty(); $sContent = $oSmarty->fetch($sFrom); } else { $sContent = file_get_contents($sFrom); } file_put_contents($sTo, $sContent); }
[ "protected", "function", "_copyAndParseFile", "(", "$", "sFrom", ",", "$", "sTo", ")", "{", "$", "this", "->", "_createMissingFolders", "(", "$", "sTo", ")", ";", "$", "sTo", "=", "preg_replace", "(", "'/\\.tpl$/'", ",", "''", ",", "$", "sTo", ")", ";", "if", "(", "preg_match", "(", "'/\\.tpl$/'", ",", "$", "sFrom", ")", ")", "{", "$", "oSmarty", "=", "$", "this", "->", "_getSmarty", "(", ")", ";", "$", "sContent", "=", "$", "oSmarty", "->", "fetch", "(", "$", "sFrom", ")", ";", "}", "else", "{", "$", "sContent", "=", "file_get_contents", "(", "$", "sFrom", ")", ";", "}", "file_put_contents", "(", "$", "sTo", ",", "$", "sContent", ")", ";", "}" ]
Copies file from one directory to another, parses file if original file extension is .tpl @param $sFrom @param $sTo
[ "Copies", "file", "from", "one", "directory", "to", "another", "parses", "file", "if", "original", "file", "extension", "is", ".", "tpl" ]
476fa3b1ddd01fb3d4566258fbad941d75ba8a5a
https://github.com/OXIDprojects/oxid-console/blob/476fa3b1ddd01fb3d4566258fbad941d75ba8a5a/src/Command/GenerateModuleCommand.php#L139-L152
train
OXIDprojects/oxid-console
src/Command/GenerateModuleCommand.php
GenerateModuleCommand._createMissingFolders
protected function _createMissingFolders($sFilePath) { $sPath = dirname($sFilePath); if (!file_exists($sPath)) { mkdir($sPath, 0777, true); } }
php
protected function _createMissingFolders($sFilePath) { $sPath = dirname($sFilePath); if (!file_exists($sPath)) { mkdir($sPath, 0777, true); } }
[ "protected", "function", "_createMissingFolders", "(", "$", "sFilePath", ")", "{", "$", "sPath", "=", "dirname", "(", "$", "sFilePath", ")", ";", "if", "(", "!", "file_exists", "(", "$", "sPath", ")", ")", "{", "mkdir", "(", "$", "sPath", ",", "0777", ",", "true", ")", ";", "}", "}" ]
Create missing folders of file path @param string $sFilePath
[ "Create", "missing", "folders", "of", "file", "path" ]
476fa3b1ddd01fb3d4566258fbad941d75ba8a5a
https://github.com/OXIDprojects/oxid-console/blob/476fa3b1ddd01fb3d4566258fbad941d75ba8a5a/src/Command/GenerateModuleCommand.php#L159-L166
train
OXIDprojects/oxid-console
src/Command/GenerateModuleCommand.php
GenerateModuleCommand._generateVendorDir
protected function _generateVendorDir($sVendor) { $sVendorDir = $this->_sModuleDir . $sVendor . DIRECTORY_SEPARATOR; if (!file_exists($sVendorDir)) { mkdir($sVendorDir); // Generate vendor metadata file file_put_contents($sVendorDir . 'vendormetadata.php', '<?php'); } }
php
protected function _generateVendorDir($sVendor) { $sVendorDir = $this->_sModuleDir . $sVendor . DIRECTORY_SEPARATOR; if (!file_exists($sVendorDir)) { mkdir($sVendorDir); // Generate vendor metadata file file_put_contents($sVendorDir . 'vendormetadata.php', '<?php'); } }
[ "protected", "function", "_generateVendorDir", "(", "$", "sVendor", ")", "{", "$", "sVendorDir", "=", "$", "this", "->", "_sModuleDir", ".", "$", "sVendor", ".", "DIRECTORY_SEPARATOR", ";", "if", "(", "!", "file_exists", "(", "$", "sVendorDir", ")", ")", "{", "mkdir", "(", "$", "sVendorDir", ")", ";", "// Generate vendor metadata file", "file_put_contents", "(", "$", "sVendorDir", ".", "'vendormetadata.php'", ",", "'<?php'", ")", ";", "}", "}" ]
Generate vendor directory @param string $sVendor
[ "Generate", "vendor", "directory" ]
476fa3b1ddd01fb3d4566258fbad941d75ba8a5a
https://github.com/OXIDprojects/oxid-console/blob/476fa3b1ddd01fb3d4566258fbad941d75ba8a5a/src/Command/GenerateModuleCommand.php#L173-L182
train
OXIDprojects/oxid-console
src/Command/GenerateModuleCommand.php
GenerateModuleCommand._buildScaffold
protected function _buildScaffold() { $oScaffold = new \stdClass(); $oScaffold->sVendor = strtolower($this->_getUserInput('Vendor Prefix', true)); $blFirstRequest = true; do { if (!$blFirstRequest) { $this->output->writeLn('Module path or id is taken with given title'); } else { $blFirstRequest = false; } $oScaffold->sModuleTitle = $this->_getUserInput('Module Title'); $oScaffold->sModuleName = str_replace(' ', '', ucwords($oScaffold->sModuleTitle)); $oScaffold->sModuleId = $oScaffold->sVendor . strtolower($oScaffold->sModuleName); } while (!$this->_modulePathAvailable($oScaffold->sVendor, $oScaffold->sModuleName) || !$this->_moduleIdAvailable($oScaffold->sModuleId)); $oScaffold->sModuleDir = $this->_getModuleDir($oScaffold->sVendor, $oScaffold->sModuleName); $oScaffold->sAuthor = $this->_getUserInput('Author', true); $oScaffold->sUrl = $this->_getUserInput('Url', true); $oScaffold->sEmail = $this->_getUserInput('Email', true); return $oScaffold; }
php
protected function _buildScaffold() { $oScaffold = new \stdClass(); $oScaffold->sVendor = strtolower($this->_getUserInput('Vendor Prefix', true)); $blFirstRequest = true; do { if (!$blFirstRequest) { $this->output->writeLn('Module path or id is taken with given title'); } else { $blFirstRequest = false; } $oScaffold->sModuleTitle = $this->_getUserInput('Module Title'); $oScaffold->sModuleName = str_replace(' ', '', ucwords($oScaffold->sModuleTitle)); $oScaffold->sModuleId = $oScaffold->sVendor . strtolower($oScaffold->sModuleName); } while (!$this->_modulePathAvailable($oScaffold->sVendor, $oScaffold->sModuleName) || !$this->_moduleIdAvailable($oScaffold->sModuleId)); $oScaffold->sModuleDir = $this->_getModuleDir($oScaffold->sVendor, $oScaffold->sModuleName); $oScaffold->sAuthor = $this->_getUserInput('Author', true); $oScaffold->sUrl = $this->_getUserInput('Url', true); $oScaffold->sEmail = $this->_getUserInput('Email', true); return $oScaffold; }
[ "protected", "function", "_buildScaffold", "(", ")", "{", "$", "oScaffold", "=", "new", "\\", "stdClass", "(", ")", ";", "$", "oScaffold", "->", "sVendor", "=", "strtolower", "(", "$", "this", "->", "_getUserInput", "(", "'Vendor Prefix'", ",", "true", ")", ")", ";", "$", "blFirstRequest", "=", "true", ";", "do", "{", "if", "(", "!", "$", "blFirstRequest", ")", "{", "$", "this", "->", "output", "->", "writeLn", "(", "'Module path or id is taken with given title'", ")", ";", "}", "else", "{", "$", "blFirstRequest", "=", "false", ";", "}", "$", "oScaffold", "->", "sModuleTitle", "=", "$", "this", "->", "_getUserInput", "(", "'Module Title'", ")", ";", "$", "oScaffold", "->", "sModuleName", "=", "str_replace", "(", "' '", ",", "''", ",", "ucwords", "(", "$", "oScaffold", "->", "sModuleTitle", ")", ")", ";", "$", "oScaffold", "->", "sModuleId", "=", "$", "oScaffold", "->", "sVendor", ".", "strtolower", "(", "$", "oScaffold", "->", "sModuleName", ")", ";", "}", "while", "(", "!", "$", "this", "->", "_modulePathAvailable", "(", "$", "oScaffold", "->", "sVendor", ",", "$", "oScaffold", "->", "sModuleName", ")", "||", "!", "$", "this", "->", "_moduleIdAvailable", "(", "$", "oScaffold", "->", "sModuleId", ")", ")", ";", "$", "oScaffold", "->", "sModuleDir", "=", "$", "this", "->", "_getModuleDir", "(", "$", "oScaffold", "->", "sVendor", ",", "$", "oScaffold", "->", "sModuleName", ")", ";", "$", "oScaffold", "->", "sAuthor", "=", "$", "this", "->", "_getUserInput", "(", "'Author'", ",", "true", ")", ";", "$", "oScaffold", "->", "sUrl", "=", "$", "this", "->", "_getUserInput", "(", "'Url'", ",", "true", ")", ";", "$", "oScaffold", "->", "sEmail", "=", "$", "this", "->", "_getUserInput", "(", "'Email'", ",", "true", ")", ";", "return", "$", "oScaffold", ";", "}" ]
Build scaffold object from user inputs @return \stdClass
[ "Build", "scaffold", "object", "from", "user", "inputs" ]
476fa3b1ddd01fb3d4566258fbad941d75ba8a5a
https://github.com/OXIDprojects/oxid-console/blob/476fa3b1ddd01fb3d4566258fbad941d75ba8a5a/src/Command/GenerateModuleCommand.php#L189-L217
train
OXIDprojects/oxid-console
src/Command/GenerateModuleCommand.php
GenerateModuleCommand._getUserInput
protected function _getUserInput($sText, $bAllowEmpty = false) { $questionHelper = $this->getHelper('question'); do { $sTitle = "$sText: " . ($bAllowEmpty ? '[optional] ' : '[required] '); $question = new Question($sTitle); $sInput = $questionHelper->ask($this->input, $this->output, $question); } while (!$bAllowEmpty && !$sInput); return $sInput; }
php
protected function _getUserInput($sText, $bAllowEmpty = false) { $questionHelper = $this->getHelper('question'); do { $sTitle = "$sText: " . ($bAllowEmpty ? '[optional] ' : '[required] '); $question = new Question($sTitle); $sInput = $questionHelper->ask($this->input, $this->output, $question); } while (!$bAllowEmpty && !$sInput); return $sInput; }
[ "protected", "function", "_getUserInput", "(", "$", "sText", ",", "$", "bAllowEmpty", "=", "false", ")", "{", "$", "questionHelper", "=", "$", "this", "->", "getHelper", "(", "'question'", ")", ";", "do", "{", "$", "sTitle", "=", "\"$sText: \"", ".", "(", "$", "bAllowEmpty", "?", "'[optional] '", ":", "'[required] '", ")", ";", "$", "question", "=", "new", "Question", "(", "$", "sTitle", ")", ";", "$", "sInput", "=", "$", "questionHelper", "->", "ask", "(", "$", "this", "->", "input", ",", "$", "this", "->", "output", ",", "$", "question", ")", ";", "}", "while", "(", "!", "$", "bAllowEmpty", "&&", "!", "$", "sInput", ")", ";", "return", "$", "sInput", ";", "}" ]
Get user input @param string $sText @param bool $bAllowEmpty @return string
[ "Get", "user", "input" ]
476fa3b1ddd01fb3d4566258fbad941d75ba8a5a
https://github.com/OXIDprojects/oxid-console/blob/476fa3b1ddd01fb3d4566258fbad941d75ba8a5a/src/Command/GenerateModuleCommand.php#L270-L281
train
OXIDprojects/oxid-console
src/Command/MigrateCommand.php
MigrateCommand._parseTimestamp
protected function _parseTimestamp($timestamp) { if (is_null($timestamp)) return AbstractQuery::getCurrentTimestamp(); if (!AbstractQuery::isValidTimestamp($timestamp)) { if ($sTime = strtotime($timestamp)) { $timestamp = date('YmdHis', $sTime); } else { throw oxNew( ConsoleException::class, 'Invalid timestamp format, use YYYYMMDDhhmmss format' ); } } return $timestamp; }
php
protected function _parseTimestamp($timestamp) { if (is_null($timestamp)) return AbstractQuery::getCurrentTimestamp(); if (!AbstractQuery::isValidTimestamp($timestamp)) { if ($sTime = strtotime($timestamp)) { $timestamp = date('YmdHis', $sTime); } else { throw oxNew( ConsoleException::class, 'Invalid timestamp format, use YYYYMMDDhhmmss format' ); } } return $timestamp; }
[ "protected", "function", "_parseTimestamp", "(", "$", "timestamp", ")", "{", "if", "(", "is_null", "(", "$", "timestamp", ")", ")", "return", "AbstractQuery", "::", "getCurrentTimestamp", "(", ")", ";", "if", "(", "!", "AbstractQuery", "::", "isValidTimestamp", "(", "$", "timestamp", ")", ")", "{", "if", "(", "$", "sTime", "=", "strtotime", "(", "$", "timestamp", ")", ")", "{", "$", "timestamp", "=", "date", "(", "'YmdHis'", ",", "$", "sTime", ")", ";", "}", "else", "{", "throw", "oxNew", "(", "ConsoleException", "::", "class", ",", "'Invalid timestamp format, use YYYYMMDDhhmmss format'", ")", ";", "}", "}", "return", "$", "timestamp", ";", "}" ]
Parse timestamp from user input @param string|null $timestamp @return string
[ "Parse", "timestamp", "from", "user", "input" ]
476fa3b1ddd01fb3d4566258fbad941d75ba8a5a
https://github.com/OXIDprojects/oxid-console/blob/476fa3b1ddd01fb3d4566258fbad941d75ba8a5a/src/Command/MigrateCommand.php#L75-L92
train
GenesisGateway/genesis_php
src/Genesis/API/Notification.php
Notification.parseNotification
public function parseNotification($notification = [], $authenticate = true) { $notificationWalk = []; array_walk($notification, function ($val, $key) use (&$notificationWalk) { $key = trim(rawurldecode($key)); $val = trim(rawurldecode($val)); $notificationWalk[$key] = $val; }); $notification = $notificationWalk; $this->notificationObj = \Genesis\Utils\Common::createArrayObject($notification); if ($this->isAPINotification()) { $this->unique_id = (string)$this->notificationObj->unique_id; } if ($this->isWPFNotification()) { $this->unique_id = (string)$this->notificationObj->wpf_unique_id; } if ($authenticate && !$this->isAuthentic()) { throw new \Genesis\Exceptions\InvalidArgument('Invalid Genesis Notification!'); } }
php
public function parseNotification($notification = [], $authenticate = true) { $notificationWalk = []; array_walk($notification, function ($val, $key) use (&$notificationWalk) { $key = trim(rawurldecode($key)); $val = trim(rawurldecode($val)); $notificationWalk[$key] = $val; }); $notification = $notificationWalk; $this->notificationObj = \Genesis\Utils\Common::createArrayObject($notification); if ($this->isAPINotification()) { $this->unique_id = (string)$this->notificationObj->unique_id; } if ($this->isWPFNotification()) { $this->unique_id = (string)$this->notificationObj->wpf_unique_id; } if ($authenticate && !$this->isAuthentic()) { throw new \Genesis\Exceptions\InvalidArgument('Invalid Genesis Notification!'); } }
[ "public", "function", "parseNotification", "(", "$", "notification", "=", "[", "]", ",", "$", "authenticate", "=", "true", ")", "{", "$", "notificationWalk", "=", "[", "]", ";", "array_walk", "(", "$", "notification", ",", "function", "(", "$", "val", ",", "$", "key", ")", "use", "(", "&", "$", "notificationWalk", ")", "{", "$", "key", "=", "trim", "(", "rawurldecode", "(", "$", "key", ")", ")", ";", "$", "val", "=", "trim", "(", "rawurldecode", "(", "$", "val", ")", ")", ";", "$", "notificationWalk", "[", "$", "key", "]", "=", "$", "val", ";", "}", ")", ";", "$", "notification", "=", "$", "notificationWalk", ";", "$", "this", "->", "notificationObj", "=", "\\", "Genesis", "\\", "Utils", "\\", "Common", "::", "createArrayObject", "(", "$", "notification", ")", ";", "if", "(", "$", "this", "->", "isAPINotification", "(", ")", ")", "{", "$", "this", "->", "unique_id", "=", "(", "string", ")", "$", "this", "->", "notificationObj", "->", "unique_id", ";", "}", "if", "(", "$", "this", "->", "isWPFNotification", "(", ")", ")", "{", "$", "this", "->", "unique_id", "=", "(", "string", ")", "$", "this", "->", "notificationObj", "->", "wpf_unique_id", ";", "}", "if", "(", "$", "authenticate", "&&", "!", "$", "this", "->", "isAuthentic", "(", ")", ")", "{", "throw", "new", "\\", "Genesis", "\\", "Exceptions", "\\", "InvalidArgument", "(", "'Invalid Genesis Notification!'", ")", ";", "}", "}" ]
Parse and Authenticate the incoming notification from Genesis @param array $notification - Incoming notification ($_POST) @param bool $authenticate - Set to true if you want to validate the notification @throws \Genesis\Exceptions\InvalidArgument()
[ "Parse", "and", "Authenticate", "the", "incoming", "notification", "from", "Genesis" ]
b2a40413fd50357f41015eb05db9af305a3f4a6f
https://github.com/GenesisGateway/genesis_php/blob/b2a40413fd50357f41015eb05db9af305a3f4a6f/src/Genesis/API/Notification.php#L76-L102
train
GenesisGateway/genesis_php
src/Genesis/API/Notification.php
Notification.initReconciliation
public function initReconciliation() { $type = ''; if ($this->isAPINotification()) { $type = 'NonFinancial\Reconcile\Transaction'; } elseif ($this->isWPFNotification()) { $type = 'WPF\Reconcile'; } $request = new \Genesis\Genesis($type); try { $request->request()->setUniqueId($this->unique_id); $request->execute(); } catch (\Genesis\Exceptions\ErrorAPI $api) { // This is reconciliation, don't throw on ErrorAPI } return $this->reconciliationObj = $request->response()->getResponseObject(); }
php
public function initReconciliation() { $type = ''; if ($this->isAPINotification()) { $type = 'NonFinancial\Reconcile\Transaction'; } elseif ($this->isWPFNotification()) { $type = 'WPF\Reconcile'; } $request = new \Genesis\Genesis($type); try { $request->request()->setUniqueId($this->unique_id); $request->execute(); } catch (\Genesis\Exceptions\ErrorAPI $api) { // This is reconciliation, don't throw on ErrorAPI } return $this->reconciliationObj = $request->response()->getResponseObject(); }
[ "public", "function", "initReconciliation", "(", ")", "{", "$", "type", "=", "''", ";", "if", "(", "$", "this", "->", "isAPINotification", "(", ")", ")", "{", "$", "type", "=", "'NonFinancial\\Reconcile\\Transaction'", ";", "}", "elseif", "(", "$", "this", "->", "isWPFNotification", "(", ")", ")", "{", "$", "type", "=", "'WPF\\Reconcile'", ";", "}", "$", "request", "=", "new", "\\", "Genesis", "\\", "Genesis", "(", "$", "type", ")", ";", "try", "{", "$", "request", "->", "request", "(", ")", "->", "setUniqueId", "(", "$", "this", "->", "unique_id", ")", ";", "$", "request", "->", "execute", "(", ")", ";", "}", "catch", "(", "\\", "Genesis", "\\", "Exceptions", "\\", "ErrorAPI", "$", "api", ")", "{", "// This is reconciliation, don't throw on ErrorAPI", "}", "return", "$", "this", "->", "reconciliationObj", "=", "$", "request", "->", "response", "(", ")", "->", "getResponseObject", "(", ")", ";", "}" ]
Reconcile with the Payment Gateway to get the latest status on the transaction @throws \Genesis\Exceptions\InvalidResponse
[ "Reconcile", "with", "the", "Payment", "Gateway", "to", "get", "the", "latest", "status", "on", "the", "transaction" ]
b2a40413fd50357f41015eb05db9af305a3f4a6f
https://github.com/GenesisGateway/genesis_php/blob/b2a40413fd50357f41015eb05db9af305a3f4a6f/src/Genesis/API/Notification.php#L110-L131
train
GenesisGateway/genesis_php
src/Genesis/API/Notification.php
Notification.isAuthentic
public function isAuthentic() { if (!isset($this->unique_id) || !isset($this->notificationObj->signature)) { throw new \Genesis\Exceptions\InvalidArgument( 'Missing field(s), required for validation!' ); } $messageSig = trim($this->notificationObj->signature); $customerPwd = trim(\Genesis\Config::getPassword()); switch (strlen($messageSig)) { default: case 40: $hashType = 'sha1'; break; case 128: $hashType = 'sha512'; break; } if ($messageSig === hash($hashType, $this->unique_id . $customerPwd)) { return true; } return false; }
php
public function isAuthentic() { if (!isset($this->unique_id) || !isset($this->notificationObj->signature)) { throw new \Genesis\Exceptions\InvalidArgument( 'Missing field(s), required for validation!' ); } $messageSig = trim($this->notificationObj->signature); $customerPwd = trim(\Genesis\Config::getPassword()); switch (strlen($messageSig)) { default: case 40: $hashType = 'sha1'; break; case 128: $hashType = 'sha512'; break; } if ($messageSig === hash($hashType, $this->unique_id . $customerPwd)) { return true; } return false; }
[ "public", "function", "isAuthentic", "(", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "unique_id", ")", "||", "!", "isset", "(", "$", "this", "->", "notificationObj", "->", "signature", ")", ")", "{", "throw", "new", "\\", "Genesis", "\\", "Exceptions", "\\", "InvalidArgument", "(", "'Missing field(s), required for validation!'", ")", ";", "}", "$", "messageSig", "=", "trim", "(", "$", "this", "->", "notificationObj", "->", "signature", ")", ";", "$", "customerPwd", "=", "trim", "(", "\\", "Genesis", "\\", "Config", "::", "getPassword", "(", ")", ")", ";", "switch", "(", "strlen", "(", "$", "messageSig", ")", ")", "{", "default", ":", "case", "40", ":", "$", "hashType", "=", "'sha1'", ";", "break", ";", "case", "128", ":", "$", "hashType", "=", "'sha512'", ";", "break", ";", "}", "if", "(", "$", "messageSig", "===", "hash", "(", "$", "hashType", ",", "$", "this", "->", "unique_id", ".", "$", "customerPwd", ")", ")", "{", "return", "true", ";", "}", "return", "false", ";", "}" ]
Verify the signature on the parsed Notification @return bool @throws \Genesis\Exceptions\InvalidArgument
[ "Verify", "the", "signature", "on", "the", "parsed", "Notification" ]
b2a40413fd50357f41015eb05db9af305a3f4a6f
https://github.com/GenesisGateway/genesis_php/blob/b2a40413fd50357f41015eb05db9af305a3f4a6f/src/Genesis/API/Notification.php#L139-L165
train
GenesisGateway/genesis_php
src/Genesis/API/Notification.php
Notification.isAPINotification
public function isAPINotification() { return (bool)(isset($this->notificationObj->unique_id) && !empty($this->notificationObj->unique_id)); }
php
public function isAPINotification() { return (bool)(isset($this->notificationObj->unique_id) && !empty($this->notificationObj->unique_id)); }
[ "public", "function", "isAPINotification", "(", ")", "{", "return", "(", "bool", ")", "(", "isset", "(", "$", "this", "->", "notificationObj", "->", "unique_id", ")", "&&", "!", "empty", "(", "$", "this", "->", "notificationObj", "->", "unique_id", ")", ")", ";", "}" ]
Is this API notification? @return bool
[ "Is", "this", "API", "notification?" ]
b2a40413fd50357f41015eb05db9af305a3f4a6f
https://github.com/GenesisGateway/genesis_php/blob/b2a40413fd50357f41015eb05db9af305a3f4a6f/src/Genesis/API/Notification.php#L172-L175
train
GenesisGateway/genesis_php
src/Genesis/API/Notification.php
Notification.isWPFNotification
public function isWPFNotification() { return (bool)(isset($this->notificationObj->wpf_unique_id) && !empty($this->notificationObj->wpf_unique_id)); }
php
public function isWPFNotification() { return (bool)(isset($this->notificationObj->wpf_unique_id) && !empty($this->notificationObj->wpf_unique_id)); }
[ "public", "function", "isWPFNotification", "(", ")", "{", "return", "(", "bool", ")", "(", "isset", "(", "$", "this", "->", "notificationObj", "->", "wpf_unique_id", ")", "&&", "!", "empty", "(", "$", "this", "->", "notificationObj", "->", "wpf_unique_id", ")", ")", ";", "}" ]
Is this WPF Notification? @return bool
[ "Is", "this", "WPF", "Notification?" ]
b2a40413fd50357f41015eb05db9af305a3f4a6f
https://github.com/GenesisGateway/genesis_php/blob/b2a40413fd50357f41015eb05db9af305a3f4a6f/src/Genesis/API/Notification.php#L182-L185
train
GenesisGateway/genesis_php
src/Genesis/Network/cURL.php
cURL.checkForErrors
public function checkForErrors() { $errNo = curl_errno($this->curlHandle); $errStr = curl_error($this->curlHandle); if ($errNo > 0) { throw new \Genesis\Exceptions\ErrorNetwork($errStr, $errNo); } }
php
public function checkForErrors() { $errNo = curl_errno($this->curlHandle); $errStr = curl_error($this->curlHandle); if ($errNo > 0) { throw new \Genesis\Exceptions\ErrorNetwork($errStr, $errNo); } }
[ "public", "function", "checkForErrors", "(", ")", "{", "$", "errNo", "=", "curl_errno", "(", "$", "this", "->", "curlHandle", ")", ";", "$", "errStr", "=", "curl_error", "(", "$", "this", "->", "curlHandle", ")", ";", "if", "(", "$", "errNo", ">", "0", ")", "{", "throw", "new", "\\", "Genesis", "\\", "Exceptions", "\\", "ErrorNetwork", "(", "$", "errStr", ",", "$", "errNo", ")", ";", "}", "}" ]
Check whether or not a cURL request is successful @return string @throws \Genesis\Exceptions\ErrorNetwork
[ "Check", "whether", "or", "not", "a", "cURL", "request", "is", "successful" ]
b2a40413fd50357f41015eb05db9af305a3f4a6f
https://github.com/GenesisGateway/genesis_php/blob/b2a40413fd50357f41015eb05db9af305a3f4a6f/src/Genesis/Network/cURL.php#L177-L185
train
GenesisGateway/genesis_php
src/Genesis/API/Traits/Request/Financial/PproAttributes.php
PproAttributes.setNationalId
public function setNationalId($value) { if (strlen($value) > $this->getNationalIdLen()) { throw new ErrorParameter("National Identifier can be max {$this->getNationalIdLen()} characters."); } $this->national_id = $value; return $this; }
php
public function setNationalId($value) { if (strlen($value) > $this->getNationalIdLen()) { throw new ErrorParameter("National Identifier can be max {$this->getNationalIdLen()} characters."); } $this->national_id = $value; return $this; }
[ "public", "function", "setNationalId", "(", "$", "value", ")", "{", "if", "(", "strlen", "(", "$", "value", ")", ">", "$", "this", "->", "getNationalIdLen", "(", ")", ")", "{", "throw", "new", "ErrorParameter", "(", "\"National Identifier can be max {$this->getNationalIdLen()} characters.\"", ")", ";", "}", "$", "this", "->", "national_id", "=", "$", "value", ";", "return", "$", "this", ";", "}" ]
National Identifier number of the customer @param string $value @return $this @throws ErrorParameter
[ "National", "Identifier", "number", "of", "the", "customer" ]
b2a40413fd50357f41015eb05db9af305a3f4a6f
https://github.com/GenesisGateway/genesis_php/blob/b2a40413fd50357f41015eb05db9af305a3f4a6f/src/Genesis/API/Traits/Request/Financial/PproAttributes.php#L114-L123
train
GenesisGateway/genesis_php
src/Genesis/Parsers/XML.php
XML.parseDocument
public function parseDocument($xmlDocument) { $reader = new \XMLReader(); $reader->open('data:text/plain;base64,' . base64_encode($xmlDocument)); if ($this->skipRootNode) { $reader->read(); } $this->stdClassObj = self::readerLoop($reader); }
php
public function parseDocument($xmlDocument) { $reader = new \XMLReader(); $reader->open('data:text/plain;base64,' . base64_encode($xmlDocument)); if ($this->skipRootNode) { $reader->read(); } $this->stdClassObj = self::readerLoop($reader); }
[ "public", "function", "parseDocument", "(", "$", "xmlDocument", ")", "{", "$", "reader", "=", "new", "\\", "XMLReader", "(", ")", ";", "$", "reader", "->", "open", "(", "'data:text/plain;base64,'", ".", "base64_encode", "(", "$", "xmlDocument", ")", ")", ";", "if", "(", "$", "this", "->", "skipRootNode", ")", "{", "$", "reader", "->", "read", "(", ")", ";", "}", "$", "this", "->", "stdClassObj", "=", "self", "::", "readerLoop", "(", "$", "reader", ")", ";", "}" ]
Parse a document to an stdClass @param string $xmlDocument XML Document @return void
[ "Parse", "a", "document", "to", "an", "stdClass" ]
b2a40413fd50357f41015eb05db9af305a3f4a6f
https://github.com/GenesisGateway/genesis_php/blob/b2a40413fd50357f41015eb05db9af305a3f4a6f/src/Genesis/Parsers/XML.php#L83-L93
train
GenesisGateway/genesis_php
src/Genesis/Parsers/XML.php
XML.readerLoop
public function readerLoop($reader) { $tree = new \stdClass(); while ($reader->read()) { switch ($reader->nodeType) { case \XMLReader::END_ELEMENT: return $tree; break; case \XMLReader::ELEMENT: $this->processElement($reader, $tree); if ($reader->hasAttributes) { $this->processAttributes($reader, $tree); } break; case \XMLReader::TEXT: case \XMLReader::CDATA: $tree = \Genesis\Utils\Common::stringToBoolean( trim($reader->expand()->textContent) ); break; } } return $tree; }
php
public function readerLoop($reader) { $tree = new \stdClass(); while ($reader->read()) { switch ($reader->nodeType) { case \XMLReader::END_ELEMENT: return $tree; break; case \XMLReader::ELEMENT: $this->processElement($reader, $tree); if ($reader->hasAttributes) { $this->processAttributes($reader, $tree); } break; case \XMLReader::TEXT: case \XMLReader::CDATA: $tree = \Genesis\Utils\Common::stringToBoolean( trim($reader->expand()->textContent) ); break; } } return $tree; }
[ "public", "function", "readerLoop", "(", "$", "reader", ")", "{", "$", "tree", "=", "new", "\\", "stdClass", "(", ")", ";", "while", "(", "$", "reader", "->", "read", "(", ")", ")", "{", "switch", "(", "$", "reader", "->", "nodeType", ")", "{", "case", "\\", "XMLReader", "::", "END_ELEMENT", ":", "return", "$", "tree", ";", "break", ";", "case", "\\", "XMLReader", "::", "ELEMENT", ":", "$", "this", "->", "processElement", "(", "$", "reader", ",", "$", "tree", ")", ";", "if", "(", "$", "reader", "->", "hasAttributes", ")", "{", "$", "this", "->", "processAttributes", "(", "$", "reader", ",", "$", "tree", ")", ";", "}", "break", ";", "case", "\\", "XMLReader", "::", "TEXT", ":", "case", "\\", "XMLReader", "::", "CDATA", ":", "$", "tree", "=", "\\", "Genesis", "\\", "Utils", "\\", "Common", "::", "stringToBoolean", "(", "trim", "(", "$", "reader", "->", "expand", "(", ")", "->", "textContent", ")", ")", ";", "break", ";", "}", "}", "return", "$", "tree", ";", "}" ]
Read through the entire document @param \XMLReader $reader @return mixed
[ "Read", "through", "the", "entire", "document" ]
b2a40413fd50357f41015eb05db9af305a3f4a6f
https://github.com/GenesisGateway/genesis_php/blob/b2a40413fd50357f41015eb05db9af305a3f4a6f/src/Genesis/Parsers/XML.php#L101-L127
train
GenesisGateway/genesis_php
src/Genesis/Parsers/XML.php
XML.processElement
public function processElement(&$reader, &$tree) { $name = $reader->name; if (isset($tree->$name)) { if (is_a($tree->$name, 'stdClass')) { $currentEl = $tree->$name; $tree->$name = new \ArrayObject(); $tree->$name->append($currentEl); } if (is_a($tree->$name, 'ArrayObject')) { $tree->$name->append(($reader->isEmptyElement) ? '' : $this->readerLoop($reader)); } } else { $tree->$name = ($reader->isEmptyElement) ? '' : $this->readerLoop($reader); } }
php
public function processElement(&$reader, &$tree) { $name = $reader->name; if (isset($tree->$name)) { if (is_a($tree->$name, 'stdClass')) { $currentEl = $tree->$name; $tree->$name = new \ArrayObject(); $tree->$name->append($currentEl); } if (is_a($tree->$name, 'ArrayObject')) { $tree->$name->append(($reader->isEmptyElement) ? '' : $this->readerLoop($reader)); } } else { $tree->$name = ($reader->isEmptyElement) ? '' : $this->readerLoop($reader); } }
[ "public", "function", "processElement", "(", "&", "$", "reader", ",", "&", "$", "tree", ")", "{", "$", "name", "=", "$", "reader", "->", "name", ";", "if", "(", "isset", "(", "$", "tree", "->", "$", "name", ")", ")", "{", "if", "(", "is_a", "(", "$", "tree", "->", "$", "name", ",", "'stdClass'", ")", ")", "{", "$", "currentEl", "=", "$", "tree", "->", "$", "name", ";", "$", "tree", "->", "$", "name", "=", "new", "\\", "ArrayObject", "(", ")", ";", "$", "tree", "->", "$", "name", "->", "append", "(", "$", "currentEl", ")", ";", "}", "if", "(", "is_a", "(", "$", "tree", "->", "$", "name", ",", "'ArrayObject'", ")", ")", "{", "$", "tree", "->", "$", "name", "->", "append", "(", "(", "$", "reader", "->", "isEmptyElement", ")", "?", "''", ":", "$", "this", "->", "readerLoop", "(", "$", "reader", ")", ")", ";", "}", "}", "else", "{", "$", "tree", "->", "$", "name", "=", "(", "$", "reader", "->", "isEmptyElement", ")", "?", "''", ":", "$", "this", "->", "readerLoop", "(", "$", "reader", ")", ";", "}", "}" ]
Process XMLReader element @param $reader @param $tree @SuppressWarnings(PHPMD.ElseExpression)
[ "Process", "XMLReader", "element" ]
b2a40413fd50357f41015eb05db9af305a3f4a6f
https://github.com/GenesisGateway/genesis_php/blob/b2a40413fd50357f41015eb05db9af305a3f4a6f/src/Genesis/Parsers/XML.php#L137-L156
train
GenesisGateway/genesis_php
src/Genesis/Parsers/XML.php
XML.processAttributes
public function processAttributes(&$reader, &$tree) { $name = $reader->name; $node = new \stdClass(); $node->attr = new \stdClass(); while ($reader->moveToNextAttribute()) { $node->attr->$name = $reader->value; } if (isset($tree->$name) && is_a($tree->$name, 'ArrayObject')) { $lastKey = $tree->$name->count() - 1; $node->value = $tree->$name->offsetGet($lastKey); $tree->$name->offsetSet($lastKey, $node); } else { $node->value = isset($tree->$name) ? $tree->$name : ''; $tree->$name = $node; } }
php
public function processAttributes(&$reader, &$tree) { $name = $reader->name; $node = new \stdClass(); $node->attr = new \stdClass(); while ($reader->moveToNextAttribute()) { $node->attr->$name = $reader->value; } if (isset($tree->$name) && is_a($tree->$name, 'ArrayObject')) { $lastKey = $tree->$name->count() - 1; $node->value = $tree->$name->offsetGet($lastKey); $tree->$name->offsetSet($lastKey, $node); } else { $node->value = isset($tree->$name) ? $tree->$name : ''; $tree->$name = $node; } }
[ "public", "function", "processAttributes", "(", "&", "$", "reader", ",", "&", "$", "tree", ")", "{", "$", "name", "=", "$", "reader", "->", "name", ";", "$", "node", "=", "new", "\\", "stdClass", "(", ")", ";", "$", "node", "->", "attr", "=", "new", "\\", "stdClass", "(", ")", ";", "while", "(", "$", "reader", "->", "moveToNextAttribute", "(", ")", ")", "{", "$", "node", "->", "attr", "->", "$", "name", "=", "$", "reader", "->", "value", ";", "}", "if", "(", "isset", "(", "$", "tree", "->", "$", "name", ")", "&&", "is_a", "(", "$", "tree", "->", "$", "name", ",", "'ArrayObject'", ")", ")", "{", "$", "lastKey", "=", "$", "tree", "->", "$", "name", "->", "count", "(", ")", "-", "1", ";", "$", "node", "->", "value", "=", "$", "tree", "->", "$", "name", "->", "offsetGet", "(", "$", "lastKey", ")", ";", "$", "tree", "->", "$", "name", "->", "offsetSet", "(", "$", "lastKey", ",", "$", "node", ")", ";", "}", "else", "{", "$", "node", "->", "value", "=", "isset", "(", "$", "tree", "->", "$", "name", ")", "?", "$", "tree", "->", "$", "name", ":", "''", ";", "$", "tree", "->", "$", "name", "=", "$", "node", ";", "}", "}" ]
Process element attributes @param \XMLReader $reader @param \stdClass $tree @SuppressWarnings(PHPMD.ElseExpression)
[ "Process", "element", "attributes" ]
b2a40413fd50357f41015eb05db9af305a3f4a6f
https://github.com/GenesisGateway/genesis_php/blob/b2a40413fd50357f41015eb05db9af305a3f4a6f/src/Genesis/Parsers/XML.php#L166-L188
train
OXIDprojects/oxid-console
src/Core/CommandCollector.php
CommandCollector.getAllCommands
public function getAllCommands() { // Avoid fatal errors for "Class 'oxConsoleCommand' not found" in case of old Commands present if (!class_exists('oxConsoleCommand')) class_alias(Command::class, 'oxConsoleCommand'); $commands = $this->getCommandsFromCore(); $commandsFromModules = $this->getCommandsFromModules(); $commandsFromComposer = $this->getCommandsFromComposer(); return array_merge( $commands, $commandsFromModules, $commandsFromComposer ); }
php
public function getAllCommands() { // Avoid fatal errors for "Class 'oxConsoleCommand' not found" in case of old Commands present if (!class_exists('oxConsoleCommand')) class_alias(Command::class, 'oxConsoleCommand'); $commands = $this->getCommandsFromCore(); $commandsFromModules = $this->getCommandsFromModules(); $commandsFromComposer = $this->getCommandsFromComposer(); return array_merge( $commands, $commandsFromModules, $commandsFromComposer ); }
[ "public", "function", "getAllCommands", "(", ")", "{", "// Avoid fatal errors for \"Class 'oxConsoleCommand' not found\" in case of old Commands present", "if", "(", "!", "class_exists", "(", "'oxConsoleCommand'", ")", ")", "class_alias", "(", "Command", "::", "class", ",", "'oxConsoleCommand'", ")", ";", "$", "commands", "=", "$", "this", "->", "getCommandsFromCore", "(", ")", ";", "$", "commandsFromModules", "=", "$", "this", "->", "getCommandsFromModules", "(", ")", ";", "$", "commandsFromComposer", "=", "$", "this", "->", "getCommandsFromComposer", "(", ")", ";", "return", "array_merge", "(", "$", "commands", ",", "$", "commandsFromModules", ",", "$", "commandsFromComposer", ")", ";", "}" ]
Get all available command objects. Command objects are collected from the following sources: 1) All core commands from `OxidProfessionalServices\OxidConsole\Command` namespace; 2) All commands from modules matching the following criteria: a) Are placed under the directory `Command` within a module; b) PHP Class file ends with `Command` as suffix of the class; c) PHP Class extends `Symfony\Component\Console\Command\Command`. @return Command[]
[ "Get", "all", "available", "command", "objects", "." ]
476fa3b1ddd01fb3d4566258fbad941d75ba8a5a
https://github.com/OXIDprojects/oxid-console/blob/476fa3b1ddd01fb3d4566258fbad941d75ba8a5a/src/Core/CommandCollector.php#L49-L63
train
OXIDprojects/oxid-console
src/Core/CommandCollector.php
CommandCollector.getCommandsFromModules
private function getCommandsFromModules() { $oConfig = Registry::getConfig(); if (! class_exists(ModuleList::class)) { print "ERROR: Oxid ModuleList class can not be loaded, please run vendor/bin/oe-eshop-unified_namespace_generator"; } else { try { $moduleList = oxNew(ModuleList::class); $modulesDir = $oConfig->getModulesDir(); $moduleList->getModulesFromDir($modulesDir); } catch (\Throwable $exception) { print "Shop is not able to list modules\n"; print $exception->getMessage(); return []; } } $paths = $this->getPathsOfAvailableModules(); $pathToPhpFiles = $this->getPhpFilesMatchingPatternForCommandFromGivenPaths( $paths ); $classes = $this->getAllClassesFromPhpFiles($pathToPhpFiles); $comanndClasses = $this->getCommandCompatibleClasses($classes); return $this->getObjectsFromClasses($comanndClasses); }
php
private function getCommandsFromModules() { $oConfig = Registry::getConfig(); if (! class_exists(ModuleList::class)) { print "ERROR: Oxid ModuleList class can not be loaded, please run vendor/bin/oe-eshop-unified_namespace_generator"; } else { try { $moduleList = oxNew(ModuleList::class); $modulesDir = $oConfig->getModulesDir(); $moduleList->getModulesFromDir($modulesDir); } catch (\Throwable $exception) { print "Shop is not able to list modules\n"; print $exception->getMessage(); return []; } } $paths = $this->getPathsOfAvailableModules(); $pathToPhpFiles = $this->getPhpFilesMatchingPatternForCommandFromGivenPaths( $paths ); $classes = $this->getAllClassesFromPhpFiles($pathToPhpFiles); $comanndClasses = $this->getCommandCompatibleClasses($classes); return $this->getObjectsFromClasses($comanndClasses); }
[ "private", "function", "getCommandsFromModules", "(", ")", "{", "$", "oConfig", "=", "Registry", "::", "getConfig", "(", ")", ";", "if", "(", "!", "class_exists", "(", "ModuleList", "::", "class", ")", ")", "{", "print", "\"ERROR: Oxid ModuleList class can not be loaded, please run vendor/bin/oe-eshop-unified_namespace_generator\"", ";", "}", "else", "{", "try", "{", "$", "moduleList", "=", "oxNew", "(", "ModuleList", "::", "class", ")", ";", "$", "modulesDir", "=", "$", "oConfig", "->", "getModulesDir", "(", ")", ";", "$", "moduleList", "->", "getModulesFromDir", "(", "$", "modulesDir", ")", ";", "}", "catch", "(", "\\", "Throwable", "$", "exception", ")", "{", "print", "\"Shop is not able to list modules\\n\"", ";", "print", "$", "exception", "->", "getMessage", "(", ")", ";", "return", "[", "]", ";", "}", "}", "$", "paths", "=", "$", "this", "->", "getPathsOfAvailableModules", "(", ")", ";", "$", "pathToPhpFiles", "=", "$", "this", "->", "getPhpFilesMatchingPatternForCommandFromGivenPaths", "(", "$", "paths", ")", ";", "$", "classes", "=", "$", "this", "->", "getAllClassesFromPhpFiles", "(", "$", "pathToPhpFiles", ")", ";", "$", "comanndClasses", "=", "$", "this", "->", "getCommandCompatibleClasses", "(", "$", "classes", ")", ";", "return", "$", "this", "->", "getObjectsFromClasses", "(", "$", "comanndClasses", ")", ";", "}" ]
Collect all available commands from modules. Dynamically scan all modules and include available command objects. @return array
[ "Collect", "all", "available", "commands", "from", "modules", "." ]
476fa3b1ddd01fb3d4566258fbad941d75ba8a5a
https://github.com/OXIDprojects/oxid-console/blob/476fa3b1ddd01fb3d4566258fbad941d75ba8a5a/src/Core/CommandCollector.php#L128-L154
train
OXIDprojects/oxid-console
src/Core/CommandCollector.php
CommandCollector.getPathsOfAvailableModules
private function getPathsOfAvailableModules() { $config = Registry::getConfig(); $modulesRootPath = $config->getModulesDir(); $modulePaths = $config->getConfigParam('aModulePaths'); if (!is_dir($modulesRootPath)) return []; if (!is_array($modulePaths)) return []; $fullModulePaths = array_map(function ($modulePath) use ($modulesRootPath) { return $modulesRootPath . $modulePath; }, array_values($modulePaths)); return array_filter($fullModulePaths, function ($fullModulePath) { return is_dir($fullModulePath); }); }
php
private function getPathsOfAvailableModules() { $config = Registry::getConfig(); $modulesRootPath = $config->getModulesDir(); $modulePaths = $config->getConfigParam('aModulePaths'); if (!is_dir($modulesRootPath)) return []; if (!is_array($modulePaths)) return []; $fullModulePaths = array_map(function ($modulePath) use ($modulesRootPath) { return $modulesRootPath . $modulePath; }, array_values($modulePaths)); return array_filter($fullModulePaths, function ($fullModulePath) { return is_dir($fullModulePath); }); }
[ "private", "function", "getPathsOfAvailableModules", "(", ")", "{", "$", "config", "=", "Registry", "::", "getConfig", "(", ")", ";", "$", "modulesRootPath", "=", "$", "config", "->", "getModulesDir", "(", ")", ";", "$", "modulePaths", "=", "$", "config", "->", "getConfigParam", "(", "'aModulePaths'", ")", ";", "if", "(", "!", "is_dir", "(", "$", "modulesRootPath", ")", ")", "return", "[", "]", ";", "if", "(", "!", "is_array", "(", "$", "modulePaths", ")", ")", "return", "[", "]", ";", "$", "fullModulePaths", "=", "array_map", "(", "function", "(", "$", "modulePath", ")", "use", "(", "$", "modulesRootPath", ")", "{", "return", "$", "modulesRootPath", ".", "$", "modulePath", ";", "}", ",", "array_values", "(", "$", "modulePaths", ")", ")", ";", "return", "array_filter", "(", "$", "fullModulePaths", ",", "function", "(", "$", "fullModulePath", ")", "{", "return", "is_dir", "(", "$", "fullModulePath", ")", ";", "}", ")", ";", "}" ]
Return list of paths to all available modules. @return string[]
[ "Return", "list", "of", "paths", "to", "all", "available", "modules", "." ]
476fa3b1ddd01fb3d4566258fbad941d75ba8a5a
https://github.com/OXIDprojects/oxid-console/blob/476fa3b1ddd01fb3d4566258fbad941d75ba8a5a/src/Core/CommandCollector.php#L173-L192
train
OXIDprojects/oxid-console
src/Core/CommandCollector.php
CommandCollector.getPhpFilesMatchingPatternForCommandFromGivenPath
private function getPhpFilesMatchingPatternForCommandFromGivenPath($path) { $folders = ['Commands','commands','Command']; foreach ($folders as $f) { $cPath = $path . DIRECTORY_SEPARATOR . $f . DIRECTORY_SEPARATOR; if (!is_dir($cPath)) { continue; } $files = glob("$cPath*[cC]ommand\.php"); return $files; } return []; }
php
private function getPhpFilesMatchingPatternForCommandFromGivenPath($path) { $folders = ['Commands','commands','Command']; foreach ($folders as $f) { $cPath = $path . DIRECTORY_SEPARATOR . $f . DIRECTORY_SEPARATOR; if (!is_dir($cPath)) { continue; } $files = glob("$cPath*[cC]ommand\.php"); return $files; } return []; }
[ "private", "function", "getPhpFilesMatchingPatternForCommandFromGivenPath", "(", "$", "path", ")", "{", "$", "folders", "=", "[", "'Commands'", ",", "'commands'", ",", "'Command'", "]", ";", "foreach", "(", "$", "folders", "as", "$", "f", ")", "{", "$", "cPath", "=", "$", "path", ".", "DIRECTORY_SEPARATOR", ".", "$", "f", ".", "DIRECTORY_SEPARATOR", ";", "if", "(", "!", "is_dir", "(", "$", "cPath", ")", ")", "{", "continue", ";", "}", "$", "files", "=", "glob", "(", "\"$cPath*[cC]ommand\\.php\"", ")", ";", "return", "$", "files", ";", "}", "return", "[", "]", ";", "}" ]
Return list of PHP files matching `Command` specific pattern. @param string $path Path to collect files from @return string[]
[ "Return", "list", "of", "PHP", "files", "matching", "Command", "specific", "pattern", "." ]
476fa3b1ddd01fb3d4566258fbad941d75ba8a5a
https://github.com/OXIDprojects/oxid-console/blob/476fa3b1ddd01fb3d4566258fbad941d75ba8a5a/src/Core/CommandCollector.php#L201-L215
train
OXIDprojects/oxid-console
src/Core/CommandCollector.php
CommandCollector.getPhpFilesMatchingPatternForCommandFromGivenPaths
private function getPhpFilesMatchingPatternForCommandFromGivenPaths($paths) { return $this->getFlatArray(array_map(function ($path) { return $this->getPhpFilesMatchingPatternForCommandFromGivenPath($path); }, $paths)); }
php
private function getPhpFilesMatchingPatternForCommandFromGivenPaths($paths) { return $this->getFlatArray(array_map(function ($path) { return $this->getPhpFilesMatchingPatternForCommandFromGivenPath($path); }, $paths)); }
[ "private", "function", "getPhpFilesMatchingPatternForCommandFromGivenPaths", "(", "$", "paths", ")", "{", "return", "$", "this", "->", "getFlatArray", "(", "array_map", "(", "function", "(", "$", "path", ")", "{", "return", "$", "this", "->", "getPhpFilesMatchingPatternForCommandFromGivenPath", "(", "$", "path", ")", ";", "}", ",", "$", "paths", ")", ")", ";", "}" ]
Helper method for `getPhpFilesMatchingPatternForCommandFromGivenPath` @param string[] $paths @return string[]
[ "Helper", "method", "for", "getPhpFilesMatchingPatternForCommandFromGivenPath" ]
476fa3b1ddd01fb3d4566258fbad941d75ba8a5a
https://github.com/OXIDprojects/oxid-console/blob/476fa3b1ddd01fb3d4566258fbad941d75ba8a5a/src/Core/CommandCollector.php#L224-L229
train
OXIDprojects/oxid-console
src/Core/CommandCollector.php
CommandCollector.getAllClassesFromPhpFile
private function getAllClassesFromPhpFile($pathToPhpFile) { $classesBefore = get_declared_classes(); try { require_once $pathToPhpFile; } catch (\Throwable $exception) { print "Can not add Command $pathToPhpFile:\n"; print $exception->getMessage() . "\n"; } $classesAfter = get_declared_classes(); $newClasses = array_diff($classesAfter, $classesBefore); if(count($newClasses) > 1) { //try to find the correct class name to use //this avoids warnings when module developer use there own command base class, that is not instantiable $name = basename($pathToPhpFile,'.php'); foreach ($newClasses as $newClass) { if ($newClass == $name){ return [$newClass]; } } } return $newClasses; }
php
private function getAllClassesFromPhpFile($pathToPhpFile) { $classesBefore = get_declared_classes(); try { require_once $pathToPhpFile; } catch (\Throwable $exception) { print "Can not add Command $pathToPhpFile:\n"; print $exception->getMessage() . "\n"; } $classesAfter = get_declared_classes(); $newClasses = array_diff($classesAfter, $classesBefore); if(count($newClasses) > 1) { //try to find the correct class name to use //this avoids warnings when module developer use there own command base class, that is not instantiable $name = basename($pathToPhpFile,'.php'); foreach ($newClasses as $newClass) { if ($newClass == $name){ return [$newClass]; } } } return $newClasses; }
[ "private", "function", "getAllClassesFromPhpFile", "(", "$", "pathToPhpFile", ")", "{", "$", "classesBefore", "=", "get_declared_classes", "(", ")", ";", "try", "{", "require_once", "$", "pathToPhpFile", ";", "}", "catch", "(", "\\", "Throwable", "$", "exception", ")", "{", "print", "\"Can not add Command $pathToPhpFile:\\n\"", ";", "print", "$", "exception", "->", "getMessage", "(", ")", ".", "\"\\n\"", ";", "}", "$", "classesAfter", "=", "get_declared_classes", "(", ")", ";", "$", "newClasses", "=", "array_diff", "(", "$", "classesAfter", ",", "$", "classesBefore", ")", ";", "if", "(", "count", "(", "$", "newClasses", ")", ">", "1", ")", "{", "//try to find the correct class name to use", "//this avoids warnings when module developer use there own command base class, that is not instantiable", "$", "name", "=", "basename", "(", "$", "pathToPhpFile", ",", "'.php'", ")", ";", "foreach", "(", "$", "newClasses", "as", "$", "newClass", ")", "{", "if", "(", "$", "newClass", "==", "$", "name", ")", "{", "return", "[", "$", "newClass", "]", ";", "}", "}", "}", "return", "$", "newClasses", ";", "}" ]
Get list of defined classes from given PHP file. @param string $pathToPhpFile @return string[]
[ "Get", "list", "of", "defined", "classes", "from", "given", "PHP", "file", "." ]
476fa3b1ddd01fb3d4566258fbad941d75ba8a5a
https://github.com/OXIDprojects/oxid-console/blob/476fa3b1ddd01fb3d4566258fbad941d75ba8a5a/src/Core/CommandCollector.php#L238-L261
train
OXIDprojects/oxid-console
src/Core/CommandCollector.php
CommandCollector.getAllClassesFromPhpFiles
private function getAllClassesFromPhpFiles($pathToPhpFiles) { return $this->getFlatArray(array_map(function ($pathToPhpFile) { return $this->getAllClassesFromPhpFile($pathToPhpFile); }, $pathToPhpFiles)); }
php
private function getAllClassesFromPhpFiles($pathToPhpFiles) { return $this->getFlatArray(array_map(function ($pathToPhpFile) { return $this->getAllClassesFromPhpFile($pathToPhpFile); }, $pathToPhpFiles)); }
[ "private", "function", "getAllClassesFromPhpFiles", "(", "$", "pathToPhpFiles", ")", "{", "return", "$", "this", "->", "getFlatArray", "(", "array_map", "(", "function", "(", "$", "pathToPhpFile", ")", "{", "return", "$", "this", "->", "getAllClassesFromPhpFile", "(", "$", "pathToPhpFile", ")", ";", "}", ",", "$", "pathToPhpFiles", ")", ")", ";", "}" ]
Helper method for `getAllClassesFromPhpFile` @param string[] $pathToPhpFiles @return string[]
[ "Helper", "method", "for", "getAllClassesFromPhpFile" ]
476fa3b1ddd01fb3d4566258fbad941d75ba8a5a
https://github.com/OXIDprojects/oxid-console/blob/476fa3b1ddd01fb3d4566258fbad941d75ba8a5a/src/Core/CommandCollector.php#L270-L275
train
OXIDprojects/oxid-console
src/Core/CommandCollector.php
CommandCollector.getObjectsFromClasses
private function getObjectsFromClasses($classes) { $objects = array_map(function ($class) { try { return new $class; } catch (\Throwable $ex) { print "Can not add command from class $class:\n"; print $ex->getMessage() . "\n"; } }, $classes); $objects = array_filter($objects, function($o){return !is_null($o);} ); return $objects; }
php
private function getObjectsFromClasses($classes) { $objects = array_map(function ($class) { try { return new $class; } catch (\Throwable $ex) { print "Can not add command from class $class:\n"; print $ex->getMessage() . "\n"; } }, $classes); $objects = array_filter($objects, function($o){return !is_null($o);} ); return $objects; }
[ "private", "function", "getObjectsFromClasses", "(", "$", "classes", ")", "{", "$", "objects", "=", "array_map", "(", "function", "(", "$", "class", ")", "{", "try", "{", "return", "new", "$", "class", ";", "}", "catch", "(", "\\", "Throwable", "$", "ex", ")", "{", "print", "\"Can not add command from class $class:\\n\"", ";", "print", "$", "ex", "->", "getMessage", "(", ")", ".", "\"\\n\"", ";", "}", "}", ",", "$", "classes", ")", ";", "$", "objects", "=", "array_filter", "(", "$", "objects", ",", "function", "(", "$", "o", ")", "{", "return", "!", "is_null", "(", "$", "o", ")", ";", "}", ")", ";", "return", "$", "objects", ";", "}" ]
Convert given list of classes to objects. @param string[] $classes @return mixed[]
[ "Convert", "given", "list", "of", "classes", "to", "objects", "." ]
476fa3b1ddd01fb3d4566258fbad941d75ba8a5a
https://github.com/OXIDprojects/oxid-console/blob/476fa3b1ddd01fb3d4566258fbad941d75ba8a5a/src/Core/CommandCollector.php#L302-L314
train
API-Skeletons/zf-doctrine-hydrator
src/Strategy/EntityLink.php
EntityLink.getHydratorForEntity
public function getHydratorForEntity($value) { $entityMetadata = $this->getMetadataMap()[ClassUtils::getRealClass(get_class($value))]; $objectManagerClass = $this->getDoctrineHydratorConfig()[$entityMetadata['hydrator']]['object_manager']; return new DoctrineHydrator($this->getServiceLocator()->get($objectManagerClass), true); }
php
public function getHydratorForEntity($value) { $entityMetadata = $this->getMetadataMap()[ClassUtils::getRealClass(get_class($value))]; $objectManagerClass = $this->getDoctrineHydratorConfig()[$entityMetadata['hydrator']]['object_manager']; return new DoctrineHydrator($this->getServiceLocator()->get($objectManagerClass), true); }
[ "public", "function", "getHydratorForEntity", "(", "$", "value", ")", "{", "$", "entityMetadata", "=", "$", "this", "->", "getMetadataMap", "(", ")", "[", "ClassUtils", "::", "getRealClass", "(", "get_class", "(", "$", "value", ")", ")", "]", ";", "$", "objectManagerClass", "=", "$", "this", "->", "getDoctrineHydratorConfig", "(", ")", "[", "$", "entityMetadata", "[", "'hydrator'", "]", "]", "[", "'object_manager'", "]", ";", "return", "new", "DoctrineHydrator", "(", "$", "this", "->", "getServiceLocator", "(", ")", "->", "get", "(", "$", "objectManagerClass", ")", ",", "true", ")", ";", "}" ]
Look up the object manager for the given entity and create a basic hydrator
[ "Look", "up", "the", "object", "manager", "for", "the", "given", "entity", "and", "create", "a", "basic", "hydrator" ]
3b91915d15dd09c37448a1c7b69b2a2805856fbc
https://github.com/API-Skeletons/zf-doctrine-hydrator/blob/3b91915d15dd09c37448a1c7b69b2a2805856fbc/src/Strategy/EntityLink.php#L72-L78
train
API-Skeletons/zf-doctrine-hydrator
src/Strategy/EntityLink.php
EntityLink.extract
public function extract($value) { if (is_null($value)) { return $value; } $entityValues = $this->getHydratorForEntity($value)->extract($value); $entityMetadata = $this->getMetadataMap()[ClassUtils::getRealClass(get_class($value))]; $link = new Link('self'); $link->setRoute($entityMetadata['route_name']); $link->setRouteParams([ $entityMetadata['route_identifier_name'] => $entityValues[$entityMetadata['entity_identifier_name']] ]); $linkCollection = new LinkCollection(); $linkCollection->add($link); $halEntity = new HalEntity(new stdClass()); $halEntity->setLinks($linkCollection); return $halEntity; }
php
public function extract($value) { if (is_null($value)) { return $value; } $entityValues = $this->getHydratorForEntity($value)->extract($value); $entityMetadata = $this->getMetadataMap()[ClassUtils::getRealClass(get_class($value))]; $link = new Link('self'); $link->setRoute($entityMetadata['route_name']); $link->setRouteParams([ $entityMetadata['route_identifier_name'] => $entityValues[$entityMetadata['entity_identifier_name']] ]); $linkCollection = new LinkCollection(); $linkCollection->add($link); $halEntity = new HalEntity(new stdClass()); $halEntity->setLinks($linkCollection); return $halEntity; }
[ "public", "function", "extract", "(", "$", "value", ")", "{", "if", "(", "is_null", "(", "$", "value", ")", ")", "{", "return", "$", "value", ";", "}", "$", "entityValues", "=", "$", "this", "->", "getHydratorForEntity", "(", "$", "value", ")", "->", "extract", "(", "$", "value", ")", ";", "$", "entityMetadata", "=", "$", "this", "->", "getMetadataMap", "(", ")", "[", "ClassUtils", "::", "getRealClass", "(", "get_class", "(", "$", "value", ")", ")", "]", ";", "$", "link", "=", "new", "Link", "(", "'self'", ")", ";", "$", "link", "->", "setRoute", "(", "$", "entityMetadata", "[", "'route_name'", "]", ")", ";", "$", "link", "->", "setRouteParams", "(", "[", "$", "entityMetadata", "[", "'route_identifier_name'", "]", "=>", "$", "entityValues", "[", "$", "entityMetadata", "[", "'entity_identifier_name'", "]", "]", "]", ")", ";", "$", "linkCollection", "=", "new", "LinkCollection", "(", ")", ";", "$", "linkCollection", "->", "add", "(", "$", "link", ")", ";", "$", "halEntity", "=", "new", "HalEntity", "(", "new", "stdClass", "(", ")", ")", ";", "$", "halEntity", "->", "setLinks", "(", "$", "linkCollection", ")", ";", "return", "$", "halEntity", ";", "}" ]
Return a HAL entity with just a self link
[ "Return", "a", "HAL", "entity", "with", "just", "a", "self", "link" ]
3b91915d15dd09c37448a1c7b69b2a2805856fbc
https://github.com/API-Skeletons/zf-doctrine-hydrator/blob/3b91915d15dd09c37448a1c7b69b2a2805856fbc/src/Strategy/EntityLink.php#L83-L105
train
GenesisGateway/genesis_php
src/Genesis/API/Traits/Request/RiskAttributes.php
RiskAttributes.getRiskParamsStructure
protected function getRiskParamsStructure() { return [ 'ssn' => $this->risk_ssn, 'mac_address' => $this->risk_mac_address, 'session_id' => $this->risk_session_id, 'user_id' => $this->risk_user_id, 'user_level' => $this->risk_user_level, 'email' => $this->risk_email, 'phone' => $this->risk_phone, 'remote_ip' => $this->risk_remote_ip, 'serial_number' => $this->risk_serial_number, 'pan_tail' => $this->risk_pan_tail, 'bin' => $this->risk_bin, 'first_name' => $this->risk_first_name, 'last_name' => $this->risk_last_name, 'country' => $this->risk_country, 'pan' => $this->risk_pan, 'forwarded_ip' => $this->risk_forwarded_ip, 'username' => $this->risk_username, 'password' => $this->risk_password, 'bin_name' => $this->risk_bin_name, 'bin_phone' => $this->risk_bin_phone ]; }
php
protected function getRiskParamsStructure() { return [ 'ssn' => $this->risk_ssn, 'mac_address' => $this->risk_mac_address, 'session_id' => $this->risk_session_id, 'user_id' => $this->risk_user_id, 'user_level' => $this->risk_user_level, 'email' => $this->risk_email, 'phone' => $this->risk_phone, 'remote_ip' => $this->risk_remote_ip, 'serial_number' => $this->risk_serial_number, 'pan_tail' => $this->risk_pan_tail, 'bin' => $this->risk_bin, 'first_name' => $this->risk_first_name, 'last_name' => $this->risk_last_name, 'country' => $this->risk_country, 'pan' => $this->risk_pan, 'forwarded_ip' => $this->risk_forwarded_ip, 'username' => $this->risk_username, 'password' => $this->risk_password, 'bin_name' => $this->risk_bin_name, 'bin_phone' => $this->risk_bin_phone ]; }
[ "protected", "function", "getRiskParamsStructure", "(", ")", "{", "return", "[", "'ssn'", "=>", "$", "this", "->", "risk_ssn", ",", "'mac_address'", "=>", "$", "this", "->", "risk_mac_address", ",", "'session_id'", "=>", "$", "this", "->", "risk_session_id", ",", "'user_id'", "=>", "$", "this", "->", "risk_user_id", ",", "'user_level'", "=>", "$", "this", "->", "risk_user_level", ",", "'email'", "=>", "$", "this", "->", "risk_email", ",", "'phone'", "=>", "$", "this", "->", "risk_phone", ",", "'remote_ip'", "=>", "$", "this", "->", "risk_remote_ip", ",", "'serial_number'", "=>", "$", "this", "->", "risk_serial_number", ",", "'pan_tail'", "=>", "$", "this", "->", "risk_pan_tail", ",", "'bin'", "=>", "$", "this", "->", "risk_bin", ",", "'first_name'", "=>", "$", "this", "->", "risk_first_name", ",", "'last_name'", "=>", "$", "this", "->", "risk_last_name", ",", "'country'", "=>", "$", "this", "->", "risk_country", ",", "'pan'", "=>", "$", "this", "->", "risk_pan", ",", "'forwarded_ip'", "=>", "$", "this", "->", "risk_forwarded_ip", ",", "'username'", "=>", "$", "this", "->", "risk_username", ",", "'password'", "=>", "$", "this", "->", "risk_password", ",", "'bin_name'", "=>", "$", "this", "->", "risk_bin_name", ",", "'bin_phone'", "=>", "$", "this", "->", "risk_bin_phone", "]", ";", "}" ]
Builds an array list with all Risk Params @return array
[ "Builds", "an", "array", "list", "with", "all", "Risk", "Params" ]
b2a40413fd50357f41015eb05db9af305a3f4a6f
https://github.com/GenesisGateway/genesis_php/blob/b2a40413fd50357f41015eb05db9af305a3f4a6f/src/Genesis/API/Traits/Request/RiskAttributes.php#L216-L240
train
GenesisGateway/genesis_php
src/Genesis/Builders/JSON.php
JSON.populateNodes
public function populateNodes($structure) { try { $this->output = json_encode($structure); } catch (\Exception $e) { throw new \Genesis\Exceptions\InvalidArgument('Invalid data/tree'); } }
php
public function populateNodes($structure) { try { $this->output = json_encode($structure); } catch (\Exception $e) { throw new \Genesis\Exceptions\InvalidArgument('Invalid data/tree'); } }
[ "public", "function", "populateNodes", "(", "$", "structure", ")", "{", "try", "{", "$", "this", "->", "output", "=", "json_encode", "(", "$", "structure", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "throw", "new", "\\", "Genesis", "\\", "Exceptions", "\\", "InvalidArgument", "(", "'Invalid data/tree'", ")", ";", "}", "}" ]
Convert multi-dimensional array to JSON object @param array $structure @throws \Genesis\Exceptions\InvalidArgument @return void
[ "Convert", "multi", "-", "dimensional", "array", "to", "JSON", "object" ]
b2a40413fd50357f41015eb05db9af305a3f4a6f
https://github.com/GenesisGateway/genesis_php/blob/b2a40413fd50357f41015eb05db9af305a3f4a6f/src/Genesis/Builders/JSON.php#L60-L67
train
GenesisGateway/genesis_php
src/Genesis/API/Request/Financial/Alternatives/Klarna/Items.php
Items.toArray
public function toArray() { return [ 'order_tax_amount' => CurrencyUtils::amountToExponent($this->getOrderTaxAmount(), $this->currency), 'items' => array_map( function ($item) { return ['item' => $item->toArray()]; }, $this->items ) ]; }
php
public function toArray() { return [ 'order_tax_amount' => CurrencyUtils::amountToExponent($this->getOrderTaxAmount(), $this->currency), 'items' => array_map( function ($item) { return ['item' => $item->toArray()]; }, $this->items ) ]; }
[ "public", "function", "toArray", "(", ")", "{", "return", "[", "'order_tax_amount'", "=>", "CurrencyUtils", "::", "amountToExponent", "(", "$", "this", "->", "getOrderTaxAmount", "(", ")", ",", "$", "this", "->", "currency", ")", ",", "'items'", "=>", "array_map", "(", "function", "(", "$", "item", ")", "{", "return", "[", "'item'", "=>", "$", "item", "->", "toArray", "(", ")", "]", ";", "}", ",", "$", "this", "->", "items", ")", "]", ";", "}" ]
Return items request attributes @return array
[ "Return", "items", "request", "attributes" ]
b2a40413fd50357f41015eb05db9af305a3f4a6f
https://github.com/GenesisGateway/genesis_php/blob/b2a40413fd50357f41015eb05db9af305a3f4a6f/src/Genesis/API/Request/Financial/Alternatives/Klarna/Items.php#L113-L124
train
OXIDprojects/oxid-console
src/Core/Migration/AbstractQuery.php
AbstractQuery._tableExists
protected static function _tableExists($sTable) { $oConfig = Registry::getConfig(); $sDbName = $oConfig->getConfigParam('dbName'); $sQuery = " SELECT 1 FROM information_schema.tables WHERE table_schema = ? AND table_name = ? "; return (bool)DatabaseProvider::getDb()->getOne($sQuery, array($sDbName, $sTable)); }
php
protected static function _tableExists($sTable) { $oConfig = Registry::getConfig(); $sDbName = $oConfig->getConfigParam('dbName'); $sQuery = " SELECT 1 FROM information_schema.tables WHERE table_schema = ? AND table_name = ? "; return (bool)DatabaseProvider::getDb()->getOne($sQuery, array($sDbName, $sTable)); }
[ "protected", "static", "function", "_tableExists", "(", "$", "sTable", ")", "{", "$", "oConfig", "=", "Registry", "::", "getConfig", "(", ")", ";", "$", "sDbName", "=", "$", "oConfig", "->", "getConfigParam", "(", "'dbName'", ")", ";", "$", "sQuery", "=", "\"\n SELECT 1\n FROM information_schema.tables\n WHERE table_schema = ?\n AND table_name = ?\n \"", ";", "return", "(", "bool", ")", "DatabaseProvider", "::", "getDb", "(", ")", "->", "getOne", "(", "$", "sQuery", ",", "array", "(", "$", "sDbName", ",", "$", "sTable", ")", ")", ";", "}" ]
Table exists in database? @param string $sTable Table name @return bool
[ "Table", "exists", "in", "database?" ]
476fa3b1ddd01fb3d4566258fbad941d75ba8a5a
https://github.com/OXIDprojects/oxid-console/blob/476fa3b1ddd01fb3d4566258fbad941d75ba8a5a/src/Core/Migration/AbstractQuery.php#L198-L210
train
OXIDprojects/oxid-console
src/Core/Migration/AbstractQuery.php
AbstractQuery._columnExists
protected static function _columnExists($sTable, $sColumn) { $oConfig = Registry::getConfig(); $sDbName = $oConfig->getConfigParam('dbName'); $sSql = 'SELECT 1 FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = ? AND TABLE_NAME = ? AND COLUMN_NAME = ?'; $oDb = DatabaseProvider::getDb(); return (bool)$oDb->getOne($sSql, array($sDbName, $sTable, $sColumn)); }
php
protected static function _columnExists($sTable, $sColumn) { $oConfig = Registry::getConfig(); $sDbName = $oConfig->getConfigParam('dbName'); $sSql = 'SELECT 1 FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = ? AND TABLE_NAME = ? AND COLUMN_NAME = ?'; $oDb = DatabaseProvider::getDb(); return (bool)$oDb->getOne($sSql, array($sDbName, $sTable, $sColumn)); }
[ "protected", "static", "function", "_columnExists", "(", "$", "sTable", ",", "$", "sColumn", ")", "{", "$", "oConfig", "=", "Registry", "::", "getConfig", "(", ")", ";", "$", "sDbName", "=", "$", "oConfig", "->", "getConfigParam", "(", "'dbName'", ")", ";", "$", "sSql", "=", "'SELECT 1\n FROM information_schema.COLUMNS\n WHERE\n TABLE_SCHEMA = ?\n AND TABLE_NAME = ?\n AND COLUMN_NAME = ?'", ";", "$", "oDb", "=", "DatabaseProvider", "::", "getDb", "(", ")", ";", "return", "(", "bool", ")", "$", "oDb", "->", "getOne", "(", "$", "sSql", ",", "array", "(", "$", "sDbName", ",", "$", "sTable", ",", "$", "sColumn", ")", ")", ";", "}" ]
Column exists in specific table? @param string $sTable Table name @param string $sColumn Column name @return bool
[ "Column", "exists", "in", "specific", "table?" ]
476fa3b1ddd01fb3d4566258fbad941d75ba8a5a
https://github.com/OXIDprojects/oxid-console/blob/476fa3b1ddd01fb3d4566258fbad941d75ba8a5a/src/Core/Migration/AbstractQuery.php#L220-L234
train
GenesisGateway/genesis_php
src/Genesis/Utils/Common.php
Common.getPHPVersion
public static function getPHPVersion() { // PHP_VERSION_ID is available as of PHP 5.2.7, if the current version is older than that - emulate it if (!defined('PHP_VERSION_ID')) { list($major, $minor, $release) = explode('.', PHP_VERSION); /** * Define PHP_VERSION_ID if its not present (unsupported version) * * format: major minor release */ define('PHP_VERSION_ID', (($major * 10000) + ($minor * 100) + $release)); } return (int)PHP_VERSION_ID; }
php
public static function getPHPVersion() { // PHP_VERSION_ID is available as of PHP 5.2.7, if the current version is older than that - emulate it if (!defined('PHP_VERSION_ID')) { list($major, $minor, $release) = explode('.', PHP_VERSION); /** * Define PHP_VERSION_ID if its not present (unsupported version) * * format: major minor release */ define('PHP_VERSION_ID', (($major * 10000) + ($minor * 100) + $release)); } return (int)PHP_VERSION_ID; }
[ "public", "static", "function", "getPHPVersion", "(", ")", "{", "// PHP_VERSION_ID is available as of PHP 5.2.7, if the current version is older than that - emulate it", "if", "(", "!", "defined", "(", "'PHP_VERSION_ID'", ")", ")", "{", "list", "(", "$", "major", ",", "$", "minor", ",", "$", "release", ")", "=", "explode", "(", "'.'", ",", "PHP_VERSION", ")", ";", "/**\n * Define PHP_VERSION_ID if its not present (unsupported version)\n *\n * format: major minor release\n */", "define", "(", "'PHP_VERSION_ID'", ",", "(", "(", "$", "major", "*", "10000", ")", "+", "(", "$", "minor", "*", "100", ")", "+", "$", "release", ")", ")", ";", "}", "return", "(", "int", ")", "PHP_VERSION_ID", ";", "}" ]
Helper to get the current PHP version @return int
[ "Helper", "to", "get", "the", "current", "PHP", "version" ]
b2a40413fd50357f41015eb05db9af305a3f4a6f
https://github.com/GenesisGateway/genesis_php/blob/b2a40413fd50357f41015eb05db9af305a3f4a6f/src/Genesis/Utils/Common.php#L51-L66
train
GenesisGateway/genesis_php
src/Genesis/Utils/Common.php
Common.pascalToSnakeCase
public static function pascalToSnakeCase($input) { preg_match_all('!([A-Z][A-Z0-9]*(?=$|[A-Z][a-z0-9])|[A-Za-z][a-z0-9]+)!', $input, $matches); foreach ($matches[0] as &$match) { $match = ($match == strtoupper($match)) ? strtolower($match) : lcfirst($match); } return implode('_', $matches[0]); }
php
public static function pascalToSnakeCase($input) { preg_match_all('!([A-Z][A-Z0-9]*(?=$|[A-Z][a-z0-9])|[A-Za-z][a-z0-9]+)!', $input, $matches); foreach ($matches[0] as &$match) { $match = ($match == strtoupper($match)) ? strtolower($match) : lcfirst($match); } return implode('_', $matches[0]); }
[ "public", "static", "function", "pascalToSnakeCase", "(", "$", "input", ")", "{", "preg_match_all", "(", "'!([A-Z][A-Z0-9]*(?=$|[A-Z][a-z0-9])|[A-Za-z][a-z0-9]+)!'", ",", "$", "input", ",", "$", "matches", ")", ";", "foreach", "(", "$", "matches", "[", "0", "]", "as", "&", "$", "match", ")", "{", "$", "match", "=", "(", "$", "match", "==", "strtoupper", "(", "$", "match", ")", ")", "?", "strtolower", "(", "$", "match", ")", ":", "lcfirst", "(", "$", "match", ")", ";", "}", "return", "implode", "(", "'_'", ",", "$", "matches", "[", "0", "]", ")", ";", "}" ]
Convert PascalCase string to a SnakeCase useful for argument parsing @param string $input @return string
[ "Convert", "PascalCase", "string", "to", "a", "SnakeCase", "useful", "for", "argument", "parsing" ]
b2a40413fd50357f41015eb05db9af305a3f4a6f
https://github.com/GenesisGateway/genesis_php/blob/b2a40413fd50357f41015eb05db9af305a3f4a6f/src/Genesis/Utils/Common.php#L76-L85
train
GenesisGateway/genesis_php
src/Genesis/Utils/Common.php
Common.isArrayKeyExists
public static function isArrayKeyExists($key, $arr) { if (!self::isValidArray($arr)) { return false; } return array_key_exists($key, $arr); }
php
public static function isArrayKeyExists($key, $arr) { if (!self::isValidArray($arr)) { return false; } return array_key_exists($key, $arr); }
[ "public", "static", "function", "isArrayKeyExists", "(", "$", "key", ",", "$", "arr", ")", "{", "if", "(", "!", "self", "::", "isValidArray", "(", "$", "arr", ")", ")", "{", "return", "false", ";", "}", "return", "array_key_exists", "(", "$", "key", ",", "$", "arr", ")", ";", "}" ]
Check if the passed key exists in the supplied array @param string $key @param array $arr @return bool
[ "Check", "if", "the", "passed", "key", "exists", "in", "the", "supplied", "array" ]
b2a40413fd50357f41015eb05db9af305a3f4a6f
https://github.com/GenesisGateway/genesis_php/blob/b2a40413fd50357f41015eb05db9af305a3f4a6f/src/Genesis/Utils/Common.php#L190-L197
train
GenesisGateway/genesis_php
src/Genesis/Utils/Common.php
Common.getSortedArrayByValue
public static function getSortedArrayByValue($arr) { $duplicate = self::copyArray($arr); if ($duplicate === null) { return null; } asort($duplicate); return $duplicate; }
php
public static function getSortedArrayByValue($arr) { $duplicate = self::copyArray($arr); if ($duplicate === null) { return null; } asort($duplicate); return $duplicate; }
[ "public", "static", "function", "getSortedArrayByValue", "(", "$", "arr", ")", "{", "$", "duplicate", "=", "self", "::", "copyArray", "(", "$", "arr", ")", ";", "if", "(", "$", "duplicate", "===", "null", ")", "{", "return", "null", ";", "}", "asort", "(", "$", "duplicate", ")", ";", "return", "$", "duplicate", ";", "}" ]
Sorts an array by value and returns a new instance @param array $arr @return array
[ "Sorts", "an", "array", "by", "value", "and", "returns", "a", "new", "instance" ]
b2a40413fd50357f41015eb05db9af305a3f4a6f
https://github.com/GenesisGateway/genesis_php/blob/b2a40413fd50357f41015eb05db9af305a3f4a6f/src/Genesis/Utils/Common.php#L220-L231
train
GenesisGateway/genesis_php
src/Genesis/Utils/Common.php
Common.appendItemsToArrayObj
public static function appendItemsToArrayObj(&$arrObj, $key, $values) { if (! $arrObj instanceof \ArrayObject) { return null; } $arr = $arrObj->getArrayCopy(); $commonArrKeyValues = Common::isArrayKeyExists($key, $arr) ? $arr[$key] : []; $arr[$key] = array_merge($commonArrKeyValues, $values); return $arrObj = self::createArrayObject($arr); }
php
public static function appendItemsToArrayObj(&$arrObj, $key, $values) { if (! $arrObj instanceof \ArrayObject) { return null; } $arr = $arrObj->getArrayCopy(); $commonArrKeyValues = Common::isArrayKeyExists($key, $arr) ? $arr[$key] : []; $arr[$key] = array_merge($commonArrKeyValues, $values); return $arrObj = self::createArrayObject($arr); }
[ "public", "static", "function", "appendItemsToArrayObj", "(", "&", "$", "arrObj", ",", "$", "key", ",", "$", "values", ")", "{", "if", "(", "!", "$", "arrObj", "instanceof", "\\", "ArrayObject", ")", "{", "return", "null", ";", "}", "$", "arr", "=", "$", "arrObj", "->", "getArrayCopy", "(", ")", ";", "$", "commonArrKeyValues", "=", "Common", "::", "isArrayKeyExists", "(", "$", "key", ",", "$", "arr", ")", "?", "$", "arr", "[", "$", "key", "]", ":", "[", "]", ";", "$", "arr", "[", "$", "key", "]", "=", "array_merge", "(", "$", "commonArrKeyValues", ",", "$", "values", ")", ";", "return", "$", "arrObj", "=", "self", "::", "createArrayObject", "(", "$", "arr", ")", ";", "}" ]
Appends items to an ArrayObject by key @param \ArrayObject $arrObj @param string $key @param array $values @return \ArrayObject|null
[ "Appends", "items", "to", "an", "ArrayObject", "by", "key" ]
b2a40413fd50357f41015eb05db9af305a3f4a6f
https://github.com/GenesisGateway/genesis_php/blob/b2a40413fd50357f41015eb05db9af305a3f4a6f/src/Genesis/Utils/Common.php#L241-L257
train
GenesisGateway/genesis_php
src/Genesis/Utils/Common.php
Common.isValidXMLName
public static function isValidXMLName($tag) { if (!is_array($tag)) { return preg_match('/^[a-z_]+[a-z0-9\:\-\.\_]*[^:]*$/i', $tag, $matches) && reset($matches) == $tag; } return false; }
php
public static function isValidXMLName($tag) { if (!is_array($tag)) { return preg_match('/^[a-z_]+[a-z0-9\:\-\.\_]*[^:]*$/i', $tag, $matches) && reset($matches) == $tag; } return false; }
[ "public", "static", "function", "isValidXMLName", "(", "$", "tag", ")", "{", "if", "(", "!", "is_array", "(", "$", "tag", ")", ")", "{", "return", "preg_match", "(", "'/^[a-z_]+[a-z0-9\\:\\-\\.\\_]*[^:]*$/i'", ",", "$", "tag", ",", "$", "matches", ")", "&&", "reset", "(", "$", "matches", ")", "==", "$", "tag", ";", "}", "return", "false", ";", "}" ]
Check if the passed argument is a valid XML tag name @param string $tag @return bool
[ "Check", "if", "the", "passed", "argument", "is", "a", "valid", "XML", "tag", "name" ]
b2a40413fd50357f41015eb05db9af305a3f4a6f
https://github.com/GenesisGateway/genesis_php/blob/b2a40413fd50357f41015eb05db9af305a3f4a6f/src/Genesis/Utils/Common.php#L279-L286
train
GenesisGateway/genesis_php
src/Genesis/Utils/Common.php
Common.stringToBoolean
public static function stringToBoolean($string) { $flag = filter_var($string, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE); if ($flag) { return true; } elseif (is_null($flag)) { return $string; } return false; }
php
public static function stringToBoolean($string) { $flag = filter_var($string, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE); if ($flag) { return true; } elseif (is_null($flag)) { return $string; } return false; }
[ "public", "static", "function", "stringToBoolean", "(", "$", "string", ")", "{", "$", "flag", "=", "filter_var", "(", "$", "string", ",", "FILTER_VALIDATE_BOOLEAN", ",", "FILTER_NULL_ON_FAILURE", ")", ";", "if", "(", "$", "flag", ")", "{", "return", "true", ";", "}", "elseif", "(", "is_null", "(", "$", "flag", ")", ")", "{", "return", "$", "string", ";", "}", "return", "false", ";", "}" ]
Evaluate a boolean expression from String or return the string itself @param $string @return bool | string
[ "Evaluate", "a", "boolean", "expression", "from", "String", "or", "return", "the", "string", "itself" ]
b2a40413fd50357f41015eb05db9af305a3f4a6f
https://github.com/GenesisGateway/genesis_php/blob/b2a40413fd50357f41015eb05db9af305a3f4a6f/src/Genesis/Utils/Common.php#L296-L307
train
GenesisGateway/genesis_php
src/Genesis/Utils/Common.php
Common.isBase64Encoded
public static function isBase64Encoded($input) { if ($input && @base64_encode(@base64_decode($input, true)) === $input) { return true; } return false; }
php
public static function isBase64Encoded($input) { if ($input && @base64_encode(@base64_decode($input, true)) === $input) { return true; } return false; }
[ "public", "static", "function", "isBase64Encoded", "(", "$", "input", ")", "{", "if", "(", "$", "input", "&&", "@", "base64_encode", "(", "@", "base64_decode", "(", "$", "input", ",", "true", ")", ")", "===", "$", "input", ")", "{", "return", "true", ";", "}", "return", "false", ";", "}" ]
Check if a string is base64 Encoded @param string $input Data to verify if its valid base64 @return bool
[ "Check", "if", "a", "string", "is", "base64", "Encoded" ]
b2a40413fd50357f41015eb05db9af305a3f4a6f
https://github.com/GenesisGateway/genesis_php/blob/b2a40413fd50357f41015eb05db9af305a3f4a6f/src/Genesis/Utils/Common.php#L335-L342
train
GenesisGateway/genesis_php
src/Genesis/Utils/Common.php
Common.arrayContainsArrayItems
public static function arrayContainsArrayItems($arr) { if (!self::isValidArray($arr)) { return false; } foreach ($arr as $item) { if (self::isValidArray($item)) { return true; } } return false; }
php
public static function arrayContainsArrayItems($arr) { if (!self::isValidArray($arr)) { return false; } foreach ($arr as $item) { if (self::isValidArray($item)) { return true; } } return false; }
[ "public", "static", "function", "arrayContainsArrayItems", "(", "$", "arr", ")", "{", "if", "(", "!", "self", "::", "isValidArray", "(", "$", "arr", ")", ")", "{", "return", "false", ";", "}", "foreach", "(", "$", "arr", "as", "$", "item", ")", "{", "if", "(", "self", "::", "isValidArray", "(", "$", "item", ")", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Check if an array has array items @param array $arr @return bool
[ "Check", "if", "an", "array", "has", "array", "items" ]
b2a40413fd50357f41015eb05db9af305a3f4a6f
https://github.com/GenesisGateway/genesis_php/blob/b2a40413fd50357f41015eb05db9af305a3f4a6f/src/Genesis/Utils/Common.php#L349-L362
train
GenesisGateway/genesis_php
src/Genesis/Utils/Common.php
Common.isClassAbstract
public static function isClassAbstract($className) { if (!class_exists($className)) { return false; } $reflectionClass = new \ReflectionClass($className); return $reflectionClass->isAbstract(); }
php
public static function isClassAbstract($className) { if (!class_exists($className)) { return false; } $reflectionClass = new \ReflectionClass($className); return $reflectionClass->isAbstract(); }
[ "public", "static", "function", "isClassAbstract", "(", "$", "className", ")", "{", "if", "(", "!", "class_exists", "(", "$", "className", ")", ")", "{", "return", "false", ";", "}", "$", "reflectionClass", "=", "new", "\\", "ReflectionClass", "(", "$", "className", ")", ";", "return", "$", "reflectionClass", "->", "isAbstract", "(", ")", ";", "}" ]
Determines if the given class is Instantiable or not Helps to prevent from creating an instance of an abstract class @param string $className @return bool
[ "Determines", "if", "the", "given", "class", "is", "Instantiable", "or", "not", "Helps", "to", "prevent", "from", "creating", "an", "instance", "of", "an", "abstract", "class" ]
b2a40413fd50357f41015eb05db9af305a3f4a6f
https://github.com/GenesisGateway/genesis_php/blob/b2a40413fd50357f41015eb05db9af305a3f4a6f/src/Genesis/Utils/Common.php#L371-L380
train
GenesisGateway/genesis_php
src/Genesis/Utils/Requirements.php
Requirements.verify
public static function verify() { // PHP interpreter version self::checkSystemVersion(); // BCMath self::isFunctionExists('bcmul', self::getErrorMessage('bcmath')); self::isFunctionExists('bcdiv', self::getErrorMessage('bcmath')); // Filter self::isFunctionExists('filter_var', self::getErrorMessage('filter')); // Hash self::isFunctionExists('hash', self::getErrorMessage('hash')); // XMLReader self::isClassExists('XMLReader', self::getErrorMessage('xmlreader')); // XMLWriter if (\Genesis\Config::getInterface('builder') == 'xml') { self::isClassExists('XMLWriter', self::getErrorMessage('xmlwriter')); } // cURL if (\Genesis\Config::getInterface('network') == 'curl') { self::isFunctionExists('curl_init', self::getErrorMessage('curl')); } }
php
public static function verify() { // PHP interpreter version self::checkSystemVersion(); // BCMath self::isFunctionExists('bcmul', self::getErrorMessage('bcmath')); self::isFunctionExists('bcdiv', self::getErrorMessage('bcmath')); // Filter self::isFunctionExists('filter_var', self::getErrorMessage('filter')); // Hash self::isFunctionExists('hash', self::getErrorMessage('hash')); // XMLReader self::isClassExists('XMLReader', self::getErrorMessage('xmlreader')); // XMLWriter if (\Genesis\Config::getInterface('builder') == 'xml') { self::isClassExists('XMLWriter', self::getErrorMessage('xmlwriter')); } // cURL if (\Genesis\Config::getInterface('network') == 'curl') { self::isFunctionExists('curl_init', self::getErrorMessage('curl')); } }
[ "public", "static", "function", "verify", "(", ")", "{", "// PHP interpreter version", "self", "::", "checkSystemVersion", "(", ")", ";", "// BCMath", "self", "::", "isFunctionExists", "(", "'bcmul'", ",", "self", "::", "getErrorMessage", "(", "'bcmath'", ")", ")", ";", "self", "::", "isFunctionExists", "(", "'bcdiv'", ",", "self", "::", "getErrorMessage", "(", "'bcmath'", ")", ")", ";", "// Filter", "self", "::", "isFunctionExists", "(", "'filter_var'", ",", "self", "::", "getErrorMessage", "(", "'filter'", ")", ")", ";", "// Hash", "self", "::", "isFunctionExists", "(", "'hash'", ",", "self", "::", "getErrorMessage", "(", "'hash'", ")", ")", ";", "// XMLReader", "self", "::", "isClassExists", "(", "'XMLReader'", ",", "self", "::", "getErrorMessage", "(", "'xmlreader'", ")", ")", ";", "// XMLWriter", "if", "(", "\\", "Genesis", "\\", "Config", "::", "getInterface", "(", "'builder'", ")", "==", "'xml'", ")", "{", "self", "::", "isClassExists", "(", "'XMLWriter'", ",", "self", "::", "getErrorMessage", "(", "'xmlwriter'", ")", ")", ";", "}", "// cURL", "if", "(", "\\", "Genesis", "\\", "Config", "::", "getInterface", "(", "'network'", ")", "==", "'curl'", ")", "{", "self", "::", "isFunctionExists", "(", "'curl_init'", ",", "self", "::", "getErrorMessage", "(", "'curl'", ")", ")", ";", "}", "}" ]
Check if the current system fulfils the project's dependencies @throws \Exception
[ "Check", "if", "the", "current", "system", "fulfils", "the", "project", "s", "dependencies" ]
b2a40413fd50357f41015eb05db9af305a3f4a6f
https://github.com/GenesisGateway/genesis_php/blob/b2a40413fd50357f41015eb05db9af305a3f4a6f/src/Genesis/Utils/Requirements.php#L44-L71
train
GenesisGateway/genesis_php
src/Genesis/Utils/Requirements.php
Requirements.checkSystemVersion
public static function checkSystemVersion() { if (\Genesis\Utils\Common::compareVersions(self::$minPHPVersion, '<')) { throw new \Exception(self::getErrorMessage('system')); } }
php
public static function checkSystemVersion() { if (\Genesis\Utils\Common::compareVersions(self::$minPHPVersion, '<')) { throw new \Exception(self::getErrorMessage('system')); } }
[ "public", "static", "function", "checkSystemVersion", "(", ")", "{", "if", "(", "\\", "Genesis", "\\", "Utils", "\\", "Common", "::", "compareVersions", "(", "self", "::", "$", "minPHPVersion", ",", "'<'", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "self", "::", "getErrorMessage", "(", "'system'", ")", ")", ";", "}", "}" ]
Check the PHP interpreter version we're currently running @throws \Exception
[ "Check", "the", "PHP", "interpreter", "version", "we", "re", "currently", "running" ]
b2a40413fd50357f41015eb05db9af305a3f4a6f
https://github.com/GenesisGateway/genesis_php/blob/b2a40413fd50357f41015eb05db9af305a3f4a6f/src/Genesis/Utils/Requirements.php#L78-L83
train
GenesisGateway/genesis_php
src/Genesis/Utils/Requirements.php
Requirements.getErrorMessage
public static function getErrorMessage($name) { $messages = [ 'system' => 'Unsupported PHP version, please upgrade!' . PHP_EOL . 'This library requires PHP version ' . self::$minPHPVersion . ' or newer.', 'bcmath' => 'BCMath extension is required!' . PHP_EOL . 'Please install the extension or rebuild with "--enable-bcmath" option.', 'filter' => 'Filter extensions is required!' . PHP_EOL . 'Please install the extension or rebuild with "--enable-filter" option.', 'hash' => 'Hash extension is required!' . PHP_EOL . 'Please install the extension or rebuild with "--enable-hash" option.', 'xmlreader' => 'XMLReader extension is required!' . PHP_EOL . 'Please install the extension or rebuild with "--enable-xmlreader" option.', 'xmlwriter' => 'XMLWriter extension is required!' . PHP_EOL . 'Please install the extension or rebuild with "--enable-xmlwriter" option.', 'curl' => 'cURL interface is selected, but its not installed on your system!' . PHP_EOL . 'Please install the extension or select "stream" as your network interface.' ]; if (array_key_exists($name, $messages)) { return $messages[$name]; } return '[' . $name . '] Missing project dependency!'; }
php
public static function getErrorMessage($name) { $messages = [ 'system' => 'Unsupported PHP version, please upgrade!' . PHP_EOL . 'This library requires PHP version ' . self::$minPHPVersion . ' or newer.', 'bcmath' => 'BCMath extension is required!' . PHP_EOL . 'Please install the extension or rebuild with "--enable-bcmath" option.', 'filter' => 'Filter extensions is required!' . PHP_EOL . 'Please install the extension or rebuild with "--enable-filter" option.', 'hash' => 'Hash extension is required!' . PHP_EOL . 'Please install the extension or rebuild with "--enable-hash" option.', 'xmlreader' => 'XMLReader extension is required!' . PHP_EOL . 'Please install the extension or rebuild with "--enable-xmlreader" option.', 'xmlwriter' => 'XMLWriter extension is required!' . PHP_EOL . 'Please install the extension or rebuild with "--enable-xmlwriter" option.', 'curl' => 'cURL interface is selected, but its not installed on your system!' . PHP_EOL . 'Please install the extension or select "stream" as your network interface.' ]; if (array_key_exists($name, $messages)) { return $messages[$name]; } return '[' . $name . '] Missing project dependency!'; }
[ "public", "static", "function", "getErrorMessage", "(", "$", "name", ")", "{", "$", "messages", "=", "[", "'system'", "=>", "'Unsupported PHP version, please upgrade!'", ".", "PHP_EOL", ".", "'This library requires PHP version '", ".", "self", "::", "$", "minPHPVersion", ".", "' or newer.'", ",", "'bcmath'", "=>", "'BCMath extension is required!'", ".", "PHP_EOL", ".", "'Please install the extension or rebuild with \"--enable-bcmath\" option.'", ",", "'filter'", "=>", "'Filter extensions is required!'", ".", "PHP_EOL", ".", "'Please install the extension or rebuild with \"--enable-filter\" option.'", ",", "'hash'", "=>", "'Hash extension is required!'", ".", "PHP_EOL", ".", "'Please install the extension or rebuild with \"--enable-hash\" option.'", ",", "'xmlreader'", "=>", "'XMLReader extension is required!'", ".", "PHP_EOL", ".", "'Please install the extension or rebuild with \"--enable-xmlreader\" option.'", ",", "'xmlwriter'", "=>", "'XMLWriter extension is required!'", ".", "PHP_EOL", ".", "'Please install the extension or rebuild with \"--enable-xmlwriter\" option.'", ",", "'curl'", "=>", "'cURL interface is selected, but its not installed on your system!'", ".", "PHP_EOL", ".", "'Please install the extension or select \"stream\" as your network interface.'", "]", ";", "if", "(", "array_key_exists", "(", "$", "name", ",", "$", "messages", ")", ")", "{", "return", "$", "messages", "[", "$", "name", "]", ";", "}", "return", "'['", ".", "$", "name", ".", "'] Missing project dependency!'", ";", "}" ]
Get error message for certain type @param string $name @return string
[ "Get", "error", "message", "for", "certain", "type" ]
b2a40413fd50357f41015eb05db9af305a3f4a6f
https://github.com/GenesisGateway/genesis_php/blob/b2a40413fd50357f41015eb05db9af305a3f4a6f/src/Genesis/Utils/Requirements.php#L134-L158
train
GenesisGateway/genesis_php
src/Genesis/Builders/XML.php
XML.populateNodes
public function populateNodes($data) { if (!\Genesis\Utils\Common::isValidArray($data)) { throw new \Genesis\Exceptions\InvalidArgument('Invalid data structure'); } // Ensure that the Array position is 0 reset($data); $this->iterateArray(key($data), reset($data)); // Finish the document $this->context->endDocument(); }
php
public function populateNodes($data) { if (!\Genesis\Utils\Common::isValidArray($data)) { throw new \Genesis\Exceptions\InvalidArgument('Invalid data structure'); } // Ensure that the Array position is 0 reset($data); $this->iterateArray(key($data), reset($data)); // Finish the document $this->context->endDocument(); }
[ "public", "function", "populateNodes", "(", "$", "data", ")", "{", "if", "(", "!", "\\", "Genesis", "\\", "Utils", "\\", "Common", "::", "isValidArray", "(", "$", "data", ")", ")", "{", "throw", "new", "\\", "Genesis", "\\", "Exceptions", "\\", "InvalidArgument", "(", "'Invalid data structure'", ")", ";", "}", "// Ensure that the Array position is 0", "reset", "(", "$", "data", ")", ";", "$", "this", "->", "iterateArray", "(", "key", "(", "$", "data", ")", ",", "reset", "(", "$", "data", ")", ")", ";", "// Finish the document", "$", "this", "->", "context", "->", "endDocument", "(", ")", ";", "}" ]
Insert tree-structured array as nodes in XMLWriter and end the current Document. @param array $data - tree-structured array @throws \Genesis\Exceptions\InvalidArgument @return void
[ "Insert", "tree", "-", "structured", "array", "as", "nodes", "in", "XMLWriter", "and", "end", "the", "current", "Document", "." ]
b2a40413fd50357f41015eb05db9af305a3f4a6f
https://github.com/GenesisGateway/genesis_php/blob/b2a40413fd50357f41015eb05db9af305a3f4a6f/src/Genesis/Builders/XML.php#L74-L87
train
GenesisGateway/genesis_php
src/Genesis/Builders/XML.php
XML.iterateArray
public function iterateArray($name, $data) { if (\Genesis\Utils\Common::isValidXMLName($name)) { $this->context->startElement($name); } foreach ($data as $key => $value) { if (is_null($value)) { continue; } // Note: XMLWriter discards Attribute writes if they are written // after an Element, so make sure the attributes are at the top if ($key === '@attributes') { $this->writeAttribute($value); continue; } if ($key === '@cdata') { $this->writeCData($value); continue; } if ($key === '@value') { $this->writeText($value); continue; } $this->writeElement($key, $value); } if (\Genesis\Utils\Common::isValidXMLName($name)) { $this->context->endElement(); } }
php
public function iterateArray($name, $data) { if (\Genesis\Utils\Common::isValidXMLName($name)) { $this->context->startElement($name); } foreach ($data as $key => $value) { if (is_null($value)) { continue; } // Note: XMLWriter discards Attribute writes if they are written // after an Element, so make sure the attributes are at the top if ($key === '@attributes') { $this->writeAttribute($value); continue; } if ($key === '@cdata') { $this->writeCData($value); continue; } if ($key === '@value') { $this->writeText($value); continue; } $this->writeElement($key, $value); } if (\Genesis\Utils\Common::isValidXMLName($name)) { $this->context->endElement(); } }
[ "public", "function", "iterateArray", "(", "$", "name", ",", "$", "data", ")", "{", "if", "(", "\\", "Genesis", "\\", "Utils", "\\", "Common", "::", "isValidXMLName", "(", "$", "name", ")", ")", "{", "$", "this", "->", "context", "->", "startElement", "(", "$", "name", ")", ";", "}", "foreach", "(", "$", "data", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "is_null", "(", "$", "value", ")", ")", "{", "continue", ";", "}", "// Note: XMLWriter discards Attribute writes if they are written", "// after an Element, so make sure the attributes are at the top", "if", "(", "$", "key", "===", "'@attributes'", ")", "{", "$", "this", "->", "writeAttribute", "(", "$", "value", ")", ";", "continue", ";", "}", "if", "(", "$", "key", "===", "'@cdata'", ")", "{", "$", "this", "->", "writeCData", "(", "$", "value", ")", ";", "continue", ";", "}", "if", "(", "$", "key", "===", "'@value'", ")", "{", "$", "this", "->", "writeText", "(", "$", "value", ")", ";", "continue", ";", "}", "$", "this", "->", "writeElement", "(", "$", "key", ",", "$", "value", ")", ";", "}", "if", "(", "\\", "Genesis", "\\", "Utils", "\\", "Common", "::", "isValidXMLName", "(", "$", "name", ")", ")", "{", "$", "this", "->", "context", "->", "endElement", "(", ")", ";", "}", "}" ]
Recursive iteration over array @param string $name name of the current leave @param array $data value of the current leave @return void
[ "Recursive", "iteration", "over", "array" ]
b2a40413fd50357f41015eb05db9af305a3f4a6f
https://github.com/GenesisGateway/genesis_php/blob/b2a40413fd50357f41015eb05db9af305a3f4a6f/src/Genesis/Builders/XML.php#L107-L141
train
GenesisGateway/genesis_php
src/Genesis/Builders/XML.php
XML.writeAttribute
public function writeAttribute($value) { if (is_array($value)) { foreach ($value as $attrName => $attrValue) { $this->context->writeAttribute($attrName, $attrValue); } } }
php
public function writeAttribute($value) { if (is_array($value)) { foreach ($value as $attrName => $attrValue) { $this->context->writeAttribute($attrName, $attrValue); } } }
[ "public", "function", "writeAttribute", "(", "$", "value", ")", "{", "if", "(", "is_array", "(", "$", "value", ")", ")", "{", "foreach", "(", "$", "value", "as", "$", "attrName", "=>", "$", "attrValue", ")", "{", "$", "this", "->", "context", "->", "writeAttribute", "(", "$", "attrName", ",", "$", "attrValue", ")", ";", "}", "}", "}" ]
Write Element's Attribute @param $value
[ "Write", "Element", "s", "Attribute" ]
b2a40413fd50357f41015eb05db9af305a3f4a6f
https://github.com/GenesisGateway/genesis_php/blob/b2a40413fd50357f41015eb05db9af305a3f4a6f/src/Genesis/Builders/XML.php#L148-L155
train
GenesisGateway/genesis_php
src/Genesis/Builders/XML.php
XML.writeCData
public function writeCData($value) { if (is_array($value)) { foreach ($value as $attrValue) { $this->context->writeCData($attrValue); } } else { $this->context->writeCData($value); } }
php
public function writeCData($value) { if (is_array($value)) { foreach ($value as $attrValue) { $this->context->writeCData($attrValue); } } else { $this->context->writeCData($value); } }
[ "public", "function", "writeCData", "(", "$", "value", ")", "{", "if", "(", "is_array", "(", "$", "value", ")", ")", "{", "foreach", "(", "$", "value", "as", "$", "attrValue", ")", "{", "$", "this", "->", "context", "->", "writeCData", "(", "$", "attrValue", ")", ";", "}", "}", "else", "{", "$", "this", "->", "context", "->", "writeCData", "(", "$", "value", ")", ";", "}", "}" ]
Write Element's CData @param $value @SuppressWarnings(PHPMD.ElseExpression)
[ "Write", "Element", "s", "CData" ]
b2a40413fd50357f41015eb05db9af305a3f4a6f
https://github.com/GenesisGateway/genesis_php/blob/b2a40413fd50357f41015eb05db9af305a3f4a6f/src/Genesis/Builders/XML.php#L164-L173
train
GenesisGateway/genesis_php
src/Genesis/Builders/XML.php
XML.writeText
public function writeText($value) { if (is_array($value)) { foreach ($value as $attrValue) { $this->context->text($attrValue); } } else { $this->context->text($value); } }
php
public function writeText($value) { if (is_array($value)) { foreach ($value as $attrValue) { $this->context->text($attrValue); } } else { $this->context->text($value); } }
[ "public", "function", "writeText", "(", "$", "value", ")", "{", "if", "(", "is_array", "(", "$", "value", ")", ")", "{", "foreach", "(", "$", "value", "as", "$", "attrValue", ")", "{", "$", "this", "->", "context", "->", "text", "(", "$", "attrValue", ")", ";", "}", "}", "else", "{", "$", "this", "->", "context", "->", "text", "(", "$", "value", ")", ";", "}", "}" ]
Write Element's Text @param $value @SuppressWarnings(PHPMD.ElseExpression)
[ "Write", "Element", "s", "Text" ]
b2a40413fd50357f41015eb05db9af305a3f4a6f
https://github.com/GenesisGateway/genesis_php/blob/b2a40413fd50357f41015eb05db9af305a3f4a6f/src/Genesis/Builders/XML.php#L182-L191
train
GenesisGateway/genesis_php
src/Genesis/Builders/XML.php
XML.writeElement
public function writeElement($key, $value) { if (is_array($value)) { $this->iterateArray($key, $value); } else { $value = \Genesis\Utils\Common::booleanToString($value); $this->context->writeElement($key, $value); } }
php
public function writeElement($key, $value) { if (is_array($value)) { $this->iterateArray($key, $value); } else { $value = \Genesis\Utils\Common::booleanToString($value); $this->context->writeElement($key, $value); } }
[ "public", "function", "writeElement", "(", "$", "key", ",", "$", "value", ")", "{", "if", "(", "is_array", "(", "$", "value", ")", ")", "{", "$", "this", "->", "iterateArray", "(", "$", "key", ",", "$", "value", ")", ";", "}", "else", "{", "$", "value", "=", "\\", "Genesis", "\\", "Utils", "\\", "Common", "::", "booleanToString", "(", "$", "value", ")", ";", "$", "this", "->", "context", "->", "writeElement", "(", "$", "key", ",", "$", "value", ")", ";", "}", "}" ]
Write XML Element @param $key @param $value @SuppressWarnings(PHPMD.ElseExpression)
[ "Write", "XML", "Element" ]
b2a40413fd50357f41015eb05db9af305a3f4a6f
https://github.com/GenesisGateway/genesis_php/blob/b2a40413fd50357f41015eb05db9af305a3f4a6f/src/Genesis/Builders/XML.php#L201-L210
train
fusonic/linq
src/Fusonic/Linq/Linq.php
Linq.range
public static function range($start, $count) { if ($count < 0) { throw new OutOfRangeException('$count must be not be negative.'); } return new Linq(range($start, $start + $count - 1)); }
php
public static function range($start, $count) { if ($count < 0) { throw new OutOfRangeException('$count must be not be negative.'); } return new Linq(range($start, $start + $count - 1)); }
[ "public", "static", "function", "range", "(", "$", "start", ",", "$", "count", ")", "{", "if", "(", "$", "count", "<", "0", ")", "{", "throw", "new", "OutOfRangeException", "(", "'$count must be not be negative.'", ")", ";", "}", "return", "new", "Linq", "(", "range", "(", "$", "start", ",", "$", "start", "+", "$", "count", "-", "1", ")", ")", ";", "}" ]
Generates a sequence of integral numbers within a specified range. @param int $start The value of the first integer in the sequence. @param int $count The number of sequential integers to generate. @return Linq An sequence that contains a range of sequential int numbers. @throws \OutOfRangeException
[ "Generates", "a", "sequence", "of", "integral", "numbers", "within", "a", "specified", "range", "." ]
065bfd32674875c9b5df25d29bfe4aa3b073c88f
https://github.com/fusonic/linq/blob/065bfd32674875c9b5df25d29bfe4aa3b073c88f/src/Fusonic/Linq/Linq.php#L74-L81
train
fusonic/linq
src/Fusonic/Linq/Linq.php
Linq.skip
public function skip($count) { // If its an array iterator we must check the arrays bounds are greater than the skip count. // This is because the LimitIterator will use the seek() method which will throw an exception if $count > array.bounds. $innerIterator = $this->iterator; if ($innerIterator instanceof \ArrayIterator) { if ($count >= $innerIterator->count()) { return new Linq([]); } } if (!($innerIterator instanceof \Iterator)) { // IteratorIterator wraps $innerIterator because it is Traversable but not an Iterator. // (see https://bugs.php.net/bug.php?id=52280) $innerIterator = new \IteratorIterator($innerIterator); } return new Linq(new \LimitIterator($innerIterator, $count, -1)); }
php
public function skip($count) { // If its an array iterator we must check the arrays bounds are greater than the skip count. // This is because the LimitIterator will use the seek() method which will throw an exception if $count > array.bounds. $innerIterator = $this->iterator; if ($innerIterator instanceof \ArrayIterator) { if ($count >= $innerIterator->count()) { return new Linq([]); } } if (!($innerIterator instanceof \Iterator)) { // IteratorIterator wraps $innerIterator because it is Traversable but not an Iterator. // (see https://bugs.php.net/bug.php?id=52280) $innerIterator = new \IteratorIterator($innerIterator); } return new Linq(new \LimitIterator($innerIterator, $count, -1)); }
[ "public", "function", "skip", "(", "$", "count", ")", "{", "// If its an array iterator we must check the arrays bounds are greater than the skip count.", "// This is because the LimitIterator will use the seek() method which will throw an exception if $count > array.bounds.", "$", "innerIterator", "=", "$", "this", "->", "iterator", ";", "if", "(", "$", "innerIterator", "instanceof", "\\", "ArrayIterator", ")", "{", "if", "(", "$", "count", ">=", "$", "innerIterator", "->", "count", "(", ")", ")", "{", "return", "new", "Linq", "(", "[", "]", ")", ";", "}", "}", "if", "(", "!", "(", "$", "innerIterator", "instanceof", "\\", "Iterator", ")", ")", "{", "// IteratorIterator wraps $innerIterator because it is Traversable but not an Iterator.", "// (see https://bugs.php.net/bug.php?id=52280)", "$", "innerIterator", "=", "new", "\\", "IteratorIterator", "(", "$", "innerIterator", ")", ";", "}", "return", "new", "Linq", "(", "new", "\\", "LimitIterator", "(", "$", "innerIterator", ",", "$", "count", ",", "-", "1", ")", ")", ";", "}" ]
Bypasses a specified number of elements and then returns the remaining elements. @param int $count The number of elements to skip before returning the remaining elements. @return Linq A Linq object that contains the elements that occur after the specified index.
[ "Bypasses", "a", "specified", "number", "of", "elements", "and", "then", "returns", "the", "remaining", "elements", "." ]
065bfd32674875c9b5df25d29bfe4aa3b073c88f
https://github.com/fusonic/linq/blob/065bfd32674875c9b5df25d29bfe4aa3b073c88f/src/Fusonic/Linq/Linq.php#L112-L129
train
fusonic/linq
src/Fusonic/Linq/Linq.php
Linq.take
public function take($count) { if ($count == 0) { return new Linq([]); } $innerIterator = $this->iterator; if (!($innerIterator instanceof \Iterator)) { // IteratorIterator wraps $this->iterator because it is Traversable but not an Iterator. // (see https://bugs.php.net/bug.php?id=52280) $innerIterator = new \IteratorIterator($innerIterator); } return new Linq(new \LimitIterator($innerIterator, 0, $count)); }
php
public function take($count) { if ($count == 0) { return new Linq([]); } $innerIterator = $this->iterator; if (!($innerIterator instanceof \Iterator)) { // IteratorIterator wraps $this->iterator because it is Traversable but not an Iterator. // (see https://bugs.php.net/bug.php?id=52280) $innerIterator = new \IteratorIterator($innerIterator); } return new Linq(new \LimitIterator($innerIterator, 0, $count)); }
[ "public", "function", "take", "(", "$", "count", ")", "{", "if", "(", "$", "count", "==", "0", ")", "{", "return", "new", "Linq", "(", "[", "]", ")", ";", "}", "$", "innerIterator", "=", "$", "this", "->", "iterator", ";", "if", "(", "!", "(", "$", "innerIterator", "instanceof", "\\", "Iterator", ")", ")", "{", "// IteratorIterator wraps $this->iterator because it is Traversable but not an Iterator.", "// (see https://bugs.php.net/bug.php?id=52280)", "$", "innerIterator", "=", "new", "\\", "IteratorIterator", "(", "$", "innerIterator", ")", ";", "}", "return", "new", "Linq", "(", "new", "\\", "LimitIterator", "(", "$", "innerIterator", ",", "0", ",", "$", "count", ")", ")", ";", "}" ]
Returns a specified number of contiguous elements from the start of a sequence @param int $count The number of elements to return. @return Linq A Linq object that contains the specified number of elements from the start.
[ "Returns", "a", "specified", "number", "of", "contiguous", "elements", "from", "the", "start", "of", "a", "sequence" ]
065bfd32674875c9b5df25d29bfe4aa3b073c88f
https://github.com/fusonic/linq/blob/065bfd32674875c9b5df25d29bfe4aa3b073c88f/src/Fusonic/Linq/Linq.php#L137-L150
train
fusonic/linq
src/Fusonic/Linq/Linq.php
Linq.all
public function all(callable $func) { foreach ($this->iterator as $current) { $match = LinqHelper::getBoolOrThrowException($func($current)); if (!$match) { return false; } } return true; }
php
public function all(callable $func) { foreach ($this->iterator as $current) { $match = LinqHelper::getBoolOrThrowException($func($current)); if (!$match) { return false; } } return true; }
[ "public", "function", "all", "(", "callable", "$", "func", ")", "{", "foreach", "(", "$", "this", "->", "iterator", "as", "$", "current", ")", "{", "$", "match", "=", "LinqHelper", "::", "getBoolOrThrowException", "(", "$", "func", "(", "$", "current", ")", ")", ";", "if", "(", "!", "$", "match", ")", "{", "return", "false", ";", "}", "}", "return", "true", ";", "}" ]
Determines whether all elements satisfy a condition. @param callable $func A function to test each element for a condition. @return bool True if every element passes the test in the specified func, or if the sequence is empty; otherwise, false.
[ "Determines", "whether", "all", "elements", "satisfy", "a", "condition", "." ]
065bfd32674875c9b5df25d29bfe4aa3b073c88f
https://github.com/fusonic/linq/blob/065bfd32674875c9b5df25d29bfe4aa3b073c88f/src/Fusonic/Linq/Linq.php#L210-L219
train
fusonic/linq
src/Fusonic/Linq/Linq.php
Linq.count
public function count() { if ($this->iterator instanceof Countable) { return $this->iterator->count(); } return iterator_count($this->iterator); }
php
public function count() { if ($this->iterator instanceof Countable) { return $this->iterator->count(); } return iterator_count($this->iterator); }
[ "public", "function", "count", "(", ")", "{", "if", "(", "$", "this", "->", "iterator", "instanceof", "Countable", ")", "{", "return", "$", "this", "->", "iterator", "->", "count", "(", ")", ";", "}", "return", "iterator_count", "(", "$", "this", "->", "iterator", ")", ";", "}" ]
Counts the elements of this Linq sequence. @return int
[ "Counts", "the", "elements", "of", "this", "Linq", "sequence", "." ]
065bfd32674875c9b5df25d29bfe4aa3b073c88f
https://github.com/fusonic/linq/blob/065bfd32674875c9b5df25d29bfe4aa3b073c88f/src/Fusonic/Linq/Linq.php#L246-L253
train
fusonic/linq
src/Fusonic/Linq/Linq.php
Linq.sum
public function sum(callable $func = null) { $sum = 0; $iterator = $this->getSelectIteratorOrInnerIterator($func); foreach ($iterator as $value) { if (!is_numeric($value)) { throw new UnexpectedValueException("sum() only works on numeric values."); } $sum += $value; } return $sum; }
php
public function sum(callable $func = null) { $sum = 0; $iterator = $this->getSelectIteratorOrInnerIterator($func); foreach ($iterator as $value) { if (!is_numeric($value)) { throw new UnexpectedValueException("sum() only works on numeric values."); } $sum += $value; } return $sum; }
[ "public", "function", "sum", "(", "callable", "$", "func", "=", "null", ")", "{", "$", "sum", "=", "0", ";", "$", "iterator", "=", "$", "this", "->", "getSelectIteratorOrInnerIterator", "(", "$", "func", ")", ";", "foreach", "(", "$", "iterator", "as", "$", "value", ")", "{", "if", "(", "!", "is_numeric", "(", "$", "value", ")", ")", "{", "throw", "new", "UnexpectedValueException", "(", "\"sum() only works on numeric values.\"", ")", ";", "}", "$", "sum", "+=", "$", "value", ";", "}", "return", "$", "sum", ";", "}" ]
Gets the sum of all items or by invoking a transform function on each item to get a numeric value. @param callable $func A func that returns any numeric type (int, float etc.) from the given element, or NULL to use the element itself. @throws \UnexpectedValueException if any element is not a numeric value. @return double The sum of all items.
[ "Gets", "the", "sum", "of", "all", "items", "or", "by", "invoking", "a", "transform", "function", "on", "each", "item", "to", "get", "a", "numeric", "value", "." ]
065bfd32674875c9b5df25d29bfe4aa3b073c88f
https://github.com/fusonic/linq/blob/065bfd32674875c9b5df25d29bfe4aa3b073c88f/src/Fusonic/Linq/Linq.php#L314-L326
train
fusonic/linq
src/Fusonic/Linq/Linq.php
Linq.min
public function min(callable $func = null) { $min = null; $iterator = $this->getSelectIteratorOrInnerIterator($func); foreach ($iterator as $value) { if (!is_numeric($value) && !is_string($value) && !($value instanceof \DateTime)) { throw new UnexpectedValueException("min() only works on numeric values, strings and DateTime objects."); } if (is_null($min)) { $min = $value; } elseif ($min > $value) { $min = $value; } } if ($min === null) { throw new \RuntimeException("Cannot calculate min() as the Linq sequence contains no elements."); } return $min; }
php
public function min(callable $func = null) { $min = null; $iterator = $this->getSelectIteratorOrInnerIterator($func); foreach ($iterator as $value) { if (!is_numeric($value) && !is_string($value) && !($value instanceof \DateTime)) { throw new UnexpectedValueException("min() only works on numeric values, strings and DateTime objects."); } if (is_null($min)) { $min = $value; } elseif ($min > $value) { $min = $value; } } if ($min === null) { throw new \RuntimeException("Cannot calculate min() as the Linq sequence contains no elements."); } return $min; }
[ "public", "function", "min", "(", "callable", "$", "func", "=", "null", ")", "{", "$", "min", "=", "null", ";", "$", "iterator", "=", "$", "this", "->", "getSelectIteratorOrInnerIterator", "(", "$", "func", ")", ";", "foreach", "(", "$", "iterator", "as", "$", "value", ")", "{", "if", "(", "!", "is_numeric", "(", "$", "value", ")", "&&", "!", "is_string", "(", "$", "value", ")", "&&", "!", "(", "$", "value", "instanceof", "\\", "DateTime", ")", ")", "{", "throw", "new", "UnexpectedValueException", "(", "\"min() only works on numeric values, strings and DateTime objects.\"", ")", ";", "}", "if", "(", "is_null", "(", "$", "min", ")", ")", "{", "$", "min", "=", "$", "value", ";", "}", "elseif", "(", "$", "min", ">", "$", "value", ")", "{", "$", "min", "=", "$", "value", ";", "}", "}", "if", "(", "$", "min", "===", "null", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "\"Cannot calculate min() as the Linq sequence contains no elements.\"", ")", ";", "}", "return", "$", "min", ";", "}" ]
Gets the minimum item value of all items or by invoking a transform function on each item to get a numeric value. @param callable $func A func that returns any numeric type (int, float etc.) from the given element, or NULL to use the element itself. @throws \RuntimeException if the sequence contains no elements @throws \UnexpectedValueException @return double Minimum item value
[ "Gets", "the", "minimum", "item", "value", "of", "all", "items", "or", "by", "invoking", "a", "transform", "function", "on", "each", "item", "to", "get", "a", "numeric", "value", "." ]
065bfd32674875c9b5df25d29bfe4aa3b073c88f
https://github.com/fusonic/linq/blob/065bfd32674875c9b5df25d29bfe4aa3b073c88f/src/Fusonic/Linq/Linq.php#L336-L357
train
fusonic/linq
src/Fusonic/Linq/Linq.php
Linq.concat
public function concat($second) { LinqHelper::assertArgumentIsIterable($second, "second"); $allItems = new \ArrayIterator([$this->iterator, $second]); return new Linq(new SelectManyIterator($allItems)); }
php
public function concat($second) { LinqHelper::assertArgumentIsIterable($second, "second"); $allItems = new \ArrayIterator([$this->iterator, $second]); return new Linq(new SelectManyIterator($allItems)); }
[ "public", "function", "concat", "(", "$", "second", ")", "{", "LinqHelper", "::", "assertArgumentIsIterable", "(", "$", "second", ",", "\"second\"", ")", ";", "$", "allItems", "=", "new", "\\", "ArrayIterator", "(", "[", "$", "this", "->", "iterator", ",", "$", "second", "]", ")", ";", "return", "new", "Linq", "(", "new", "SelectManyIterator", "(", "$", "allItems", ")", ")", ";", "}" ]
Concatenates this Linq object with the given sequence. @param array|\Iterator $second A sequence which will be concatenated with this Linq object. @throws InvalidArgumentException if the given sequence is not traversable. @return Linq A new Linq object that contains the concatenated elements of the input sequence and the original Linq sequence.
[ "Concatenates", "this", "Linq", "object", "with", "the", "given", "sequence", "." ]
065bfd32674875c9b5df25d29bfe4aa3b073c88f
https://github.com/fusonic/linq/blob/065bfd32674875c9b5df25d29bfe4aa3b073c88f/src/Fusonic/Linq/Linq.php#L448-L455
train
fusonic/linq
src/Fusonic/Linq/Linq.php
Linq.intersect
public function intersect($second) { LinqHelper::assertArgumentIsIterable($second, "second"); return new Linq(new IntersectIterator($this->iterator, LinqHelper::getIteratorOrThrow($second))); }
php
public function intersect($second) { LinqHelper::assertArgumentIsIterable($second, "second"); return new Linq(new IntersectIterator($this->iterator, LinqHelper::getIteratorOrThrow($second))); }
[ "public", "function", "intersect", "(", "$", "second", ")", "{", "LinqHelper", "::", "assertArgumentIsIterable", "(", "$", "second", ",", "\"second\"", ")", ";", "return", "new", "Linq", "(", "new", "IntersectIterator", "(", "$", "this", "->", "iterator", ",", "LinqHelper", "::", "getIteratorOrThrow", "(", "$", "second", ")", ")", ")", ";", "}" ]
Intersects the Linq sequence with second Iterable sequence. @param \Iterator|array An iterator to intersect with: @return Linq intersected items
[ "Intersects", "the", "Linq", "sequence", "with", "second", "Iterable", "sequence", "." ]
065bfd32674875c9b5df25d29bfe4aa3b073c88f
https://github.com/fusonic/linq/blob/065bfd32674875c9b5df25d29bfe4aa3b073c88f/src/Fusonic/Linq/Linq.php#L474-L478
train
fusonic/linq
src/Fusonic/Linq/Linq.php
Linq.except
public function except($second) { LinqHelper::assertArgumentIsIterable($second, "second"); return new Linq(new ExceptIterator($this->iterator, LinqHelper::getIteratorOrThrow($second))); }
php
public function except($second) { LinqHelper::assertArgumentIsIterable($second, "second"); return new Linq(new ExceptIterator($this->iterator, LinqHelper::getIteratorOrThrow($second))); }
[ "public", "function", "except", "(", "$", "second", ")", "{", "LinqHelper", "::", "assertArgumentIsIterable", "(", "$", "second", ",", "\"second\"", ")", ";", "return", "new", "Linq", "(", "new", "ExceptIterator", "(", "$", "this", "->", "iterator", ",", "LinqHelper", "::", "getIteratorOrThrow", "(", "$", "second", ")", ")", ")", ";", "}" ]
Returns all elements except the ones of the given sequence. @param array|\Iterator $second @return Linq Returns all items of this not occuring in $second
[ "Returns", "all", "elements", "except", "the", "ones", "of", "the", "given", "sequence", "." ]
065bfd32674875c9b5df25d29bfe4aa3b073c88f
https://github.com/fusonic/linq/blob/065bfd32674875c9b5df25d29bfe4aa3b073c88f/src/Fusonic/Linq/Linq.php#L486-L490
train
OXIDprojects/oxid-console
src/Core/Module/ModuleExtensionCleanerDebug.php
ModuleExtensionCleanerDebug.filterExtensionsByModuleId
protected function filterExtensionsByModuleId($modules, $moduleId) { $modulePaths = \OxidEsales\Eshop\Core\Registry::getConfig()->getConfigParam('aModulePaths'); $path = ''; if (isset($modulePaths[$moduleId])) { $path = $modulePaths[$moduleId] . '/'; } // TODO: This condition should be removed. Need to check integration tests. if (!$path) { $path = $moduleId . "/"; } $filteredModules = []; foreach ($modules as $class => $extend) { foreach ($extend as $extendPath) { if (strpos($extendPath, $path) === 0) { $filteredModules[$class][] = $extendPath; } } } return $filteredModules; }
php
protected function filterExtensionsByModuleId($modules, $moduleId) { $modulePaths = \OxidEsales\Eshop\Core\Registry::getConfig()->getConfigParam('aModulePaths'); $path = ''; if (isset($modulePaths[$moduleId])) { $path = $modulePaths[$moduleId] . '/'; } // TODO: This condition should be removed. Need to check integration tests. if (!$path) { $path = $moduleId . "/"; } $filteredModules = []; foreach ($modules as $class => $extend) { foreach ($extend as $extendPath) { if (strpos($extendPath, $path) === 0) { $filteredModules[$class][] = $extendPath; } } } return $filteredModules; }
[ "protected", "function", "filterExtensionsByModuleId", "(", "$", "modules", ",", "$", "moduleId", ")", "{", "$", "modulePaths", "=", "\\", "OxidEsales", "\\", "Eshop", "\\", "Core", "\\", "Registry", "::", "getConfig", "(", ")", "->", "getConfigParam", "(", "'aModulePaths'", ")", ";", "$", "path", "=", "''", ";", "if", "(", "isset", "(", "$", "modulePaths", "[", "$", "moduleId", "]", ")", ")", "{", "$", "path", "=", "$", "modulePaths", "[", "$", "moduleId", "]", ".", "'/'", ";", "}", "// TODO: This condition should be removed. Need to check integration tests.", "if", "(", "!", "$", "path", ")", "{", "$", "path", "=", "$", "moduleId", ".", "\"/\"", ";", "}", "$", "filteredModules", "=", "[", "]", ";", "foreach", "(", "$", "modules", "as", "$", "class", "=>", "$", "extend", ")", "{", "foreach", "(", "$", "extend", "as", "$", "extendPath", ")", "{", "if", "(", "strpos", "(", "$", "extendPath", ",", "$", "path", ")", "===", "0", ")", "{", "$", "filteredModules", "[", "$", "class", "]", "[", "]", "=", "$", "extendPath", ";", "}", "}", "}", "return", "$", "filteredModules", ";", "}" ]
Returns extensions list by module id. @param array $modules Module array (nested format) @param string $moduleId Module id/folder name @return array
[ "Returns", "extensions", "list", "by", "module", "id", "." ]
476fa3b1ddd01fb3d4566258fbad941d75ba8a5a
https://github.com/OXIDprojects/oxid-console/blob/476fa3b1ddd01fb3d4566258fbad941d75ba8a5a/src/Core/Module/ModuleExtensionCleanerDebug.php#L114-L138
train
GenesisGateway/genesis_php
src/Genesis/API/Validators/Request/RegexValidator.php
RegexValidator.validate
protected function validate() { if (!CommonUtils::isRegexExpr($this->pattern)) { return false; } return (bool) preg_match( $this->pattern, $this->getRequestValue() ); }
php
protected function validate() { if (!CommonUtils::isRegexExpr($this->pattern)) { return false; } return (bool) preg_match( $this->pattern, $this->getRequestValue() ); }
[ "protected", "function", "validate", "(", ")", "{", "if", "(", "!", "CommonUtils", "::", "isRegexExpr", "(", "$", "this", "->", "pattern", ")", ")", "{", "return", "false", ";", "}", "return", "(", "bool", ")", "preg_match", "(", "$", "this", "->", "pattern", ",", "$", "this", "->", "getRequestValue", "(", ")", ")", ";", "}" ]
Execute field name validation @return bool
[ "Execute", "field", "name", "validation" ]
b2a40413fd50357f41015eb05db9af305a3f4a6f
https://github.com/GenesisGateway/genesis_php/blob/b2a40413fd50357f41015eb05db9af305a3f4a6f/src/Genesis/API/Validators/Request/RegexValidator.php#L78-L88
train
kodeine/laravel-meta
src/Kodeine/Metable/Metable.php
Metable.metas
public function metas() { $model = new \Kodeine\Metable\MetaData(); $model->setTable($this->getMetaTable()); return new HasMany($model->newQuery(), $this, $this->getMetaKeyName(), $this->getKeyName()); }
php
public function metas() { $model = new \Kodeine\Metable\MetaData(); $model->setTable($this->getMetaTable()); return new HasMany($model->newQuery(), $this, $this->getMetaKeyName(), $this->getKeyName()); }
[ "public", "function", "metas", "(", ")", "{", "$", "model", "=", "new", "\\", "Kodeine", "\\", "Metable", "\\", "MetaData", "(", ")", ";", "$", "model", "->", "setTable", "(", "$", "this", "->", "getMetaTable", "(", ")", ")", ";", "return", "new", "HasMany", "(", "$", "model", "->", "newQuery", "(", ")", ",", "$", "this", ",", "$", "this", "->", "getMetaKeyName", "(", ")", ",", "$", "this", "->", "getKeyName", "(", ")", ")", ";", "}" ]
Relationship for meta tables
[ "Relationship", "for", "meta", "tables" ]
0b0a8f4dcfd110a483307b224f02f769f3a7dbb0
https://github.com/kodeine/laravel-meta/blob/0b0a8f4dcfd110a483307b224f02f769f3a7dbb0/src/Kodeine/Metable/Metable.php#L151-L157
train
kodeine/laravel-meta
src/Kodeine/Metable/MetaData.php
MetaData.setValueAttribute
public function setValueAttribute($value) { $type = gettype($value); if (is_array($value)) { $this->type = 'array'; $this->attributes['value'] = json_encode($value); } elseif ($value instanceof DateTime) { $this->type = 'datetime'; $this->attributes['value'] = $this->fromDateTime($value); } elseif ($value instanceof Model) { $this->type = 'model'; $this->attributes['value'] = get_class($value).(!$value->exists ? '' : '#'.$value->getKey()); } elseif (is_object($value)) { $this->type = 'object'; $this->attributes['value'] = json_encode($value); } else { $this->type = in_array($type, $this->dataTypes) ? $type : 'string'; $this->attributes['value'] = $value; } }
php
public function setValueAttribute($value) { $type = gettype($value); if (is_array($value)) { $this->type = 'array'; $this->attributes['value'] = json_encode($value); } elseif ($value instanceof DateTime) { $this->type = 'datetime'; $this->attributes['value'] = $this->fromDateTime($value); } elseif ($value instanceof Model) { $this->type = 'model'; $this->attributes['value'] = get_class($value).(!$value->exists ? '' : '#'.$value->getKey()); } elseif (is_object($value)) { $this->type = 'object'; $this->attributes['value'] = json_encode($value); } else { $this->type = in_array($type, $this->dataTypes) ? $type : 'string'; $this->attributes['value'] = $value; } }
[ "public", "function", "setValueAttribute", "(", "$", "value", ")", "{", "$", "type", "=", "gettype", "(", "$", "value", ")", ";", "if", "(", "is_array", "(", "$", "value", ")", ")", "{", "$", "this", "->", "type", "=", "'array'", ";", "$", "this", "->", "attributes", "[", "'value'", "]", "=", "json_encode", "(", "$", "value", ")", ";", "}", "elseif", "(", "$", "value", "instanceof", "DateTime", ")", "{", "$", "this", "->", "type", "=", "'datetime'", ";", "$", "this", "->", "attributes", "[", "'value'", "]", "=", "$", "this", "->", "fromDateTime", "(", "$", "value", ")", ";", "}", "elseif", "(", "$", "value", "instanceof", "Model", ")", "{", "$", "this", "->", "type", "=", "'model'", ";", "$", "this", "->", "attributes", "[", "'value'", "]", "=", "get_class", "(", "$", "value", ")", ".", "(", "!", "$", "value", "->", "exists", "?", "''", ":", "'#'", ".", "$", "value", "->", "getKey", "(", ")", ")", ";", "}", "elseif", "(", "is_object", "(", "$", "value", ")", ")", "{", "$", "this", "->", "type", "=", "'object'", ";", "$", "this", "->", "attributes", "[", "'value'", "]", "=", "json_encode", "(", "$", "value", ")", ";", "}", "else", "{", "$", "this", "->", "type", "=", "in_array", "(", "$", "type", ",", "$", "this", "->", "dataTypes", ")", "?", "$", "type", ":", "'string'", ";", "$", "this", "->", "attributes", "[", "'value'", "]", "=", "$", "value", ";", "}", "}" ]
Set the value and type. @param $value
[ "Set", "the", "value", "and", "type", "." ]
0b0a8f4dcfd110a483307b224f02f769f3a7dbb0
https://github.com/kodeine/laravel-meta/blob/0b0a8f4dcfd110a483307b224f02f769f3a7dbb0/src/Kodeine/Metable/MetaData.php#L52-L72
train
boomcms/boom-core
src/BoomCMS/FileInfo/Drivers/Video.php
Video.getThumbnail
public function getThumbnail() { try { $ffmpeg = FFMpeg::create(); $video = $ffmpeg->open($this->file->getPathname()); $frame = $video->frame(TimeCode::fromSeconds(0)); $base64 = $frame->save(tempnam(sys_get_temp_dir(), $this->file->getBasename()), true, true); return Imagick::readImageBlob($base64); } catch (Exception $e) { return; } }
php
public function getThumbnail() { try { $ffmpeg = FFMpeg::create(); $video = $ffmpeg->open($this->file->getPathname()); $frame = $video->frame(TimeCode::fromSeconds(0)); $base64 = $frame->save(tempnam(sys_get_temp_dir(), $this->file->getBasename()), true, true); return Imagick::readImageBlob($base64); } catch (Exception $e) { return; } }
[ "public", "function", "getThumbnail", "(", ")", "{", "try", "{", "$", "ffmpeg", "=", "FFMpeg", "::", "create", "(", ")", ";", "$", "video", "=", "$", "ffmpeg", "->", "open", "(", "$", "this", "->", "file", "->", "getPathname", "(", ")", ")", ";", "$", "frame", "=", "$", "video", "->", "frame", "(", "TimeCode", "::", "fromSeconds", "(", "0", ")", ")", ";", "$", "base64", "=", "$", "frame", "->", "save", "(", "tempnam", "(", "sys_get_temp_dir", "(", ")", ",", "$", "this", "->", "file", "->", "getBasename", "(", ")", ")", ",", "true", ",", "true", ")", ";", "return", "Imagick", "::", "readImageBlob", "(", "$", "base64", ")", ";", "}", "catch", "(", "Exception", "$", "e", ")", "{", "return", ";", "}", "}" ]
Generates a thumbnail for the video from the first frame. @return Imagick
[ "Generates", "a", "thumbnail", "for", "the", "video", "from", "the", "first", "frame", "." ]
cc835772e3c33dac3e56c36a8db2c9e6da313c7b
https://github.com/boomcms/boom-core/blob/cc835772e3c33dac3e56c36a8db2c9e6da313c7b/src/BoomCMS/FileInfo/Drivers/Video.php#L17-L30
train
boomcms/boom-core
src/BoomCMS/Observers/DeletionLogObserver.php
DeletionLogObserver.deleting
public function deleting(Model $model) { $model->deleted_by = $this->guard->check() ? $this->guard->user()->getId() : null; }
php
public function deleting(Model $model) { $model->deleted_by = $this->guard->check() ? $this->guard->user()->getId() : null; }
[ "public", "function", "deleting", "(", "Model", "$", "model", ")", "{", "$", "model", "->", "deleted_by", "=", "$", "this", "->", "guard", "->", "check", "(", ")", "?", "$", "this", "->", "guard", "->", "user", "(", ")", "->", "getId", "(", ")", ":", "null", ";", "}" ]
Set deleted_by on the model prior to deletion. @param Model $model @return void
[ "Set", "deleted_by", "on", "the", "model", "prior", "to", "deletion", "." ]
cc835772e3c33dac3e56c36a8db2c9e6da313c7b
https://github.com/boomcms/boom-core/blob/cc835772e3c33dac3e56c36a8db2c9e6da313c7b/src/BoomCMS/Observers/DeletionLogObserver.php#L30-L33
train
boomcms/boom-core
src/BoomCMS/Chunk/Library.php
Library.getParam
public function getParam($key) { return isset($this->params[$key]) ? $this->params[$key] : null; }
php
public function getParam($key) { return isset($this->params[$key]) ? $this->params[$key] : null; }
[ "public", "function", "getParam", "(", "$", "key", ")", "{", "return", "isset", "(", "$", "this", "->", "params", "[", "$", "key", "]", ")", "?", "$", "this", "->", "params", "[", "$", "key", "]", ":", "null", ";", "}" ]
Returns a search parameter by key. @param string $key @return mixed
[ "Returns", "a", "search", "parameter", "by", "key", "." ]
cc835772e3c33dac3e56c36a8db2c9e6da313c7b
https://github.com/boomcms/boom-core/blob/cc835772e3c33dac3e56c36a8db2c9e6da313c7b/src/BoomCMS/Chunk/Library.php#L63-L66
train
boomcms/boom-core
src/BoomCMS/Chunk/Library.php
Library.hasFilters
public function hasFilters() { $params = array_except($this->params, ['order', 'limit']); return !empty($params) && !empty(array_values($params)); }
php
public function hasFilters() { $params = array_except($this->params, ['order', 'limit']); return !empty($params) && !empty(array_values($params)); }
[ "public", "function", "hasFilters", "(", ")", "{", "$", "params", "=", "array_except", "(", "$", "this", "->", "params", ",", "[", "'order'", ",", "'limit'", "]", ")", ";", "return", "!", "empty", "(", "$", "params", ")", "&&", "!", "empty", "(", "array_values", "(", "$", "params", ")", ")", ";", "}" ]
Returns whether the parameters array contains any filters. @return bool
[ "Returns", "whether", "the", "parameters", "array", "contains", "any", "filters", "." ]
cc835772e3c33dac3e56c36a8db2c9e6da313c7b
https://github.com/boomcms/boom-core/blob/cc835772e3c33dac3e56c36a8db2c9e6da313c7b/src/BoomCMS/Chunk/Library.php#L96-L101
train
markstory/mini-asset
src/File/Callback.php
Callback.files
public function files() { $files = []; foreach (call_user_func($this->callable) as $file) { $path = $this->scanner->find($file); if ($path === false) { throw new RuntimeException("Could not locate {$file} for {$this->callable} in any configured path."); } $files[] = new Local($path); } return $files; }
php
public function files() { $files = []; foreach (call_user_func($this->callable) as $file) { $path = $this->scanner->find($file); if ($path === false) { throw new RuntimeException("Could not locate {$file} for {$this->callable} in any configured path."); } $files[] = new Local($path); } return $files; }
[ "public", "function", "files", "(", ")", "{", "$", "files", "=", "[", "]", ";", "foreach", "(", "call_user_func", "(", "$", "this", "->", "callable", ")", "as", "$", "file", ")", "{", "$", "path", "=", "$", "this", "->", "scanner", "->", "find", "(", "$", "file", ")", ";", "if", "(", "$", "path", "===", "false", ")", "{", "throw", "new", "RuntimeException", "(", "\"Could not locate {$file} for {$this->callable} in any configured path.\"", ")", ";", "}", "$", "files", "[", "]", "=", "new", "Local", "(", "$", "path", ")", ";", "}", "return", "$", "files", ";", "}" ]
Get the list of files from the callback. @return array
[ "Get", "the", "list", "of", "files", "from", "the", "callback", "." ]
5564bcbe2749a28d7978d36362c390bce39083a3
https://github.com/markstory/mini-asset/blob/5564bcbe2749a28d7978d36362c390bce39083a3/src/File/Callback.php#L49-L60
train
markstory/mini-asset
src/Filter/ScssFilter.php
ScssFilter.input
public function input($filename, $input) { if (substr($filename, strlen($this->_settings['ext']) * -1) !== $this->_settings['ext']) { return $input; } $filename = preg_replace('/ /', '\\ ', $filename); $bin = $this->_settings['sass'] . ' ' . $filename; $return = $this->_runCmd($bin, '', array('PATH' => $this->_settings['path'])); return $return; }
php
public function input($filename, $input) { if (substr($filename, strlen($this->_settings['ext']) * -1) !== $this->_settings['ext']) { return $input; } $filename = preg_replace('/ /', '\\ ', $filename); $bin = $this->_settings['sass'] . ' ' . $filename; $return = $this->_runCmd($bin, '', array('PATH' => $this->_settings['path'])); return $return; }
[ "public", "function", "input", "(", "$", "filename", ",", "$", "input", ")", "{", "if", "(", "substr", "(", "$", "filename", ",", "strlen", "(", "$", "this", "->", "_settings", "[", "'ext'", "]", ")", "*", "-", "1", ")", "!==", "$", "this", "->", "_settings", "[", "'ext'", "]", ")", "{", "return", "$", "input", ";", "}", "$", "filename", "=", "preg_replace", "(", "'/ /'", ",", "'\\\\ '", ",", "$", "filename", ")", ";", "$", "bin", "=", "$", "this", "->", "_settings", "[", "'sass'", "]", ".", "' '", ".", "$", "filename", ";", "$", "return", "=", "$", "this", "->", "_runCmd", "(", "$", "bin", ",", "''", ",", "array", "(", "'PATH'", "=>", "$", "this", "->", "_settings", "[", "'path'", "]", ")", ")", ";", "return", "$", "return", ";", "}" ]
Runs SCSS compiler against any files that match the configured extension. @param string $filename The name of the input file. @param string $input The content of the file. @return string
[ "Runs", "SCSS", "compiler", "against", "any", "files", "that", "match", "the", "configured", "extension", "." ]
5564bcbe2749a28d7978d36362c390bce39083a3
https://github.com/markstory/mini-asset/blob/5564bcbe2749a28d7978d36362c390bce39083a3/src/Filter/ScssFilter.php#L51-L60
train
markstory/mini-asset
src/Filter/CoffeeScript.php
CoffeeScript.input
public function input($filename, $input) { if (substr($filename, strlen($this->_settings['ext']) * -1) !== $this->_settings['ext']) { return $input; } $cmd = $this->_settings['node'] . ' ' . $this->_settings['coffee'] . ' -c -p -s '; $env = array('NODE_PATH' => $this->_settings['node_path']); return $this->_runCmd($cmd, $input, $env); }
php
public function input($filename, $input) { if (substr($filename, strlen($this->_settings['ext']) * -1) !== $this->_settings['ext']) { return $input; } $cmd = $this->_settings['node'] . ' ' . $this->_settings['coffee'] . ' -c -p -s '; $env = array('NODE_PATH' => $this->_settings['node_path']); return $this->_runCmd($cmd, $input, $env); }
[ "public", "function", "input", "(", "$", "filename", ",", "$", "input", ")", "{", "if", "(", "substr", "(", "$", "filename", ",", "strlen", "(", "$", "this", "->", "_settings", "[", "'ext'", "]", ")", "*", "-", "1", ")", "!==", "$", "this", "->", "_settings", "[", "'ext'", "]", ")", "{", "return", "$", "input", ";", "}", "$", "cmd", "=", "$", "this", "->", "_settings", "[", "'node'", "]", ".", "' '", ".", "$", "this", "->", "_settings", "[", "'coffee'", "]", ".", "' -c -p -s '", ";", "$", "env", "=", "array", "(", "'NODE_PATH'", "=>", "$", "this", "->", "_settings", "[", "'node_path'", "]", ")", ";", "return", "$", "this", "->", "_runCmd", "(", "$", "cmd", ",", "$", "input", ",", "$", "env", ")", ";", "}" ]
Runs `coffee` against files that match the configured extension. @param string $filename Filename being processed. @param string $content Content of the file being processed. @return string
[ "Runs", "coffee", "against", "files", "that", "match", "the", "configured", "extension", "." ]
5564bcbe2749a28d7978d36362c390bce39083a3
https://github.com/markstory/mini-asset/blob/5564bcbe2749a28d7978d36362c390bce39083a3/src/Filter/CoffeeScript.php#L42-L50
train
boomcms/boom-core
src/BoomCMS/Link/Link.php
Link.getParameter
public function getParameter($key) { $query = $this->getQuery(); return isset($query[$key]) ? $query[$key] : null; }
php
public function getParameter($key) { $query = $this->getQuery(); return isset($query[$key]) ? $query[$key] : null; }
[ "public", "function", "getParameter", "(", "$", "key", ")", "{", "$", "query", "=", "$", "this", "->", "getQuery", "(", ")", ";", "return", "isset", "(", "$", "query", "[", "$", "key", "]", ")", "?", "$", "query", "[", "$", "key", "]", ":", "null", ";", "}" ]
Returns a query string parameter for a given key. @param string $key @return mixed
[ "Returns", "a", "query", "string", "parameter", "for", "a", "given", "key", "." ]
cc835772e3c33dac3e56c36a8db2c9e6da313c7b
https://github.com/boomcms/boom-core/blob/cc835772e3c33dac3e56c36a8db2c9e6da313c7b/src/BoomCMS/Link/Link.php#L116-L121
train
boomcms/boom-core
src/BoomCMS/Link/Link.php
Link.getQuery
public function getQuery() { if ($this->query === null) { $string = parse_url($this->link, PHP_URL_QUERY); parse_str($string, $this->query); } return $this->query; }
php
public function getQuery() { if ($this->query === null) { $string = parse_url($this->link, PHP_URL_QUERY); parse_str($string, $this->query); } return $this->query; }
[ "public", "function", "getQuery", "(", ")", "{", "if", "(", "$", "this", "->", "query", "===", "null", ")", "{", "$", "string", "=", "parse_url", "(", "$", "this", "->", "link", ",", "PHP_URL_QUERY", ")", ";", "parse_str", "(", "$", "string", ",", "$", "this", "->", "query", ")", ";", "}", "return", "$", "this", "->", "query", ";", "}" ]
Returns an array of query string parameters in the URL. @return array
[ "Returns", "an", "array", "of", "query", "string", "parameters", "in", "the", "URL", "." ]
cc835772e3c33dac3e56c36a8db2c9e6da313c7b
https://github.com/boomcms/boom-core/blob/cc835772e3c33dac3e56c36a8db2c9e6da313c7b/src/BoomCMS/Link/Link.php#L128-L137
train
boomcms/boom-core
src/BoomCMS/Support/Helpers.php
Helpers.assetURL
public static function assetURL(array $params) { if (isset($params['asset']) && is_object($params['asset'])) { $asset = $params['asset']; $params['asset'] = $params['asset']->getId(); } if (!isset($params['action'])) { $params['action'] = 'view'; } if (isset($params['height']) && !isset($params['width'])) { $params['width'] = 0; } $url = route('asset', $params); if (isset($asset)) { $url .= '?'.$asset->getLastModified()->getTimestamp(); } return $url; }
php
public static function assetURL(array $params) { if (isset($params['asset']) && is_object($params['asset'])) { $asset = $params['asset']; $params['asset'] = $params['asset']->getId(); } if (!isset($params['action'])) { $params['action'] = 'view'; } if (isset($params['height']) && !isset($params['width'])) { $params['width'] = 0; } $url = route('asset', $params); if (isset($asset)) { $url .= '?'.$asset->getLastModified()->getTimestamp(); } return $url; }
[ "public", "static", "function", "assetURL", "(", "array", "$", "params", ")", "{", "if", "(", "isset", "(", "$", "params", "[", "'asset'", "]", ")", "&&", "is_object", "(", "$", "params", "[", "'asset'", "]", ")", ")", "{", "$", "asset", "=", "$", "params", "[", "'asset'", "]", ";", "$", "params", "[", "'asset'", "]", "=", "$", "params", "[", "'asset'", "]", "->", "getId", "(", ")", ";", "}", "if", "(", "!", "isset", "(", "$", "params", "[", "'action'", "]", ")", ")", "{", "$", "params", "[", "'action'", "]", "=", "'view'", ";", "}", "if", "(", "isset", "(", "$", "params", "[", "'height'", "]", ")", "&&", "!", "isset", "(", "$", "params", "[", "'width'", "]", ")", ")", "{", "$", "params", "[", "'width'", "]", "=", "0", ";", "}", "$", "url", "=", "route", "(", "'asset'", ",", "$", "params", ")", ";", "if", "(", "isset", "(", "$", "asset", ")", ")", "{", "$", "url", ".=", "'?'", ".", "$", "asset", "->", "getLastModified", "(", ")", "->", "getTimestamp", "(", ")", ";", "}", "return", "$", "url", ";", "}" ]
Generate a URL to link to an asset. @param array $params @return string
[ "Generate", "a", "URL", "to", "link", "to", "an", "asset", "." ]
cc835772e3c33dac3e56c36a8db2c9e6da313c7b
https://github.com/boomcms/boom-core/blob/cc835772e3c33dac3e56c36a8db2c9e6da313c7b/src/BoomCMS/Support/Helpers.php#L54-L76
train
boomcms/boom-core
src/BoomCMS/Support/Helpers.php
Helpers.chunk
public static function chunk($type, $slotname, $page = null) { return ChunkFacade::insert($type, $slotname, $page); }
php
public static function chunk($type, $slotname, $page = null) { return ChunkFacade::insert($type, $slotname, $page); }
[ "public", "static", "function", "chunk", "(", "$", "type", ",", "$", "slotname", ",", "$", "page", "=", "null", ")", "{", "return", "ChunkFacade", "::", "insert", "(", "$", "type", ",", "$", "slotname", ",", "$", "page", ")", ";", "}" ]
Interest a chunk into a page. @param string $type @param string $slotname @param PageInterface|null $page @return Chunk
[ "Interest", "a", "chunk", "into", "a", "page", "." ]
cc835772e3c33dac3e56c36a8db2c9e6da313c7b
https://github.com/boomcms/boom-core/blob/cc835772e3c33dac3e56c36a8db2c9e6da313c7b/src/BoomCMS/Support/Helpers.php#L87-L90
train
boomcms/boom-core
src/BoomCMS/Support/Helpers.php
Helpers.description
public static function description(PageInterface $page = null) { $page = $page ?: Router::getActivePage(); $description = $page->getDescription() ?: ChunkFacade::get('text', 'standfirst', $page)->text(); return strip_tags($description); }
php
public static function description(PageInterface $page = null) { $page = $page ?: Router::getActivePage(); $description = $page->getDescription() ?: ChunkFacade::get('text', 'standfirst', $page)->text(); return strip_tags($description); }
[ "public", "static", "function", "description", "(", "PageInterface", "$", "page", "=", "null", ")", "{", "$", "page", "=", "$", "page", "?", ":", "Router", "::", "getActivePage", "(", ")", ";", "$", "description", "=", "$", "page", "->", "getDescription", "(", ")", "?", ":", "ChunkFacade", "::", "get", "(", "'text'", ",", "'standfirst'", ",", "$", "page", ")", "->", "text", "(", ")", ";", "return", "strip_tags", "(", "$", "description", ")", ";", "}" ]
Reutrn the meta description for a page. If no page is given then the active page is used. The page description property will be used, if that isn't set then the page standfirst is used. @param null|Page $page @return string
[ "Reutrn", "the", "meta", "description", "for", "a", "page", "." ]
cc835772e3c33dac3e56c36a8db2c9e6da313c7b
https://github.com/boomcms/boom-core/blob/cc835772e3c33dac3e56c36a8db2c9e6da313c7b/src/BoomCMS/Support/Helpers.php#L127-L134
train
boomcms/boom-core
src/BoomCMS/Support/Helpers.php
Helpers.getTags
public static function getTags() { $finder = new Tag\Finder\Finder(); foreach (func_get_args() as $arg) { if (is_string($arg)) { $finder->addFilter(new Tag\Finder\Group($arg)); } elseif ($arg instanceof PageInterface) { $finder->addFilter(new Tag\Finder\AppliedToPage($arg)); } elseif ($arg instanceof TagInterface) { $finder->addFilter(new Tag\Finder\AppliedWith($arg)); } } return $finder ->setOrderBy('group', 'asc') ->setOrderBy('name', 'asc') ->findAll(); }
php
public static function getTags() { $finder = new Tag\Finder\Finder(); foreach (func_get_args() as $arg) { if (is_string($arg)) { $finder->addFilter(new Tag\Finder\Group($arg)); } elseif ($arg instanceof PageInterface) { $finder->addFilter(new Tag\Finder\AppliedToPage($arg)); } elseif ($arg instanceof TagInterface) { $finder->addFilter(new Tag\Finder\AppliedWith($arg)); } } return $finder ->setOrderBy('group', 'asc') ->setOrderBy('name', 'asc') ->findAll(); }
[ "public", "static", "function", "getTags", "(", ")", "{", "$", "finder", "=", "new", "Tag", "\\", "Finder", "\\", "Finder", "(", ")", ";", "foreach", "(", "func_get_args", "(", ")", "as", "$", "arg", ")", "{", "if", "(", "is_string", "(", "$", "arg", ")", ")", "{", "$", "finder", "->", "addFilter", "(", "new", "Tag", "\\", "Finder", "\\", "Group", "(", "$", "arg", ")", ")", ";", "}", "elseif", "(", "$", "arg", "instanceof", "PageInterface", ")", "{", "$", "finder", "->", "addFilter", "(", "new", "Tag", "\\", "Finder", "\\", "AppliedToPage", "(", "$", "arg", ")", ")", ";", "}", "elseif", "(", "$", "arg", "instanceof", "TagInterface", ")", "{", "$", "finder", "->", "addFilter", "(", "new", "Tag", "\\", "Finder", "\\", "AppliedWith", "(", "$", "arg", ")", ")", ";", "}", "}", "return", "$", "finder", "->", "setOrderBy", "(", "'group'", ",", "'asc'", ")", "->", "setOrderBy", "(", "'name'", ",", "'asc'", ")", "->", "findAll", "(", ")", ";", "}" ]
Get tags matching given parameters. Accepts a page, group name, or tag as arguments in any order to search by. @return array
[ "Get", "tags", "matching", "given", "parameters", ".", "Accepts", "a", "page", "group", "name", "or", "tag", "as", "arguments", "in", "any", "order", "to", "search", "by", "." ]
cc835772e3c33dac3e56c36a8db2c9e6da313c7b
https://github.com/boomcms/boom-core/blob/cc835772e3c33dac3e56c36a8db2c9e6da313c7b/src/BoomCMS/Support/Helpers.php#L193-L211
train
boomcms/boom-core
src/BoomCMS/Support/Helpers.php
Helpers.getTagsInSection
public static function getTagsInSection(PageInterface $page = null, $group = null) { $page = $page ?: Router::getActivePage(); $finder = new Tag\Finder\Finder(); $finder->addFilter(new Tag\Finder\AppliedToPageDescendants($page)); $finder->addFilter(new Tag\Finder\Group($group)); return $finder->setOrderBy('name', 'asc')->findAll(); }
php
public static function getTagsInSection(PageInterface $page = null, $group = null) { $page = $page ?: Router::getActivePage(); $finder = new Tag\Finder\Finder(); $finder->addFilter(new Tag\Finder\AppliedToPageDescendants($page)); $finder->addFilter(new Tag\Finder\Group($group)); return $finder->setOrderBy('name', 'asc')->findAll(); }
[ "public", "static", "function", "getTagsInSection", "(", "PageInterface", "$", "page", "=", "null", ",", "$", "group", "=", "null", ")", "{", "$", "page", "=", "$", "page", "?", ":", "Router", "::", "getActivePage", "(", ")", ";", "$", "finder", "=", "new", "Tag", "\\", "Finder", "\\", "Finder", "(", ")", ";", "$", "finder", "->", "addFilter", "(", "new", "Tag", "\\", "Finder", "\\", "AppliedToPageDescendants", "(", "$", "page", ")", ")", ";", "$", "finder", "->", "addFilter", "(", "new", "Tag", "\\", "Finder", "\\", "Group", "(", "$", "group", ")", ")", ";", "return", "$", "finder", "->", "setOrderBy", "(", "'name'", ",", "'asc'", ")", "->", "findAll", "(", ")", ";", "}" ]
Get the pages applied to the children of a page. @param Page\Page $page @param string $group @return array
[ "Get", "the", "pages", "applied", "to", "the", "children", "of", "a", "page", "." ]
cc835772e3c33dac3e56c36a8db2c9e6da313c7b
https://github.com/boomcms/boom-core/blob/cc835772e3c33dac3e56c36a8db2c9e6da313c7b/src/BoomCMS/Support/Helpers.php#L221-L230
train
boomcms/boom-core
src/BoomCMS/Support/Helpers.php
Helpers.pub
public static function pub($file, $theme = null) { $theme = $theme ?: static::activeThemeName(); return "/vendor/boomcms/themes/$theme/".ltrim(trim($file), '/'); }
php
public static function pub($file, $theme = null) { $theme = $theme ?: static::activeThemeName(); return "/vendor/boomcms/themes/$theme/".ltrim(trim($file), '/'); }
[ "public", "static", "function", "pub", "(", "$", "file", ",", "$", "theme", "=", "null", ")", "{", "$", "theme", "=", "$", "theme", "?", ":", "static", "::", "activeThemeName", "(", ")", ";", "return", "\"/vendor/boomcms/themes/$theme/\"", ".", "ltrim", "(", "trim", "(", "$", "file", ")", ",", "'/'", ")", ";", "}" ]
Get a relative path to a file in a theme's public directory. @param string $file @param string $theme @return string
[ "Get", "a", "relative", "path", "to", "a", "file", "in", "a", "theme", "s", "public", "directory", "." ]
cc835772e3c33dac3e56c36a8db2c9e6da313c7b
https://github.com/boomcms/boom-core/blob/cc835772e3c33dac3e56c36a8db2c9e6da313c7b/src/BoomCMS/Support/Helpers.php#L240-L245
train
keboola/php-component
src/Config/BaseConfig.php
BaseConfig.getValue
public function getValue(array $keys, $default = null) { $config = $this->config; $pointer = &$config; foreach ($keys as $key) { if (!array_key_exists($key, $pointer)) { if ($default === null) { throw new InvalidArgumentException(sprintf( 'Key "%s" does not exist', implode('.', $keys) )); } return $default; } $pointer = &$pointer[$key]; } return $pointer; }
php
public function getValue(array $keys, $default = null) { $config = $this->config; $pointer = &$config; foreach ($keys as $key) { if (!array_key_exists($key, $pointer)) { if ($default === null) { throw new InvalidArgumentException(sprintf( 'Key "%s" does not exist', implode('.', $keys) )); } return $default; } $pointer = &$pointer[$key]; } return $pointer; }
[ "public", "function", "getValue", "(", "array", "$", "keys", ",", "$", "default", "=", "null", ")", "{", "$", "config", "=", "$", "this", "->", "config", ";", "$", "pointer", "=", "&", "$", "config", ";", "foreach", "(", "$", "keys", "as", "$", "key", ")", "{", "if", "(", "!", "array_key_exists", "(", "$", "key", ",", "$", "pointer", ")", ")", "{", "if", "(", "$", "default", "===", "null", ")", "{", "throw", "new", "InvalidArgumentException", "(", "sprintf", "(", "'Key \"%s\" does not exist'", ",", "implode", "(", "'.'", ",", "$", "keys", ")", ")", ")", ";", "}", "return", "$", "default", ";", "}", "$", "pointer", "=", "&", "$", "pointer", "[", "$", "key", "]", ";", "}", "return", "$", "pointer", ";", "}" ]
Returns value by key. You can supply default value for when the key is missing. Without default value exception is thrown for nonexistent keys. @param string[] $keys @param mixed $default @return mixed
[ "Returns", "value", "by", "key", ".", "You", "can", "supply", "default", "value", "for", "when", "the", "key", "is", "missing", ".", "Without", "default", "value", "exception", "is", "thrown", "for", "nonexistent", "keys", "." ]
5a068b1dcbf461d8209f7f2358e01f7afca344a5
https://github.com/keboola/php-component/blob/5a068b1dcbf461d8209f7f2358e01f7afca344a5/src/Config/BaseConfig.php#L73-L90
train
boomcms/boom-core
src/BoomCMS/Chunk/Slideshow/Slide.php
Slide.hasLink
public function hasLink() { return isset($this->attrs['url']) && trim($this->attrs['url']) && $this->attrs['url'] !== '#' && $this->attrs['url'] !== 'http://'; }
php
public function hasLink() { return isset($this->attrs['url']) && trim($this->attrs['url']) && $this->attrs['url'] !== '#' && $this->attrs['url'] !== 'http://'; }
[ "public", "function", "hasLink", "(", ")", "{", "return", "isset", "(", "$", "this", "->", "attrs", "[", "'url'", "]", ")", "&&", "trim", "(", "$", "this", "->", "attrs", "[", "'url'", "]", ")", "&&", "$", "this", "->", "attrs", "[", "'url'", "]", "!==", "'#'", "&&", "$", "this", "->", "attrs", "[", "'url'", "]", "!==", "'http://'", ";", "}" ]
Whether the current slide has a link associated with it. @return bool
[ "Whether", "the", "current", "slide", "has", "a", "link", "associated", "with", "it", "." ]
cc835772e3c33dac3e56c36a8db2c9e6da313c7b
https://github.com/boomcms/boom-core/blob/cc835772e3c33dac3e56c36a8db2c9e6da313c7b/src/BoomCMS/Chunk/Slideshow/Slide.php#L77-L83
train
markstory/mini-asset
src/Output/FreshTrait.php
FreshTrait.isFresh
public function isFresh(AssetTarget $target) { $buildName = $this->buildFileName($target); $buildFile = $this->outputDir($target) . DIRECTORY_SEPARATOR . $buildName; if (!file_exists($buildFile)) { return false; } $buildTime = filemtime($buildFile); if ($this->configTime && $this->configTime >= $buildTime) { return false; } foreach ($target->files() as $file) { $time = $file->modifiedTime(); if ($time === false || $time >= $buildTime) { return false; } } $filters = $this->filterRegistry->collection($target); foreach ($filters->filters() as $filter) { foreach ($filter->getDependencies($target) as $child) { $time = $child->modifiedTime(); if ($time >= $buildTime) { return false; } } } return true; }
php
public function isFresh(AssetTarget $target) { $buildName = $this->buildFileName($target); $buildFile = $this->outputDir($target) . DIRECTORY_SEPARATOR . $buildName; if (!file_exists($buildFile)) { return false; } $buildTime = filemtime($buildFile); if ($this->configTime && $this->configTime >= $buildTime) { return false; } foreach ($target->files() as $file) { $time = $file->modifiedTime(); if ($time === false || $time >= $buildTime) { return false; } } $filters = $this->filterRegistry->collection($target); foreach ($filters->filters() as $filter) { foreach ($filter->getDependencies($target) as $child) { $time = $child->modifiedTime(); if ($time >= $buildTime) { return false; } } } return true; }
[ "public", "function", "isFresh", "(", "AssetTarget", "$", "target", ")", "{", "$", "buildName", "=", "$", "this", "->", "buildFileName", "(", "$", "target", ")", ";", "$", "buildFile", "=", "$", "this", "->", "outputDir", "(", "$", "target", ")", ".", "DIRECTORY_SEPARATOR", ".", "$", "buildName", ";", "if", "(", "!", "file_exists", "(", "$", "buildFile", ")", ")", "{", "return", "false", ";", "}", "$", "buildTime", "=", "filemtime", "(", "$", "buildFile", ")", ";", "if", "(", "$", "this", "->", "configTime", "&&", "$", "this", "->", "configTime", ">=", "$", "buildTime", ")", "{", "return", "false", ";", "}", "foreach", "(", "$", "target", "->", "files", "(", ")", "as", "$", "file", ")", "{", "$", "time", "=", "$", "file", "->", "modifiedTime", "(", ")", ";", "if", "(", "$", "time", "===", "false", "||", "$", "time", ">=", "$", "buildTime", ")", "{", "return", "false", ";", "}", "}", "$", "filters", "=", "$", "this", "->", "filterRegistry", "->", "collection", "(", "$", "target", ")", ";", "foreach", "(", "$", "filters", "->", "filters", "(", ")", "as", "$", "filter", ")", "{", "foreach", "(", "$", "filter", "->", "getDependencies", "(", "$", "target", ")", "as", "$", "child", ")", "{", "$", "time", "=", "$", "child", "->", "modifiedTime", "(", ")", ";", "if", "(", "$", "time", ">=", "$", "buildTime", ")", "{", "return", "false", ";", "}", "}", "}", "return", "true", ";", "}" ]
Check to see if a cached build file is 'fresh'. Fresh cached files have timestamps newer than all of the component files. @param AssetTarget $target The target file being built. @return boolean
[ "Check", "to", "see", "if", "a", "cached", "build", "file", "is", "fresh", ".", "Fresh", "cached", "files", "have", "timestamps", "newer", "than", "all", "of", "the", "component", "files", "." ]
5564bcbe2749a28d7978d36362c390bce39083a3
https://github.com/markstory/mini-asset/blob/5564bcbe2749a28d7978d36362c390bce39083a3/src/Output/FreshTrait.php#L70-L101
train
markstory/mini-asset
src/Output/AssetCacher.php
AssetCacher.buildFileName
public function buildFileName(AssetTarget $target) { $file = $target->name(); if ($target->isThemed() && $this->theme) { $file = $this->theme . '-' . $file; } return $file; }
php
public function buildFileName(AssetTarget $target) { $file = $target->name(); if ($target->isThemed() && $this->theme) { $file = $this->theme . '-' . $file; } return $file; }
[ "public", "function", "buildFileName", "(", "AssetTarget", "$", "target", ")", "{", "$", "file", "=", "$", "target", "->", "name", "(", ")", ";", "if", "(", "$", "target", "->", "isThemed", "(", ")", "&&", "$", "this", "->", "theme", ")", "{", "$", "file", "=", "$", "this", "->", "theme", ".", "'-'", ".", "$", "file", ";", "}", "return", "$", "file", ";", "}" ]
Get the final build file name for a target. @param AssetTarget $target The target to get a name for. @return string
[ "Get", "the", "final", "build", "file", "name", "for", "a", "target", "." ]
5564bcbe2749a28d7978d36362c390bce39083a3
https://github.com/markstory/mini-asset/blob/5564bcbe2749a28d7978d36362c390bce39083a3/src/Output/AssetCacher.php#L56-L63
train
markstory/mini-asset
src/Output/AssetCacher.php
AssetCacher.read
public function read(AssetTarget $target) { $buildName = $this->buildFileName($target); return file_get_contents($this->path . $buildName); }
php
public function read(AssetTarget $target) { $buildName = $this->buildFileName($target); return file_get_contents($this->path . $buildName); }
[ "public", "function", "read", "(", "AssetTarget", "$", "target", ")", "{", "$", "buildName", "=", "$", "this", "->", "buildFileName", "(", "$", "target", ")", ";", "return", "file_get_contents", "(", "$", "this", "->", "path", ".", "$", "buildName", ")", ";", "}" ]
Get the cached result for a build target. @param AssetTarget $target The target to get content for. @return string
[ "Get", "the", "cached", "result", "for", "a", "build", "target", "." ]
5564bcbe2749a28d7978d36362c390bce39083a3
https://github.com/markstory/mini-asset/blob/5564bcbe2749a28d7978d36362c390bce39083a3/src/Output/AssetCacher.php#L90-L94
train
markstory/mini-asset
src/Filter/AssetFilter.php
AssetFilter.settings
public function settings(array $settings = null) { if ($settings) { $this->_settings = array_merge($this->_settings, $settings); } return $this->_settings; }
php
public function settings(array $settings = null) { if ($settings) { $this->_settings = array_merge($this->_settings, $settings); } return $this->_settings; }
[ "public", "function", "settings", "(", "array", "$", "settings", "=", "null", ")", "{", "if", "(", "$", "settings", ")", "{", "$", "this", "->", "_settings", "=", "array_merge", "(", "$", "this", "->", "_settings", ",", "$", "settings", ")", ";", "}", "return", "$", "this", "->", "_settings", ";", "}" ]
Gets settings for this filter. Will always include 'paths' key which points at paths available for the type of asset being generated. @param array $settings Array of settings. @return array Array of updated settings.
[ "Gets", "settings", "for", "this", "filter", ".", "Will", "always", "include", "paths", "key", "which", "points", "at", "paths", "available", "for", "the", "type", "of", "asset", "being", "generated", "." ]
5564bcbe2749a28d7978d36362c390bce39083a3
https://github.com/markstory/mini-asset/blob/5564bcbe2749a28d7978d36362c390bce39083a3/src/Filter/AssetFilter.php#L41-L47
train
markstory/mini-asset
src/Filter/AssetFilter.php
AssetFilter._runCmd
protected function _runCmd($cmd, $content, $environment = null) { $Process = new AssetProcess(); $Process->environment($environment); $Process->command($cmd)->run($content); if ($Process->error()) { throw new RuntimeException($Process->error()); } return $Process->output(); }
php
protected function _runCmd($cmd, $content, $environment = null) { $Process = new AssetProcess(); $Process->environment($environment); $Process->command($cmd)->run($content); if ($Process->error()) { throw new RuntimeException($Process->error()); } return $Process->output(); }
[ "protected", "function", "_runCmd", "(", "$", "cmd", ",", "$", "content", ",", "$", "environment", "=", "null", ")", "{", "$", "Process", "=", "new", "AssetProcess", "(", ")", ";", "$", "Process", "->", "environment", "(", "$", "environment", ")", ";", "$", "Process", "->", "command", "(", "$", "cmd", ")", "->", "run", "(", "$", "content", ")", ";", "if", "(", "$", "Process", "->", "error", "(", ")", ")", "{", "throw", "new", "RuntimeException", "(", "$", "Process", "->", "error", "(", ")", ")", ";", "}", "return", "$", "Process", "->", "output", "(", ")", ";", "}" ]
Run the compressor command and get the output @param string $cmd The command to run. @param string $content The content to run through the command. @return The result of the command. @throws RuntimeException
[ "Run", "the", "compressor", "command", "and", "get", "the", "output" ]
5564bcbe2749a28d7978d36362c390bce39083a3
https://github.com/markstory/mini-asset/blob/5564bcbe2749a28d7978d36362c390bce39083a3/src/Filter/AssetFilter.php#L93-L103
train
markstory/mini-asset
src/Filter/ClosureCompiler.php
ClosureCompiler._query
protected function _query($content, $args = array()) { if (!extension_loaded('curl')) { throw new \Exception('Missing the `curl` extension.'); } $args = array_merge($this->_defaults, $args); if (!empty($this->_settings['level'])) { $args['compilation_level'] = $this->_settings['level']; } foreach ($this->_settings as $key => $val) { if (in_array($key, $this->_params)) { $args[$key] = $val; } } $ch = curl_init(); curl_setopt_array($ch, array( CURLOPT_URL => 'https://closure-compiler.appspot.com/compile', CURLOPT_POST => 1, CURLOPT_POSTFIELDS => 'js_code=' . urlencode($content) . '&' . http_build_query($args), CURLOPT_RETURNTRANSFER => 1, CURLOPT_HEADER => 0, CURLOPT_FOLLOWLOCATION => 0 )); $output = curl_exec($ch); if (false === $output) { throw new \Exception('Curl error: ' . curl_error($ch)); } curl_close($ch); return $output; }
php
protected function _query($content, $args = array()) { if (!extension_loaded('curl')) { throw new \Exception('Missing the `curl` extension.'); } $args = array_merge($this->_defaults, $args); if (!empty($this->_settings['level'])) { $args['compilation_level'] = $this->_settings['level']; } foreach ($this->_settings as $key => $val) { if (in_array($key, $this->_params)) { $args[$key] = $val; } } $ch = curl_init(); curl_setopt_array($ch, array( CURLOPT_URL => 'https://closure-compiler.appspot.com/compile', CURLOPT_POST => 1, CURLOPT_POSTFIELDS => 'js_code=' . urlencode($content) . '&' . http_build_query($args), CURLOPT_RETURNTRANSFER => 1, CURLOPT_HEADER => 0, CURLOPT_FOLLOWLOCATION => 0 )); $output = curl_exec($ch); if (false === $output) { throw new \Exception('Curl error: ' . curl_error($ch)); } curl_close($ch); return $output; }
[ "protected", "function", "_query", "(", "$", "content", ",", "$", "args", "=", "array", "(", ")", ")", "{", "if", "(", "!", "extension_loaded", "(", "'curl'", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "'Missing the `curl` extension.'", ")", ";", "}", "$", "args", "=", "array_merge", "(", "$", "this", "->", "_defaults", ",", "$", "args", ")", ";", "if", "(", "!", "empty", "(", "$", "this", "->", "_settings", "[", "'level'", "]", ")", ")", "{", "$", "args", "[", "'compilation_level'", "]", "=", "$", "this", "->", "_settings", "[", "'level'", "]", ";", "}", "foreach", "(", "$", "this", "->", "_settings", "as", "$", "key", "=>", "$", "val", ")", "{", "if", "(", "in_array", "(", "$", "key", ",", "$", "this", "->", "_params", ")", ")", "{", "$", "args", "[", "$", "key", "]", "=", "$", "val", ";", "}", "}", "$", "ch", "=", "curl_init", "(", ")", ";", "curl_setopt_array", "(", "$", "ch", ",", "array", "(", "CURLOPT_URL", "=>", "'https://closure-compiler.appspot.com/compile'", ",", "CURLOPT_POST", "=>", "1", ",", "CURLOPT_POSTFIELDS", "=>", "'js_code='", ".", "urlencode", "(", "$", "content", ")", ".", "'&'", ".", "http_build_query", "(", "$", "args", ")", ",", "CURLOPT_RETURNTRANSFER", "=>", "1", ",", "CURLOPT_HEADER", "=>", "0", ",", "CURLOPT_FOLLOWLOCATION", "=>", "0", ")", ")", ";", "$", "output", "=", "curl_exec", "(", "$", "ch", ")", ";", "if", "(", "false", "===", "$", "output", ")", "{", "throw", "new", "\\", "Exception", "(", "'Curl error: '", ".", "curl_error", "(", "$", "ch", ")", ")", ";", "}", "curl_close", "(", "$", "ch", ")", ";", "return", "$", "output", ";", "}" ]
Query the Closure compiler API. @param string $content Javascript to compile. @param array $args API parameters. @throws \Exception If curl extension is missing. @throws \Exception If curl triggers an error. @return string
[ "Query", "the", "Closure", "compiler", "API", "." ]
5564bcbe2749a28d7978d36362c390bce39083a3
https://github.com/markstory/mini-asset/blob/5564bcbe2749a28d7978d36362c390bce39083a3/src/Filter/ClosureCompiler.php#L115-L150
train
markstory/mini-asset
src/Factory.php
Factory.writer
public function writer($tmpPath = '') { $tmpPath = $tmpPath ?: $this->config->get('general.timestampPath'); if (!$tmpPath) { $tmpPath = sys_get_temp_dir() . DIRECTORY_SEPARATOR; } $timestamp = [ 'js' => $this->config->get('js.timestamp'), 'css' => $this->config->get('css.timestamp'), ]; $writer = new AssetWriter($timestamp, $tmpPath, $this->config->theme()); $writer->configTimestamp($this->config->modifiedTime()); $writer->filterRegistry($this->filterRegistry()); return $writer; }
php
public function writer($tmpPath = '') { $tmpPath = $tmpPath ?: $this->config->get('general.timestampPath'); if (!$tmpPath) { $tmpPath = sys_get_temp_dir() . DIRECTORY_SEPARATOR; } $timestamp = [ 'js' => $this->config->get('js.timestamp'), 'css' => $this->config->get('css.timestamp'), ]; $writer = new AssetWriter($timestamp, $tmpPath, $this->config->theme()); $writer->configTimestamp($this->config->modifiedTime()); $writer->filterRegistry($this->filterRegistry()); return $writer; }
[ "public", "function", "writer", "(", "$", "tmpPath", "=", "''", ")", "{", "$", "tmpPath", "=", "$", "tmpPath", "?", ":", "$", "this", "->", "config", "->", "get", "(", "'general.timestampPath'", ")", ";", "if", "(", "!", "$", "tmpPath", ")", "{", "$", "tmpPath", "=", "sys_get_temp_dir", "(", ")", ".", "DIRECTORY_SEPARATOR", ";", "}", "$", "timestamp", "=", "[", "'js'", "=>", "$", "this", "->", "config", "->", "get", "(", "'js.timestamp'", ")", ",", "'css'", "=>", "$", "this", "->", "config", "->", "get", "(", "'css.timestamp'", ")", ",", "]", ";", "$", "writer", "=", "new", "AssetWriter", "(", "$", "timestamp", ",", "$", "tmpPath", ",", "$", "this", "->", "config", "->", "theme", "(", ")", ")", ";", "$", "writer", "->", "configTimestamp", "(", "$", "this", "->", "config", "->", "modifiedTime", "(", ")", ")", ";", "$", "writer", "->", "filterRegistry", "(", "$", "this", "->", "filterRegistry", "(", ")", ")", ";", "return", "$", "writer", ";", "}" ]
Create an AssetWriter @param string $tmpPath The path where the build timestamp lookup should be stored. @return \MiniAsset\AssetWriter
[ "Create", "an", "AssetWriter" ]
5564bcbe2749a28d7978d36362c390bce39083a3
https://github.com/markstory/mini-asset/blob/5564bcbe2749a28d7978d36362c390bce39083a3/src/Factory.php#L90-L104
train
markstory/mini-asset
src/Factory.php
Factory.cacher
public function cacher($path = '') { if (!$path) { $path = sys_get_temp_dir() . DIRECTORY_SEPARATOR; } $cache = new AssetCacher($path, $this->config->theme()); $cache->configTimestamp($this->config->modifiedTime()); $cache->filterRegistry($this->filterRegistry()); return $cache; }
php
public function cacher($path = '') { if (!$path) { $path = sys_get_temp_dir() . DIRECTORY_SEPARATOR; } $cache = new AssetCacher($path, $this->config->theme()); $cache->configTimestamp($this->config->modifiedTime()); $cache->filterRegistry($this->filterRegistry()); return $cache; }
[ "public", "function", "cacher", "(", "$", "path", "=", "''", ")", "{", "if", "(", "!", "$", "path", ")", "{", "$", "path", "=", "sys_get_temp_dir", "(", ")", ".", "DIRECTORY_SEPARATOR", ";", "}", "$", "cache", "=", "new", "AssetCacher", "(", "$", "path", ",", "$", "this", "->", "config", "->", "theme", "(", ")", ")", ";", "$", "cache", "->", "configTimestamp", "(", "$", "this", "->", "config", "->", "modifiedTime", "(", ")", ")", ";", "$", "cache", "->", "filterRegistry", "(", "$", "this", "->", "filterRegistry", "(", ")", ")", ";", "return", "$", "cache", ";", "}" ]
Create an AssetCacher @param string $path The path to cache assets into. @return \MiniAsset\AssetCacher
[ "Create", "an", "AssetCacher" ]
5564bcbe2749a28d7978d36362c390bce39083a3
https://github.com/markstory/mini-asset/blob/5564bcbe2749a28d7978d36362c390bce39083a3/src/Factory.php#L112-L121
train
markstory/mini-asset
src/Factory.php
Factory.target
public function target($name) { if (!$this->config->hasTarget($name)) { throw new RuntimeException("The target named '$name' does not exist."); } $ext = $this->config->getExt($name); $themed = $this->config->isThemed($name); $filters = $this->config->targetFilters($name); $target = $this->config->cachePath($ext) . $name; $files = []; $scanner = $this->scanner($this->config->paths($ext, $name)); $paths = $scanner->paths(); $required = $this->config->requires($name); if ($required) { $compiler = $this->cachedCompiler(); foreach ($required as $dependency) { $files[] = new Target($this->target($dependency), $compiler); } } foreach ($this->config->files($name) as $file) { if (preg_match('#^https?://#', $file)) { $files[] = new Remote($file); } else { if (preg_match('/(.*\/)(\*.*?)$/U', $file, $matches)) { $path = $scanner->find($matches[1]); if ($path === false) { throw new RuntimeException("Could not locate folder $file for $name in any configured path."); } $glob = new Glob($path, $matches[2]); $files = array_merge($files, $glob->files()); } elseif (preg_match(static::CALLBACK_PATTERN, $file, $matches)) { $callback = new Callback($matches[1], $matches[2], $scanner); $files = array_merge($files, $callback->files()); } else { $path = $scanner->find($file); if ($path === false) { throw new RuntimeException("Could not locate $file for $name in any configured path."); } $files[] = new Local($path); } } } return new AssetTarget($target, $files, $filters, $paths, $themed); }
php
public function target($name) { if (!$this->config->hasTarget($name)) { throw new RuntimeException("The target named '$name' does not exist."); } $ext = $this->config->getExt($name); $themed = $this->config->isThemed($name); $filters = $this->config->targetFilters($name); $target = $this->config->cachePath($ext) . $name; $files = []; $scanner = $this->scanner($this->config->paths($ext, $name)); $paths = $scanner->paths(); $required = $this->config->requires($name); if ($required) { $compiler = $this->cachedCompiler(); foreach ($required as $dependency) { $files[] = new Target($this->target($dependency), $compiler); } } foreach ($this->config->files($name) as $file) { if (preg_match('#^https?://#', $file)) { $files[] = new Remote($file); } else { if (preg_match('/(.*\/)(\*.*?)$/U', $file, $matches)) { $path = $scanner->find($matches[1]); if ($path === false) { throw new RuntimeException("Could not locate folder $file for $name in any configured path."); } $glob = new Glob($path, $matches[2]); $files = array_merge($files, $glob->files()); } elseif (preg_match(static::CALLBACK_PATTERN, $file, $matches)) { $callback = new Callback($matches[1], $matches[2], $scanner); $files = array_merge($files, $callback->files()); } else { $path = $scanner->find($file); if ($path === false) { throw new RuntimeException("Could not locate $file for $name in any configured path."); } $files[] = new Local($path); } } } return new AssetTarget($target, $files, $filters, $paths, $themed); }
[ "public", "function", "target", "(", "$", "name", ")", "{", "if", "(", "!", "$", "this", "->", "config", "->", "hasTarget", "(", "$", "name", ")", ")", "{", "throw", "new", "RuntimeException", "(", "\"The target named '$name' does not exist.\"", ")", ";", "}", "$", "ext", "=", "$", "this", "->", "config", "->", "getExt", "(", "$", "name", ")", ";", "$", "themed", "=", "$", "this", "->", "config", "->", "isThemed", "(", "$", "name", ")", ";", "$", "filters", "=", "$", "this", "->", "config", "->", "targetFilters", "(", "$", "name", ")", ";", "$", "target", "=", "$", "this", "->", "config", "->", "cachePath", "(", "$", "ext", ")", ".", "$", "name", ";", "$", "files", "=", "[", "]", ";", "$", "scanner", "=", "$", "this", "->", "scanner", "(", "$", "this", "->", "config", "->", "paths", "(", "$", "ext", ",", "$", "name", ")", ")", ";", "$", "paths", "=", "$", "scanner", "->", "paths", "(", ")", ";", "$", "required", "=", "$", "this", "->", "config", "->", "requires", "(", "$", "name", ")", ";", "if", "(", "$", "required", ")", "{", "$", "compiler", "=", "$", "this", "->", "cachedCompiler", "(", ")", ";", "foreach", "(", "$", "required", "as", "$", "dependency", ")", "{", "$", "files", "[", "]", "=", "new", "Target", "(", "$", "this", "->", "target", "(", "$", "dependency", ")", ",", "$", "compiler", ")", ";", "}", "}", "foreach", "(", "$", "this", "->", "config", "->", "files", "(", "$", "name", ")", "as", "$", "file", ")", "{", "if", "(", "preg_match", "(", "'#^https?://#'", ",", "$", "file", ")", ")", "{", "$", "files", "[", "]", "=", "new", "Remote", "(", "$", "file", ")", ";", "}", "else", "{", "if", "(", "preg_match", "(", "'/(.*\\/)(\\*.*?)$/U'", ",", "$", "file", ",", "$", "matches", ")", ")", "{", "$", "path", "=", "$", "scanner", "->", "find", "(", "$", "matches", "[", "1", "]", ")", ";", "if", "(", "$", "path", "===", "false", ")", "{", "throw", "new", "RuntimeException", "(", "\"Could not locate folder $file for $name in any configured path.\"", ")", ";", "}", "$", "glob", "=", "new", "Glob", "(", "$", "path", ",", "$", "matches", "[", "2", "]", ")", ";", "$", "files", "=", "array_merge", "(", "$", "files", ",", "$", "glob", "->", "files", "(", ")", ")", ";", "}", "elseif", "(", "preg_match", "(", "static", "::", "CALLBACK_PATTERN", ",", "$", "file", ",", "$", "matches", ")", ")", "{", "$", "callback", "=", "new", "Callback", "(", "$", "matches", "[", "1", "]", ",", "$", "matches", "[", "2", "]", ",", "$", "scanner", ")", ";", "$", "files", "=", "array_merge", "(", "$", "files", ",", "$", "callback", "->", "files", "(", ")", ")", ";", "}", "else", "{", "$", "path", "=", "$", "scanner", "->", "find", "(", "$", "file", ")", ";", "if", "(", "$", "path", "===", "false", ")", "{", "throw", "new", "RuntimeException", "(", "\"Could not locate $file for $name in any configured path.\"", ")", ";", "}", "$", "files", "[", "]", "=", "new", "Local", "(", "$", "path", ")", ";", "}", "}", "}", "return", "new", "AssetTarget", "(", "$", "target", ",", "$", "files", ",", "$", "filters", ",", "$", "paths", ",", "$", "themed", ")", ";", "}" ]
Create a single build target @param string $name The name of the target to build @return \MiniAsset\AssetTarget @throws \RuntimeException
[ "Create", "a", "single", "build", "target" ]
5564bcbe2749a28d7978d36362c390bce39083a3
https://github.com/markstory/mini-asset/blob/5564bcbe2749a28d7978d36362c390bce39083a3/src/Factory.php#L152-L199
train
markstory/mini-asset
src/Factory.php
Factory.filterRegistry
public function filterRegistry() { $filters = []; foreach ($this->config->allFilters() as $name) { $filters[$name] = $this->buildFilter($name, $this->config->filterConfig($name)); } return new FilterRegistry($filters); }
php
public function filterRegistry() { $filters = []; foreach ($this->config->allFilters() as $name) { $filters[$name] = $this->buildFilter($name, $this->config->filterConfig($name)); } return new FilterRegistry($filters); }
[ "public", "function", "filterRegistry", "(", ")", "{", "$", "filters", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "config", "->", "allFilters", "(", ")", "as", "$", "name", ")", "{", "$", "filters", "[", "$", "name", "]", "=", "$", "this", "->", "buildFilter", "(", "$", "name", ",", "$", "this", "->", "config", "->", "filterConfig", "(", "$", "name", ")", ")", ";", "}", "return", "new", "FilterRegistry", "(", "$", "filters", ")", ";", "}" ]
Create a filter registry containing all the configured filters. @return \MiniAsset\Filter\FilterRegistry
[ "Create", "a", "filter", "registry", "containing", "all", "the", "configured", "filters", "." ]
5564bcbe2749a28d7978d36362c390bce39083a3
https://github.com/markstory/mini-asset/blob/5564bcbe2749a28d7978d36362c390bce39083a3/src/Factory.php#L206-L213
train
boomcms/boom-core
src/BoomCMS/Database/Models/PageVersion.php
PageVersion.getNext
public function getNext() { return $this ->where(self::ATTR_PAGE, $this->getPageId()) ->where(self::ATTR_CREATED_AT, '>', $this->getEditedTime()->getTimestamp()) ->orderBy(self::ATTR_CREATED_AT, 'asc') ->first(); }
php
public function getNext() { return $this ->where(self::ATTR_PAGE, $this->getPageId()) ->where(self::ATTR_CREATED_AT, '>', $this->getEditedTime()->getTimestamp()) ->orderBy(self::ATTR_CREATED_AT, 'asc') ->first(); }
[ "public", "function", "getNext", "(", ")", "{", "return", "$", "this", "->", "where", "(", "self", "::", "ATTR_PAGE", ",", "$", "this", "->", "getPageId", "(", ")", ")", "->", "where", "(", "self", "::", "ATTR_CREATED_AT", ",", "'>'", ",", "$", "this", "->", "getEditedTime", "(", ")", "->", "getTimestamp", "(", ")", ")", "->", "orderBy", "(", "self", "::", "ATTR_CREATED_AT", ",", "'asc'", ")", "->", "first", "(", ")", ";", "}" ]
Returns the next version. @return PageVersion
[ "Returns", "the", "next", "version", "." ]
cc835772e3c33dac3e56c36a8db2c9e6da313c7b
https://github.com/boomcms/boom-core/blob/cc835772e3c33dac3e56c36a8db2c9e6da313c7b/src/BoomCMS/Database/Models/PageVersion.php#L104-L111
train
boomcms/boom-core
src/BoomCMS/Database/Models/PageVersion.php
PageVersion.isPublished
public function isPublished(DateTime $time = null) { $timestamp = $time ? $time->getTimestamp() : time(); return $this->{self::ATTR_EMBARGOED_UNTIL} && $this->{self::ATTR_EMBARGOED_UNTIL} <= $timestamp; }
php
public function isPublished(DateTime $time = null) { $timestamp = $time ? $time->getTimestamp() : time(); return $this->{self::ATTR_EMBARGOED_UNTIL} && $this->{self::ATTR_EMBARGOED_UNTIL} <= $timestamp; }
[ "public", "function", "isPublished", "(", "DateTime", "$", "time", "=", "null", ")", "{", "$", "timestamp", "=", "$", "time", "?", "$", "time", "->", "getTimestamp", "(", ")", ":", "time", "(", ")", ";", "return", "$", "this", "->", "{", "self", "::", "ATTR_EMBARGOED_UNTIL", "}", "&&", "$", "this", "->", "{", "self", "::", "ATTR_EMBARGOED_UNTIL", "}", "<=", "$", "timestamp", ";", "}" ]
Whether the version is published. If a time is given then the embargo time is compared with the given time. Otherwise it is compared with the current time. @param null|DateTime $time @return bool
[ "Whether", "the", "version", "is", "published", "." ]
cc835772e3c33dac3e56c36a8db2c9e6da313c7b
https://github.com/boomcms/boom-core/blob/cc835772e3c33dac3e56c36a8db2c9e6da313c7b/src/BoomCMS/Database/Models/PageVersion.php#L235-L240
train
boomcms/boom-core
src/BoomCMS/Database/Models/PageVersion.php
PageVersion.status
public function status(DateTime $time = null) { if ($this->isPendingApproval()) { return 'pending approval'; } elseif ($this->isDraft()) { return 'draft'; } elseif ($this->isPublished($time)) { return 'published'; } elseif ($this->isEmbargoed($time)) { return 'embargoed'; } }
php
public function status(DateTime $time = null) { if ($this->isPendingApproval()) { return 'pending approval'; } elseif ($this->isDraft()) { return 'draft'; } elseif ($this->isPublished($time)) { return 'published'; } elseif ($this->isEmbargoed($time)) { return 'embargoed'; } }
[ "public", "function", "status", "(", "DateTime", "$", "time", "=", "null", ")", "{", "if", "(", "$", "this", "->", "isPendingApproval", "(", ")", ")", "{", "return", "'pending approval'", ";", "}", "elseif", "(", "$", "this", "->", "isDraft", "(", ")", ")", "{", "return", "'draft'", ";", "}", "elseif", "(", "$", "this", "->", "isPublished", "(", "$", "time", ")", ")", "{", "return", "'published'", ";", "}", "elseif", "(", "$", "this", "->", "isEmbargoed", "(", "$", "time", ")", ")", "{", "return", "'embargoed'", ";", "}", "}" ]
Returns the status of the current page version. If a time parameter is given then the status of the page at that time will be returned. @param null|DateTime $time @return string
[ "Returns", "the", "status", "of", "the", "current", "page", "version", "." ]
cc835772e3c33dac3e56c36a8db2c9e6da313c7b
https://github.com/boomcms/boom-core/blob/cc835772e3c33dac3e56c36a8db2c9e6da313c7b/src/BoomCMS/Database/Models/PageVersion.php#L335-L346
train
boomcms/boom-core
src/BoomCMS/Database/Models/Group.php
Group.addRole
public function addRole($roleId, $allowed, $pageId = 0) { if (!$this->hasRole($roleId, $pageId)) { $this->roles() ->attach($roleId, [ self::PIVOT_ATTR_ALLOWED => $allowed, self::PIVOT_ATTR_PAGE_ID => $pageId, ]); } return $this; }
php
public function addRole($roleId, $allowed, $pageId = 0) { if (!$this->hasRole($roleId, $pageId)) { $this->roles() ->attach($roleId, [ self::PIVOT_ATTR_ALLOWED => $allowed, self::PIVOT_ATTR_PAGE_ID => $pageId, ]); } return $this; }
[ "public", "function", "addRole", "(", "$", "roleId", ",", "$", "allowed", ",", "$", "pageId", "=", "0", ")", "{", "if", "(", "!", "$", "this", "->", "hasRole", "(", "$", "roleId", ",", "$", "pageId", ")", ")", "{", "$", "this", "->", "roles", "(", ")", "->", "attach", "(", "$", "roleId", ",", "[", "self", "::", "PIVOT_ATTR_ALLOWED", "=>", "$", "allowed", ",", "self", "::", "PIVOT_ATTR_PAGE_ID", "=>", "$", "pageId", ",", "]", ")", ";", "}", "return", "$", "this", ";", "}" ]
Adds a role to the current group. This will also add the role to all members of the group. @param int $roleId ID of the role to add @param int $allowed Whether the group is allowed or prevented from the role. @param int $pageId Make the role active at a particular point in the page tree. @return $this
[ "Adds", "a", "role", "to", "the", "current", "group", "." ]
cc835772e3c33dac3e56c36a8db2c9e6da313c7b
https://github.com/boomcms/boom-core/blob/cc835772e3c33dac3e56c36a8db2c9e6da313c7b/src/BoomCMS/Database/Models/Group.php#L36-L47
train
boomcms/boom-core
src/BoomCMS/Database/Models/Group.php
Group.removeRole
public function removeRole($roleId, $pageId = 0) { $this->roles() ->wherePivot(self::PIVOT_ATTR_ROLE_ID, '=', $roleId) ->wherePivot(self::PIVOT_ATTR_PAGE_ID, '=', $pageId) ->detach(); return $this; }
php
public function removeRole($roleId, $pageId = 0) { $this->roles() ->wherePivot(self::PIVOT_ATTR_ROLE_ID, '=', $roleId) ->wherePivot(self::PIVOT_ATTR_PAGE_ID, '=', $pageId) ->detach(); return $this; }
[ "public", "function", "removeRole", "(", "$", "roleId", ",", "$", "pageId", "=", "0", ")", "{", "$", "this", "->", "roles", "(", ")", "->", "wherePivot", "(", "self", "::", "PIVOT_ATTR_ROLE_ID", ",", "'='", ",", "$", "roleId", ")", "->", "wherePivot", "(", "self", "::", "PIVOT_ATTR_PAGE_ID", ",", "'='", ",", "$", "pageId", ")", "->", "detach", "(", ")", ";", "return", "$", "this", ";", "}" ]
Remove a role from a group. After removing the role from the group the permissions for the people the group are updated. @param int $roleId @return $this
[ "Remove", "a", "role", "from", "a", "group", "." ]
cc835772e3c33dac3e56c36a8db2c9e6da313c7b
https://github.com/boomcms/boom-core/blob/cc835772e3c33dac3e56c36a8db2c9e6da313c7b/src/BoomCMS/Database/Models/Group.php#L87-L95
train