_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
83
13k
language
stringclasses
1 value
meta_information
dict
q264300
EntityModifierByCurrentAction.modifyByNewsletterController
test
protected function modifyByNewsletterController() { /** @var \OxidEsales\Eshop\Application\Controller\NewsletterController $currentController */ $currentController = Registry::getConfig()->getActiveView(); if ($currentController->getNewsletterStatus()) { $this->activePageEntity->...
php
{ "resource": "" }
q264301
EntityModifierByCurrentAction.modifyWithUserRegistrationAction
test
protected function modifyWithUserRegistrationAction($user) { $errorCode = Registry::getRequest()->getRequestEscapedParameter('newslettererror'); $successCode = Registry::getRequest()->getRequestEscapedParameter('success'); if ($errorCode && $errorCode < 0) { $this->activePageEnt...
php
{ "resource": "" }
q264302
EventsTrait.disableEventSubscriber
test
public function disableEventSubscriber($subscriberClass) { $subscriberClass = $this->getSubscriberClassName($subscriberClass); $eventManager = $this->getEventManager(); /* @var EventSubscriber[] $subscribers */ foreach ($this->getEventListeners() as $subscribers) { while...
php
{ "resource": "" }
q264303
EventsTrait.restoreEventSubscribers
test
public function restoreEventSubscribers() { $eventManager = $this->getEventManager(); foreach ($this->disabledSubscribers as $subscriber) { $eventManager->addEventSubscriber($subscriber); } $this->disabledSubscribers = []; }
php
{ "resource": "" }
q264304
EventsTrait.disableEventListeners
test
public function disableEventListeners(string $event) { $eventManager = $this->getEventManager(); if (!\array_key_exists($event, $this->disabledListeners)) { $this->disabledListeners[$event] = []; } foreach ($this->getEventListeners($event) as $listener) { $e...
php
{ "resource": "" }
q264305
EventsTrait.disableEventListener
test
public function disableEventListener(string $event, $subscriberClass) { $subscriberClass = $this->getSubscriberClassName($subscriberClass); if (!\array_key_exists($event, $this->disabledListeners)) { $this->disabledListeners[$event] = []; } $eventManager = $this->getEve...
php
{ "resource": "" }
q264306
EventsTrait.restoreAllEventListeners
test
public function restoreAllEventListeners() { $eventManager = $this->getEventManager(); foreach ($this->disabledListeners as $event => $listeners) { /* @var EventSubscriber[] $listeners */ foreach ($listeners as $listener) { $eventManager->addEventListener($ev...
php
{ "resource": "" }
q264307
EventsTrait.restoreEventListeners
test
public function restoreEventListeners(string $event) { if (!\array_key_exists($event, $this->disabledListeners) || empty($this->disabledListeners[$event])) { return; } $eventManager = $this->getEventManager(); /* @var EventSubscriber[] $listeners */ $listeners =...
php
{ "resource": "" }
q264308
EventsTrait.getSubscriberClassName
test
protected function getSubscriberClassName($subscriberClass): string { if ($this->isEventSubscriber($subscriberClass)) { return \is_object($subscriberClass) ? \get_class($subscriberClass) : $subscriberClass; } throw new \InvalidArgumentException('subscriberClass must be an EventS...
php
{ "resource": "" }
q264309
EventsTrait.isEventSubscriber
test
private function isEventSubscriber($subscriberClass): bool { return \is_object($subscriberClass) || (\is_string($subscriberClass) && \class_exists($subscriberClass)) ? \in_array(EventSubscriber::class, \class_implements($subscriberClass), true) : false; }
php
{ "resource": "" }
q264310
EventsTrait.getEventListeners
test
protected function getEventListeners($event = null): array { $eventManager = $this->getEventManager(); return $event !== null && !$eventManager->hasListeners($event) ? [] : $eventManager->getListeners($event); }
php
{ "resource": "" }
q264311
ActiveUserDataProvider.getActiveUserHashedId
test
public function getActiveUserHashedId() { $id = null; if ($this->isLoaded()) { $id = md5($this->user->oxuser__oxid->value); } return $id; }
php
{ "resource": "" }
q264312
ActiveUserDataProvider.getActiveUserHashedEmail
test
public function getActiveUserHashedEmail() { $email = null; if ($this->isLoaded()) { $email = md5($this->user->oxuser__oxusername->value); } return $email; }
php
{ "resource": "" }
q264313
CacheProvider.generateCacheKey
test
public static function generateCacheKey() { $args = func_get_args(); if (empty($args)) { throw new \InvalidArgumentException('At least one argument must be passed to generate cache key.'); } $const = $args[0] . '::VERSION'; $version = defined($const) ? self::$deli...
php
{ "resource": "" }
q264314
CacheProvider.generateCacheKeys
test
public static function generateCacheKeys() { $args = func_get_args(); if (empty($args)) { throw new \InvalidArgumentException('At least one argument must be passed to generate cache key.'); } $ids = array_pop($args); if (!is_array($ids)) { throw new \I...
php
{ "resource": "" }
q264315
GetRequest.send
test
public function send() { $cc = curl_init($this->url); $this->logger->log("API connection established"); curl_setopt($cc, CURLOPT_HTTPHEADER, array('Authorization: Bearer ' . $this->apiKey, 'Content-type: application/json')); curl_setopt($cc, CURLOPT_RETURNTRANSFER, true)...
php
{ "resource": "" }
q264316
DotKey.exists
test
public function exists($key) { $index = explode('.', $key); self::getValue($this->item, $index, false, $err); return !$err; }
php
{ "resource": "" }
q264317
DotKey.get
test
public function get($key) { $index = explode('.', $key); $ret = self::getValue($this->item, $index, true, $err); if ($err) { $invalidPath = join('.', array_slice($index, 0, -1 * $err->incomplete)); trigger_error("Unable to get '$key': '$invalidPath' is a {$er...
php
{ "resource": "" }
q264318
DotKey.getValue
test
protected static function getValue($item, $index, $ignore = false, &$err = null) { $err = null; if (empty($index)) return $item; $key = array_shift($index); if ((is_array($item) || $item instanceof \Traversable) && isset($item[$key])) { return s...
php
{ "resource": "" }
q264319
DotKey.set
test
public function set($key, $value) { $index = explode('.', $key); self::setValue($this->item, $index, $value, false, $err); if ($err) { $invalidPath = join('.', array_slice($index, 0, -1 * $err->incomplete)); $reason = isset($err->var) ? "'$invalidPath' is a {...
php
{ "resource": "" }
q264320
DotKey.put
test
public function put($key, $value) { $index = explode('.', $key); $err = null; self::setValue($this->item, $index, $value, $this->assoc ? 'array' : 'object', $err); if ($err) { $invalidPath = join('.', array_slice($index, 0, -1 * $err->incomplete)); ...
php
{ "resource": "" }
q264321
DotKey.setValue
test
protected static function setValue(&$item, $index, $value, $create = false, &$err = null) { $err = null; $key = array_shift($index); if (is_array($item) || $item instanceof \Traversable) { if (empty($index)) { $item[$key] = $value; return...
php
{ "resource": "" }
q264322
DotKey.remove
test
public function remove($key) { $index = explode('.', $key); self::removeValue($this->item, $index, $err); if ($err) { $invalidPath = join('.', array_slice($index, 0, -1 * $err->incomplete)); trigger_error("Unable to remove '$key': '$invalidPath' is a {$err->v...
php
{ "resource": "" }
q264323
DotKey.removeValue
test
protected static function removeValue(&$item, $index, &$err = null) { $err = null; if (!is_object($item) && !is_array($item)) { $err = (object)['var' => gettype($item), 'incomplete' => count($index)]; return; } $key = array_shift($index); ...
php
{ "resource": "" }
q264324
Connector.setLogger
test
public function setLogger($loggerClass, $loggerFunc) { if(empty($loggerClass)) { $this->helper->setLogger($loggerFunc); } else { $this->helper->setLogger(array($loggerClass, $loggerFunc)); } }
php
{ "resource": "" }
q264325
SettingServiceProvider.boot
test
public function boot() { $this->registerTranslations(); $this->registerConfig(); $this->registerViews(); $this->registerFactories(); $this->setMailConfig(); }
php
{ "resource": "" }
q264326
SettingServiceProvider.setMailConfig
test
private function setMailConfig() { try { config([ 'mail.host' => setting()->get('mail.mail_host', ''), 'mail.port' => setting()->get('mail.mail_port', '2525'), 'mail.username' => setting()->get('mail.mail_user', ''), 'mail.password'...
php
{ "resource": "" }
q264327
ParcelshopConfig.get
test
public function get($key) { if (!isset($this->setFields[$key])) return null; return $this->setFields[$key]; }
php
{ "resource": "" }
q264328
ArrayFixtureGenerator.convertValue
test
protected function convertValue($value) { if (!is_array($value)) { return $value; } $result = 'array('; $values = array(); foreach ($value as $key => $val) { $values[] .= sprintf("'%s' => %s", $key, $this->convertValue($val)); } $resu...
php
{ "resource": "" }
q264329
ApiController.getPageSize
test
public function getPageSize(Request $request): int { $pageSize = $request->get('pageSize', 50); if ($pageSize > 5000) { return 5000; } return (int) $pageSize; }
php
{ "resource": "" }
q264330
CapsuleServiceProvider.register
test
public function register(Application $app) { $app['capsule.connection_defaults'] = array( 'driver' => 'mysql', 'host' => 'localhost', 'database' => null, 'username' => 'root', 'password' => null, 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci', ...
php
{ "resource": "" }
q264331
Config.validate
test
public function validate() { $resultingData = array_merge($this->defaultFields, $this->setFields); return $this->_arrayKeysExists($this->requiredFields, $resultingData); }
php
{ "resource": "" }
q264332
WP_Notice.instance
test
public static function instance() { if ( ! isset( self::$instance ) && ! ( self::$instance instanceof WP_Notice ) ) { self::$instance = new WP_Notice; self::$instance->init(); } return self::$instance; }
php
{ "resource": "" }
q264333
WP_Notice.init
test
private function init() { add_action( 'admin_notices', array( self::$instance, 'display' ) ); add_action( 'admin_print_scripts', array( self::$instance, 'load_script' ) ); add_action( 'wp_ajax_tdp_dismiss_notice', array( self::$instance, 'dismiss_notice_ajax' ) ); }
php
{ "resource": "" }
q264334
WP_Notice.load_script
test
public function load_script() { wp_register_script( 'tdp', trailingslashit( plugin_dir_url( __FILE__ ) ) . 'assets/js/main.js', array( 'jquery' ), self::$instance->version, true ); wp_enqueue_script( 'tdp' ); }
php
{ "resource": "" }
q264335
WP_Notice.display
test
public function display() { if ( is_null( self::$instance->notices ) || empty( self::$instance->notices ) ) { return; } foreach ( self::$instance->notices as $id => $notice ) { $id = self::$instance->get_id( $id ); // Check if the notice was dismissed. if ( self::$instance->is_dismissed( $id ) ) {...
php
{ "resource": "" }
q264336
WP_Notice.register_notice
test
public function register_notice( $id, $type, $content, $args = array() ) { if ( is_null( self::$instance->notices ) ) { self::$instance->notices = array(); } $id = self::$instance->get_id( $id ); $type = in_array( $t = sanitize_text_field( $type ), self::$instance->get_types() ) ? $t : 'updated'; ...
php
{ "resource": "" }
q264337
WP_Notice.dismiss_notice_ajax
test
public function dismiss_notice_ajax() { if ( ! isset( $_POST['id'] ) ) { echo 0; exit; } if ( empty( $_POST['id'] ) || false === strpos( $_POST['id'], 'tdp-' ) ) { echo 0; exit; } $id = self::$instance->get_id( str_replace( 'tdp-', '', $_POST['id'] ) ); echo self::$instance->dismiss_notice( $id...
php
{ "resource": "" }
q264338
WP_Notice.dismiss_notice
test
public function dismiss_notice( $id ) { $notice = self::$instance->get_notice( self::$instance->get_id( $id ) ); if ( self::$instance->is_dismissed( $id ) ) { return false; } return 'user' === $notice['scope'] ? self::$instance->dismiss_user( $id ) : self::$instance->dismiss_global( $id ); }
php
{ "resource": "" }
q264339
WP_Notice.dismiss_user
test
private function dismiss_user( $id ) { $dismissed = self::$instance->dismissed_user(); if ( in_array( $id, $dismissed ) ) { return false; } array_push( $dismissed, $id ); return update_user_meta( get_current_user_id(), 'tdp_dismissed_notices', $dismissed ); }
php
{ "resource": "" }
q264340
WP_Notice.dismiss_global
test
private function dismiss_global( $id ) { $dismissed = self::$instance->dismissed_global(); if ( in_array( $id, $dismissed ) ) { return false; } array_push( $dismissed, $id ); return update_option( 'tdp_dismissed_notices', $dismissed ); }
php
{ "resource": "" }
q264341
WP_Notice.restore_notice
test
public function restore_notice( $id ) { $id = self::$instance->get_id( $id ); $notice = self::$instance->get_notice( $id ); if ( false === $notice ) { return false; } return 'user' === $notice['scope'] ? self::$instance->restore_user( $id ) : self::$instance->restore_global( $id ); }
php
{ "resource": "" }
q264342
WP_Notice.restore_user
test
private function restore_user( $id ) { $id = self::$instance->get_id( $id ); $notice = self::$instance->get_notice( $id ); if ( false === $notice ) { return false; } $dismissed = self::$instance->dismissed_user(); if ( ! in_array( $id, $dismissed ) ) { return false; } $flip = array_flip( $d...
php
{ "resource": "" }
q264343
WP_Notice.restore_global
test
private function restore_global( $id ) { $id = self::$instance->get_id( $id ); $notice = self::$instance->get_notice( $id ); if ( false === $notice ) { return false; } $dismissed = self::$instance->dismissed_global(); if ( ! in_array( $id, $dismissed ) ) { return false; } $flip = array_fli...
php
{ "resource": "" }
q264344
WP_Notice.dismissed_notices
test
public function dismissed_notices() { $user = self::$instance->dismissed_user(); $global = self::$instance->dismissed_global(); return array_merge( $user, $global ); }
php
{ "resource": "" }
q264345
WP_Notice.is_dismissed
test
public function is_dismissed( $id ) { $dismissed = self::$instance->dismissed_notices(); if ( ! in_array( self::$instance->get_id( $id ), $dismissed ) ) { return false; } return true; }
php
{ "resource": "" }
q264346
WP_Notice.get_notice
test
public function get_notice( $id ) { $id = self::$instance->get_id( $id ); if ( ! is_array( self::$instance->notices ) || ! array_key_exists( $id, self::$instance->notices ) ) { return false; } return self::$instance->notices[ $id ]; }
php
{ "resource": "" }
q264347
Refinery.refineItem
test
public function refineItem($raw) { $refined = $this->setTemplate($raw); if ( ! empty($this->attachments)) { $refined = $this->merge($refined, $this->includeAttachments($raw)); } return $refined; }
php
{ "resource": "" }
q264348
Refinery.refineCollection
test
public function refineCollection($raw, $retainKey = false) { $refined = []; foreach ($raw as $key => $item) { if ($retainKey) { $this->key = $key; $refined[ $key ] = $this->refineItem($item); } else { $refined[] = $this->refine...
php
{ "resource": "" }
q264349
Refinery.includeAttachments
test
protected function includeAttachments($raw) { $attachments = []; foreach ($this->attachments as $attachment => $refinery) { if (isset($refinery['raw'])) { $attachments[$attachment] = $refinery['raw']($raw); } else { $class = $refinery['class']...
php
{ "resource": "" }
q264350
Refinery.getItems
test
protected function getItems($raw, $class, $attachment) { if ($class->hasFilter()) { $query = $class->getFilter(); return call_user_func_array($query, [$raw->$attachment()]); } else { return is_object($raw) ? $raw->$attachment : $raw[$attachment]; } }
php
{ "resource": "" }
q264351
Refinery.bring
test
public function bring($attachments) { if (is_string($attachments)) { $attachments = func_get_args(); } $this->attachments = $this->parseAttachments($attachments); return $this; }
php
{ "resource": "" }
q264352
Refinery.parseAttachments
test
protected function parseAttachments(array $relations) { $parsedRelations = []; foreach ($relations as $key => $relation) { if ( ! is_numeric($key)) { if (is_callable($relation)) { $parsedRelations[$key] = $this->attachItem($key); $...
php
{ "resource": "" }
q264353
Refinery.attachItem
test
protected function attachItem($attachment) { if ( ! method_exists($this, $attachment)) { throw new RefineryMethodNotFound( "No attachment set with the name '{$attachment}' on '" . get_class($this) . "'." ); } return $this->$attachment(); }
php
{ "resource": "" }
q264354
Refinery.attach
test
public function attach($className, callable $callback = null) { // If the user has passed through a callable item then we want // to attach the raw result of that call. if (is_callable($className)) { return ['raw' => $className]; } if ( ! class_exists($className)...
php
{ "resource": "" }
q264355
Refinery.merge
test
protected function merge($original, $merge) { if (is_array($original) && is_array($merge)) { return array_merge($original, $merge); } if (is_array($original)) { foreach ($merge as $key => $value) { $original[$key] = $value; } } els...
php
{ "resource": "" }
q264356
Request.getResponseHeaders
test
public function getResponseHeaders() { $headers = array(); $header_text = substr($this->result, 0, $this->headerSize); foreach (explode("\r\n", $header_text) as $i => $line) if (strlen($line) > 4 && substr($line, 0, 4) === "HTTP") { $headers['http_code'] = $line...
php
{ "resource": "" }
q264357
RestResponse.getCardReference
test
public function getCardReference() { if (isset($this->data['response']['token'])) { return $this->data['response']['token']; } if (isset($this->data['response']['card_token'])) { return $this->data['response']['card_token']; } }
php
{ "resource": "" }
q264358
RestResponse.getCustomerReference
test
public function getCustomerReference() { if (isset($this->data['response']['customer'])) { return $this->data['response']['customer']; } if (isset($this->data['response']['id'])) { return $this->data['response']['id']; } }
php
{ "resource": "" }
q264359
ClassUtils.getClassName
test
public static function getClassName($class) { if (!is_object($class) && !is_string($class)) { throw new InvalidArgumentException(sprintf('$object must be a string or an object, %s given', gettype($class))); } $className = is_string($class) ? $class : get_class($class); $...
php
{ "resource": "" }
q264360
ClassUtils.getNamespace
test
public static function getNamespace($class) { if (!is_object($class) && !is_string($class)) { throw new InvalidArgumentException('$object must be a string or an object'); } $class = (is_string($class) ? $class : get_class($class)); $pos = strrpos($class, '\\'); ...
php
{ "resource": "" }
q264361
ClassFixtureGenerator.findAdderMethod
test
private function findAdderMethod($obj, $key) { if (method_exists($obj, $method = 'add'.$key)) { return $method; } foreach ((array) StringUtil::singularify($key) as $singularForm) { if (method_exists($obj, $method = 'add'.$singularForm)) { return $meth...
php
{ "resource": "" }
q264362
ClassMetadataProxy.initMappings
test
protected function initMappings() { if ($this->initialized) { return $this; } foreach ($this->classMetadata->fieldMappings as $key => $mapping) { if (isset($mapping['reference'])) { $this->associationMappings[$key] = $mapping; } else { ...
php
{ "resource": "" }
q264363
Helper.setTranslationLang
test
public function setTranslationLang($lang) { global $translationData; $translationData = array(); $file = realpath(dirname(dirname(__FILE__)) . "/etc/lang/en-" . strtolower($lang) . ".csv"); if (file_exists($file)) { if (($handle = fopen($file, "r")) !== FALSE) { ...
php
{ "resource": "" }
q264364
AbstractGenerator.readProperty
test
protected function readProperty($object, $property) { foreach ($this->propertyReader as $reader) { /** @var PropertyReaderInterface $reader */ if ($reader->supports($object, $property)) { return $reader->getValue($object, $property); } } $...
php
{ "resource": "" }
q264365
EntityManagerController.defaultAction
test
public function defaultAction($name = null, $selfedit = 'false', $installMode = null) { $this->selfedit = $selfedit; $this->installMode = $installMode; $name = $name ? $name : 'entityManager'; $this->instanceName = $name; if ($selfedit == 'true') { $this->moufMa...
php
{ "resource": "" }
q264366
ModelHook.before
test
final public function before(string $action, Record $record, Record $previous = null): bool { $action = ucfirst($action); $method = "before{$action}"; $container = Container::instance(); if ($container->exists($this, $method)) { return $container->invoke($this, $method, [...
php
{ "resource": "" }
q264367
ModelHook.after
test
final public function after(string $action, Record $record, $extra = true) { $data = is_array($extra) ? $extra : []; $data = $this->afterDefault($action, $record, $data); $name = ucfirst($action); $method = "after{$name}"; $container = Container::instance(); if ($co...
php
{ "resource": "" }
q264368
Collection.extend
test
public function extend(Collection $collection) { foreach ($collection as $entity) { $this->append($entity); } return $this; }
php
{ "resource": "" }
q264369
Collection.append
test
public function append($data) { if (is_array($data) || $data instanceof \Traversable) { foreach ($data as $entity) { if (!$entity instanceof Entity) { throw new InvalidArgumentException('Collection can contain only Entities class'); } ...
php
{ "resource": "" }
q264370
Collection.prepend
test
public function prepend($entity) { $collection = $this->getNewCollection(); $collection->append($entity); foreach ($this as $entity) { $collection->append($entity); } $this->clear(); $this->append($collection); return $this; }
php
{ "resource": "" }
q264371
Collection.__isset
test
public function __isset($name) { if ($this->count() > 1) { throw new LogicException( 'Collection has more then one element, you cannot get entity property directly' ); } $current = $this->first(); if (!$current) { return false; ...
php
{ "resource": "" }
q264372
Collection.last
test
public function last() { $this->seek($this->count() - 1); $entity = $this->current(); $this->rewind(); return $entity; }
php
{ "resource": "" }
q264373
Collection.getElementMovedByOffset
test
private function getElementMovedByOffset($offset) { if (!is_int($this->key())) { throw new LogicException(sprintf("Can't get element moved by %s as current key is not numeric", $offset)); } $oldPosition = $this->key(); $newPosition = $oldPosition + $offset; $this-...
php
{ "resource": "" }
q264374
Collection.has
test
public function has($field, $value, $strict = false) { return !(false === $this->search($field, $value, $strict)); }
php
{ "resource": "" }
q264375
Collection.search
test
public function search($field, $value, $strict = false) { $value = is_array($value) ? $value : array($value); foreach ($this as $key => $entity) { if (isset($entity->$field) && in_array($entity->$field, $value, $strict)) { return $key; } } ret...
php
{ "resource": "" }
q264376
Collection.shift
test
public function shift() { $slice = $this->slice(0, 1); $offset = $slice->getKeys(); $this->offsetUnset($offset[0]); return $slice->first(); }
php
{ "resource": "" }
q264377
Collection.filter
test
public function filter(\Closure $callback) { $offsetToRemove = []; foreach ($this as $offset => $entity) { if (!$callback($entity)) { $offsetToRemove[] = $offset; } } $this->offsetUnset($offsetToRemove); return $this; }
php
{ "resource": "" }
q264378
Collection.getBy
test
public function getBy(\Closure $callback) { $instanceCopy = $this->getNewCollection(); foreach ($this as $offset => $entity) { if ($callback($entity)) { $instanceCopy->append($entity); } } return $instanceCopy; }
php
{ "resource": "" }
q264379
Collection.chunk
test
public function chunk($size) { $collection = $this->getNewCollection(); foreach (array_chunk($this->getKeys(), $size) as $chunkIndex => $keys) { $collection[$chunkIndex] = $this->getNewCollection(); foreach ($keys as $key) { $collection[$chunkIndex]->append(...
php
{ "resource": "" }
q264380
Collection.slice
test
public function slice($offset, $length = null) { $keys = $this->getKeys(); $keys = array_slice($keys, $offset, $length); $collection = $this->getNewCollection(); foreach ($this as $key => $entity) { if (in_array($key, $keys)) { $collection[$key] = $enti...
php
{ "resource": "" }
q264381
Collection.split
test
public function split($parts) { $elementsPerChunk = ceil($this->count() / $parts); return $this->chunk($elementsPerChunk); }
php
{ "resource": "" }
q264382
Collection.offsetUnset
test
public function offsetUnset($index) { $index = is_array($index) ? $index : (array)$index; foreach ($index as $key) { parent::offsetUnset($key); } return $this; }
php
{ "resource": "" }
q264383
Collection.distinctOn
test
public function distinctOn($propertyName) { $values = []; $keys = []; foreach ($this as $key => $entity) { if (in_array($entity->$propertyName, $values)) { $keys[] = $key; } else { $values[] = $entity->$propertyName; } ...
php
{ "resource": "" }
q264384
Collection.reverse
test
public function reverse() { $positions = array_flip($this->getKeys()); $this->uksort( function ($a, $b) use ($positions) { return ($positions[$a] < $positions[$b] ? 1 : -1); } ); return $this; }
php
{ "resource": "" }
q264385
Collection.getAllValuesForProperty
test
public function getAllValuesForProperty($name) { $values = []; foreach ($this as $entity) { if (isset($entity->$name)) { $value = $entity->$name; if (!($value === null || $value instanceof Collection && $value->isEmpty())) { if (is_scal...
php
{ "resource": "" }
q264386
Collection.bindCollection
test
public function bindCollection(Collection $collection, array $compareKeys, $propertyName) { $reflection = new \ReflectionClass($collection); $fromKey = key($compareKeys); $toKey = $compareKeys[$fromKey]; $collection = $collection->groupByField($fromKey); foreach ($this as ...
php
{ "resource": "" }
q264387
Collection.groupByField
test
private function groupByField($name) { $collection = $this->getNewCollection(); foreach ($this as $entity) { if (!isset($entity->$name) || $entity->$name === null) { continue; //when entity dosen't have set property it will be omitted } $value = $...
php
{ "resource": "" }
q264388
Configurator.prepareScopes
test
public function prepareScopes() { $result = []; foreach ($this->scopes as $key => $scope) { // If no scope configuration has been provided, just make scope's name to be its alias if (!is_array($scope)) { $result[$scope] = ['alias' => $scope]; ...
php
{ "resource": "" }
q264389
Configurator.parseScopeArguments
test
public function parseScopeArguments(array $scope) { $scope = new MosaicArray($scope); $result = []; // If "type" key has been provided, we have to typecast the result $type = $scope->getItem('type'); // Get default scope argument value $default = $scope->getItem('de...
php
{ "resource": "" }
q264390
Configurator.setType
test
protected function setType($variable, $type) { // Do nothing if $type is not a string if (is_string($type)) { if (in_array($type, ['bool', 'boolean'])) { // Only 1, '1', true and 'true' values will be converted to boolean true // Any other value will be co...
php
{ "resource": "" }
q264391
DoctrineInstallUtils.registerAnnotationBasedEntities
test
public function registerAnnotationBasedEntities($namespace, $directory) { $mappingDriver = InstallUtils::getOrCreateInstance('mappingDriver.'.$namespace, null, $this->moufManager); $mappingDriver->setCode('return new Doctrine\\ORM\\Mapping\\Driver\\AnnotationDriver($container->get(\'annotationReader\'),...
php
{ "resource": "" }
q264392
PathToNamespaceClassname.convert
test
public function convert($string) { $stringToCamelCase = new StringToCamelCase(); $parts = []; foreach (explode('/', trim($string, '/')) as $part) { $parts[] = ucfirst($stringToCamelCase->convert($part, '-')); } return implode('\\', $parts); }
php
{ "resource": "" }
q264393
Settings.prepareDataForInsert
test
private function prepareDataForInsert($data) { $items = []; foreach ($data as $key => $value) { $items[] = ['key' => $key, 'value' => $value]; } return $items; }
php
{ "resource": "" }
q264394
Settings.updateData
test
private function updateData($data) { $this->data = $data; $cache = Yii::$app->{$this->cache}; $cache->delete($this->cacheName); if (is_array($this->data) && count($this->data)) { $cache->set($this->cacheName, serialize($this->data)); } }
php
{ "resource": "" }
q264395
ModelParser.parseFilterFields
test
protected function parseFilterFields(array $data = []): array { $filters = []; foreach ($data as $name => $value) { if (is_array($value) && $name === '__filter__') { $filters = $this->parseFilterRules($filters, $value); continue; } ...
php
{ "resource": "" }
q264396
ModelParser.parseFilterValues
test
protected function parseFilterValues(array $filters = []): array { $values = []; foreach ($filters as $filter) { if (is_array($filter)) { $values = array_merge($values, $this->parseFilterValues($filter['filter'])); continue; } /** @...
php
{ "resource": "" }
q264397
ArrayToObject.convert
test
public function convert($data) { if (is_array($data)) { if (!is_numeric(key($data))) { return (object) array_map(__METHOD__, $data); } /** @var stdClass $data */ return $data; } else { /** @var stdClass $data */ ...
php
{ "resource": "" }
q264398
MenuItem.getLabel
test
public function getLabel() { if ($this->translationService) { return $this->translationService->getTranslation($this->label); } else { return $this->label; } }
php
{ "resource": "" }
q264399
MenuItem.getAdditionalStyleByType
test
public function getAdditionalStyleByType($type) { $return = null; if($this->additionalStyles) { foreach ($this->additionalStyles as $additionalStyle) { if($additionalStyle instanceof $type) { if($return === null) $return = $additionalStyle; else throw new \Exception("MenuItem: There are...
php
{ "resource": "" }