_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
83
13k
language
stringclasses
1 value
meta_information
dict
q259800
Configure.configured
test
public static function configured($name = null) { if ($name !== null) { return isset(static::$engines[$name]); } return array_keys(static::$engines); }
php
{ "resource": "" }
q259801
Hash.expand
test
public static function expand(array $data, $separator = '.') { $result = []; foreach ($data as $flat => $value) { $keys = explode($separator, $flat); $keys = array_reverse($keys); $child = [ $keys[0] => $value ]; array_shift($keys); foreach ($keys as $k) { $child = [ $k => $child ]; } $stack = [[$child, &$result]]; static::mergeHelper($stack, $result); } return $result; }
php
{ "resource": "" }
q259802
Hash.splitConditions
test
protected static function splitConditions($token) { $conditions = false; $position = strpos($token, '['); if ($position !== false) { $conditions = substr($token, $position); $token = substr($token, 0, $position); } return [$token, $conditions]; }
php
{ "resource": "" }
q259803
Hash.matchToken
test
protected static function matchToken($key, $token) { if ($token === '{n}') { return is_numeric($key); } if ($token === '{s}') { return is_string($key); } if (is_numeric($token)) { return ($key == $token); } return ($key === $token); }
php
{ "resource": "" }
q259804
Inflector.cache
test
protected static function cache($type, $key, $value = false) { $key = '_' . $key; $type = '_' . $type; if ($value !== false) { static::$cache[$type][$key] = $value; return $value; } if (!isset(static::$cache[$type][$key])) { return false; } return static::$cache[$type][$key]; }
php
{ "resource": "" }
q259805
Wrapper.setInstances
test
public function setInstances($message, $moduleManager) { $this->ModuleManager = $moduleManager; $this->Message = $message; $this->Channel = $message->channel; if (isset($message->channel->guild) && is_object($message->channel->guild)) { $this->Guild = $message->channel->guild; } if (isset($message->channel->guild->members) && is_object($message->channel->guild->members)) { $this->Members = $message->channel->guild->members; } return $this; }
php
{ "resource": "" }
q259806
Debugger.trace
test
public static function trace(array $options = []) { $self = Debugger::getInstance(); $defaults = [ 'depth' => 999, 'format' => $self->outputFormat, 'args' => false, 'start' => 0, 'scope' => null, 'exclude' => ['call_user_func_array', 'trigger_error'] ]; $options = Hash::merge($defaults, $options); $backtrace = debug_backtrace(); $count = count($backtrace); $back = []; $_trace = [ 'line' => '??', 'file' => '[internal]', 'class' => null, 'function' => '[main]' ]; for ($i = $options['start']; $i < $count && $i < $options['depth']; $i++) { $trace = $backtrace[$i] + ['file' => '[internal]', 'line' => '??']; $signature = $reference = '[main]'; if (isset($backtrace[$i + 1])) { $next = $backtrace[$i + 1] + $_trace; $signature = $reference = $next['function']; if (!empty($next['class'])) { $signature = $next['class'] . '::' . $next['function']; $reference = $signature . '('; if ($options['args'] && isset($next['args'])) { $args = []; foreach ($next['args'] as $arg) { $args[] = Debugger::exportVar($arg); } $reference .= implode(', ', $args); } $reference .= ')'; } } if (in_array($signature, $options['exclude'])) { continue; } if ($options['format'] === 'points' && $trace['file'] !== '[internal]') { $back[] = ['file' => $trace['file'], 'line' => $trace['line']]; } else { $back[] = $trace; } } if ($options['format'] === 'array' || $options['format'] === 'points') { return $back; } return implode("\n", $back); }
php
{ "resource": "" }
q259807
Debugger.export
test
protected static function export($var, $depth, $indent) { switch (static::getType($var)) { case 'boolean': return ($var) ? 'true' : 'false'; case 'integer': return '(int) ' . $var; case 'float': return '(float) ' . $var; case 'string': if (trim($var) === '') { return "''"; } return "'" . $var . "'"; case 'array': return static::arrayExport($var, $depth - 1, $indent + 1); case 'resource': return strtolower(gettype($var)); case 'null': return 'null'; case 'unknown': return 'unknown'; default: return static::object($var, $depth - 1, $indent + 1); } }
php
{ "resource": "" }
q259808
Server.listen
test
public function listen() { $this->Discord->on('ready', function ($discord) { $discord->on('message', function ($message) { if ($this->Discord->id === $message->author->id) { return; } $content = Message::parse($message->content); $wrapper = Wrapper::getInstance()->setInstances($message, $this->ModuleManager); //Handle the type of the message. //Note : The order is very important ! if ($wrapper->Channel->is_private === true) { $this->ModuleManager->onPrivateMessage($wrapper, $content); } elseif ($content['commandCode'] === Configure::read('Command.prefix') && isset(Configure::read('Commands')[$content['command']])) { $command = Configure::read('Commands')[$content['command']]; if ((isset($command['admin']) && $command['admin'] === true) && !User::hasPermission($wrapper->Message->author->id, Configure::read('Bot.admins'))) { $wrapper->Message->reply('You are not administrator of the bot.'); return; } if (count($content['arguments']) < $command['params']) { $wrapper->Message->reply(Command::syntax($content)); return; } $this->ModuleManager->onCommandMessage($wrapper, $content); } else { $this->ModuleManager->onChannelMessage($wrapper, $content); } }); }); }
php
{ "resource": "" }
q259809
Message.parse
test
public static function parse($message) { static::resetConfig(); $chr32 = chr(32); $config = []; if (empty($message) || !is_string($message)) { return static::read(); } $config += [ 'raw' => $message, 'parts' => explode($chr32, trim($message), 2) ]; $config += [ 'commandCode' => substr($config['parts'][0], 0, 1), 'command' => strtolower(substr($config['parts'][0], 1)) ]; if (count($config['parts']) > 1) { $config += [ 'message' => $config['parts'][1], 'arguments' => array_map( 'strtolower', explode( $chr32, $config['parts'][1] ) ) ]; } static::config($config); return static::read(); }
php
{ "resource": "" }
q259810
FileConfigTrait.getFilePath
test
protected function getFilePath($key, $checkExists = false) { if (strpos($key, '..') !== false) { throw new Exception('Cannot load/dump configuration files with ../ in them.'); } list($plugin, $key) = pluginSplit($key); if ($plugin) { $file = Plugin::configPath($plugin) . $key; } else { $file = $this->path . $key; } $file .= $this->extension; if (!$checkExists || is_file($file)) { return $file; } if (is_file(realpath($file))) { return realpath($file); } throw new Exception(sprintf('Could not load configuration file: %s', $file)); }
php
{ "resource": "" }
q259811
Plugin.load
test
public static function load($plugin, array $config = []) { if (is_array($plugin)) { foreach ($plugin as $name => $conf) { list($name, $conf) = (is_numeric($name)) ? [$conf, $config] : [$name, $conf]; static::load($name, $conf); } return; } static::loadConfig(); $config += [ 'bootstrap' => false, 'classBase' => 'src', 'ignoreMissing' => false ]; if (!isset($config['path'])) { $config['path'] = Configure::read('plugins.' . $plugin); } if (empty($config['path'])) { $paths = (array)Configure::read('App.paths.plugins'); $pluginPath = str_replace('/', DIRECTORY_SEPARATOR, $plugin); foreach ($paths as $path) { if (is_dir($path . $pluginPath)) { $config['path'] = $path . $pluginPath . DIRECTORY_SEPARATOR; break; } } } if (empty($config['path'])) { throw new MissingPluginException(['plugin' => $plugin]); } $config['classPath'] = $config['path'] . $config['classBase'] . DIRECTORY_SEPARATOR; if (!isset($config['configPath'])) { $config['configPath'] = $config['path'] . 'config' . DIRECTORY_SEPARATOR; } static::$plugins[$plugin] = $config; if ($config['bootstrap'] === true) { static::bootstrap($plugin); } }
php
{ "resource": "" }
q259812
Plugin.loadConfig
test
protected static function loadConfig() { if (Configure::check('plugins')) { return; } $vendorFile = dirname(dirname(__DIR__)) . DIRECTORY_SEPARATOR . 'skinny-plugins.php'; if (!file_exists($vendorFile)) { $vendorFile = dirname(dirname(dirname(dirname(__DIR__)))) . DIRECTORY_SEPARATOR . 'skinny-plugins.php'; if (!file_exists($vendorFile)) { Configure::write(['plugins' => []]); return; } } $config = require $vendorFile; Configure::write($config); }
php
{ "resource": "" }
q259813
Plugin.loadAll
test
public static function loadAll(array $options = []) { static::loadConfig(); $plugins = []; foreach ((array)Configure::read('App.paths.plugins') as $path) { if (!is_dir($path)) { continue; } $dir = new DirectoryIterator($path); foreach ($dir as $path) { if ($path->isDir() && !$path->isDot()) { $plugins[] = $path->getBasename(); } } } if (Configure::check('plugins')) { $plugins = array_merge($plugins, array_keys(Configure::read('plugins'))); $plugins = array_unique($plugins); } foreach ($plugins as $p) { $opts = isset($options[$p]) ? $options[$p] : null; if ($opts === null && isset($options[0])) { $opts = $options[0]; } if (isset(static::$plugins[$p])) { continue; } static::load($p, (array)$opts); } }
php
{ "resource": "" }
q259814
Plugin.bootstrap
test
public static function bootstrap($plugin) { $config = static::$plugins[$plugin]; if ($config['bootstrap'] === false) { return false; } if ($config['bootstrap'] === true) { return static::includeFile( $config['configPath'] . 'bootstrap.php', $config['ignoreMissing'] ); } }
php
{ "resource": "" }
q259815
PhpConfig.read
test
public function read($key) { $file = $this->getFilePath($key, true); $return = include $file; if (!is_array($return)) { throw new Exception(sprintf('Config file "%s" did not return an array', $key . '.php')); } return $return; }
php
{ "resource": "" }
q259816
StaticMessageTrait.config
test
public static function config($key, $value = null) { if (is_string($key)) { static::$config[$key] = $value; return; } if (!is_array($key)) { throw new InvalidArgumentException('Only string and array can be passed to config.'); } foreach ($key as $name => $value) { static::$config[$name] = $value; } return; }
php
{ "resource": "" }
q259817
StaticMessageTrait.read
test
public static function read($key = null) { if ($key === null) { return static::$config; } return isset(static::$config[$key]) ? static::$config[$key] : null; }
php
{ "resource": "" }
q259818
ModuleManager.loadModules
test
protected function loadModules(DirectoryIterator $files, array $config = []) { foreach ($files as $file) { $filename = $file->getFilename(); if ($file->isDot() || $file->isDir() || $filename[0] == '.') { continue; } elseif ($file->isFile() && substr($filename, -4) != '.php') { continue; } else { try { $this->load(substr($filename, 0, -4), $config); } catch (Exception $e) { throw new RuntimeException(sprintf('Error while loading module : %s', $e->getMessage())); } } } }
php
{ "resource": "" }
q259819
ModuleManager.checkPlugins
test
protected function checkPlugins($module) { $loadedPlugins = Configure::read('plugins'); $arr = []; if (empty($loadedPlugins) || !is_array($loadedPlugins)) { return $arr; } foreach ($loadedPlugins as $plugin => $pluginPath) { $pluginPath = Plugin::classPath($plugin) . 'Module' . DS . 'Modules'; $files = new DirectoryIterator($pluginPath); foreach ($files as $file) { $filename = $file->getFilename(); if ($file->isDot() || $file->isDir() || $filename[0] == '.') { continue; } elseif ($file->isFile() && substr($filename, -4) != '.php') { continue; } elseif (Inflector::camelize(substr($filename, 0, -4)) !== $module) { continue; } else { $arr = ['pathDir' => $pluginPath, 'plugin' => $plugin]; return $arr; } } } return $arr; }
php
{ "resource": "" }
q259820
ModuleManager.unload
test
public function unload($module) { $module = Inflector::camelize($module); if (!isset($this->loadedModules[$module])) { //Return the message AlreadyUnloaded. return 'AU'; } //Remove this module, also calling the __destruct method of it. $object = $this->loadedModules[$module]['object']; unset($object); unset($this->loadedModules[$module]); //Return the message Unloaded. return 'U'; }
php
{ "resource": "" }
q259821
ModuleManager.reload
test
public function reload($module) { $module = Inflector::camelize($module); $config = []; if (isset($this->loadedModules[$module]) && $this->loadedModules[$module]['plugin'] === true) { $config += [ 'pathDir' => $this->loadedModules[$module]['pluginPath'], 'plugin' => $this->loadedModules[$module]['pluginName'] ]; } $unload = $this->unload($module); if ($unload != "U") { return $unload; } return $this->load($module, $config); }
php
{ "resource": "" }
q259822
ModuleManager.timeLoaded
test
public function timeLoaded($module) { $module = Inflector::camelize($module); if (!isset($this->loadedModules[$module])) { return false; } return $this->loadedModules[$module]['loaded']; }
php
{ "resource": "" }
q259823
ModuleManager.isModified
test
public function isModified($module) { $module = Inflector::camelize($module); if (!isset($this->loadedModules[$module])) { return -1; } return $this->loadedModules[$module]['modified']; }
php
{ "resource": "" }
q259824
ModuleManager.offsetGet
test
public function offsetGet($module) { $module = Inflector::camelize($module); if (!isset($this->loadedModules[$module])) { return false; } return $this->loadedModules[$module]; }
php
{ "resource": "" }
q259825
ModuleManager.offsetExists
test
public function offsetExists($module) { $module = Inflector::camelize($module); return isset($this->loadedModules[$module]); }
php
{ "resource": "" }
q259826
ModuleManager.offsetSet
test
public function offsetSet($offset, $module) { if (!$module instanceof ModuleInterface) { throw new RuntimeException( sprintf('ModuleManager::offsetSet() expects "%s" to be an instance of ModuleInterface.', $module) ); } $newModule = [ 'object' => $module, 'loaded' => time(), 'plugin' => false, 'pluginName' => '', 'pluginPath' => MODULE_DIR, 'name' => get_class($module), 'modified' => false ]; if (in_array($offset, $this->priorityList)) { $temp = array_reverse($this->loadedModules, true); $temp[$offset] = $newModule; $this->loadedModules = array_reverse($temp, true); } else { $this->loadedModules[$offset] = $newModule; } }
php
{ "resource": "" }
q259827
Redis.get
test
public function get($key, $default = null) { $result = $this->call('get', [$key]); if ($result === false || $result === null) { return $default; } return $result; }
php
{ "resource": "" }
q259828
Redis.set
test
public function set($key, $value, $ttl = null): bool { $ttl = $this->getTtl($ttl); $params = ($ttl <= 0) ? [$key, $value] : [$key, $value, $ttl]; return $this->call('set', $params); }
php
{ "resource": "" }
q259829
Redis.getMultiple
test
public function getMultiple($keys, $default = null) { $mgetResult = $this->call('mget', [$keys]); if ($mgetResult === false) { return $default; } $result = []; foreach ($mgetResult ?? [] as $key => $value) { $result[$keys[$key]] = $value; } return $result; }
php
{ "resource": "" }
q259830
Redis.setMultiple
test
public function setMultiple($values, $ttl = null): bool { $result = $this->call('mset', [$values]); return $result; }
php
{ "resource": "" }
q259831
Redis.call
test
public function call(string $method, array $params) { /* @var PoolInterface $connectPool */ $connectPool = App::getPool($this->poolName); /* @var ConnectionInterface $client */ $connection = $connectPool->getConnection(); $result = $connection->$method(...$params); $connection->release(true); return $result; }
php
{ "resource": "" }
q259832
RedisAspect.before
test
public function before(JoinPoint $joinPoint) { $profileKey = $this->getProfileKey($joinPoint); Log::profileStart($profileKey); }
php
{ "resource": "" }
q259833
RedisAspect.afterReturning
test
public function afterReturning(JoinPoint $joinPoint) { $profileKey = $this->getProfileKey($joinPoint); Log::profileEnd($profileKey); return $joinPoint->getReturn(); }
php
{ "resource": "" }
q259834
RedisAspect.getProfileKey
test
private function getProfileKey(JoinPoint $joinPoint) { $method = $joinPoint->getMethod(); if ($method == '__call') { list($method) = $joinPoint->getArgs(); } return self::PROFILE_PREFIX . '.' . $method; }
php
{ "resource": "" }
q259835
PrefixProcessor.all
test
public static function all(CommandInterface $command, $prefix) { if ($arguments = $command->getArguments()) { foreach ($arguments as &$key) { $key = "$prefix$key"; } $arguments = [$arguments]; $command->setRawArguments($arguments); } }
php
{ "resource": "" }
q259836
PrefixProcessor.interleaved
test
public static function interleaved(CommandInterface $command, $prefix) { if ($arguments = $command->getArguments()) { $newArguments = []; foreach ($arguments as $key => $value) { $newKey = "{$prefix}{$key}"; $newArguments[$newKey] = $value; } $arguments = [$newArguments]; $command->setRawArguments($arguments); } }
php
{ "resource": "" }
q259837
PrefixProcessor.evalKeys
test
public static function evalKeys(CommandInterface $command, $prefix) { if ($arguments = $command->getArguments()) { $command->setRawArguments($arguments); } }
php
{ "resource": "" }
q259838
Token.setExpires
test
protected function setExpires() { $created = $this->created; if ($this->lifetime === null) { $this->lifetime = self::DEFAULT_LIFETIME; } $this->expires = $created->modify($this->lifetime); }
php
{ "resource": "" }
q259839
RandomBytesAdapter.setLength
test
protected function setLength($length) { if ($length === null) { $length = self::DEFAULT_LENGTH; } $this->length = $length; }
php
{ "resource": "" }
q259840
OrientDBSocket.read
test
public function read($length = null) { $data = fread($this->socket, $length === null ? $this->bufferLen : $length); if ($this->debug) { OrientDBHelpers::hexDump($data); } return $data; }
php
{ "resource": "" }
q259841
OrientDBSocket.send
test
public function send($data) { fwrite($this->socket, $data); if ($this->debug) { OrientDBHelpers::hexDump($data); } }
php
{ "resource": "" }
q259842
OrientDB.canExecute
test
protected function canExecute($command) { if (!$this->active) { throw new OrientDBWrongCommandException('DBClose was executed. No interaction is possible.'); } if (in_array($command->opType, $this->getCommandsRequiresConnect()) && !$this->isConnected()) { throw new OrientDBWrongCommandException('Not connected to server'); } if (in_array($command->opType, $this->getCommandsRequiresDBOpen()) && !$this->isDBOpen()) { throw new OrientDBWrongCommandException('Database not open'); } }
php
{ "resource": "" }
q259843
OrientDB.setProtocolVersion
test
public function setProtocolVersion($version) { $this->protocolVersion = $version; if ($this->protocolVersion < $this->clientVersion) { throw new OrientDBException('Binary protocol is uncompatible with the Server connected: clientVersion=' . $this->clientVersion . ', serverVersion=' . $this->protocolVersion); } }
php
{ "resource": "" }
q259844
OrientDBRecordEncoder.process
test
protected function process($data, $isAssoc = true, $isArray = false) { $tokens = array(); foreach ($data as $key => $value) { $buffer = ''; if ($isAssoc) { if ($isArray) { $buffer = self::encodeString($key) . ':'; } else { $buffer = $key . ':'; } } /** * * PHP manual says what gettype() is slow and we should use is_* functions instead. But tests says that its approx. 5-10% faster encoding using single gettype() call instead of separate calls to is_int(), is_string(), etc. * @var string */ $valueType = gettype($value); switch ($valueType) { case 'integer': $buffer .= $value; break; case 'double': $buffer .= $value . chr(OrientDBRecordDecoder::CCODE_NUM_FLOAT); break; case 'string': $buffer .= self::encodeString($value); break; case 'boolean': if ($value === true) { $buffer .= 'true'; } else { $buffer .= 'false'; } break; case 'array': $arrayAssoc = self::isAssoc($value); if ($arrayAssoc === true) { // This is assoc array, using map $boundStart = chr(OrientDBRecordDecoder::CCODE_OPEN_CURLY); $boundEnd = chr(OrientDBRecordDecoder::CCODE_CLOSE_CURLY); } else { // Array will always be encoded as a set, as 1) Orient itself converts set to list (and vice-versa too) 2) PHP lacks build-in set type $boundStart = chr(OrientDBRecordDecoder::CCODE_OPEN_SQUARE); $boundEnd = chr(OrientDBRecordDecoder::CCODE_CLOSE_SQUARE); } $buffer .= $boundStart; /** * @TODO Fix possible PHP fatal: Maximum function nesting level of '100' reached, aborting! */ $buffer .= implode(',', $this->process($value, $arrayAssoc, true)); $buffer .= $boundEnd; break; case 'NULL': break; case is_a($value, 'OrientDBTypeLink'): /** @var $value OrientDBTypeLink */ $buffer .= $value->getHash(); break; case is_a($value, 'OrientDBTypeDate'): $buffer .= (string) $value; break; case is_a($value, 'OrientDBRecord'): $buffer .= chr(OrientDBRecordDecoder::CCODE_OPEN_PARENTHESES); /** @var $value OrientDBRecord */ $buffer .= $value->__toString(); $buffer .= chr(OrientDBRecordDecoder::CCODE_CLOSE_PARENTHESES); break; default: throw new OrientDBException('Can\'t serialize: ' . $valueType); } $tokens[] = $buffer; } return $tokens; }
php
{ "resource": "" }
q259845
OrientDBRecordDecoder.stackGetLastKey
test
protected function stackGetLastKey() { $depth = false; for ($i = count($this->stackTT) - 1; $i >= 0; $i--) { if ($this->stackTT[$i] === self::TTYPE_NAME) { $depth = $i; break; } } if ($depth !== false) { return $this->stackTV[$depth]; } return null; }
php
{ "resource": "" }
q259846
OrientDBCommandAbstract.prepare
test
public function prepare() { $this->addByte(chr($this->opType)); if ($this->opType === self::DB_OPEN || $this->opType === self::CONNECT) { $this->currentTransactionID = -(++self::$transactionID); } else { if (in_array($this->opType, $this->parent->getCommandsRequiresConnect())) { $this->currentTransactionID = $this->parent->getSessionIDServer(); } elseif (in_array($this->opType, $this->parent->getCommandsRequiresDBOpen())) { $this->currentTransactionID = $this->parent->getSessionIDDB(); } else { throw new OrientDBWrongCommandException('Unknown command'); } } $this->addInt($this->currentTransactionID); }
php
{ "resource": "" }
q259847
OrientDBCommandAbstract.execute
test
public function execute() { $this->socket->debug = $this->debug; $this->socket->send($this->requestBytes); if (is_null($this->parent->protocolVersion)) { $this->debugCommand('protocol_version'); $serverProtocolVersion = $this->readShort(); $this->parent->setProtocolVersion($serverProtocolVersion); } if ($this->opType == self::DB_CLOSE) { // No incoming bytes return null; } $this->debugCommand('request_status'); $this->requestStatus = $this->readByte(); $this->debugCommand('TransactionID'); $requestTransactionID = $this->readInt(); if ($requestTransactionID !== $this->currentTransactionID) { throw new OrientDBException('Transaction ID mismatch'); } if ($this->requestStatus === chr(OrientDBCommandAbstract::STATUS_SUCCESS)) { $data = $this->parseResponse(); if ($this->opType === self::DB_OPEN) { $this->parent->setSessionIDDB($this->sessionID); } elseif ($this->opType === self::CONNECT) { $this->parent->setSessionIDServer($this->sessionID); } return $data; } elseif ($this->requestStatus === chr(OrientDBCommandAbstract::STATUS_ERROR)) { $exception = null; while ($this->readByte() === chr(OrientDBCommandAbstract::STATUS_ERROR)) { $this->debugCommand('exception_javaclass'); $javaException = $this->readString(); $this->debugCommand('exception_message'); $javaExceptionDescr = $this->readString(); $exception = new OrientDBException($javaException . ': ' . $javaExceptionDescr, 0, is_null($exception) ? null : $exception); } throw $exception; } else { throw new OrientDBException('Unknown error'); } }
php
{ "resource": "" }
q259848
OrientDBCommandAbstract.readRaw
test
protected function readRaw($length) { $data = ''; $dataLeft = $length; do { $data .= $this->socket->read($dataLeft); $dataLeft = $length - strlen($data); } while ($dataLeft > 0); return $data; }
php
{ "resource": "" }
q259849
OrientDBCommandAbstract.readLong
test
protected function readLong() { // First of all, read 8 bytes, divided into hi and low parts $hi = unpack('N', $this->readRaw(4)); $hi = reset($hi); $low = unpack('N', $this->readRaw(4)); $low = reset($low); // Unpack 64-bit signed long return self::unpackI64($hi, $low); }
php
{ "resource": "" }
q259850
OrientDBCommandAbstract.readString
test
protected function readString() { $size = $this->readInt(); if ($size === -1) { return null; } if ($size === 0) { return ''; } return $this->readRaw($size); }
php
{ "resource": "" }
q259851
OrientDBCommandAbstract.readBytes
test
protected function readBytes() { $size = $this->readInt(); if ($size === -1) { return null; } if ($size === 0) { return ''; } return $this->readRaw($size); }
php
{ "resource": "" }
q259852
OrientDBCommandAbstract.readRecord
test
protected function readRecord() { $this->debugCommand('record_marker'); $marker = $this->readShort(); /** * @see enterprise/src/main/java/com/orientechnologies/orient/enterprise/channel/binary/OChannelBinaryProtocol.java */ // -2=no record if ($marker == -2) { // no record return false; } // -3=Only recordID if ($marker == -3) { // only recordID $this->debugCommand('record_clusterID'); $clusterID = $this->readShort(); $this->debugCommand('record_position'); $recordPos = $this->readLong(); return new OrientDBTypeLink($clusterID, $recordPos); } $record = new OrientDBRecord(); $this->debugCommand('record_type'); $record->type = $this->readByte(); $this->debugCommand('record_clusterID'); $record->clusterID = $this->readShort(); $this->debugCommand('record_position'); $record->recordPos = $this->readLong(); $this->debugCommand('record_version'); $record->version = $this->readInt(); $this->debugCommand('record_content'); $record->content = $this->readBytes(); return $record; }
php
{ "resource": "" }
q259853
OrientDBCommandAbstract.addBytes
test
protected function addBytes($string) { if ($string instanceof OrientDBRecord) { $string = (string) $string; } $this->addInt(strlen($string)); $this->requestBytes .= $string; }
php
{ "resource": "" }
q259854
OrientDBCommandAbstract.unpackI64
test
public static function unpackI64($hi, $low) { // Packing is: // OrientDBHelpers::hexDump(pack('NN', $int >> 32, $int & 0xFFFFFFFF)); // If x64 system, just shift hi bytes to the left, add low bytes. Piece of cake. if (PHP_INT_SIZE === 8) { return ($hi << 32) + $low; } // x32 // Check if long could fit into int $hiComplement = self::convertComplementInt($hi); if ($hiComplement === 0) { // Hi part is 0, low will fit in x32 int return $low; } elseif ($hiComplement === -1) { // Hi part is negative, so we just can convert low part if ($low >= 0x80000000) { // Check if low part is lesser than minimum 32 bit signed integer return self::convertComplementInt($low); } } // x32 string with bc_match // Check if module is available if (!extension_loaded('bcmath')) { throw new OrientDBException('Required bcmath module to continue'); } // Sign char $sign = ''; $lastBit = 0; // This is negative number if ($hiComplement < 0) { $hi = ~$hi; $low = ~$low; $lastBit = 1; $sign = '-'; } // Format bytes properly $hi = sprintf('%u', $hi); $low = sprintf('%u', $low); // Do math $temp = bcmul($hi, '4294967296'); $temp = bcadd($low, $temp); $temp = bcadd($temp, $lastBit); return $sign . $temp; }
php
{ "resource": "" }
q259855
OrientDBRecord.resetData
test
public function resetData() { $this->data = new OrientDBData($this); $this->content = null; $this->isParsed = true; $this->recordPos = null; $this->recordID = null; $this->version = null; }
php
{ "resource": "" }
q259856
ComponentImplementation.getProps
test
public function getProps() { $sortedChildFusionKeys = $this->sortNestedFusionKeys(); $props = []; foreach ($sortedChildFusionKeys as $key) { try { $props[$key] = $this->fusionValue($key); } catch (\Exception $e) { $props[$key] = $this->runtime->handleRenderingException($this->path . '/' . $key, $e); } } return $props; }
php
{ "resource": "" }
q259857
ComponentImplementation.renderComponent
test
public function renderComponent(array $props) { $context = $this->runtime->getCurrentContext(); $context['props'] = $props; $this->runtime->pushContextArray($context); $result = $this->runtime->render($this->path . '/renderer'); $this->runtime->popContext(); return $result; }
php
{ "resource": "" }
q259858
AtomicFusionHelper.classNames
test
public function classNames(...$arguments) { $classNames = []; foreach ($arguments as $argument) { if ((bool)$argument === true) { if (is_array($argument)) { $keys = array_keys($argument); $isAssoc = array_keys($keys) !== $keys; if ($isAssoc) { foreach ($argument as $className => $condition) { if ((bool)$condition === true) { $classNames[] = (string)$className; } } } else { foreach ($argument as $className) { if (is_scalar($className) && !!is_bool($condition) && (bool)$className === true) { $classNames[] = (string)$className; } } } } elseif (is_scalar($argument) && !is_bool($argument)) { $classNames[] = (string)$argument; } } } return implode(' ', $classNames); }
php
{ "resource": "" }
q259859
Client.getIdealIssuers
test
public function getIdealIssuers() { try { $response = $this->getHttpClient() ->method(Http::GET) ->uri($this->baseUrl . 'ideal/issuers/') ->send(); if ($response->hasErrors()) { throw new \Exception($response->raw_body, $response->code); } return Issuers::fromArray($response->body); } catch (\Exception $exception) { throw new ClientException( 'An error occurred while processing the request: '.$exception->getMessage(), $exception->getCode(), $exception ); } }
php
{ "resource": "" }
q259860
Client.getAllowedProducts
test
public function getAllowedProducts() { try { $response = $this->getHttpClient() ->method(Http::GET) ->uri($this->baseUrl . 'merchants/self/projects/self/') ->send(); if ($response->hasErrors()) { throw new \Exception($response->raw_body, $response->code); } return $this->processProducts($response->body); } catch (\Exception $exception) { return []; } }
php
{ "resource": "" }
q259861
Client.processProducts
test
private function processProducts($details) { $result = array(); if (!array_key_exists('permissions', $details)) { return $result; } $products_to_check = array( 'ideal' => 'ideal', 'bank-transfer' => 'banktransfer', 'bancontact' => 'bancontact', 'cash-on-delivery' => 'cashondelivery', 'credit-card' => 'creditcard', 'paypal' => 'paypal', 'homepay' => 'homepay', 'klarna' => 'klarna', 'sofort' => 'sofort', 'payconiq' => 'payconiq', 'afterpay' => 'afterpay' ); foreach ($products_to_check as $permission_id => $id) { if (array_key_exists('/payment-methods/'.$permission_id.'/', $details['permissions']) && array_key_exists('POST', $details['permissions']['/payment-methods/'.$permission_id.'/']) && $details['permissions']['/payment-methods/'.$permission_id.'/']['POST'] ) { $result[] = $id; } } return $result; }
php
{ "resource": "" }
q259862
Client.createIdealOrder
test
public function createIdealOrder( $amount, $currency, $issuerId, $description = null, $merchantOrderId = null, $returnUrl = null, $expirationPeriod = null, $customer = null, $extra = null, $webhookUrl = null ) { return $this->postOrder( Order::createWithIdeal( $amount, $currency, $issuerId, $description, $merchantOrderId, $returnUrl, $expirationPeriod, $customer, $extra, $webhookUrl ) ); }
php
{ "resource": "" }
q259863
Client.createSepaOrder
test
public function createSepaOrder( $amount, $currency, array $paymentMethodDetails = [], $description = null, $merchantOrderId = null, $returnUrl = null, $expirationPeriod = null, $customer = null, $extra = null, $webhookUrl = null ) { return $this->postOrder( Order::createWithSepa( $amount, $currency, $paymentMethodDetails, $description, $merchantOrderId, $returnUrl, $expirationPeriod, $customer, $extra, $webhookUrl ) ); }
php
{ "resource": "" }
q259864
Client.createSofortOrder
test
public function createSofortOrder( $amount, $currency, array $paymentMethodDetails = [], $description = null, $merchantOrderId = null, $returnUrl = null, $expirationPeriod = null, $customer = null, $extra = null, $webhookUrl = null ) { return $this->postOrder( Order::createWithSofort( $amount, $currency, $paymentMethodDetails, $description, $merchantOrderId, $returnUrl, $expirationPeriod, $customer, $extra, $webhookUrl ) ); }
php
{ "resource": "" }
q259865
Client.createPayconicOrder
test
public function createPayconicOrder( $amount, $currency, array $paymentMethodDetails = [], $description = null, $merchantOrderId = null, $returnUrl = null, $expirationPeriod = null, $customer = null, $extra = null, $webhookUrl = null ) { return $this->postOrder( Order::createWithPayconiq( $amount, $currency, $paymentMethodDetails, $description, $merchantOrderId, $returnUrl, $expirationPeriod, $customer, $extra, $webhookUrl ) ); }
php
{ "resource": "" }
q259866
Client.createCreditCardOrder
test
public function createCreditCardOrder( $amount, $currency, $description = null, $merchantOrderId = null, $returnUrl = null, $expirationPeriod = null, $customer = null, $extra = null, $webhookUrl = null ) { return $this->postOrder( Order::createWithCreditCard( $amount, $currency, $description, $merchantOrderId, $returnUrl, $expirationPeriod, $customer, $extra, $webhookUrl ) ); }
php
{ "resource": "" }
q259867
Client.createBancontactOrder
test
public function createBancontactOrder( $amount, $currency, $description = null, $merchantOrderId = null, $returnUrl = null, $expirationPeriod = null, $customer = null, $extra = null, $webhookUrl = null ) { return $this->postOrder( Order::createWithBancontact( $amount, $currency, $description, $merchantOrderId, $returnUrl, $expirationPeriod, $customer, $extra, $webhookUrl ) ); }
php
{ "resource": "" }
q259868
Client.createCashOnDeliveryOrder
test
public function createCashOnDeliveryOrder( $amount, $currency, array $paymentMethodDetails = [], $description = null, $merchantOrderId = null, $returnUrl = null, $expirationPeriod = null, $customer = null, $extra = null, $webhookUrl = null ) { return $this->postOrder( Order::createWithCod( $amount, $currency, $paymentMethodDetails, $description, $merchantOrderId, $returnUrl, $expirationPeriod, $customer, $extra, $webhookUrl ) ); }
php
{ "resource": "" }
q259869
Client.createKlarnaOrder
test
public function createKlarnaOrder( $amount, $currency, $description = null, $merchantOrderId = null, $returnUrl = null, $expirationPeriod = null, $customer = null, $extra = null, $webhookUrl = null, $orderLines = null ) { return $this->postOrder( Order::createWithKlarna( $amount, $currency, $description, $merchantOrderId, $returnUrl, $expirationPeriod, $customer, $extra, $webhookUrl, $orderLines ) ); }
php
{ "resource": "" }
q259870
Client.createPaypalOrder
test
public function createPaypalOrder( $amount, $currency, array $paymentMethodDetails = [], $description = null, $merchantOrderId = null, $returnUrl = null, $expirationPeriod = null, $customer = null, $extra = null, $webhookUrl = null ) { return $this->postOrder( Order::createWithPaypal( $amount, $currency, $paymentMethodDetails, $description, $merchantOrderId, $returnUrl, $expirationPeriod, $customer, $extra, $webhookUrl ) ); }
php
{ "resource": "" }
q259871
Client.createHomepayOrder
test
public function createHomepayOrder( $amount, $currency, array $paymentMethodDetails = [], $description = null, $merchantOrderId = null, $returnUrl = null, $expirationPeriod = null, $customer = null, $extra = null, $webhookUrl = null ) { return $this->postOrder( Order::createWithHomepay( $amount, $currency, $paymentMethodDetails, $description, $merchantOrderId, $returnUrl, $expirationPeriod, $customer, $extra, $webhookUrl ) ); }
php
{ "resource": "" }
q259872
Client.createAfterPayOrder
test
public function createAfterPayOrder( $amount, $currency, $description = null, $merchantOrderId = null, $returnUrl = null, $expirationPeriod = null, $customer = null, $extra = null, $webhookUrl = null, $orderLines = null ) { return $this->postOrder( Order::createWithAfterPay( $amount, $currency, $description, $merchantOrderId, $returnUrl, $expirationPeriod, $customer, $extra, $webhookUrl, $orderLines ) ); }
php
{ "resource": "" }
q259873
Client.createOrder
test
public function createOrder( $amount, $currency, $paymentMethod, array $paymentMethodDetails = [], $description = null, $merchantOrderId = null, $returnUrl = null, $expirationPeriod = null, $customer = null, $extra = null, $webhookUrl = null ) { return $this->postOrder( Order::create( $amount, $currency, $paymentMethod, $paymentMethodDetails, $description, $merchantOrderId, $returnUrl, $expirationPeriod, $customer, $extra, $webhookUrl ) ); }
php
{ "resource": "" }
q259874
Client.getOrder
test
public function getOrder($id) { try { $response = $this->getHttpClient() ->method(Http::GET) ->uri($this->baseUrl . 'orders/' . $id . '/') ->send(); if ($response->hasErrors()) { throw new \Exception($response->raw_body, $response->code); } return Order::fromArray($response->body); } catch (\Exception $exception) { if ($exception->getCode() == 404) { throw new OrderNotFoundException('No order with that ID was found.', 404, $exception); } throw new ClientException( 'An error occurred while getting the order: '.$exception->getMessage(), $exception->getCode(), $exception ); } }
php
{ "resource": "" }
q259875
Client.postOrder
test
private function postOrder(Order $order) { try { $response = $this->getHttpClient() ->method(Http::POST) ->uri($this->baseUrl . 'orders/') ->timeout(30) ->sends(Mime::JSON) ->body(ArrayFunctions::withoutNullValues($order->toArray())) ->send(); if ($response->hasErrors()) { throw new \Exception($response->raw_body, $response->code); } return Order::fromArray($response->body); } catch (\Exception $exception) { throw new ClientException( 'An error occurred while posting the order: '.$exception->getMessage(), $exception->getCode(), $exception ); } }
php
{ "resource": "" }
q259876
Client.setOrderCapturedStatus
test
public function setOrderCapturedStatus(Order $order) { try { $transactionId = $order->transactions()->current()->id()->toString(); $response = $this->getHttpClient() ->method(Http::POST) ->uri($this->baseUrl . 'orders/' . $order->id() . '/transactions/'. $transactionId . '/captures/') ->timeout(30) ->sends(Mime::JSON) ->send(); if ($response->hasErrors()) { throw new \Exception($response->raw_body, $response->code); } return Transaction::fromArray($response->body); } catch (\Exception $exception) { if ($exception->getCode() == 404) { throw new OrderNotFoundException('No order with that ID was found.', 404, $exception); } throw new ClientException( 'An error occurred while updating the order: '.$exception->getMessage(), $exception->getCode(), $exception ); } }
php
{ "resource": "" }
q259877
Order.createWithIdeal
test
public static function createWithIdeal( $amount, $currency, $issuerId, $description = null, $merchantOrderId = null, $returnUrl = null, $expirationPeriod = null, $customer = null, $extra = null, $webhookUrl = null ) { return static::create( $amount, $currency, PaymentMethod::IDEAL, ['issuer_id' => $issuerId], $description, $merchantOrderId, $returnUrl, $expirationPeriod, $customer, $extra, $webhookUrl ); }
php
{ "resource": "" }
q259878
Order.createWithCreditCard
test
public static function createWithCreditCard( $amount, $currency, $description = null, $merchantOrderId = null, $returnUrl = null, $expirationPeriod = null, $customer = null, $extra = null, $webhookUrl = null ) { return static::create( $amount, $currency, PaymentMethod::CREDIT_CARD, [], $description, $merchantOrderId, $returnUrl, $expirationPeriod, $customer, $extra, $webhookUrl ); }
php
{ "resource": "" }
q259879
Order.createWithSepa
test
public static function createWithSepa( $amount, $currency, array $paymentMethodDetails = [], $description = null, $merchantOrderId = null, $returnUrl = null, $expirationPeriod = null, $customer = null, $extra = null, $webhookUrl = null ) { return static::create( $amount, $currency, PaymentMethod::BANK_TRANSFER, $paymentMethodDetails, $description, $merchantOrderId, $returnUrl, $expirationPeriod, $customer, $extra, $webhookUrl ); }
php
{ "resource": "" }
q259880
Order.createWithSofort
test
public static function createWithSofort( $amount, $currency, array $paymentMethodDetails = [], $description = null, $merchantOrderId = null, $returnUrl = null, $expirationPeriod = null, $customer = null, $extra = null, $webhookUrl = null ) { return static::create( $amount, $currency, PaymentMethod::SOFORT, $paymentMethodDetails, $description, $merchantOrderId, $returnUrl, $expirationPeriod, $customer, $extra, $webhookUrl ); }
php
{ "resource": "" }
q259881
Order.createWithBancontact
test
public static function createWithBancontact( $amount, $currency, $description = null, $merchantOrderId = null, $returnUrl = null, $expirationPeriod = null, $customer = null, $extra = null, $webhookUrl = null ) { return static::create( $amount, $currency, PaymentMethod::BANCONTACT, [], $description, $merchantOrderId, $returnUrl, $expirationPeriod, $customer, $extra, $webhookUrl ); }
php
{ "resource": "" }
q259882
Order.createWithPaypal
test
public static function createWithPaypal( $amount, $currency, array $paymentMethodDetails = [], $description = null, $merchantOrderId = null, $returnUrl = null, $expirationPeriod = null, $customer = null, $extra = null, $webhookUrl = null ) { return static::create( $amount, $currency, PaymentMethod::PAYPAL, $paymentMethodDetails, $description, $merchantOrderId, $returnUrl, $expirationPeriod, $customer, $extra, $webhookUrl ); }
php
{ "resource": "" }
q259883
Order.createWithHomepay
test
public static function createWithHomepay( $amount, $currency, array $paymentMethodDetails = [], $description = null, $merchantOrderId = null, $returnUrl = null, $expirationPeriod = null, $customer = null, $extra = null, $webhookUrl = null ) { return static::create( $amount, $currency, PaymentMethod::HOMEPAY, $paymentMethodDetails, $description, $merchantOrderId, $returnUrl, $expirationPeriod, $customer, $extra, $webhookUrl ); }
php
{ "resource": "" }
q259884
Order.createWithPayconiq
test
public static function createWithPayconiq( $amount, $currency, array $paymentMethodDetails = [], $description = null, $merchantOrderId = null, $returnUrl = null, $expirationPeriod = null, $customer = null, $extra = null, $webhookUrl = null ) { return static::create( $amount, $currency, PaymentMethod::PAYCONIQ, $paymentMethodDetails, $description, $merchantOrderId, $returnUrl, $expirationPeriod, $customer, $extra, $webhookUrl ); }
php
{ "resource": "" }
q259885
Order.create
test
public static function create( $amount, $currency, $paymentMethod, array $paymentMethodDetails = [], $description = null, $merchantOrderId = null, $returnUrl = null, $expirationPeriod = null, $customer = null, $extra = null, $webhookUrl = null, $orderLines = null ) { return new static( Transactions::fromArray( [ [ 'payment_method' => $paymentMethod, 'payment_method_details' => $paymentMethodDetails ] ] ), Amount::fromInteger($amount), Currency::fromString($currency), ($description !== null) ? Description::fromString($description) : null, ($merchantOrderId !== null) ? MerchantOrderId::fromString($merchantOrderId) : null, ($returnUrl !== null) ? Url::fromString($returnUrl) : null, ($expirationPeriod !== null) ? new \DateInterval($expirationPeriod) : null, null, null, null, null, null, null, ($customer !== null) ? Customer::fromArray($customer) : null, ($extra !== null) ? Extra::fromArray($extra) : null, ($webhookUrl !== null) ? Url::fromString($webhookUrl) : null, ($orderLines !== null) ? OrderLines::fromArray($orderLines) : null ); }
php
{ "resource": "" }
q259886
ArrayFunctions.withoutNullValues
test
public static function withoutNullValues(array $array) { static $fn = __FUNCTION__; foreach ($array as $key => $value) { if (is_array($value)) { $array[$key] = self::$fn($array[$key]); } if (empty($array[$key]) && $array[$key] !== '0' && $array[$key] !== 0) { unset($array[$key]); } } return $array; }
php
{ "resource": "" }
q259887
Ginger.createClient
test
public static function createClient($apiKey, $product = null) { Guard::uuid( static::apiKeyToUuid($apiKey), 'ING API key is invalid: '.$apiKey ); if (!static::validPHPVersion()) { throw new \Exception('Minimum required PHP version must be '.MIN_PHP_VERSION.' or above.'); } return new Client( strtr( static::getEndpoint($product), ['{version}' => self::API_VERSION] ), Request::init() ->authenticateWith($apiKey, '') ->addHeaders([ 'User-Agent' => 'ing-php/'.self::CLIENT_VERSION, 'X-PHP-Version' => PHP_VERSION ]) ); }
php
{ "resource": "" }
q259888
Ginger.getEndpoint
test
public static function getEndpoint($product) { switch ($product) { case 'kassacompleet': return (new Client\EndpointResolver())->getEndpointKassa(); case 'ingcheckout': return (new Client\EndpointResolver())->getEndpointIng(); case 'epay': return (new Client\EndpointResolver())->getEndpointEpay(); default: return (new Client\EndpointResolver())->getEndpointGinger(); } }
php
{ "resource": "" }
q259889
ISO3166.isValid
test
public static function isValid($value) { try { $ISO3166 = new Alcohol\ISO3166(); $ISO3166->getByAlpha2($value); return true; } catch (\DomainException $e) { return false; } }
php
{ "resource": "" }
q259890
PaymentRequestBodyBuilder.build
test
public function build($intent, $payer, $urls, $transactions, $returnArray = false) { $this->assertIntent($intent); $this->intent = $intent; $requestBody = array(); $requestBody['intent'] = $this->intent; $requestBody['payer'] = $this->payerBuilder->buildArray($payer); $requestBody['transactions'] = $this->transactionsBuilder->buildArray($transactions); $requestBody['redirect_urls'] = $this->urlsBuilder->buildArray($urls); if ($returnArray) { return $requestBody; } return json_encode($requestBody); }
php
{ "resource": "" }
q259891
PaymentService.execute
test
public function execute( AccessToken $accessToken, Payment $payment, $payerId ) { $request = $this->client->createRequest( 'POST', $payment->getExecuteUrl(), array( 'Accept' => 'application/json', 'Accept-Language' => 'en_US', 'Authorization' => $accessToken->getTokenType().' '.$accessToken->getAccessToken(), 'Content-Type' => 'application/json' ), '{"payer_id":"'.$payerId.'"}', array( 'debug' => $this->debug ) ); $response = $this->send($request, 200, "Payment error:"); $data = json_decode($response->getBody(), true); if ('authorize' === $data['intent']) { $authorizationBuilder = new PaymentAuthorizationBuilder(); $authorization = $authorizationBuilder->build($data); return $authorization; } $paymentBuilder = new PaymentBuilder(); $payment = $paymentBuilder->build($data); return $payment; }
php
{ "resource": "" }
q259892
PaymentService.capture
test
public function capture(AccessToken $accessToken, PaymentAuthorizationInterface $paymentAuthorization, $isFinalCapture = true) { $amount = $paymentAuthorization->getAmount(); $data = array( 'amount' => array( 'total' => $amount->getTotal(), 'currency' => $amount->getCurrency() ), 'is_final_capture' => $isFinalCapture ); $request = $this->client->createRequest( 'POST', $paymentAuthorization->getCaptureUrl(), array( 'Accept' => 'application/json', 'Accept-Language' => 'en_US', 'Authorization' => $accessToken->getTokenType().' '.$accessToken->getAccessToken(), 'Content-Type' => 'application/json' ), json_encode($data), array( 'debug' => $this->debug ) ); $response = $this->send($request, 200, "Payment error:"); $data = json_decode($response->getBody(), true); $captureBuilder = new CaptureBuilder(); $capture = $captureBuilder->build($data); return $capture; }
php
{ "resource": "" }
q259893
PaymentService.authorize
test
public function authorize( AccessToken $accessToken, $payer, $urls, $transactions ) { $requestBody = $this->paymentRequestBodyBuilder->build( 'authorize', $payer, $urls, $transactions ); $this->assertReqeustJsonSchema($requestBody); $request = $this->buildRequest($accessToken, $requestBody); $response = $this->send($request, 201, "Payment error:"); $data = json_decode($response->getBody(), true); $authorizationBuilder = new PaymentAuthorizationBuilder(); $authorization = $authorizationBuilder->build($data); return $authorization; }
php
{ "resource": "" }
q259894
PaymentService.create
test
public function create( AccessToken $accessToken, $payer, $urls, $transactions ) { $requestBody = $this->paymentRequestBodyBuilder->build( 'sale', $payer, $urls, $transactions ); $this->assertReqeustJsonSchema($requestBody); $request = $this->buildRequest($accessToken, $requestBody); $response = $this->send($request, 201, "Payment error:"); $data = json_decode($response->getBody(), true); $paymentBuilder = new PaymentBuilder(); $payment = $paymentBuilder->build($data); return $payment; }
php
{ "resource": "" }
q259895
AccessTokenRepository.getAccessToken
test
public function getAccessToken($clientId, $secret) { $request = $this->client->createRequest( 'POST', $this->baseUrl.'/v1/oauth2/token', array( 'Accept' => 'application/json', 'Accept-Language' => 'en_US', 'Content-Type' => 'application/x-www-form-urlencoded' ), 'grant_type=client_credentials', array( 'auth' => array($clientId, $secret), 'debug' => $this->debug ) ); $response = $this->send($request, $acceptedStatusCode = 200, 'Error requesting token:'); $data = json_decode($response->getBody(), true); $builder = new AccessTokenBuilder(); return $builder->build($data); }
php
{ "resource": "" }
q259896
LinkBuilder.build
test
public function build(array $data) { $this->validateArrayKeys( array('href', 'rel', 'method'), $data ); $link = new Link( $data['href'], $data['rel'], $data['method'] ); return $link; }
php
{ "resource": "" }
q259897
CaptureBuilder.build
test
public function build(array $data) { $this->validateArrayKeys( array('id', 'create_time', 'update_time', 'amount', 'is_final_capture', 'state', 'parent_payment', 'links'), $data ); $links = array(); foreach ($data['links'] as $link) { $links[] = $this->linkBuilder->build($link); } $capture = new Capture( $data['id'], $data['create_time'], $data['update_time'], $this->amountBuilder->build($data['amount']), $data['is_final_capture'], $data['state'], $data['parent_payment'], $links ); $capture->setPaypalData($data); return $capture; }
php
{ "resource": "" }
q259898
AmountBuilder.build
test
public function build(array $data) { $this->validateArrayKeys( array('currency', 'total'), $data ); $details = array(); if (isset($data['details'])) { $details = $data['details']; } $amount = new Amount( $data['currency'], $data['total'], $details ); return $amount; }
php
{ "resource": "" }
q259899
UrlsBuilder.buildArray
test
public function buildArray($urls) { if ( ($urls instanceof \ArrayAccess || is_array($urls)) && (isset($urls['return_url']) && isset($urls['cancel_url'])) ) { return array( 'return_url' => $urls['return_url'], 'cancel_url' => $urls['cancel_url'] ); } throw new BuilderException("urls array is not valid: return_url and cancel_url are mandatory"); }
php
{ "resource": "" }