_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
83
13k
language
stringclasses
1 value
meta_information
dict
q236700
View_Factory.build
train
public function build() : Response { $view_root = ''; $template_name = $this->get_template_name(); $file_extension = $this->get_file_extension( $view_root, $template_name ); $view_data = $this->view_data; $content = ''; if ( 'handlebars' === $file_extension ) { $view = new Simple_Handl...
php
{ "resource": "" }
q236701
View_Factory.get_file_extension
train
private function get_file_extension( $view_root, $template_name ) { $paths = to_array( $this->get_path_to_views() ); // get first element in array $path = reset( $paths ); if ( ! empty( $view_root ) ) { $path .= '/' . $view_root; } $path .= '/' . $template_name; $files = glob( $path . '.*' ); //re...
php
{ "resource": "" }
q236702
Auth_Login_Ormauth.get
train
public function get($field, $default = null) { // if it's an object property, return it, else return the default return isset($this->user->{$field}) ? $this->user->{$field} : $default; }
php
{ "resource": "" }
q236703
Auth_Login_Ormauth.get_profile_fields
train
public function get_profile_fields($field = null, $default = null) { // collect all meta data $profile_fields = array(); foreach ($this->user->metadata as $metadata) { if (empty($field)) { $profile_fields[$metadata->key] = $metadata->value; } elseif ($field == $metadata->key) { return $...
php
{ "resource": "" }
q236704
BuildClass.replaceClassNameSingular
train
protected function replaceClassNameSingular(&$stub, $name) { $stub = str_replace( '[[DummyClassNameSingular]]', Str::singular($this->getNameInput()), $stub ); return $this; }
php
{ "resource": "" }
q236705
BuildClass.replaceClassNameLowerCase
train
protected function replaceClassNameLowerCase(&$stub, $name) { $stub = str_replace( '[[DummyClassNameLowerCase]]', Str::plural(Str::lower($this->getNameInput())), $stub ); return $this; }
php
{ "resource": "" }
q236706
AbstractRoute.run
train
public function run() { try { $response = $this->buildResponse(); } catch (Error\Base $ex) { $response = $this->handleError($ex); } $this->serializer->serialize($response, $this); return $this; }
php
{ "resource": "" }
q236707
AbstractRoute.handleError
train
public function handleError(Error\Base $ex) { // build response body $body = [ 'type' => $this->singularClassName($ex), 'message' => $ex->getMessage(), ]; if ($ex instanceof InvalidRequest && $param = $ex->getParam()) { $body['param'] = $param; ...
php
{ "resource": "" }
q236708
AbstractRoute.getEndpoint
train
public function getEndpoint() { $basePath = $this->app['config']->get('api.base_path', self::DEFAULT_BASE_PATH); $basePath = $this->stripTrailingSlash($basePath); // determine the base URL for the API, // i.e. https://api.example.com/v1 $urlBase = $this->app['config']->get('...
php
{ "resource": "" }
q236709
AbstractRoute.humanClassName
train
public function humanClassName($class) { // get the class name if an object is given if (is_object($class)) { $class = get_class($class); } // split the class name up by namespaces $namespace = explode('\\', $class); $className = end($namespace); ...
php
{ "resource": "" }
q236710
AbstractRoute.singularClassName
train
public function singularClassName($class) { // get the class name if an object is given if (is_object($class)) { $class = get_class($class); } // split the class name up by namespaces $namespace = explode('\\', $class); $className = end($namespace); ...
php
{ "resource": "" }
q236711
AbstractRoute.pluralClassName
train
public function pluralClassName($class) { // get the class name if an object is given if (is_object($class)) { $class = get_class($class); } // split the class name up by namespaces $namespace = explode('\\', $class); $className = end($namespace); ...
php
{ "resource": "" }
q236712
DoctrineConsoleRunner.run
train
public function run() { $helperSet = $this->getConsoleHelperSet(); ConsoleRunner::run($helperSet, $this->getConsoleCommands($helperSet)); }
php
{ "resource": "" }
q236713
WidgetFactory.add
train
public function add($name, $title, $properties, $controllerClass) { register_widget(new Widget($name, $title, $properties, $this->plugin, $controllerClass)); }
php
{ "resource": "" }
q236714
FootprintGenerator.generate
train
public function generate() { $reference = []; $scanner = $this->getScanner(); /** @var $class ClassScanner */ foreach ($scanner->getClasses() as $class) { $footprint = $this->getClassFootprint($class); $reference[$class->getName()] = $footprint->export(); ...
php
{ "resource": "" }
q236715
FootprintGenerator.getClassFootprint
train
protected function getClassFootprint(ClassScanner $class) { $footprint = new ClassFootprint(); if ($class->isInterface()) { $footprint->setType(ClassFootprint::TYPE_INTERFACE); } elseif ($class->isTrait()) { $footprint->setType(ClassFootprint::TYPE_TRAIT); } ...
php
{ "resource": "" }
q236716
Doctrine.buildIdentificationCriteria
train
protected function buildIdentificationCriteria(array $subject) { $criteria = []; foreach ($this->identificationFields as $dbField => $subjectField) { if (empty($subject[$subjectField])) { throw new \InvalidArgumentException(sprintf('Subject must contain a(n) "%s" field',...
php
{ "resource": "" }
q236717
PHPUnitHelper.addExpectedValue
train
protected function addExpectedValue($key, $value) { if (isset($this->expectedMocks[$key]) || isset($this->expectedMocksCollections[$key]) || isset($this->expectedValues[$key])) { throw new \LogicException( sprintf('The expected value "%s" you are trying to add is already set as m...
php
{ "resource": "" }
q236718
PHPUnitHelper.addHelpMock
train
protected function addHelpMock($key, \PHPUnit_Framework_MockObject_MockObject $mock) { if (isset($this->helpMocks[$key])) { throw new \LogicException('The help mock you are trying to add is already set.'); } $this->helpMocks[$key] = $mock; return $this; }
php
{ "resource": "" }
q236719
PHPUnitHelper.addHelpResource
train
protected function addHelpResource($key, $resource) { if (isset($this->helpResources[$key])) { throw new \LogicException('The resource you are trying to add is already set.'); } if (false === is_object(($resource))) { throw new \InvalidArgumentException(sprintf('The ...
php
{ "resource": "" }
q236720
PHPUnitHelper.addHelpValue
train
protected function addHelpValue($key, $value) { if (is_object($value)) { throw new \InvalidArgumentException(sprintf('The HelpValue with ID "%s" you are trying to add is an object. Use $this->addHelpMock() instead.', $key)); } if (isset($this->helpValues[$key])) { th...
php
{ "resource": "" }
q236721
PHPUnitHelper.bindExpectedToObject
train
protected function bindExpectedToObject() { $accessor = PropertyAccess::createPropertyAccessor(); $values = array_merge($this->expectedValues, $this->expectedMocks, $this->expectedMocksCollections); foreach ($values as $property => $value) { if (is_array($value)) { ...
php
{ "resource": "" }
q236722
PHPUnitHelper.generateMocksCollection
train
protected function generateMocksCollection(\PHPUnit_Framework_MockObject_MockObject $mock, $repeatFor = 1) { $collection = []; for ($i = 1; $i <= $repeatFor; $i++) { $collection[] = clone $mock; } return $collection; }
php
{ "resource": "" }
q236723
PHPUnitHelper.getHelpMock
train
protected function getHelpMock($key) { if (!isset($this->helpMocks[$key])) { throw new \InvalidArgumentException(sprintf('The required mock object "%s" doesn\'t exist.', $key)); } return $this->helpMocks[$key]; }
php
{ "resource": "" }
q236724
PHPUnitHelper.getHelpResource
train
protected function getHelpResource($key) { if (!isset($this->helpResources[$key])) { throw new \InvalidArgumentException(sprintf("The resource \"%s\" you are asking for doesn't exist.", $key)); } return $this->helpResources[$key]; }
php
{ "resource": "" }
q236725
PHPUnitHelper.getMockFromMocksCollection
train
protected function getMockFromMocksCollection($mockName, $collection, $andRemove = false) { if (!isset($this->expectedMocksCollections[$collection][$mockName])) { throw new \InvalidArgumentException(sprintf('The required mock "%s" doesn\'t exist in collection "%s".', $mockName, $collection)); ...
php
{ "resource": "" }
q236726
PHPUnitHelper.removeMockFromMocksCollection
train
protected function removeMockFromMocksCollection($mockName, $collection) { if (!isset($this->expectedMocksCollections[$collection][$mockName])) { throw new \InvalidArgumentException(sprintf('The required mock "%s" doesn\'t exist in collection "%s".', $mockName, $collection)); } ...
php
{ "resource": "" }
q236727
PHPUnitHelper.helpTearDown
train
protected function helpTearDown() { // At least unset the helper properties $this->actualResult = null; $this->expectedMocks = null; $this->expectedMocksCollections = null; $this->expectedValues = null; $this->helpMocks = null; $this->helpResources = null; ...
php
{ "resource": "" }
q236728
PHPUnitHelper.printMemoryUsageInfo
train
public function printMemoryUsageInfo() { if (null === $this->memoryBeforeTearDown) { throw new \BadMethodCallException('To use measurement features you need to call PHPUnit_Helper::measureMemoryBeforeTearDown() first.'); } if (null === $this->memoryAfterTearDown) { $...
php
{ "resource": "" }
q236729
PHPUnitHelper.tearDownWithReflection
train
public function tearDownWithReflection() { $this->helpTearDown(); $refl = new \ReflectionObject($this); foreach ($refl->getProperties() as $prop) { if (!$prop->isStatic() && 0 !== strpos($prop->getDeclaringClass()->getName(), 'PHPUnit_')) { $prop->setAccessible(t...
php
{ "resource": "" }
q236730
PHPUnitHelper.formatMemory
train
private function formatMemory($size) { $isNegative = false; $unit = ['b', 'kb', 'mb', 'gb', 'tb', 'pb']; if (0 > $size) { // This is a negative value $isNegative = true; } $return = ($isNegative) ? '-' : ''; return $return .round( ...
php
{ "resource": "" }
q236731
Str.smrtr
train
public static function smrtr($haystack, $aMatch, $aDelimiter = array("{","}")) { $aCleaned = array(); foreach ($aMatch as $key => $v) { $aCleaned[$aDelimiter[0].$key.$aDelimiter[1]] = $v; } return strtr($haystack, $aCleaned); }
php
{ "resource": "" }
q236732
PresenterTrait.setPresenter
train
public function setPresenter($presenter) { if (is_string($presenter)) { $this->presenter = $this->getPresenter($presenter); } else { $this->presenter = $presenter; } return $this->presenter; }
php
{ "resource": "" }
q236733
Cookie.setExpireTimestamp
train
public function setExpireTimestamp($unixTimestamp) { $this->expire = new \DateTime(); $this->expire->setTimestamp($unixTimestamp); return $this; }
php
{ "resource": "" }
q236734
Object.__send
train
final public function __send() { $args = func_get_args(); $method = array_shift($args); if ($this->__respondTo($method)) { return call_user_func_array(array($this, $method), $args); } $message = new KoineString("Undefined method '"); $message->append($...
php
{ "resource": "" }
q236735
Document.contains
train
public function contains($name){ foreach($this->segments as $segment){ if($segment->getName() == $name) return true; } return false; }
php
{ "resource": "" }
q236736
Document.addSegment
train
public function addSegment($segment, $other = null){ if(!$segment instanceof Segment){ $segment = new Segment($segment); } if($this->getIndexOf($segment->getName())) throw new \Exception('Section with this name already exists'); if($other){ if(($index = $this->getIndexOf($other))===false) throw new \Excep...
php
{ "resource": "" }
q236737
Document.getSegment
train
public function getSegment($name){ foreach($this->segments as $segment){ if($segment->getName() == $name) return $segment; } return false; }
php
{ "resource": "" }
q236738
Document.getIndexOf
train
private function getIndexOf($segment){ if($segment instanceof Segment){ foreach($this->segments as $index=>$other){ if($other === $segment){ return $index; } } }else{ foreach($this->segments as $index=>$other){ if($other->getName() === $segment){ return $index; } } } return...
php
{ "resource": "" }
q236739
AppController._loadSettings
train
protected function _loadSettings() { $settings = Cache::remember('settings', function () { /** @var SettingsTable $Settings */ $Settings = $this->loadModel('Wasabi/Core.Settings'); return $Settings->getAllKeyValues(); }, 'wasabi/core/longterm'); $event = ...
php
{ "resource": "" }
q236740
Sms.logSending
train
protected function logSending() { $text = $this->getText(); Log::Debug("Sending sms to recipients: " . $this->getRecipientList(), "Sms"); Log::BulkData( "Sms content", "Sms", "\r\n\r\n" . $text ); return; }
php
{ "resource": "" }
q236741
Scheme.myParse
train
private static function myParse(string $scheme, ?string &$result = null, ?int &$type = null, ?int &$defaultPort = null, ?string &$error = null): bool { if ($scheme === '') { $error = 'Scheme "' . $scheme . '" is empty.'; return false; } $result = strtolower($scheme)...
php
{ "resource": "" }
q236742
BaseAdminController.editAction
train
public function editAction($id = null) { try { return parent::editAction($id); } catch (\Exception $e) { return $this->editActionException($e); } }
php
{ "resource": "" }
q236743
BaseAdminController.deleteAction
train
public function deleteAction($id) { try { return parent::deleteAction($id); } catch (\Exception $e) { return $this->deleteActionException($e); } }
php
{ "resource": "" }
q236744
Attachable.notifyObjects
train
public function notifyObjects($method, array $args = []) { if ($this->_classes) { foreach ($this->_classes as $options) { if (!$options['callback'] || in_array($options['alias'], $this->_restricted)) { continue; } $object = $this->...
php
{ "resource": "" }
q236745
Str.format
train
public static function format($value, $format) { // Verificar se value eh um array if (is_array($value)) { return array_map(function ($val) use ($format) { return sprintf($format, $val); }, $value); } return sprintf($format, $value); }
php
{ "resource": "" }
q236746
Orders.initialize
train
protected function initialize() { parent::initialize(); $this->data = new stdClass(); $this->data->ownId = null; $this->data->amount = new stdClass(); $this->data->amount->currency = self::AMOUNT_CURRENCY; $this->data->amount->subtotals = new stdClass(); $thi...
php
{ "resource": "" }
q236747
Orders.find
train
public function find($order_id) { $response = $this->client->get('/{order_id}', [$order_id]); $this->populate($response); return $this; }
php
{ "resource": "" }
q236748
Orders.addItem
train
public function addItem($product, $quantity, $detail, $price) { $item = new stdClass(); $item->product = $product; $item->quantity = $quantity; $item->detail = $detail; $item->price = $this->convertAmount($price); $this->data->items[] = $item; return $this; ...
php
{ "resource": "" }
q236749
Orders.setCustomer
train
public function setCustomer($customer) { $this->data->customer = new stdClass; $this->data->customer = $customer; return $this; }
php
{ "resource": "" }
q236750
Orders.setAddition
train
public function setAddition($value) { $this->data->amount->subtotals->addition = $this->convertAmount($value); return $this; }
php
{ "resource": "" }
q236751
Orders.addAddition
train
public function addAddition($value) { $this->data->amount->subtotals->addition += $this->convertAmount($value); return $this; }
php
{ "resource": "" }
q236752
Orders.setDiscount
train
public function setDiscount($value) { $this->data->amount->subtotals->discount = $this->convertAmount($value); return $this; }
php
{ "resource": "" }
q236753
Orders.addDiscount
train
public function addDiscount($value) { $this->data->amount->subtotals->discount -= $this->convertAmount($value); return $this; }
php
{ "resource": "" }
q236754
Orders.setShippingAmount
train
public function setShippingAmount($value) { $this->data->amount->subtotals->shipping = $this->convertAmount($value); return $this; }
php
{ "resource": "" }
q236755
UrlGenerator.route
train
public function route($name, $parameters = []) { $route = router()->route($name); if (is_null($route)) { throw new \Exception("Route name [$name] not found"); } $route_url = $route->url($parameters); return $this->to($route_url); }
php
{ "resource": "" }
q236756
AccessLevelManager.loadAccessLevels
train
protected function loadAccessLevels() { $accessLevels = $this->accessLevelsObjectBackend->loadObject(); if (!is_array($accessLevels)) { $accessLevels = array(); } $this->accessLevels = $accessLevels; }
php
{ "resource": "" }
q236757
AccessLevelManager.addAccessLevel
train
public function addAccessLevel(AccessLevel $accessLevel) { // Add the access level $this->accessLevels[$accessLevel->getKey()] = $accessLevel; // Save the access levels $this->saveAccessLevels(); }
php
{ "resource": "" }
q236758
AccessLevelManager.removeAccessLevel
train
public function removeAccessLevel($key) { if (!isset($this->accessLevels[$key])) { return false; } // Remove the access level unset($this->accessLevels[$key]); // Save the access levels $this->saveAccessLevels(); // Revok...
php
{ "resource": "" }
q236759
AccessLevelManager.getAccessLevels
train
public function getAccessLevels() { // Give the modules the opportunity to add additional access levels $runtimeManager = $this->framework->getRuntimeManager(); $accessLevels = $runtimeManager->executeFilter('\\Zepi\\Core\\AccessControl\\Filter\\AccessLevelManager\\RegisterAccessLev...
php
{ "resource": "" }
q236760
Validator.errorArray
train
public function errorArray() { $messages = []; foreach ($this->failures as $key => $rule) { foreach ($rule->getFailures() as $fail) { $messages[] = $fail; } } return $messages; }
php
{ "resource": "" }
q236761
Arr.filter
train
public static function filter(array $arr, callable $callback) { foreach ($arr as $key => $value) { if (is_array($value) && count($value) > 0) { $arr[$key] = static::filter($value, $callback); } if (!call_user_func($callback, $arr[$key], $key)) { ...
php
{ "resource": "" }
q236762
Arr.pull
train
public static function pull(&$array, $key, $default = null) { if (array_key_exists($key, $array)) { $value = $array[$key]; unset($array[$key]); } else { $value = $default; } return $value; }
php
{ "resource": "" }
q236763
Arr.toString
train
public static function toString(array $arr, $kvsep, $psep) { $result = []; foreach ($arr as $k => $v) { $result[] = "{$k}{$kvsep}{$v}"; } return implode($psep, $result); }
php
{ "resource": "" }
q236764
Arr.getObjectWithKey
train
public static function getObjectWithKey(array $array, $key) { foreach ($array as $object) { if (is_array($object) && array_key_exists($key, $object)) { return $object; } } return null; }
php
{ "resource": "" }
q236765
Arr.getObjectWithKeyAndValue
train
public static function getObjectWithKeyAndValue(array $array, $key, $value) { foreach ($array as $object) { if (is_array($object) && array_key_exists($key, $object) && $object[$key] === $value) { return $object; } } return null; }
php
{ "resource": "" }
q236766
BaseInstallShell.getFieldInput
train
public function getFieldInput($field) { $model = ClassRegistry::init($this->usersModel); switch ($field) { case 'username': $username = trim($this->in('Username:')); if (!$username) { $username = $this->getFieldInput($field);...
php
{ "resource": "" }
q236767
EventDispatcher.addListener
train
public function addListener($name, $listener, $priority = 0) { if (! isset($this->listeners[$name])) $this->listeners[$name] = []; $this->listeners[$name][$priority][] = $listener; }
php
{ "resource": "" }
q236768
EltDecoration.setAttribute
train
public function setAttribute( string $name, $value = '', bool $replaceIfExists = false, $condition = true) { $name = trim(Text::toLower($name)); if ($condition) { if (!preg_match('/^[a-z0-9_-]+$/', $name)) { Checkers::not...
php
{ "resource": "" }
q236769
EltDecoration.removeCssClass
train
public function removeCssClass($cssClass) { if (array_key_exists($cssClass, $this->cssClasses)) { unset($this->cssClasses[$cssClass]); } return $this; }
php
{ "resource": "" }
q236770
EltDecoration.appendStyle
train
public function appendStyle($cssStyle) { $cssStyle = trim($cssStyle, " \n;"); $cssStyle && $this->styles[] = $cssStyle; return $this; }
php
{ "resource": "" }
q236771
EltDecoration.getAttributes
train
public function getAttributes():array { $attributes = $this->attributes; if ($this->cssClasses) { $attributes['class'] = implode(' ', array_keys($this->cssClasses)); } if ($this->styles) { $attributes['style'] = implode(';', $this->styles); } r...
php
{ "resource": "" }
q236772
EltDecoration.buildIdAttr
train
protected function buildIdAttr($eltId = null, bool $errorIfExists = false) { if ($errorIfExists && isset($this->attributes['id'])) { throw new \Osf\Exception\ArchException('Id element already set'); } if ($eltId === null) { $eltId = 'e' . self::$eltIdCount++; ...
php
{ "resource": "" }
q236773
MetaApiService.getAssociationCategories
train
public function getAssociationCategories() { $url = $this->getBaseApiUrl() . '/meta/association/categories'; $xml = $this->queryXml($url); return $xml->metalist; }
php
{ "resource": "" }
q236774
MetaApiService.getAssociationRepertoires
train
public function getAssociationRepertoires() { $url = $this->getBaseApiUrl() . '/meta/association/repertoires'; $xml = $this->queryXml($url); return $xml->metalist; }
php
{ "resource": "" }
q236775
MetaApiService.getAssociationPerformancelevels
train
public function getAssociationPerformancelevels() { $url = $this->getBaseApiUrl() . '/meta/association/performancelevels'; $xml = $this->queryXml($url); return $xml->metalist; }
php
{ "resource": "" }
q236776
MetaApiService.getEventTypes
train
public function getEventTypes() { $url = $this->getBaseApiUrl() . '/meta/event/types'; $xml = $this->queryXml($url); return $xml->metalist; }
php
{ "resource": "" }
q236777
Profiler.replaceParamInSql
train
protected function replaceParamInSql()/*# : string */ { $count = 0; $params = $this->params; return preg_replace_callback( '/\?|\:\w+/', function ($m) use ($count, $params) { if ('?' === $m[0]) { $res = $params[$count++]; ...
php
{ "resource": "" }
q236778
Database.escape
train
public function escape($VAL) { // save data if (is_numeric($VAL)) { if (floatval($VAL) == intval($VAL)) { $VAL = intval($VAL); settype($VAL, 'integer'); } else { $VAL = floatval($VAL); settype($VAL, 'float'); ...
php
{ "resource": "" }
q236779
Database.get
train
public function get($table, $cols, $options = array(), $distinct = false, $total_rows = false) { // Get Data $rows = array(); $result = $this->select($table, $cols, $options, $distinct, $total_rows); while ($row = $result->fetch(\PDO::FETCH_ASSOC)) { $rows[] = $row; ...
php
{ "resource": "" }
q236780
Database.getRow
train
public function getRow($table, $cols, $options = array(), $start = 0) { // Set Limit $options['L'] = $start . ",1"; // Get Result $result = $this->get($table, $cols, $options); if (count($result['data']) >= 1) { return $result['data'][0]; } else { ...
php
{ "resource": "" }
q236781
Database.getField
train
public function getField($table, $field, $options = array(), $start = 0) { // Get Result $result = $this->getRow($table, array($field), $options, $start); if (count($result) >= 1) return array_shift($result); else return false; }
php
{ "resource": "" }
q236782
Database.save
train
public function save($table, $data, $id = 'id', $auto_id = true) { // Update if (isset($data[$id]) && $this->getFieldById($table, $id, $this->escape($data[$id]), $id) !== false) { try { return $this->updateById($table, $data, $id); } catch (\Exception $e) { ...
php
{ "resource": "" }
q236783
Database.error
train
public function error($return = false) { if (!empty($this->error)) { if ($return) { return $this->error; } var_dump($this->error); return null; } return false; }
php
{ "resource": "" }
q236784
Database.last
train
public function last($return = false) { if (!empty($this->query)) { if ($return) { return $this->query; } var_dump($this->query); return null; } return false; }
php
{ "resource": "" }
q236785
Extractor.fromMethod
train
public static function fromMethod( string $method, string $class = null, bool $withParents = false ): array { if ($class) { try { $refMethod = new \ReflectionMethod($class, $method); } catch (\ReflectionException $e) { ...
php
{ "resource": "" }
q236786
Extractor.fromProperty
train
public static function fromProperty( string $class, string $property ): array { try { $property = new \ReflectionProperty($class, $property); } catch (\ReflectionException $e) { throw new Exception( "Property '{$class}::{$property...
php
{ "resource": "" }
q236787
Extractor.fromClass
train
public static function fromClass( string $class, bool $withParents = false ): array { try { $class = new \ReflectionClass($class); } catch (\ReflectionException $e) { throw new Exception( "Class '{$class}' not found.", ...
php
{ "resource": "" }
q236788
Extractor.fromFunction
train
public static function fromFunction( string $fn ): array { try { $fn = new \ReflectionFunction($fn); } catch (\ReflectionException $e) { throw new Exception( "Function {$fn} not found.", Exception::FUNCTION_NOT_FOUND ...
php
{ "resource": "" }
q236789
Group.getGroups
train
public function getGroups($byid = false, $skip_guest = false) { if ($byid) { $data = $this->byid; if ($skip_guest) { unset($data[- 1]); } } else { $data = $this->groups; if ($skip_guest) { unset($d...
php
{ "resource": "" }
q236790
Group.getGroupById
train
public function getGroupById($id_group) { if (array_key_exists($id_group, $this->byid)) { return $this->byid[$id_group]; } return false; }
php
{ "resource": "" }
q236791
Group.getGroupByAppAndName
train
public function getGroupByAppAndName($app, $name) { if (array_key_exists($app, $this->groups) && array_key_exists($name, $this->groups[$app])) { return $this->groups[$app][$name]; } return false; }
php
{ "resource": "" }
q236792
VerifyEventName.execute
train
public function execute(Framework $framework, RequestAbstract $request, Response $response, $value = null) { if (!($request instanceof WebRequest)) { return $value; } $fullUrl = $request->getRequestedUrl(); $urlParts = parse_url($fullUrl); ...
php
{ "resource": "" }
q236793
VerifyEventName.verifyPath
train
protected function verifyPath($urlParts) { if (isset($urlParts['path'])) { $path = $urlParts['path']; if (substr($path, -1) !== '/' && (strrpos($path, '.') === false || strrpos($path, '.') < strrpos($path, '/'))) { $path .= '/'; } $ur...
php
{ "resource": "" }
q236794
Game.generateMovesForBots
train
private function generateMovesForBots() { foreach ($this->getPlayers() as &$player) { $last_move = $player->getLastMoveIndex(); // generate move for bots if ($player->isBot() && empty($last_move)) { $move = $this->generateMove(); $player-...
php
{ "resource": "" }
q236795
Game.getWinners
train
public function getWinners() { $outcomes = $this->getOutcomes(); foreach ($outcomes as $outcome) { $winners[] = $outcome['winners']; } return $winners; }
php
{ "resource": "" }
q236796
MongoDBRegistry.findByKey
train
public function findByKey($key) { $document = $this->collection->findOne(['_id' => $key]); return $this->hydrateEntity($document); }
php
{ "resource": "" }
q236797
MongoDBRegistry.findByKeys
train
public function findByKeys(array $keys) { $result = []; /** @var Cursor $list */ $list = $this->collection->find(['_id' => ['$in' => $keys]]); foreach ($list as $document) { $result[] = $this->hydrateEntity($document); } return $result; }
php
{ "resource": "" }
q236798
MongoDBRegistry.add
train
public function add($key, $data) { $toInsert = $this->getDocumentData($data); $result = $this->collection->insertOne($toInsert); $data->_id = $result->getInsertedId(); }
php
{ "resource": "" }
q236799
MongoDBRegistry.getDocumentData
train
protected function getDocumentData($document) { if (is_array($document)) { $data = $document; } elseif ($document instanceof AbstractDocument) { $reflectionClass = new \ReflectionClass($document); $documentProperty = $reflectionClass->getParentClass()->getProperty...
php
{ "resource": "" }