_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
83
13k
language
stringclasses
1 value
meta_information
dict
q241100
ORM.reset
train
private function reset() { $vars = get_object_vars($this); // foreach ($vars as $key => $value) { unset($this->$key); } }
php
{ "resource": "" }
q241101
ORM.restore
train
public function restore() { if ($this->_kept) { $this->bring(); // Query::table(static::$table) ->set('deleted_at', 'NULL', false) ->where($this->_keyName, '=', $this->_keyValue) ->update(); } }
php
{ "resource": "" }
q241102
ORM.bring
train
private function bring() { foreach ($this->_keptData as $key => $value) { $this->$key = $value; } // $this->_keyValue = $this->_keptData[$this->_keyName]; // $this->_keptData = null; $this->_kept = false; }
php
{ "resource": "" }
q241103
ORM.all
train
public static function all() { $class = get_called_class(); $object = new $class(); $table = $object->_table; $key = $object->_keyName; // $data = Query::table($table)->select('*')->where("'true'", '=', 'true'); // if ($object->_canKept) { ...
php
{ "resource": "" }
q241104
ORM.onlyTrash
train
public static function onlyTrash() { $class = get_called_class(); $object = new $class(); $table = $object->_table; $key = $object->_keyName; // $data = Query::table($table)->select('*'); // if ($object->_canKept) { $data = $data->where('de...
php
{ "resource": "" }
q241105
ORM.where
train
public static function where($column, $relation, $value) { $self = self::instance(); $key = $self->_keyName; $data = \Query::from($self->_table)->select($key)->where($column, $relation, $value)->get(); $rows = []; if (!is_null($data)) { foreach ($data as $item) {...
php
{ "resource": "" }
q241106
View.forge
train
public static function forge($file = null, $data = null, $auto_encode = null) { $class = null; if ($file !== null) { $extension = pathinfo($file, PATHINFO_EXTENSION); $class = \Config::get('parser.extensions.'.$extension, null); } if ($class === null) { $class = get_called_class(); } // On...
php
{ "resource": "" }
q241107
Smarty.setTemplateExtension
train
public function setTemplateExtension($extension) { $extension = (string) $extension; $extension = trim($extension); if ('.' == $extension[0]) { $extension = substr($extension, 1); } $this->extension = $extension; }
php
{ "resource": "" }
q241108
Smarty.setLayoutVariableName
train
public function setLayoutVariableName($name) { $name = (string) $name; $name = trim($name); if (! preg_match('/^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/', $name)) { throw new InvalidArgumentException('Invalid variable name'); } $this->layoutVariableName = $name; ...
php
{ "resource": "" }
q241109
NestedSet.hasChildren
train
public function hasChildren(): bool { $children = (($this->getRgt() - $this->getLft()) - 1) / 2; return (0 === $children) ? false : true; }
php
{ "resource": "" }
q241110
Generator.generateSearchRules
train
public function generateSearchRules() { if (($table = $this->getTableSchema()) === false) { return ["[['" . implode("', '", $this->getColumnNames()) . "'], 'safe']"]; } $types = []; foreach ($table->columns as $column) { switch ($column->type) { ...
php
{ "resource": "" }
q241111
Observer.instance
train
public static function instance($model_class) { $observer = get_called_class(); if (empty(static::$_instances[$observer][$model_class])) { static::$_instances[$observer][$model_class] = new static($model_class); } return static::$_instances[$observer][$model_class]; }
php
{ "resource": "" }
q241112
Compiler.compiledExists
train
public function compiledExists() { return $this->cached === false ? false : file_exists($this->cachePath.'/'.$this->getClassName().'.php'); }
php
{ "resource": "" }
q241113
Compiler.compile
train
public function compile() { if($this->compiledExists() === false) { if(is_file($this->filepath) === false) { throw new \Exception('File "'.$this->filepath.'" does not exists.'); } $this->raw = file_get_contents($this->filepath); ...
php
{ "resource": "" }
q241114
Compiler.resolveExtending
train
public function resolveExtending() { /** * Extending of view. */ preg_match_all('/@extends\(\'([a-zA-Z0-9\.\-]+)\'\)/', $this->prepared, $matches); if(isset($matches[1][0])) { $this->extends = trim($matches[1][0]); $this->prepared = trim(s...
php
{ "resource": "" }
q241115
Compiler.compileSpecialStatements
train
public function compileSpecialStatements() { /** * Statemet that sets the variable value. */ preg_match_all('/@set\s?(.*)/', $this->prepared, $matches); foreach($matches[0] as $key => $val) { $exploded = explode(' ', $matches[1][$key]); $var...
php
{ "resource": "" }
q241116
Compiler.createFiltersMethods
train
public function createFiltersMethods(array $names, $variable) { if($names === array()) { return $variable; } $filter = array_shift($names); if($filter === 'raw') { $result = $this->createFiltersMethods($names, $variable); } el...
php
{ "resource": "" }
q241117
Native.get
train
public function get($key) { $session = $this->getSessionData(); return $this->has($key) ? $session[$key] : null; }
php
{ "resource": "" }
q241118
Native.getSessionData
train
protected function getSessionData() { $data = isset($_SESSION[$this->config['key']]) ? $_SESSION[$this->config['key']] : []; return array_merge($data, $this->flash); }
php
{ "resource": "" }
q241119
TrackingParameterAppender.append
train
public function append($url, $formatterName = null) { $urlComponents = parse_url($url); $parameters = array(); if (isset($urlComponents['query'])) { parse_str($urlComponents['query'], $parameters); } $trackingParameters = $this->persister->getAllTrackingParamete...
php
{ "resource": "" }
q241120
CallQueue.execute
train
public function execute($objectContext) { if (!$this->ok) return; foreach ($this->entries as $entry) { if (!$this->ok) return; $entry->execute($objectContext); } }
php
{ "resource": "" }
q241121
Library.classMethod
train
protected function classMethod(&$class = NULL, &$method = NULL, $command) { $commandEx = explode(':', $command); $class = $commandEx[0]; $method = $commandEx[1] ?? NULL; }
php
{ "resource": "" }
q241122
FileConfigurationLoader.checkConfiguration
train
public final function checkConfiguration($deep = false) { if (!file_exists($this->filename) || !is_readable($this->filename)) { throw new ConfigurationNotFoundException("File $this->filename does not exist or is not readable"); } $fileExtension = pathinfo($this->filename, PATHINFO_EXTENSION); if ...
php
{ "resource": "" }
q241123
RedirectResponse.setTarget
train
public function setTarget($target) { if (!is_string($target) || $target == '') { throw new \InvalidArgumentException('No valid URL given.'); } $this->target = $target; // Set meta refresh content if header location is ignored $this->setContent( ...
php
{ "resource": "" }
q241124
Editor.editFile
train
public function editFile(ProcessBuilder $processBuilder, $filePath) { $proc = $processBuilder->setPrefix($this->_editorCommand)->setArguments([$filePath])->getProcess(); $proc->setTty(true)->run(); return $proc; }
php
{ "resource": "" }
q241125
Editor.editData
train
public function editData(ProcessBuilder $processBuilder, $data) { $filePath = tempnam(sys_get_temp_dir(), 'sensibleEditor'); file_put_contents($filePath, $data); $proc = $this->editFile($processBuilder, $filePath); if ($proc->isSuccessful()) { $data = file_get_contents($...
php
{ "resource": "" }
q241126
BaseAbstract.execute
train
public function execute() { $repositoryResponse = []; $arrayOfObjects = []; $resultCount = 0; $responseStatus = ResponseAbstract::STATUS_SUCCESS; try { $this->executeDataGateway(); if ($this->repository != null) { $arrayOfObjects = ...
php
{ "resource": "" }
q241127
ContentPackageDefinition.module
train
public function module(string $name, string $icon, callable $definitionCallback) { $definition = new ContentModuleDefinition($name, $icon, $this->config); $definitionCallback($definition); $this->customModules([ $name => function () use ($definition) { return $de...
php
{ "resource": "" }
q241128
Num.value
train
public static function value($str, $round = false) { if (is_string($str)) { $str = strtr($str, '.', ''); $str = strtr($str, ',', '.'); } $val = floatval($str); if ($round !== false) { $val = round($val, intval($round)); } return ...
php
{ "resource": "" }
q241129
SimpleXMLNodeTypedAttributeGetter.getValue
train
public function getValue() { $type = (string) $this->element->attributes()->type; $type = (empty($type)) ? 'string' : $type; $value = (string) $this->element->attributes()->value; $casterClassName = $this->resolveCasterClassName($type); /** @type \BuildR\TestTools\Caster\Caster...
php
{ "resource": "" }
q241130
SimpleXMLNodeTypedAttributeGetter.resolveCasterClassName
train
private function resolveCasterClassName($type) { foreach($this->casters as $typeNames => $casterClass) { $names = explode('|', $typeNames); if(!in_array($type, $names)) { continue; } return $casterClass; } throw CasterExc...
php
{ "resource": "" }
q241131
Form.addFormDeclaration
train
private function addFormDeclaration($formTypeName) { $name = strtolower($this->model); $extension = $matches = preg_split('/(?=[A-Z])/', $this->bundle->getName(), -1, PREG_SPLIT_NO_EMPTY); $bundleName = $this->getBundlePrefix(); array_pop($extension); $path = $this->bundle->g...
php
{ "resource": "" }
q241132
Form.addService
train
private function addService($path, $bundleName, $name, $formTypeName) { $ref = '<services>'; $replaceBefore = true; $group = $bundleName . '_' . $name; $declaration = <<<EOF <service id="$bundleName.form.type.$name" class="%$bundleName.form.type.$name.class%"> <a...
php
{ "resource": "" }
q241133
Form.addParameter
train
private function addParameter($path, $bundleName, $name) { $formPath = $this->configuration['namespace'] . '\\' . $this->model . 'Type'; $ref = '<parameters>'; $replaceBefore = true; $declaration = <<<EOF <parameter key="$bundleName.form.type.$name.class">$formPath</paramete...
php
{ "resource": "" }
q241134
CommentWalker.start_lvl
train
public function start_lvl(&$output, $depth = 0, $args = []) { $GLOBALS['comment_depth'] = $depth + 1; switch ($args['style']) { case 'div': break; case 'ol': $output .= '<ol class="children list-unstyled">'.PHP_EOL; break; ...
php
{ "resource": "" }
q241135
CommentWalker.end_lvl
train
public function end_lvl(&$output, $depth = 0, $args = []) { $tab = ' '; $indent = ($depth == 1) ? 8 + $depth : 7 + ($depth * 2); switch ($args['style']) { case 'div': break; case 'ol': case 'ul': default: $ou...
php
{ "resource": "" }
q241136
Generator.next
train
public function next() { $operation = $this->operation; $this->value = $operation($this->value); $this->elementsGenerated++; }
php
{ "resource": "" }
q241137
Exception.create
train
public static function create($message, $messageVariables = null, $code = null, PhpException $previous = null) { $messageFormat = [ 'message' => $message, 'messageVariables' => $messageVariables ]; return new static($messageFormat, $code, $previous); }
php
{ "resource": "" }
q241138
Exception.setCode
train
public function setCode($code) { if (!is_scalar($code)) { throw new InvalidArgumentException( sprintf( 'Wrong parameters for %s([int|string $code]); %s given.', __METHOD__, is_object($code) ? get_class($code) : gettype($...
php
{ "resource": "" }
q241139
Exception.setMessage
train
public function setMessage($message) { $messageVariables = null; if (is_array($message)) { if (array_key_exists('messageVariables', $message)) { $messageVariables = $message['messageVariables']; } if (array_key_exists('message', $message)) { ...
php
{ "resource": "" }
q241140
Exception.createMessage
train
protected function createMessage($message, $variables = null) { if (null !== $variables && is_array($variables)) { $variables = array_merge($this->getMessageVariables(), $variables); } else { $variables = $this->getMessageVariables(); } foreach ($variables as...
php
{ "resource": "" }
q241141
Exception.getCauseMessage
train
public function getCauseMessage() { $causes = []; $current = [ 'class' => get_class($this), 'message' => $this->getMessage(), 'code' => $this->getCode(), 'file' => $this->getFile(), 'line' => $this->getLine() ]; ...
php
{ "resource": "" }
q241142
Exception.getTraceSaveAsString
train
public function getTraceSaveAsString() { $traces = $this->getTrace(); $messages = ['STACK TRACE DETAILS : ']; foreach ($traces as $index => $trace) { $message = sprintf('#%d ', $index + 1); /** @noinspection UnSafeIsSetOverArrayInspection */ if (isset(...
php
{ "resource": "" }
q241143
Exception.switchType
train
protected function switchType($argument) { $stringType = null; $type = strtolower(gettype($argument)); switch ($type) { case 'boolean': $stringType = sprintf( '[%s "%s"]', ucwords($type), ((int) $argument === 1) ? 'Tr...
php
{ "resource": "" }
q241144
MysqlDriver.initialize
train
public function initialize() { $this->setDialect(new MysqlDialect($this)); $flags = $this->getConfig('flags'); if ($timezone = $this->getConfig('timezone')) { if ($timezone === 'UTC') { $timezone = '+00:00'; } $flags[PDO::MYSQL_ATTR_INIT_COM...
php
{ "resource": "" }
q241145
ProductController.listJsonAction
train
public function listJsonAction() { $em = $this->getDoctrine()->getManager(); $adminManager = $this->get('admin_manager'); /** @var \AdminBundle\Services\DataTables\JsonList $jsonList */ $jsonList = $this->get('json_list'); $jsonList->setRepository($em->getRepository('Ecommerc...
php
{ "resource": "" }
q241146
ProductController.statsAction
train
public function statsAction($id, $from, $to) { $em = $this->getDoctrine()->getManager(); /** @var Actor $entity */ $entity = $em->getRepository('EcommerceBundle:Product')->find($id); /** @var FrontManager $frontManager */ $adminManager = $this->container->get('admi...
php
{ "resource": "" }
q241147
ProductController.editAction
train
public function editAction(Request $request, Product $product) { //access control $user = $this->container->get('security.token_storage')->getToken()->getUser(); if ($user->isGranted('ROLE_USER') && $product->getActor()->getId() != $user->getId()) { return $this->redirect($this...
php
{ "resource": "" }
q241148
ProductController.createDeleteForm
train
private function createDeleteForm(Product $product) { return $this->createFormBuilder() ->setAction($this->generateUrl('ecommerce_product_delete', array('id' => $product->getId()))) ->setMethod('DELETE') ->getForm() ; }
php
{ "resource": "" }
q241149
ProductController.updateImage
train
public function updateImage(Request $request) { $fileName = $request->query->get('file'); $type = $request->query->get('type'); $value = $request->query->get('value'); /** @var Image $entity */ $qb = $this->getDoctrine()->getManager()->getRepository('CoreBundle:Image')...
php
{ "resource": "" }
q241150
VanillaStatsPlugin.Gdn_Dispatcher_BeforeDispatch_Handler
train
public function Gdn_Dispatcher_BeforeDispatch_Handler($Sender) { $Enabled = C('Garden.Analytics.Enabled', TRUE); if ($Enabled && !Gdn::PluginManager()->HasNewMethod('SettingsController', 'Index')) { Gdn::PluginManager()->RegisterNewMethod('VanillaStatsPlugin', 'StatsDashboard', 'SettingsContro...
php
{ "resource": "" }
q241151
VanillaStatsPlugin.StatsDashboard
train
public function StatsDashboard($Sender) { $StatsUrl = $this->AnalyticsServer; if (!StringBeginsWith($StatsUrl, 'http:') && !StringBeginsWith($StatsUrl, 'https:')) $StatsUrl = Gdn::Request()->Scheme()."://{$StatsUrl}"; // Tell the page where to find the Vanilla Analytics provider ...
php
{ "resource": "" }
q241152
VanillaStatsPlugin.SettingsController_DashboardSummaries_Create
train
public function SettingsController_DashboardSummaries_Create($Sender) { // Load javascript & css, check permissions, and load side menu for this page. $Sender->AddJsFile('settings.js'); $Sender->Title(T('Dashboard Summaries')); $Sender->RequiredAdminPermissions[] = 'Garden.Settings.Manage'; ...
php
{ "resource": "" }
q241153
Software.get
train
public function get() { $keys = $this->registry ->setRoot(Registry::HKEY_LOCAL_MACHINE) ->setPath($this->path) ->get(); $software = []; foreach ($keys as $key) { // Set a new temporary path for the software key $path = $this->path...
php
{ "resource": "" }
q241154
AbstractDbMapper.getResultSet
train
protected function getResultSet() { if (!$this->resultSetPrototype instanceof HydratingResultSet) { $resultSetPrototype = new HydratingResultSet; $resultSetPrototype->setHydrator($this->getHydrator()); $resultSetPrototype->setObjectPrototype($this->getModel()); ...
php
{ "resource": "" }
q241155
AbstractDbMapper.getById
train
public function getById($id, $col = null) { $col = ($col) ?: $this->getPrimaryKey(); $select = $this->getSelect()->where([$col => $id]); $resultSet = $this->fetchResult($select); if ($resultSet->count() > 1) { $rowSet = []; foreach ($resultSet as $row) { ...
php
{ "resource": "" }
q241156
AbstractDbMapper.fetchAll
train
public function fetchAll($sort = null) { $select = $this->getSelect(); $select = $this->setSortOrder($select, $sort); $resultSet = $this->fetchResult($select); return $resultSet; }
php
{ "resource": "" }
q241157
AbstractDbMapper.search
train
public function search(array $search, $sort, $select = null) { $select = ($select) ?: $this->getSelect(); foreach ($search as $key => $value) { if (!$value['searchString'] == '') { if (substr($value['searchString'], 0, 1) == '=' && $key == 0) { $id = ...
php
{ "resource": "" }
q241158
AbstractDbMapper.insert
train
public function insert(array $data, $table = null) { $table = ($table) ?: $this->getTable(); $sql = $this->getSql(); $insert = $sql->insert($table); $insert->values($data); $statement = $sql->prepareStatementForSqlObject($insert); $result = $statement->execute(); ...
php
{ "resource": "" }
q241159
AbstractDbMapper.paginate
train
public function paginate($select, $resultSet = null) { $resultSet = $resultSet ?: $this->getResultSet(); $adapter = new DbSelect($select, $this->getAdapter(), $resultSet); $paginator = new Paginator($adapter); $options = $this->getPaginatorOptions(); if (isset($options['lim...
php
{ "resource": "" }
q241160
AbstractDbMapper.fetchResult
train
protected function fetchResult(Select $select, AbstractResultSet $resultSet = null) { $resultSet = $resultSet ?: $this->getResultSet(); $resultSet->buffer(); if ($this->usePaginator()) { $this->setUsePaginator(false); $resultSet = $this->paginate($select, $resultSet)...
php
{ "resource": "" }
q241161
AbstractDbMapper.setSortOrder
train
public function setSortOrder(Select $select, $sort) { if ($sort === '' || null === $sort || empty($sort)) { return $select; } $select->reset('order'); if (is_string($sort)) { $sort = explode(' ', $sort); } $order = []; foreach ($sor...
php
{ "resource": "" }
q241162
Application.run
train
public static function run($root = '../', $routes = true, $session = true) { self::setScreen(); self::setRoot($root); // self::setCaseVars(false, false); // call the connector and run it self::callBus(); // Connector::run('web',$session); Bus::run('we...
php
{ "resource": "" }
q241163
Application.console
train
public static function console($root = '', $session = true) { self::setCaseVars(true, false); // self::consoleServerVars(); // self::setScreen(); self::setRoot($root); // call the connector and run it self::consoleBus(); Bus::run('lumos'); ...
php
{ "resource": "" }
q241164
Application.ini
train
protected static function ini($database = true, $test = false) { Alias::ini(self::$root); Url::ini(); Path::ini(); Template::run(); if (Component::isOn('faker')) { Faker::ini(); } Link::ini(); Lang::ini($test); if ($database && Comp...
php
{ "resource": "" }
q241165
Application.vendor
train
public static function vendor() { self::checkVendor(); $path = is_null(self::$root) ? 'vendor/autoload.php' : self::$root.'vendor/autoload.php'; include_once $path; }
php
{ "resource": "" }
q241166
Routes.setRoutes
train
private function setRoutes(array $routes) { $this->routes = []; foreach ($routes as $name => $route) { $this->add($name, $route); } }
php
{ "resource": "" }
q241167
RepositoryManager.registerRepository
train
public function registerRepository(ManagedRepositoryInterface $repository) { $name = $repository->getName(); if($this->hasRepository($name)) { throw new \LogicException(sprintf('Repository %s is already registered.', $name)); } $event = new ManagedRepositoryEvent($repository); $this->eventDispatcher->disp...
php
{ "resource": "" }
q241168
Parser.validate
train
public function validate ($object = null) { if (!isset ($this->context)) { throw new InvalidParameter ("You must set a context before validating or filtering."); } $result = $this->reduce ($this->context, $object); if ($result) { return true; } else { return false; } }
php
{ "resource": "" }
q241169
Configurator.loadEnv
train
public function loadEnv(string $path): Configurator { if (is_readable($path)) { $this->dotEnv->load($path); } return $this; }
php
{ "resource": "" }
q241170
Configurator.readConfigDir
train
public function readConfigDir(string $path): Configurator { if (!is_dir($path)) { throw new \InvalidArgumentException( sprintf("Config dir isn't a directory! %s given.", $path)); } $entitiesDir = new \DirectoryIterator($path); foreach ($entitiesDir as $fi...
php
{ "resource": "" }
q241171
TextFormHandler.process
train
public function process(Request $request, FormInterface $form) { if ($request->isMethod('POST')) { $form->submit($request); if ($form->isValid()) { /** @var TextInterface $text */ $text = $form->getData(); foreach ($text->getTranslation...
php
{ "resource": "" }
q241172
Rules._init
train
protected function _init() { parent::_init(); $this->_rules += [ 'allowAll' => [ 'rule' => function() { return true; } ], 'denyAll' => [ 'rule' => function() { return false; } ], 'allowAnyUser' => [ 'message' => 'You must be logged in.', 'rule' => function($user) { ...
php
{ "resource": "" }
q241173
Rules.check
train
public function check($user, $request, array $options = []) { $defaults = ['rules' => $this->_defaults, 'allowAny' => $this->_allowAny]; $options += $defaults; if (empty($options['rules'])) { throw new RuntimeException("Missing `'rules'` option."); } $rules = (array) $options['rules']; $this->_error = ...
php
{ "resource": "" }
q241174
SNMP.realWalk
train
public function realWalk($oid, $suffixAsKey = false) { try { $return = $this->_lastResult = $this->_session->walk($oid, $suffixAsKey); } catch (Exception $exc) { $this->close(); throw new Exception("Erro '{$this->_session->getError()}' with execute WALK OID ({$oid}): ...
php
{ "resource": "" }
q241175
SNMP.realWalkToArray
train
public function realWalkToArray($oid, $suffixAsKey = false) { $arrayData = $this->realWalk($oid, $suffixAsKey); foreach ($arrayData as $_oid => $value) { $this->_lastResult[$_oid] = $this->parseSnmpValue($value); } return $this->_lastResult; }
php
{ "resource": "" }
q241176
SNMP.realWalk1d
train
public function realWalk1d($oid) { $arrayData = $this->realWalk($oid); $result = array(); foreach ($arrayData as $_oid => $value) { $oidPrefix = substr($_oid, 0, strrpos($_oid, '.')); if (!isset($result[$oidPrefix])) { $result[$oidPrefix] = Array(); ...
php
{ "resource": "" }
q241177
SNMP.get
train
public function get($oid, $preserveKeys = false) { if ($this->cache() && ( $rtn = $this->getCache()->load($oid) ) !== null) { return $rtn; } try { $this->_lastResult = $this->_session->get($oid, $preserveKeys); } catch (Exception $exc) { $this->close(...
php
{ "resource": "" }
q241178
SNMP.subOidWalk
train
public function subOidWalk($oid, $position, $elements = 1) { if ($this->cache() && ( $rtn = $this->getCache()->load($oid) ) !== null) { return $rtn; } $this->_lastResult = $this->realWalk($oid); if ($this->_lastResult === false) { $this->close(); thr...
php
{ "resource": "" }
q241179
SNMP.walkIPv4
train
public function walkIPv4($oid) { if ($this->cache() && ( $rtn = $this->getCache()->load($oid) ) !== null) { return $rtn; } $this->_lastResult = $this->realWalk($oid); if ($this->_lastResult === false) { throw new Exception('Could not perform walk for OID ' . $oi...
php
{ "resource": "" }
q241180
SNMP.parseSnmpValue
train
public function parseSnmpValue($v) { // first, rule out an empty string if ($v == '""' || $v == '') { return ""; } $type = substr($v, 0, strpos($v, ':')); $value = trim(substr($v, strpos($v, ':') + 1)); switch ($type) { case 'STRING': ...
php
{ "resource": "" }
q241181
SNMP.setHost
train
public function setHost($h) { $this->_host = $h; // clear the temporary result cache and last result $this->_lastResult = null; unset($this->_resultCache); $this->_resultCache = array(); return $this; }
php
{ "resource": "" }
q241182
SNMP.getCache
train
public function getCache() { if ($this->_cache === null) { $this->_cache = new \Cityware\Snmp\Cache\Basic(); } return $this->_cache; }
php
{ "resource": "" }
q241183
SNMP.useExtension
train
public function useExtension($mib, $args) { $mib = '\\Cityware\\Snmp\\MIBS\\' . str_replace('_', '\\', $mib); $m = new $mib(); $m->setSNMP($this); return $m; }
php
{ "resource": "" }
q241184
SNMP.subOidWalkLong
train
public function subOidWalkLong($oid, $positionS, $positionE) { if ($this->cache() && ( $rtn = $this->getCache()->load($oid) ) !== null) { return $rtn; } $this->_lastResult = $this->realWalk($oid); if ($this->_lastResult === false) { throw new Exception('Could no...
php
{ "resource": "" }
q241185
Extension.addFormatter
train
protected function addFormatter(ServiceContainer $container, $name, $class) { $container->set( 'formatter.formatters.' . $name, function (ServiceContainer $c) use ($class) { $c->set('formatter.presenter', new StringPresenter($c->get('formatter.presenter.differ'))); ...
php
{ "resource": "" }
q241186
PluginList.getPluginClassNames
train
public function getPluginClassNames() { $plugins = array(); if (TRUE === $this->isEnabled('NamelessCoder\\GizzleGitPlugins\\GizzlePlugins\\ClonePlugin')) { $plugins[] = 'NamelessCoder\\GizzleGitPlugins\\GizzlePlugins\\ClonePlugin'; } if (TRUE === $this->isEnabled('NamelessCoder\\GizzleGitPlugins\\GizzlePlugi...
php
{ "resource": "" }
q241187
UshiosElasticSearchExtension.clientSettings
train
protected function clientSettings(array $configs, ContainerBuilder $container) { foreach($configs as $key => $infos){ $clientDefinition = new Definition(); $clientDefinition->setClass($infos['class']); $hostsSettings = $this->hostSettings($infos); ...
php
{ "resource": "" }
q241188
iauApcg.Apcg
train
public static function Apcg($date1, $date2, array $ebpv, array $ehp, iauASTROM &$astrom) { /* Geocentric observer */ $pv = [ [ 0.0, 0.0, 0.0], [ 0.0, 0.0, 0.0]]; /* Compute the star-independent astrometry parameters. */ IAU::Apcs($date1, $date2, $pv, $ebpv, $ehp, $astrom); /* Fi...
php
{ "resource": "" }
q241189
GroupDomainTrait.doRemoveSkills
train
protected function doRemoveSkills(Group $model, $data) { $errors = []; foreach ($data as $entry) { if (!isset($entry['id'])) { $errors[] = 'Missing id for Skill'; } else { $related = SkillQuery::create()->findOneById($entry['id']); $model->removeSkill($related); } } if (count($errors) > 0)...
php
{ "resource": "" }
q241190
GroupDomainTrait.doUpdateSkills
train
protected function doUpdateSkills(Group $model, $data) { // remove all relationships before SkillGroupQuery::create()->filterByGroup($model)->delete(); // add them $errors = []; foreach ($data as $entry) { if (!isset($entry['id'])) { $errors[] = 'Missing id for Skill'; } else { $related = Skill...
php
{ "resource": "" }
q241191
FormErrorsParser.realParseErrors
train
private function realParseErrors(FormInterface $form, array &$results) { $errors = $form->getErrors(); if (count($errors) > 0) { $config = $form->getConfig(); $name = $form->getName(); $label = $config->getOption('label'); $translation = $this->getTranslationDomain($form); if (e...
php
{ "resource": "" }
q241192
FormErrorsParser.getTranslationDomain
train
private function getTranslationDomain(FormInterface $form) { $translation = $form->getConfig()->getOption('translation_domain'); if (empty($translation)) { $parent = $form->getParent(); if (empty($parent)) $translation = 'messages'; while (empty($translation)) { $translation = $parent->g...
php
{ "resource": "" }
q241193
Entity.addFieldValidators
train
public function addFieldValidators(array $fieldValidators) { foreach ($fieldValidators as $fieldName => $validators) { $this->fieldValidators[$fieldName] = $validators; } }
php
{ "resource": "" }
q241194
Entity.getFieldsData
train
public function getFieldsData() { $fieldsData = array(); foreach ($this->getFields() as $field) { $fieldData = $this->$field; // If the field is an Entity, decode it. if ($fieldData instanceof self) { $fieldData = $fieldData->getFieldsData(); ...
php
{ "resource": "" }
q241195
Entity.store
train
public function store() { // Check whether the object has ever been stored. if ($this->isNew) { Logger::get()->debug('Storing new entity ' . get_class($this) . '...'); // Create the record. Get an ID back. $this->id = $this->getDataSource()->create($this->getField...
php
{ "resource": "" }
q241196
Entity.destroy
train
public function destroy() { // Delete from the persistence layer. $this->getDataSource()->destroy($this->id); // Remove from the registry. $this->getFactory()->unregisterEntity($this); // Done, garbage collection should do the rest. }
php
{ "resource": "" }
q241197
Compress.setOptions
train
public function setOptions($options) { if (!is_array($options) && !$options instanceof Traversable) { throw new Exception\InvalidArgumentException(sprintf( '"%s" expects an array or Traversable; received "%s"', __METHOD__, (is_object($options) ? ge...
php
{ "resource": "" }
q241198
Compress.getAdapter
train
public function getAdapter() { if ($this->adapter instanceof Compress\CompressionAlgorithmInterface) { return $this->adapter; } $adapter = $this->adapter; $options = $this->getAdapterOptions(); if (!class_exists($adapter)) { $adapter = 'Zend\\Filter\\...
php
{ "resource": "" }
q241199
Compress.setAdapter
train
public function setAdapter($adapter) { if ($adapter instanceof Compress\CompressionAlgorithmInterface) { $this->adapter = $adapter; return $this; } if (!is_string($adapter)) { throw new Exception\InvalidArgumentException('Invalid adapter provided; must be ...
php
{ "resource": "" }