_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
83
13k
language
stringclasses
1 value
meta_information
dict
q264400
MenuItem.getAdditionalStylesByType
test
public function getAdditionalStylesByType($type) { $return = array(); if($this->additionalStyles) { foreach ($this->additionalStyles as $additionalStyle) { if($additionalStyle instanceof $type) { $return[] = $additionalStyle; } } } return $return; }
php
{ "resource": "" }
q264401
MenuItem.getLink
test
public function getLink() { if ($this->url === null) { return null; } $link = $this->getLinkWithoutParams(); $params = array(); // First, get the list of all parameters to be propagated if (is_array($this->propagatedUrlParameters)) { foreach ($this->propagatedUrlParameters as $parameter) { if (isset($_REQUEST[$parameter])) { $params[$parameter] = \get($parameter); } } } if (!empty($params)) { if (strpos($link, "?") === FALSE) { $link .= "?"; } else { $link .= "&"; } $paramsAsStrArray = array(); foreach ($params as $key=>$value) { $paramsAsStrArray[] = urlencode($key).'='.urlencode($value); } $link .= implode("&", $paramsAsStrArray); } return $link; }
php
{ "resource": "" }
q264402
ObjectToArray.convert
test
public function convert($data) { if (is_object($data)) { $data = get_object_vars($data); } if (is_array($data)) { return array_map(__METHOD__, $data); } else { return $data; } }
php
{ "resource": "" }
q264403
ModelAbstract.configure
test
protected function configure(string $collection, string $primaryKey = 'id', string $relationship = '') { if ($relationship) { $reference = get_parent_class($this); $call = 'construct'; if (method_exists($reference, $call)) { $reference::$call(); } } if ($this->collection) { $this->parents[$relationship] = clone $this; $this->add($relationship)->integer()->collection($collection)->update(false); if (!$relationship) { throw new SimplesRunTimeError("When extending one model you need give a name to relationship"); } } $this->collection = $collection; $this->primaryKey = $primaryKey; $this->add($this->hashKey)->hashKey(); foreach ([$this->destroyKeys, $this->createKeys, $this->updateKeys] as $keys) { foreach ($keys as $key => $name) { $this->add($name)->type($this->getTimestampType($key))->recover(false); } } $this->add($primaryKey)->primaryKey(); return $this; }
php
{ "resource": "" }
q264404
ModelAbstract.connection
test
private function connection($connection): string { $this->connection = !is_null($connection) ? $connection : env('DEFAULT_DATABASE'); if (!$this->connection) { throw new SimplesRunTimeError( "There is no `connection` to be used. Check .env file or configure the model property" ); } return $this->connection; }
php
{ "resource": "" }
q264405
ModelAbstract.import
test
protected function import(string $name, string $relationship, array $options = []): Field { $source = $this->get($relationship); $reference = $source->getReferences(); $class = off($reference, 'class'); if (!class_exists($class)) { throw new SimplesRunTimeError("Cant not import '{$name}' from '{$class}'"); } /** @var DataMapper $class */ $import = $class::instance()->get($name); $options = array_merge($import->getOptions(), $options); $from = new Field($import->getCollection(), $name, $import->getType(), $options); $this->fields[$name] = $from->from($source); return $this->fields[$name]; }
php
{ "resource": "" }
q264406
NamespaceClassnameToPath.convert
test
public function convert($string) { $parts = []; foreach (explode('\\', trim($string, '\\')) as $name) { $name = strtolower(preg_replace('/([a-z])([A-Z])/', '$1-$2', $name)); $parts[] = $name; } return implode('/', $parts); }
php
{ "resource": "" }
q264407
MysqlJob.fire
test
public function fire() { $this->record['attempts'] += 1; $this->record['status'] = 'running'; DB::table($this->table)->where('ID', $this->id)->update([ 'attempts' => $this->record['attempts'], 'status' => $this->record['status'], ]); $this->resolveAndFire(array('job' => $this->job, 'data' => $this->data)); /** * Auto delete is implemented. * However, WTF is this AUTO DELETE ??? * None of laravel builtin Job class implements it, * nor any document mentions it. */ if ($this->autoDelete()) { $this->delete(); return; } /** * Auto release if job was not explicitly deleted/released. */ if ($this->record['status'] == 'running') { $this->release(); } }
php
{ "resource": "" }
q264408
MysqlJob.delete
test
public function delete() { $this->record['status'] = 'deleted'; DB::table($this->table)->where('ID', $this->id)->update([ 'status' => $this->record['status'], ]); }
php
{ "resource": "" }
q264409
ResetableEntityManager.getClassMetadata
test
public function getClassMetadata($className) { try{ return $this->entityManager->getClassMetadata($className); } catch(ORMException $e) { if (!$this->entityManager->isOpen()) { $this->resetEntityManager(); } throw $e; } }
php
{ "resource": "" }
q264410
ResetableEntityManager.flush
test
public function flush($entity = null) { try{ return $this->entityManager->flush($entity); } catch(ORMException $e) { if (!$this->entityManager->isOpen()) { $this->resetEntityManager(); } throw $e; } }
php
{ "resource": "" }
q264411
ResetableEntityManager.find
test
public function find($entityName, $id, $lockMode = null, $lockVersion = null) { try{ return $this->entityManager->find($entityName, $id, $lockMode, $lockVersion); } catch(ORMException $e) { if (!$this->entityManager->isOpen()) { $this->resetEntityManager(); } throw $e; } }
php
{ "resource": "" }
q264412
ResetableEntityManager.clear
test
public function clear($entityName = null) { try{ return $this->entityManager->clear($entityName); } catch(ORMException $e) { if (!$this->entityManager->isOpen()) { $this->resetEntityManager(); } throw $e; } }
php
{ "resource": "" }
q264413
ResetableEntityManager.remove
test
public function remove($entity) { try{ return $this->entityManager->remove($entity); } catch(ORMException $e) { if (!$this->entityManager->isOpen()) { $this->resetEntityManager(); } throw $e; } }
php
{ "resource": "" }
q264414
ResetableEntityManager.refresh
test
public function refresh($entity) { try{ return $this->entityManager->refresh($entity); } catch(ORMException $e) { if (!$this->entityManager->isOpen()) { $this->resetEntityManager(); } throw $e; } }
php
{ "resource": "" }
q264415
ResetableEntityManager.getRepository
test
public function getRepository($entityName) { try{ return $this->entityManager->getRepository($entityName); } catch(ORMException $e) { if (!$this->entityManager->isOpen()) { $this->resetEntityManager(); } throw $e; } }
php
{ "resource": "" }
q264416
ResetableEntityManager.contains
test
public function contains($entity) { try{ return $this->entityManager->contains($entity); } catch(ORMException $e) { if (!$this->entityManager->isOpen()) { $this->resetEntityManager(); } throw $e; } }
php
{ "resource": "" }
q264417
ResetableEntityManager.create
test
public static function create($conn, Configuration $config, EventManager $eventManager = null) { try{ return self::getEntityManager()->create($conn, $config, $eventManager); } catch(ORMException $e) { if (!self::getEntityManager()->isOpen()) { self::resetEntityManager(); } throw $e; } }
php
{ "resource": "" }
q264418
WsapiServer.processXcdr
test
public function processXcdr(XcdrListenerInterface $listener, array$options = array()) { $xcdrRequest = new XcdrRequest($listener, $options); $schema = $xcdrRequest->getSchema(); ini_set("soap.wsdl_cache_enabled", "0"); $soapServer = new \SoapServer(null, array( 'uri' => $schema, 'soap_version' => SOAP_1_2, )); $soapServer->setObject($xcdrRequest); try { ob_start(); $soapServer->handle(); } catch (\Exception $e) { return array( 'status' => 'error', 'type' => 'soap_fault', 'code' => $e->getCode(), 'message' => $e->getMessage(), 'class' => get_class($this) ); } $result = $this->filterResponse(ob_get_clean(), $schema, 'xcdr'); return array( 'status' => 'success', 'result' => $result ); }
php
{ "resource": "" }
q264419
ThreeWayMerge.performMerge
test
public function performMerge(array $ancestor, array $local, array $remote) { // Returning a new Array for now. Can return the modified ancestor as well. $merged = []; foreach ($ancestor as $key => $value) { // Checks if the value contains an array itself. if (is_array($value) && array_key_exists($key, $local) && array_key_exists($key, $remote)) { $merged[$key] = $this->performMerge( $value, $local[$key], $remote[$key] ); } else { if (array_key_exists($key, $local) && array_key_exists($key, $remote)) { $merged[$key] = $this->merge( $ancestor[$key], $local[$key], $remote[$key], $key ); } elseif (array_key_exists($key, $local)) { if ($ancestor[$key] != $local[$key]) { throw new ConflictException("A conflict has occured"); } } elseif (array_key_exists($key, $remote)) { if ($ancestor[$key] != $remote[$key]) { throw new ConflictException("A conflict has occured"); } } else { unset($merged[$key]); } } } return $merged; }
php
{ "resource": "" }
q264420
ThreeWayMerge.merge
test
protected function merge($x, $y, $z, $key) { // Convert the value into array. $ancestor = (strpos($x, PHP_EOL) !== false ? explode(PHP_EOL, $x) : array($x)); $local = (strpos($y, PHP_EOL) !== false ? explode(PHP_EOL, $y) : array($y)); $remote = (strpos($z, PHP_EOL) !== false ? explode(PHP_EOL, $z) : array($z)); // Count number of lines in value or elements in new formed array. $count_ancestor = count($ancestor); $count_remote = count($remote); $count_local = count($local); // If number of lines is different in all 3 values. // For example : addition in remote and removal in local node. // // Else get the value of number of lines in updated node. // For example : Addition of 2 lines in local. // Suppose: $count_ancestor = 2 and $count_remote = 2 // then, $count_local would be 4 now. if ($count_ancestor != $count_local && $count_local!= $count_remote && $count_ancestor != $count_remote ) { $merged = $this->linesAddedRemovedAndModified( $ancestor, $local, $remote, $count_ancestor, $count_local, $count_remote ); } else { // Store the updated count value in a variable $count. if ($count_ancestor == $count_local) { $count = $count_remote; } else { $count = $count_local; } // If $count > $count_ancestor, that means lines have been added. // Otherwise, lines has been removed or modified. if ($count > $count_ancestor) { $merged = $this->linesAddedOrModified( $ancestor, $local, $remote, $count, $count_remote, $count_ancestor, $count_local ); } else { $merged = $this->linesRemovedOrModified( $ancestor, $local, $remote, $count_ancestor, $count_local, $count_remote ); } } // Convert returned array back to string. $merged[$key] = implode(PHP_EOL, $merged); return $merged[$key]; }
php
{ "resource": "" }
q264421
ThreeWayMerge.linesAddedOrModified
test
protected function linesAddedOrModified( array $ancestor, array $local, array $remote, $count, $count_remote, $count_ancestor, $count_local ) { $merged = []; $counter = 0; // For all ancestors lines, it will check local and remote // and make sure only one of them has been edited. // Otherwise, throw an Exception. foreach ($ancestor as $key => $value) { $counter = $counter + 1; if ($ancestor[$key] == $local[$key]) { $merged[$key] = $remote[$key]; } elseif ($ancestor[$key] == $remote[$key] || $local[$key] == $remote[$key]) { $merged[$key] = $local[$key]; } else { throw new ConflictException("A conflict has occured"); } } // Once done with ancestor lines, we have hunk of // lines added. We will add them as they are. // If the lines are added in both remote and local, // We will make sure they are same or throw exception. for ($i = $count_ancestor; $i < $count; $i++) { if ($count_ancestor == $count_remote) { $merged[$i] == $local[$i]; } elseif ($count_ancestor == $count_local) { $merged[$i] = $remote[$i]; } elseif ($count_local == $count_remote) { if ($local[$i] == $remote[$i]) { $merged[$i] = $local[$i]; } else { throw new ConflictException("A conflict has occured"); } } } return $merged; }
php
{ "resource": "" }
q264422
ThreeWayMerge.linesRemovedOrModified
test
protected function linesRemovedOrModified( array $ancestor, array $local, array $remote, $count_ancestor, $count_local, $count_remote ) { $merged = []; $count_array = [$count_ancestor, $count_local, $count_remote]; sort($count_array); $mincount = min($count_local, $count_ancestor, $count_remote); // First for loop compares all 3 nodes and returns updated node. for ($key = 0; $key < $mincount; $key++) { if ($ancestor[$key] == $local[$key]) { $merged[$key] = $remote[$key]; } elseif ($ancestor[$key] == $remote[$key] || $local[$key] == $remote[$key]) { $merged[$key] = $local[$key]; } else { throw new ConflictException("A conflict has occured"); } } for ($key = $mincount; $key < $count_array[1]; $key++) { if ($mincount == $count_local && $ancestor[$key] != $remote[$key]) { throw new ConflictException("A whole new conflict arised"); } elseif ($mincount == $count_remote && $ancestor[$key] != $local[$key]) { throw new ConflictException("A whole new conflict arised"); } } return $merged; }
php
{ "resource": "" }
q264423
XcdrRequest.NotifyXcdrRecord
test
public function NotifyXcdrRecord($msgHeader, $format, $type, $cdr) { $this->msgHeader = $msgHeader; $this->registrationID = $msgHeader->registrationID; $this->transactionID = $msgHeader->transactionID; $this->cdrFormat = $format; $this->cdrType = $type; $this->cdrRecord = $cdr; $response = $this->listener->processRecord($this, null); if (!$this->isValid()) return; return $response; }
php
{ "resource": "" }
q264424
WordPress_Provider.register
test
public function register( PimpleContainer $container ) { $container['wp'] = $container->factory( function() { return isset( $GLOBALS['wp'] ) ? $GLOBALS['wp'] : null; } ); $container['wpdb'] = $container->factory( function() { return isset( $GLOBALS['wpdb'] ) ? $GLOBALS['wpdb'] : null; } ); $container['wp_query'] = $container->factory( function() { return isset( $GLOBALS['wp_query'] ) ? $GLOBALS['wp_query'] : null; } ); $container['wp_rewrite'] = $container->factory( function() { return isset( $GLOBALS['wp_rewrite'] ) ? $GLOBALS['wp_rewrite'] : null; } ); $container['wp_filesystem'] = $container->factory( function() { if ( ! function_exists( 'WP_Filesystem' ) ) { require_once ABSPATH . '/wp-admin/includes/file.php'; } if ( ! isset( $GLOBALS['wp_filesystem'] ) ) { WP_Filesystem(); } return $GLOBALS['wp_filesystem']; } ); $container['wp_object_cache'] = $container->factory( function() { if ( ! isset( $GLOBALS['wp_object_cache'] ) && function_exists( 'wp_cache_init' ) ) { wp_cache_init(); } return isset( $GLOBALS['wp_object_cache'] ) ? $GLOBALS['wp_object_cache'] : null; } ); }
php
{ "resource": "" }
q264425
EnvProvider.applyConfigs
test
protected function applyConfigs(Container $app, $config) { foreach ($config as $varName => $options) { if (isset($options[self::CONFIG_KEY_DEFAULT])) { if (isset($app[$varName]) === false) { $app[$varName] = $options[self::CONFIG_KEY_DEFAULT]; } } if (isset($options[self::CONFIG_KEY_REQUIRED])) { if ($options[self::CONFIG_KEY_REQUIRED]) { \Dotenv::required($app['env.options']['prefix'].'_'.strtoupper($varName)); } } if (isset($options[self::CONFIG_KEY_ALLOWED])) { \Dotenv::required( $app['env.options']['prefix'].'_'.strtoupper($varName), $options[self::CONFIG_KEY_ALLOWED] ); } if (isset($options[self::CONFIG_KEY_CAST])) { switch ($options[self::CONFIG_KEY_CAST]) { case self::CAST_TYPE_INT: $app[$varName] = (int)$app[$varName]; break; case self::CAST_TYPE_FLOAT: $app[$varName] = (float)$app[$varName]; break; case self::CAST_TYPE_BOOLEAN: $app[$varName] = filter_var(($app[$varName]), FILTER_VALIDATE_BOOLEAN); break; default: //string break; } } } }
php
{ "resource": "" }
q264426
EnvProvider.addEnvVarsToApp
test
protected function addEnvVarsToApp(Container $app) { $hasPrefix = function ($elem) use ($app) { return strpos($elem, $app['env.options']['prefix'].'_') !== false; }; $arrayFilterKeys = function ($input, $callback) { if (!is_array($input)) { trigger_error( 'array_filter_key() expects parameter 1 to be array, '.gettype($input).' given', E_USER_WARNING ); return null; } if (empty($input)) { return $input; } $filteredKeys = array_filter(array_keys($input), $callback); if (empty($filteredKeys)) { return array(); } $input = array_intersect_key(array_flip($filteredKeys), $input); return $input; }; $envVars = $arrayFilterKeys($_ENV, $hasPrefix); $envVars = array_merge($arrayFilterKeys($_SERVER, $hasPrefix), $envVars); foreach ($envVars as $envVar => $empty) { $var = \Dotenv::findEnvironmentVariable($envVar); if ($var) { $key = strtolower(str_replace($app['env.options']['prefix'].'_', '', $envVar)); $app[$key] = $var; } } }
php
{ "resource": "" }
q264427
MysqlQueue.pop
test
public function pop($queue = null) { if ($queue === null) { $queue = $this->queue; } $query = DB::table($this->table)->where('queue_name', $queue) ->where('status', 'pending') ->where('fireon', '<', time()) ->orderBy('fireon', 'asc'); if ($query->count() == 0) {return null;} $record = $query->first(); return new Jobs\MysqlJob($this->container, $record->ID, $record); }
php
{ "resource": "" }
q264428
MysqlQueue.insertJobRecord
test
private function insertJobRecord($payload, $time, $queue) { if (!$time instanceof DateTime) { throw new ErrorException('An explicit DateTime value $time is required. '); } $jobId = DB::table($this->table)->insertGetId([ 'queue_name' => $queue, 'payload' => $payload, 'status' => 'pending', 'attempts' => 1, 'fireon' => $time->getTimestamp(), ]); return $jobId; }
php
{ "resource": "" }
q264429
XcdrClient.requestXcdrSetAttribute
test
private function requestXcdrSetAttribute($result, $schema) { $msgHeader = $result['msgHeader']; $soapObjectXML = '<format>DETAIL</format> <msgHeader> <transactionID>' . $msgHeader->transactionID . '</transactionID> <registrationID>' . $msgHeader->registrationID . '</registrationID> </msgHeader>' ; $soapXML = new \SoapVar($soapObjectXML, XSD_ANYXML, null, null, null, $schema); try { $result = $this->soapClient->RequestXcdrSetAttribute($soapXML); } catch (SoapTimeoutException $e) { return array( 'status' => 'error', 'type' => 'soap_fault', 'message' => 'XCDR Soap Client Timeout. ' . $e->getMessage(), 'class' => get_class($this) ); } catch (\Exception $e) { return array( 'status' => 'error', 'type' => 'exception', 'message' => 'XCDR Soap Client Exception. ' . $e->getMessage(), 'class' => get_class($this) ); } if (is_soap_fault($result)) { return array( 'status' => 'error', 'type' => 'soap_fault', 'code' => $result->faultcode, 'message' => $result->faultstring, 'class' => get_class($this) ); } return array( 'status' => 'success', 'result' => $result ); }
php
{ "resource": "" }
q264430
StringToCamelCase.convert
test
public function convert($string, $delimiter = '_') { $func = create_function('$c', 'return strtoupper($c[1]);'); return preg_replace_callback('/[\s]+(.)/', $func, str_replace($delimiter, ' ', $string)); }
php
{ "resource": "" }
q264431
DataMapper.create
test
final public function create($record = null, string $alias = null): Record { $record = Record::parse($record); foreach ($this->getParents() as $relationship => $parent) { /** @var DataMapper $parent */ $create = $parent->create($record); $record->set($relationship, $create->get($parent->getPrimaryKey())); $record->import($create->all()); } $action = coalesce($alias, Action::CREATE); if (!$this->before($action, $record)) { throw new SimplesHookError(get_class($this), $action, 'before'); } if (!$record->get($this->hashKey)) { $record->set($this->hashKey, $this->hashKey()); } $create = $this->configureRecord(Action::CREATE, $record); $fields = $create->keys(); $values = $create->values(); foreach ($this->createKeys as $type => $timestampsKey) { $fields[] = $timestampsKey; $values[] = $this->getTimestampValue($type); } $created = $this ->source($this->getCollection()) ->fields($fields) ->register($values); $this->reset(); if ($this->getPrimaryKey()) { $record->set($this->getPrimaryKey(), $created); } $record->merge($create->all()); if (!$this->after($action, $record)) { throw new SimplesHookError(get_class($this), $action, 'after'); } return $record; }
php
{ "resource": "" }
q264432
DataMapper.read
test
final public function read($record = null, string $alias = null, $trash = false, $clean = false): Collection { $record = Record::parse(coalesce($record, [])); $action = coalesce($alias, Action::READ); if (!$this->before($action, $record)) { throw new SimplesHookError(get_class($this), $action, 'before'); } $filters = []; $values = []; if (!$record->isEmpty()) { $filters = $this->parseFilterFields($record->all()); $values = $this->parseFilterValues($filters); } if ($this->destroyKeys) { $filters[] = $this->getDestroyFilter($this->destroyKeys['at'], $trash); } $fields = $this->getActionFields(Action::READ, false); if ($clean) { $fields = $this->clear($fields); } $order = is_array($this->order) ? $this->order : [$this->order]; $where = off($this->getClauses(), 'where', []); if ($where) { $filters = array_merge($filters, $where); $values = array_merge($values, off($this->getClauses(), 'values', [])); } $array = $this ->source($this->getCollection()) ->relation($this->parseReadRelations($this->fields)) ->fields($fields) ->order($order) ->where($filters)// TODO: needs review ->recover($values); $this->reset(); $after = $this->after($action, $record, $array); if (!is_array($after)) { throw new SimplesHookError(get_class($this), $action, 'after'); } $array = $after; return Collection::make($array); }
php
{ "resource": "" }
q264433
DataMapper.update
test
final public function update($record = null, string $alias = null, bool $trash = false): Record { $record = Record::parse($record); foreach ($this->getParents() as $parent) { /** @var DataMapper $parent */ $record->import($parent->update($record)->all()); } $action = coalesce($alias, Action::UPDATE); $previous = $this->previous($record, $this->hashKey, $trash); if ($previous->isEmpty()) { throw new SimplesResourceError([$this->getHashKey() => $record->get($this->getHashKey())]); } if (!$this->before($action, $record, $previous)) { throw new SimplesHookError(get_class($this), $action, 'before'); } $record->setPrivate($this->getHashKey()); $update = $this->configureRecord(Action::UPDATE, $record, $previous, !$trash); $fields = $update->keys(); $values = $update->values(); foreach ($this->updateKeys as $type => $timestampsKey) { $fields[] = $timestampsKey; $values[] = $this->getTimestampValue($type); } $filter = new Filter($this->get($this->getPrimaryKey()), $record->get($this->getPrimaryKey())); $updated = $this ->source($this->getCollection()) ->fields($fields) ->where([$filter])// TODO: needs review ->change($values, [$filter->getValue()]); $this->reset(); if (!$updated) { throw new SimplesActionError(get_class($this), $action); } $record->setPublic($this->getHashKey()); $record = $previous->merge($record->all()); if (!$this->after($action, $record)) { throw new SimplesHookError(get_class($this), $action, 'after'); } return $record; }
php
{ "resource": "" }
q264434
DataMapper.destroy
test
final public function destroy($record = null, string $alias = null): Record { $record = Record::parse($record); foreach ($this->getParents() as $parent) { /** @var DataMapper $parent */ $record->import($parent->destroy($record)->all()); } $action = coalesce($alias, Action::DESTROY); $previous = $this->previous($record, $this->hashKey); if ($previous->isEmpty()) { throw new SimplesResourceError([$this->getHashKey() => $record->get($this->getHashKey())]); } if (!$this->before($action, $record, $previous)) { throw new SimplesHookError(get_class($this), $action, 'before'); } $filter = new Filter($this->get($this->getPrimaryKey()), $record->get($this->getPrimaryKey())); $filters = [$filter]; if ($this->destroyKeys) { $fields = []; $values = []; foreach ($this->destroyKeys as $type => $deletedKey) { $fields[] = $deletedKey; $values[] = $this->getTimestampValue($type); } $removed = $this ->source($this->getCollection()) ->fields($fields) ->where($filters)// TODO: needs review ->change($values, [$filter->getValue()]); } if (!isset($removed)) { $removed = $this ->source($this->getCollection()) ->where($filters)// TODO: needs review ->remove([$record->get($this->getPrimaryKey())]); } $this->reset(); if (!$removed) { throw new SimplesActionError(get_class($this), $action); } $record = $previous->merge($record->all()); if (!$this->after($action, $record)) { throw new SimplesHookError(get_class($this), $action, 'after'); } return $record; }
php
{ "resource": "" }
q264435
DataMapper.recycle
test
final public function recycle($record = null): Record { if (!$this->destroyKeys) { throw new SimplesValidationError( ['destroyKeys' => 'requires'], "Recycle needs the `destroyKeys`" ); } $record = Record::parse($record); foreach ($this->destroyKeys as $deletedKey) { $record->set($deletedKey, __NULL__); } return $this->update($record, 'recycle', true); }
php
{ "resource": "" }
q264436
DataMapper.count
test
final public function count(Record $record): int { $alias = 'count'; $collection = $this->getCollection(); $name = $this->getPrimaryKey(); $type = Field::AGGREGATOR_COUNT; $options = ['alias' => $alias]; $fields = [Field::make($collection, $name, $type, $options)]; $this->reset(); $count = $this ->fields($fields) ->limit(null) ->read($record, null, false) ->current(); $this->reset(); if (!$count->has($alias)) { throw new SimplesActionError(get_class($this), $alias); } return (int)$count->get($alias); }
php
{ "resource": "" }
q264437
Base_Provider.proxy
test
public function proxy( Container $container, $key ) { if ( isset( $this->proxies[ $key ] ) ) { return $this->proxies[ $key ]; } $this->proxies[ $key ] = new Proxy( $container, $key ); return $this->proxies[ $key ]; }
php
{ "resource": "" }
q264438
Log.close
test
public function close():Log{ if(!empty($this->logOutputInterfaces)){ foreach($this->logOutputInterfaces as $instanceName => $instance){ unset($this->logOutputInterfaces[$instanceName]); } } return $this; }
php
{ "resource": "" }
q264439
PotterCore.loadWidgets
test
protected function loadWidgets() { $widgets_folder = apply_filters('potter_widgets_folder', $this->widgetsFolder); $pattern = $this->themeDIR . $widgets_folder . "/*.php"; foreach (glob($pattern) as $file): // Load File require_once($file); $widget = basename($file, '.php'); // Register if (class_exists($widget)): $this->widgets->push($widget); endif; endforeach; }
php
{ "resource": "" }
q264440
PotterCore.loadThemeOptions
test
private function loadThemeOptions() { $file = cleanURI($this->themeDIR . 'app/ThemeOptions.php'); $file = apply_filters('potter_autoload_themeoptions', $file); $class = $this->loadFile($file); if (!$class): $class = new OptionsEmpty(); add_action('admin_menu', array($this, 'remove_ot_theme_options_page'), 999); endif; $this->optionsInstance = $class; }
php
{ "resource": "" }
q264441
Plugin.onXmlRpcEliteBeginTurn
test
function onXmlRpcEliteBeginTurn($content) { $this->postTwitterMessage(sprintf("Turn #%d: %s attack", $content->TurnNumber, $this->formatForTwitter($content->AttackingPlayer->Name))); }
php
{ "resource": "" }
q264442
TaskBarIcon.addChild
test
public function addChild(ElementInterface $child) { if ($child instanceof Menu) { $this->element->setMenu($child); } $this->children[] = $child; }
php
{ "resource": "" }
q264443
PermissionController.store
test
public function store(CreatePermissionRequest $request) { $input = $request->all(); $permission = $this->permissionRepository->create([ 'name' => $input['name'], ]); foreach ($input['roles'] as $role) { $permission->roles()->attach($role); } Flash::success(trans('l5starter::messages.create.success')); return redirect(route('admin.permissions.index')); }
php
{ "resource": "" }
q264444
PermissionController.edit
test
public function edit($id) { $permission = $this->permissionRepository->findWithoutFail($id); if (empty($permission)) { Flash::error(trans('l5starter::messages.404_not_found')); return redirect(route('admin.permissions.index')); } return view('permissions::edit')->with([ 'roles' => $this->roleRepository->all(), 'permission' => $permission, ]); }
php
{ "resource": "" }
q264445
PermissionController.update
test
public function update($id, UpdatePermissionRequest $request) { $permission = $this->permissionRepository->findWithoutFail($id); if (empty($permission)) { Flash::error(trans('l5starter::messages.404_not_found')); return redirect(route('admin.permissions.index')); } $input = $request->all(); $permission = $this->permissionRepository->update([ 'name' => $input['name'], ], $id); $roles = []; if (!empty($input['roles'])) { foreach ($input['roles'] as $role) { $roles[$role] = $role; } } $permission->roles()->sync($roles); Flash::success(trans('l5starter::messages.update.success')); return redirect(route('admin.permissions.index')); }
php
{ "resource": "" }
q264446
PermissionController.destroy
test
public function destroy($id) { $permission = $this->permissionRepository->findWithoutFail($id); if (empty($permission)) { Flash::error(trans('l5starter::messages.404_not_found')); return redirect(route('admin.permissions.index')); } $this->permissionRepository->delete($id); Flash::success(trans('l5starter::messages.delete.success')); return redirect(route('admin.permissions.index')); }
php
{ "resource": "" }
q264447
AbstractTransport.setAdapter
test
public function setAdapter(\ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\Adapter\AbstractAdapter $adapter) { $this->adapter = $adapter; }
php
{ "resource": "" }
q264448
AbstractTransport.getAdapterType
test
public function getAdapterType() { if($this->adapter instanceof \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\Adapter\AbstractAdapter) { $string = \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\Helper\String::factory(get_class($this->adapter)); return $string->substr($string->findLast("\\"))->replace(array("\\", " "), "")->toString(); } return "Unknown"; }
php
{ "resource": "" }
q264449
AbstractTransport.waitForReadyRead
test
protected function waitForReadyRead($time = 0) { if(!$this->isConnected() || $this->config["blocking"]) return; do { $read = array($this->stream); $null = null; if($time) { \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\Helper\Signal::getInstance()->emit(strtolower($this->getAdapterType()) . "WaitTimeout", $time, $this->getAdapter()); } $time = $time+$this->config["timeout"]; } while(@stream_select($read, $null, $null, $this->config["timeout"]) == 0); }
php
{ "resource": "" }
q264450
SearchRepository.getChannels
test
public function getChannels($params = array()) { $params = 0 < count($params) ? '?'.http_build_query($params) : ''; $response = $this->getClient()->get(self::ENDPOINT.'channels'.$params); $data = $this->jsonResponse($response); return $this->setFactory((new ChannelFactory()))->getFactory()->createList($data); }
php
{ "resource": "" }
q264451
SearchRepository.getGames
test
public function getGames($params = array()) { $params = 0 < count($params) ? '?'.http_build_query($params) : ''; $response = $this->getClient()->get(self::ENDPOINT.'games'.$params); $data = $this->jsonResponse($response); return $this->setFactory((new GameFactory()))->getFactory()->createList($data); }
php
{ "resource": "" }
q264452
Validate.asArray
test
public static function asArray($data, $default = null) { $json = is_string($data) ? $data : json_encode($data); $array = json_decode($json, true) ?? null; $array = $array ? filter_var_array($array) : false; return $array !== false ? $array : $default; }
php
{ "resource": "" }
q264453
Validate.asObject
test
public static function asObject($data, $default = null) { $json = is_string($data) ? $data : json_encode($data); $object = json_decode($json); return is_object($object) ? $object : $default; }
php
{ "resource": "" }
q264454
Validate.asJson
test
public static function asJson($data, $default = null) { $json = is_string($data) ? $data : json_encode($data); return $json !== false ? $json : $default; }
php
{ "resource": "" }
q264455
Validate.asString
test
public static function asString($data, $default = null) { $string = filter_var( $data ?? [], FILTER_SANITIZE_STRING, FILTER_FLAG_NO_ENCODE_QUOTES ); return $string !== false ? $string : $default; }
php
{ "resource": "" }
q264456
Validate.asInteger
test
public static function asInteger($data, $default = null) { $int = filter_var($data ?? '', FILTER_VALIDATE_INT); return $int !== false ? $int : $default; }
php
{ "resource": "" }
q264457
Validate.asFloat
test
public static function asFloat($data, $default = null) { $float = filter_var($data ?? '', FILTER_VALIDATE_FLOAT); return $float !== false ? $float : $default; }
php
{ "resource": "" }
q264458
Validate.asBoolean
test
public static function asBoolean($data, $default = null) { $boolean = filter_var($data ?? [], FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE); return ! is_null($boolean) ? $boolean : $default; }
php
{ "resource": "" }
q264459
PHP5HydratorGenerator.generate
test
public function generate(\ReflectionClass $originalClass, string $realClassName, string $originalClassName) : string { $position = \strrpos($realClassName, '\\'); $namespace = \substr($realClassName, 0, $position); $className = \substr($realClassName, $position + 1); $visiblePropertyMap = []; $hiddenPropertyMap = []; foreach ($this->findAllInstanceProperties($originalClass) as $property) { $declaringClassName = $property->getDeclaringClass()->getName(); if ($property->isPrivate() || $property->isProtected()) { $hiddenPropertyMap[$declaringClassName][] = $property->getName(); } else { $visiblePropertyMap[] = $property->getName(); } } return <<<EOT <?php namespace {$namespace}; use Zend\Hydrator\HydratorInterface; /** * This is a generated hydrator for the {$originalClassName} class */ class {$className} implements HydratorInterface { private \$hydrateCallbacks = []; private \$extractCallbacks = []; public function __construct() { {$this->createContructor($visiblePropertyMap, $hiddenPropertyMap)} } public function hydrate(array \$data, \$object) { {$this->createHydrateMethod($visiblePropertyMap, $hiddenPropertyMap)} } public function extract(\$object) { {$this->createExtractMethod($visiblePropertyMap, $hiddenPropertyMap)} } } EOT; }
php
{ "resource": "" }
q264460
PHP5HydratorGenerator.findAllInstanceProperties
test
private function findAllInstanceProperties(\ReflectionClass $class = null) { if (! $class) { return []; } return \array_values(\array_merge( $this->findAllInstanceProperties($class->getParentClass() ?: null), // of course PHP is shit. \array_values(\array_filter( $class->getProperties(), function (\ReflectionProperty $property) : bool { return ! $property->isStatic(); } )) )); }
php
{ "resource": "" }
q264461
PHP5HydratorGenerator.createContructor
test
private function createContructor(array $visiblePropertyMap, array $hiddenPropertyMap) : string { $content = []; // Create a set of closures that will be called to hydrate the object. // Array of closures in a naturally indexed array, ordered, which will // then be called in order in the hydrate() and extract() methods. foreach ($hiddenPropertyMap as $className => $propertyNames) { // Hydrate closures $content[] = "\$this->hydrateCallbacks[] = \\Closure::bind(function (\$object, \$values) {"; foreach ($propertyNames as $propertyName) { $content[] = " if (isset(\$values['" . $propertyName . "']) || \$object->" . $propertyName . " !== null && \\array_key_exists('" . $propertyName . "', \$values)) {"; $content[] = " \$object->" . $propertyName . " = \$values['" . $propertyName . "'];"; $content[] = " }"; } $content[] = '}, null, ' . \var_export($className, true) . ');' . "\n"; // Extract closures $content[] = "\$this->extractCallbacks[] = \\Closure::bind(function (\$object, &\$values) {"; foreach ($propertyNames as $propertyName) { $content[] = " \$values['" . $propertyName . "'] = \$object->" . $propertyName . ";"; } $content[] = '}, null, ' . \var_export($className, true) . ');' . "\n"; } return \implode("\n", \array_map( function ($line) { return " " . $line; }, $content )); }
php
{ "resource": "" }
q264462
PHP5HydratorGenerator.createHydrateMethod
test
private function createHydrateMethod(array $visiblePropertyMap, array $hiddenPropertyMap) : string { $content = []; foreach ($visiblePropertyMap as $propertyName) { $content[] = "if (isset(\$data['" . $propertyName . "']) || \$object->" . $propertyName . " !== null && \\array_key_exists('" . $propertyName . "', \$data)) {"; $content[] = " \$object->" . $propertyName . " = \$data['" . $propertyName . "'];"; $content[] = "}"; } $index = 0; foreach ($hiddenPropertyMap as $className => $propertyNames) { $content[] = "\$this->hydrateCallbacks[" . ($index++) . "]->__invoke(\$object, \$data);"; } $content[] = "return \$object;"; return \implode("\n", \array_map( function ($line) { return " " . $line; }, $content )); }
php
{ "resource": "" }
q264463
ExtensionFileWriter.updateConfig
test
public static function updateConfig() { /** @var ExtensionsManager $module */ $module = ExtensionsManager::module(); $extensions = $module->getExtensions(); $installed = ComposerInstalledSet::get(true)->getInstalled(); $fileName = Yii::getAlias($module->extensionsStorage); $writer = new ApplicationConfigWriter(['filename' => $fileName]); $config = self::rebuldConfig($installed); if (false === empty($extensions)) { $toAdd = array_udiff($config, $extensions, [self::className(), 'arraysCompareCallback']); $toRemove = array_udiff($extensions, $config, [self::className(), 'arraysCompareCallback']); foreach ($toRemove as $name => $ext) { if (true === isset($extensions[$name])) { unset($extensions[$name]); } } $config = array_merge($extensions, $toAdd); } $writer->addValues($config); return $writer->commit(); }
php
{ "resource": "" }
q264464
ExtensionFileWriter.checkLocalStorage
test
public static function checkLocalStorage($dir, $data) { $fn = $dir . '/composer.json'; $created = true; if (true === FileHelper::createDirectory($dir)) { if (false === file_exists($fn)) { $created = file_put_contents( $fn, Json::encode($data, JSON_FORCE_OBJECT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT) ); } if (false === $created) { Yii::$app->session->setFlash( 'error', Yii::t('extensions-manager', 'Unable to create local composer.json file') ); } } else { Yii::$app->session->setFlash( 'error', Yii::t('extensions-manager', 'Unable to create folder to store local composer.json file') ); $created = false; } return $created; }
php
{ "resource": "" }
q264465
NavigationContainer.findOneByAttribute
test
public function findOneByAttribute(string $attribute, $value): ?Page { $iterator = new \RecursiveIteratorIterator($this, \RecursiveIteratorIterator::SELF_FIRST); /** @var Page $page */ foreach ($iterator as $page) { if ($page->getAttribute($attribute) === $value) { return $page; } } return null; }
php
{ "resource": "" }
q264466
NavigationContainer.findByAttribute
test
public function findByAttribute(string $attribute, $value): array { $result = []; $iterator = new \RecursiveIteratorIterator($this, \RecursiveIteratorIterator::SELF_FIRST); /** @var Page $page */ foreach ($iterator as $page) { if ($page->getAttribute($attribute) == $value) { $result[] = $page; } } return $result; }
php
{ "resource": "" }
q264467
NavigationContainer.findOneByOption
test
public function findOneByOption(string $option, $value): ?Page { $iterator = new \RecursiveIteratorIterator($this, \RecursiveIteratorIterator::SELF_FIRST); /** @var Page $page */ foreach ($iterator as $page) { if ($page->getOption($option) == $value) { return $page; } } return null; }
php
{ "resource": "" }
q264468
NavigationContainer.findByOption
test
public function findByOption(string $option, $value): array { $result = []; $iterator = new \RecursiveIteratorIterator($this, \RecursiveIteratorIterator::SELF_FIRST); /** @var Page $page */ foreach ($iterator as $page) { if ($page->getOption($option) == $value) { $result[] = $page; } } return $result; }
php
{ "resource": "" }
q264469
ServiceProvider.register
test
public function register($binding) { if ( ! extension_loaded('wxwidgets')) { if ( ! @dl('wxwidgets.'.PHP_SHLIB_SUFFIX)) { echo 'wxWidgets extension not installed or dynamically loaded extensions are not enabled'.PHP_EOL; exit(1); } } switch ($binding) { case 'view.viewparser': $this->registerViewParser(); break; case 'wx': $this->registerWx(); break; case 'launcher': $this->registerLauncher(); break; case 'giml.collection': $this->registerGimlCollection(); break; default: $this->registerGimlCollection(); $this->registerViewParser(); $this->registerWx(); $this->registerLauncher(); break; } }
php
{ "resource": "" }
q264470
ServiceProvider.registerViewParser
test
protected function registerViewParser() { $this->container->bind('view.viewparser', function() { return new ViewParser( $this->container['giml.reader'], $this->container['giml.collection'], new NamespaceElementFactory('Encore\Wx\Element') ); }); }
php
{ "resource": "" }
q264471
ServiceProvider.registerLauncher
test
protected function registerLauncher() { $this->container->bind('launcher', function() { wxInitAllImageHandlers(); \wxApp::SetInstance($this->container['wx']); wxEntry(); }); }
php
{ "resource": "" }
q264472
DatabaseDriver.driver
test
protected function driver($name, $data = array()) { if (in_array($name, $this->mysql) === true) { $dsn = (string) 'mysql:host=%s;dbname=%s'; $dsn = sprintf($dsn, $data['hostname'], $data['database']); $pdo = new \PDO($dsn, $data['username'], $data['password']); return new MySQLDriver($pdo, (string) $data['database']); } if (in_array($name, $this->sqlite)) { return new SQLiteDriver(new \PDO($data['hostname'])); } $message = 'Database driver "%s" not found.'; $message = sprintf($message, (string) $name); throw new DriverNotFoundException($message); }
php
{ "resource": "" }
q264473
AbstractValidator.getInvalidResult
test
protected function getInvalidResult(string $code, array $parameters = null): ResultInterface { $templates = $this->getTemplates(); if (array_key_exists($code, $templates) === false) { throw new TemplateNotFound($code); } return new InvalidResult($code, $templates[$code], $parameters ?? []); }
php
{ "resource": "" }
q264474
Profiler.start
test
public static function start($name = "default") { if(array_key_exists($name, self::$timers)) { self::$timers[$name]->start(); } else { self::$timers[$name] = new Profiler\Timer($name); } }
php
{ "resource": "" }
q264475
Signal.subscribe
test
public function subscribe($signal, $callback) { if(empty($this->sigslots[$signal])) { $this->sigslots[$signal] = array(); } $index = md5(serialize($callback)); if(!array_key_exists($index, $this->sigslots[$signal])) { $this->sigslots[$signal][$index] = new Signal\Handler($signal, $callback); } return $this->sigslots[$signal][$index]; }
php
{ "resource": "" }
q264476
Signal.unsubscribe
test
public function unsubscribe($signal, $callback = null) { if(!$this->hasHandlers($signal)) { return; } if($callback !== null) { $index = md5(serialize($callback)); if(!array_key_exists($index, $this->sigslots[$signal])) { return; } unset($this->sigslots[$signal][$index]); } else { unset($this->sigslots[$signal]); } }
php
{ "resource": "" }
q264477
BaseActionsInfoWidget.getValue
test
protected function getValue($value, $type) { switch ($type) { case self::ATTRIBUTE_TYPE_USER: return $this->getUsername($value); case self::ATTRIBUTE_TYPE_DATE: return date('Y-m-d h:i:s', $value); default: return $value; } }
php
{ "resource": "" }
q264478
MySQLDriver.keys
test
protected function keys($row, Column $column) { switch ($row->Key) { case 'PRI': $column->setPrimary(true); break; case 'MUL': $column->setForeign(true); break; case 'UNI': $column->setUnique(true); break; } return $column; }
php
{ "resource": "" }
q264479
MySQLDriver.query
test
protected function query($table, $query, $columns = array()) { $result = $this->pdo->prepare($query); $result->execute(); $result->setFetchMode(\PDO::FETCH_OBJ); while ($row = $result->fetch()) { $column = $this->column(new Column, $table, $row); array_push($columns, $column); } if (empty($columns) === true) { $message = 'Table "' . $table . '" does not exists!'; throw new TableNotFoundException($message); } return $columns; }
php
{ "resource": "" }
q264480
MySQLDriver.properties
test
protected function properties($row, Column $column) { $increment = $row->Extra === 'auto_increment'; $column->setAutoIncrement($increment); $column->setNull($row->{'Null'} === 'YES'); return $column; }
php
{ "resource": "" }
q264481
MySQLDriver.strip
test
protected function strip($table) { $exists = strpos($table, '.') !== false; $updated = substr($table, strpos($table, '.') + 1); return $exists ? $updated : $table; }
php
{ "resource": "" }
q264482
Host.serverSelect
test
public function serverSelect($sid, $virtual = null) { if($this->whoami !== null && $this->serverSelectedId() == $sid) return; $virtual = ($virtual !== null) ? $virtual : $this->start_offline_virtual; $getargs = func_get_args(); $this->execute("use", array("sid" => $sid, $virtual ? "-virtual" : null)); if($sid != 0 && $this->predefined_query_name !== null) { $this->execute("clientupdate", array("client_nickname" => (string) $this->predefined_query_name)); } $this->whoamiReset(); $this->setStorage("_server_use", array(__FUNCTION__, $getargs)); \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\Helper\Signal::getInstance()->emit("notifyServerselected", $this); }
php
{ "resource": "" }
q264483
Host.serverSelectByPort
test
public function serverSelectByPort($port, $virtual = null) { if($this->whoami !== null && $this->serverSelectedPort() == $port) return; $virtual = ($virtual !== null) ? $virtual : $this->start_offline_virtual; $getargs = func_get_args(); $this->execute("use", array("port" => $port, $virtual ? "-virtual" : null)); if($port != 0 && $this->predefined_query_name !== null) { $this->execute("clientupdate", array("client_nickname" => (string) $this->predefined_query_name)); } $this->whoamiReset(); $this->setStorage("_server_use", array(__FUNCTION__, $getargs)); \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\Helper\Signal::getInstance()->emit("notifyServerselected", $this); }
php
{ "resource": "" }
q264484
Host.serverGetPortById
test
public function serverGetPortById($sid) { if(!array_key_exists((string) $sid, $this->serverList())) { throw new \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\Adapter\ServerQuery\Exception("invalid serverID", 0x400); } return $this->serverList[intval((string) $sid)]["virtualserver_port"]; }
php
{ "resource": "" }
q264485
Host.serverGetByName
test
public function serverGetByName($name) { foreach($this->serverList() as $server) { if($server["virtualserver_name"] == $name) return $server; } throw new \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\Adapter\ServerQuery\Exception("invalid serverID", 0x400); }
php
{ "resource": "" }
q264486
Host.serverGetByUid
test
public function serverGetByUid($uid) { foreach($this->serverList() as $server) { if($server["virtualserver_unique_identifier"] == $uid) return $server; } throw new \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\Adapter\ServerQuery\Exception("invalid serverID", 0x400); }
php
{ "resource": "" }
q264487
Host.serverCreate
test
public function serverCreate(array $properties = array()) { $this->serverListReset(); $detail = $this->execute("servercreate", $properties)->toList(); $server = new Server($this, array("virtualserver_id" => intval($detail["sid"]))); \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\Helper\Signal::getInstance()->emit("notifyServercreated", $this, $detail["sid"]); \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\Helper\Signal::getInstance()->emit("notifyTokencreated", $server, $detail["token"]); return $detail; }
php
{ "resource": "" }
q264488
Host.serverDelete
test
public function serverDelete($sid) { $this->serverListReset(); $this->execute("serverdelete", array("sid" => $sid)); \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\Helper\Signal::getInstance()->emit("notifyServerdeleted", $this, $sid); }
php
{ "resource": "" }
q264489
Host.serverStart
test
public function serverStart($sid) { if($sid == $this->serverSelectedId()) { $this->serverDeselect(); } $this->execute("serverstart", array("sid" => $sid)); $this->serverListReset(); \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\Helper\Signal::getInstance()->emit("notifyServerstarted", $this, $sid); }
php
{ "resource": "" }
q264490
Host.serverStopProcess
test
public function serverStopProcess() { \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\Helper\Signal::getInstance()->emit("notifyServershutdown", $this); $this->execute("serverprocessstop"); }
php
{ "resource": "" }
q264491
Host.permissionList
test
public function permissionList() { if($this->permissionList === null) { $this->permissionList = $this->request("permissionlist")->toAssocArray("permname"); } return $this->permissionList; }
php
{ "resource": "" }
q264492
Host.permissionFind
test
public function permissionFind($permid) { $permident = (is_numeric($permid)) ? "permid" : "permsid"; return $this->execute("permfind", array($permident => $permid))->toArray(); }
php
{ "resource": "" }
q264493
Host.permissionGetIdByName
test
public function permissionGetIdByName($name) { if(!array_key_exists((string) $name, $this->permissionList())) { throw new \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\Adapter\ServerQuery\Exception("invalid permission ID", 0xA02); } return $this->permissionList[(string) $name]["permid"]; }
php
{ "resource": "" }
q264494
Host.permissionGetNameById
test
public function permissionGetNameById($permid) { foreach($this->permissionList() as $name => $perm) { if($perm["permid"] == $permid) return new \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\Helper\String($name); } throw new \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\Adapter\ServerQuery\Exception("invalid permission ID", 0xA02); }
php
{ "resource": "" }
q264495
Host.permissionGetCategoryById
test
public function permissionGetCategoryById($permid) { if(!is_numeric($permid)) { $permid = $this->permissionGetIdByName($permid); } return (int) $permid >> 8; }
php
{ "resource": "" }
q264496
Host.selfPermCheck
test
public function selfPermCheck($permid) { $permident = (is_numeric($permid)) ? "permid" : "permsid"; return $this->execute("permget", array($permident => $permid))->toAssocArray("permsid"); }
php
{ "resource": "" }
q264497
Host.logAdd
test
public function logAdd($logmsg, $loglevel = \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\TeamSpeak3::LOGLEVEL_INFO) { $sid = $this->serverSelectedId(); $this->serverDeselect(); $this->execute("logadd", array("logmsg" => $logmsg, "loglevel" => $loglevel)); $this->serverSelect($sid); }
php
{ "resource": "" }
q264498
Host.login
test
public function login($username, $password) { $this->execute("login", array("client_login_name" => $username, "client_login_password" => $password)); $this->whoamiReset(); $crypt = new \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\Helper\Crypt($username); $this->setStorage("_login_user", $username); $this->setStorage("_login_pass", $crypt->encrypt($password)); \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\Helper\Signal::getInstance()->emit("notifyLogin", $this); }
php
{ "resource": "" }
q264499
Host.logout
test
public function logout() { $this->request("logout"); $this->whoamiReset(); $this->delStorage("_login_user"); $this->delStorage("_login_pass"); \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\Helper\Signal::getInstance()->emit("notifyLogout", $this); }
php
{ "resource": "" }