_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
83
13k
language
stringclasses
1 value
meta_information
dict
q264000
ActiveRecord.listTypes
test
public function listTypes($type) { $data = []; // create a reflection class to get constants $refl = new ReflectionClass(get_called_class()); $constants = $refl->getConstants(); foreach ($constants as $constantName => $constantValue) { // add prettified name to ...
php
{ "resource": "" }
q264001
ActiveRecord.getTypeLabel
test
public function getTypeLabel($type, $constId) { if (!is_null($type)) { $array = $this->listTypes($constId); if (isset($array[$type])) { return $array[$type]; } } return false; }
php
{ "resource": "" }
q264002
ActiveRecord.getListingOrderArray
test
public function getListingOrderArray() { $count = static::find() ->count(); $array = []; for ($i = 1; $i <= $count; $i++) { $array[$i] = $i; } return $array; }
php
{ "resource": "" }
q264003
FindReplace.findReplaceValue
test
public function findReplaceValue() { if (is_array($this->findText)) { //can be array $searchReplaceArray = []; foreach ($this->findText as $key => $value) { $searchReplaceArray[$value] = $this->replaceText; } } else { $searc...
php
{ "resource": "" }
q264004
NavigationIterator.next
test
public function next(): void { if ($this->currentItem instanceof Dropdown) { $this->currentDropdownItem = next($this->dropdownItems) ?: null; if ($this->currentDropdownItem) { return; } } $this->currentItem = next($this->items) ?: null; ...
php
{ "resource": "" }
q264005
NavigationIterator.currentTitle
test
public function currentTitle(): array { if (!$this->currentItem) { return []; } $title = [$this->currentItem->title()]; if ($this->currentItem instanceof Dropdown && $this->currentDropdownItem) { $title[] = $this->currentDropdownItem->title(); } ...
php
{ "resource": "" }
q264006
Generator.generateActiveField
test
public function generateActiveField($attribute) { $tableSchema = $this->getTableSchema(); if ($tableSchema === false || !isset($tableSchema->columns[$attribute])) { if (preg_match('/^(password|pass|passwd|passcode)$/i', $attribute)) { return "\$form->field(\$model, '$attr...
php
{ "resource": "" }
q264007
Factory.make
test
public function make($name, $attributes) { if (Str::contains($name, '.') || Str::contains($name, '/')) { throw new InvalidArgumentException("Invalid character in resource name [{$name}]."); } return $this->drivers[$name] = new Router($name, $attributes); }
php
{ "resource": "" }
q264008
Factory.of
test
public function of($name, $attributes = null) { if (! isset($this->drivers[$name])) { return $this->make($name, $attributes); } return $this->drivers[$name]; }
php
{ "resource": "" }
q264009
Factory.call
test
public function call($name, $parameters = []) { $child = null; // Available drivers does not include childs, we should split the // name into two (parent.child) where parent would be the name of // the resource. if (false !== strpos($name, '.')) { list($name, $ch...
php
{ "resource": "" }
q264010
Dispatcher.call
test
public function call(Router $driver, $name = null, array $parameters = []) { $resolver = $this->resolveDispatchDependencies($driver, $name, $parameters); // This would cater request to valid resource but pointing to an // invalid child. We should show a 404 response to the user on this ...
php
{ "resource": "" }
q264011
Dispatcher.resolveDispatchDependencies
test
public function resolveDispatchDependencies(Router $driver, $name, array $parameters) { $segments = $this->getNestedParameters($name, $parameters); $key = implode('.', array_keys($segments)); $uses = $driver->get('uses'); if (! is_null($name)) { if (isset($drive...
php
{ "resource": "" }
q264012
Dispatcher.getNestedParameters
test
protected function getNestedParameters($name, array $parameters) { $reserved = ['create', 'show', 'index', 'delete', 'destroy', 'edit']; $nested = []; if (($nestedCount = count($parameters)) > 0) { $nested = [$name => $parameters[0]]; for ($index = 1; $index < $ne...
php
{ "resource": "" }
q264013
Dispatcher.findRoutableAttributes
test
protected function findRoutableAttributes(Resolver $resolver) { $type = $resolver->getType(); if (in_array($type, ['restful', 'resource'])) { $method = 'find'.Str::studly($type).'Routable'; list($action, $parameters) = call_user_func([$this, $method], $resolver); } ...
php
{ "resource": "" }
q264014
Dispatcher.findRestfulRoutable
test
protected function findRestfulRoutable(Resolver $resolver) { $parameters = $resolver->getParameters(); $verb = $resolver->getVerb(); $action = (count($parameters) > 0 ? array_shift($parameters) : 'index'); $action = Str::camel("{$verb}_{$action}"); return [$action, $p...
php
{ "resource": "" }
q264015
Dispatcher.findResourceRoutable
test
protected function findResourceRoutable(Resolver $resolver) { $verb = $resolver->getVerb(); $swappable = [ 'post' => 'store', 'put' => 'update', 'patch' => 'update', 'delete' => 'destroy', ]; if (! isset($swappable[$verb])) ...
php
{ "resource": "" }
q264016
Dispatcher.getAlternativeResourceAction
test
protected function getAlternativeResourceAction(Resolver $resolver) { $parameters = $resolver->getParameters(); $segments = $resolver->getSegments(); $last = array_pop($parameters); $resources = array_keys($segments); if (in_array($last, ['edit', 'create', 'delete'...
php
{ "resource": "" }
q264017
Dispatcher.dispatch
test
protected function dispatch(Router $driver, $name, Resolver $resolver) { // Next we need to the action and parameters before we can call // the destination controller, the resolver would determine both // restful and resource controller. list($action, $parameters) = $this->findRoutab...
php
{ "resource": "" }
q264018
PickupController.listAction
test
public function listAction(Request $request, ?string $method): Response { $calculator = $this->getCalculator($method); $params = $request->request->all(); $pickupTemplate = $this->getDefaultTemplate(); $pickupCurrentId = null; $pickupList = []; $currentAddress...
php
{ "resource": "" }
q264019
PickupController.getCalculator
test
protected function getCalculator(string $shippingMethod): CalculatorInterface { $method = $this->getMethod($shippingMethod); if ($method === null) { return false; } /** @var CalculatorInterface $calculator */ $calculator = $this->calculatorRegistry->get($method-...
php
{ "resource": "" }
q264020
PickupController.getMethod
test
protected function getMethod(?string $shippingMethod): ShippingMethod { /** @var ShippingMethod|null $method */ $method = $this->getShippingMethodRepository()->findOneBy(['code' => $shippingMethod]); if ($method === null) { return false; } return $method; }
php
{ "resource": "" }
q264021
Router.route
test
public function route($name, $uses) { if (in_array($name, $this->reserved)) { throw new InvalidArgumentException("Unable to use reserved keyword [{$name}]."); } elseif (Str::contains($name, '/')) { throw new InvalidArgumentException("Invalid character in resource name [{$name...
php
{ "resource": "" }
q264022
Router.buildResourceSchema
test
protected function buildResourceSchema($name, $attributes) { $schema = [ 'name' => '', 'uses' => '', 'routes' => [], 'visible' => true, ]; if (! is_array($attributes)) { $uses = $attributes; $attributes = [...
php
{ "resource": "" }
q264023
OrderInitializeCompleteListener.updateShippingAddress
test
public function updateShippingAddress(ResourceControllerEvent $event): void { /** @var Order $order */ $order = $event->getSubject(); $pickup = $this->getPickupAddress($order); if (!empty($pickup)) { $shipping = clone $order->getShippingAddress(); $shipping-...
php
{ "resource": "" }
q264024
ControllerDispatcher.call
test
protected function call($instance, $route, $method) { $controller = get_class($instance); if (! method_exists($instance, $method)) { throw new NotFoundHttpException("Unable to call [{$controller}@{$method}]."); } return parent::call($instance, $route, $method); }
php
{ "resource": "" }
q264025
Response.handleIlluminateResponse
test
protected function handleIlluminateResponse(IlluminateResponse $content, Closure $callback = null) { $code = $content->getStatusCode(); $response = $content->getContent(); if ($this->isRenderableResponse($response)) { return $response->render(); } elseif ($this->isNo...
php
{ "resource": "" }
q264026
Response.handleResponseCallback
test
protected function handleResponseCallback($content, Closure $callback = null) { if ($callback instanceof Closure) { $content = call_user_func($callback, $content); } if (false === $content) { return $this->abort(404); } elseif (is_null($content)) { ...
php
{ "resource": "" }
q264027
Response.abort
test
protected function abort($code, $message = '', array $headers = []) { if ($code == 404) { throw new NotFoundHttpException($message); } throw new HttpException($code, $message, null, $headers); }
php
{ "resource": "" }
q264028
Response.isNoneHtmlResponse
test
protected function isNoneHtmlResponse(IlluminateResponse $content) { $contentType = $content->headers->get('Content-Type'); $isHtml = Str::startsWith($contentType, 'text/html'); return ! is_null($content) && ! $isHtml; }
php
{ "resource": "" }
q264029
Commands.register
test
public static function register(string $prefix, array $actions = [], array $options = []) { $handler = new ErrorHandler(); $handler->register(); Yii::$app->set('errorHandler', $handler); Yii::$app->controllerMap[$prefix] = [ 'class' => get_called_class(), ...
php
{ "resource": "" }
q264030
Commands.options
test
public function options($actionID) { $actionClass = $this->actions()[$actionID] ?? null; $action = new \ReflectionClass($actionClass); $actionOptions = []; foreach ($action->getProperties(\ReflectionProperty::IS_PUBLIC) as $property) { if (in_array($property->ge...
php
{ "resource": "" }
q264031
Psr6MemoryCache.deleteItem
test
public function deleteItem($key) { \WildWolf\Cache\Validator::validateKey($key); unset($this->cache[$key]); return true; }
php
{ "resource": "" }
q264032
Psr6MemoryCache.save
test
public function save(\Psr\Cache\CacheItemInterface $item) { $key = $item->getKey(); $val = $item->get(); if (is_object($val)) { $val = clone $val; } if (!($item instanceof \WildWolf\Cache\CacheItem)) { $expires = null; } else { $ex...
php
{ "resource": "" }
q264033
BlockOutputTrait.block
test
public function block($messages, $type = null, $style = null, $prefix = ' ', $padding = true, $escape = true) { $this->output->block($messages, $type, $style, $prefix, $padding, $escape); }
php
{ "resource": "" }
q264034
Psr16MemoryCache.get
test
public function get($key, $default = null) { \WildWolf\Cache\Validator::validateKey($key); if (isset($this->cache[$key])) { list($data, $expires) = $this->cache[$key]; if (null === $expires || (new \DateTime()) < $expires) { return $data; } ...
php
{ "resource": "" }
q264035
Psr16MemoryCache.set
test
public function set($key, $value, $ttl = null) { \WildWolf\Cache\Validator::validateKey($key); \WildWolf\Cache\Validator::validateTtl($ttl); if ($ttl instanceof \DateInterval) { $expires = new \DateTime(); $expires->add($ttl); } elseif (is_numeric($ttl)) { ...
php
{ "resource": "" }
q264036
Psr16MemoryCache.setMultiple
test
public function setMultiple($values, $ttl = null) { \WildWolf\Cache\Validator::validateIterable($values); \WildWolf\Cache\Validator::validateTtl($ttl); $result = true; foreach ($values as $key => $value) { if (is_int($key)) { $key = (string)$key; ...
php
{ "resource": "" }
q264037
Psr16MemoryCache.deleteMultiple
test
public function deleteMultiple($keys) { \WildWolf\Cache\Validator::validateIterable($keys); $result = true; foreach ($keys as $key) { $result = $this->delete($key) && $result; } return $result; }
php
{ "resource": "" }
q264038
Psr16MemoryCache.has
test
public function has($key) { \WildWolf\Cache\Validator::validateKey($key); if (isset($this->cache[$key])) { list(, $expires) = $this->cache[$key]; if (null === $expires || (new \DateTime()) < $expires) { return true; } unset($this->ca...
php
{ "resource": "" }
q264039
TextInputCustomLabel.getLabel
test
public function getLabel($caption = NULL) { $label = clone $this->label; $label->for = $this->getHtmlId(); if (!$label->getHtml()) { $label->setText($this->translate($caption === NULL ? $this->caption : $caption)); } return $label; }
php
{ "resource": "" }
q264040
NodeCategoryTrait.fullPathName
test
public function fullPathName($delimiter = '/') { $parents = $this->parents(); return implode($delimiter, $parents->pluck('name')->toArray()) . $delimiter . $this->name; }
php
{ "resource": "" }
q264041
NodeCategoryTrait.makeTree
test
public static function makeTree(\Illuminate\Database\Eloquent\Collection $collection, \Closure $map = null) { if (is_callable($map)) { $collection->map($map); } $categories = $collection->keyBy('id')->toArray(); $nodesKey = (new static)->getNodesKey(); foreach(...
php
{ "resource": "" }
q264042
OutputStyle.type
test
public function type(string $command, string $style = "fg=white", $speed = 5, string $prepend = "$ ") { if (!is_null($prepend)) { $this->write($prepend); } $chars = str_split($command); foreach ($chars as $char) { $this->write(sprintf("<%s>%s</>", $style, $...
php
{ "resource": "" }
q264043
SnsEndpoint.setResourceMembers
test
protected function setResourceMembers($resourcePath = null) { parent::setResourceMembers($resourcePath); $this->resource = array_get($this->resourceArray, 0); $pos = 1; $more = array_get($this->resourceArray, $pos); if (!empty($more)) { // This will be the ful...
php
{ "resource": "" }
q264044
Loader.loadPSRClass
test
private function loadPSRClass($class) { $prefix = $class; while (false !== $pos = strrpos($prefix, '\\')) { $prefix = substr($class, 0, $pos + 1); $relative_class = substr($class, $pos + 1); $mapped_file = $this->loadMappedFile($prefix, $relative_class); ...
php
{ "resource": "" }
q264045
Sns.setAccountId
test
protected function setAccountId($config) { $config['version'] = '2010-05-08'; $iam = new IamClient($config); $user = $iam->getUser()->get('User'); $arn = explode(':', array_get($user, 'Arn')); $this->accountId = array_get($arn, 4); }
php
{ "resource": "" }
q264046
Sns.translateException
test
static public function translateException(\Exception $exception, $add_msg = null) { $msg = strval($add_msg) . $exception->getMessage(); switch (get_class($exception)) { case 'Aws\Sns\Exception\AuthorizationErrorException': case 'Aws\Sns\Exception\EndpointDisabledException': ...
php
{ "resource": "" }
q264047
DoctrineMigrationsProvider.getConsole
test
public function getConsole(Container $app = null) { return $this->console ?: (isset($app['console']) ? $app['console'] : new Console()); }
php
{ "resource": "" }
q264048
Client.execute
test
function execute() { $data_to_post = array( 'apikey' => $this->apikey, 'command' => $this->command, 'params' => json_encode($this->params) ); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, PayPro::$apiUrl); curl_setopt($ch, CURLOPT_RETURNT...
php
{ "resource": "" }
q264049
Enum.values
test
public static function values() { $class = get_called_class(); if (!isset(self::$cache[$class])) { $reflected = new \ReflectionClass($class); self::$cache[$class] = $reflected->getConstants(); } return self::$cache[$class]; }
php
{ "resource": "" }
q264050
S3FileSystem.listContainers
test
public function listContainers($include_properties = false) { $this->checkConnection(); if (!empty($this->container)) { return $this->listResource($include_properties); } /** @noinspection PhpUndefinedMethodInspection */ $buckets = $this->blobConn->listBuckets()...
php
{ "resource": "" }
q264051
S3FileSystem.updateContainerProperties
test
public function updateContainerProperties($container, $properties = []) { $this->checkConnection(); try { if ($this->blobConn->doesBucketExist($container)) { throw new \Exception("No container named '$container'"); } } catch (\Exception $ex) { ...
php
{ "resource": "" }
q264052
S3FileSystem.blobExists
test
public function blobExists($container = '', $name = '') { try { $this->checkConnection(); return $this->blobConn->doesObjectExist($container, $name); } catch (\Exception $ex) { return false; } }
php
{ "resource": "" }
q264053
JWT.encode
test
public function encode(string $iss, string $aud, string $sub, string $expires = null, array $claims = []): string { $now = new DateTimeImmutable(); $claims = array_merge($claims, [ 'iss' => $iss, 'aud' => $aud, 'sub' => $sub, 'iat' => $now->getTimesta...
php
{ "resource": "" }
q264054
JWT.decode
test
public function decode(string $token, bool $ignoreExceptions = false): ?array { try { $payload = FirebaseJWT::decode($token, $this->publicKey, [self::ALGO]); return json_decode(json_encode($payload), true); } catch (Exception $exception) { $this->exceptionHandler...
php
{ "resource": "" }
q264055
JWT.payload
test
public function payload(string $token): array { $segments = $this->segments($token); return json_decode( FirebaseJWT::urlsafeB64Decode($segments[1]), true ); }
php
{ "resource": "" }
q264056
JWT.segments
test
protected function segments(string $token): array { $segments = explode('.', $token); if (3 !== count($segments)) { throw new Exception("Malformed jwt received."); } return $segments; }
php
{ "resource": "" }
q264057
JWT.expires
test
protected function expires(DateTimeImmutable $now, string $expires = null) { return !$expires ? null : $now->modify($expires)->getTimestamp(); }
php
{ "resource": "" }
q264058
RedshiftSchema.createIndex
test
public function createIndex($name, $table, $columns, $unique = false) { $cols = []; if (is_string($columns)) { $columns = preg_split('/\s*,\s*/', $columns, -1, PREG_SPLIT_NO_EMPTY); } foreach ($columns as $col) { if (strpos($col, '(') !== false) { ...
php
{ "resource": "" }
q264059
RedshiftSchema.extractDefault
test
public function extractDefault(ColumnSchema $field, $defaultValue) { if ($defaultValue === 'true') { $field->defaultValue = true; } elseif ($defaultValue === 'false') { $field->defaultValue = false; } elseif (0 === stripos($defaultValue, '"identity"')) { $...
php
{ "resource": "" }
q264060
PaginationHelper.addPrevButton
test
protected static function addPrevButton($sCode) { if(self::$iCurrentPage <= self::$arSettings[$sCode.'_button_limit']) { return; } //Get button value $sValue = self::getValue($sCode); //Get button name $sName = self::$arSettings[$sCode.'_button_name']; ...
php
{ "resource": "" }
q264061
PaginationHelper.addNextButton
test
protected static function addNextButton($sCode) { if(self::$iCurrentPage + self::$arSettings[$sCode.'_button_limit'] > self::$iTotalCountPages) { return; } //Get button value $sValue = self::getValue($sCode); //Get button name $sName = self::$arSettings[$sC...
php
{ "resource": "" }
q264062
PaginationHelper.getValue
test
protected static function getValue($sCode) { switch($sCode) { case self::FIRST_BUTTON_CODE: return 1; case self::FIRST_MORE_BUTTON_CODE: return null; case self::PREV_BUTTON_CODE: $iValue = self::$iCurrentPage - 1; ...
php
{ "resource": "" }
q264063
GraphTraverser.reveal
test
public static function reveal($object) { if ($object instanceof RecordInterface) { return $object; } elseif ($object instanceof JsonSerializable) { return $object->jsonSerialize(); } elseif ($object instanceof ArrayObject) { return $object->getArrayCopy();...
php
{ "resource": "" }
q264064
GraphTraverser.isObject
test
public static function isObject($value) { return $value instanceof RecordInterface || $value instanceof \stdClass || (is_array($value) && CurveArray::isAssoc($value)); }
php
{ "resource": "" }
q264065
GraphTraverser.isEmpty
test
public static function isEmpty($value) { if (empty($value)) { return true; } elseif ($value instanceof \stdClass) { return count((array) $value) === 0; } elseif ($value instanceof RecordInterface) { return count($value->getProperties()) === 0; } ...
php
{ "resource": "" }
q264066
Transformer.toRecord
test
public static function toRecord($data, RecordInterface $root = null) { $visitor = new RecordSerializeVisitor($root); $traverser = new GraphTraverser(); $traverser->traverse($data, $visitor); return $visitor->getObject(); }
php
{ "resource": "" }
q264067
Response.parseResponse
test
private function parseResponse($data, $op) { $arr = array(); $xml = new \SimpleXMLElement($data); $xml = $xml->xpath('/soap:Envelope/soap:Body'); $xml = $xml[0]; $data = json_decode(json_encode($xml)); $opResponse = $op . 'Response'; $opResult = $op . 'Result'...
php
{ "resource": "" }
q264068
DatagridRegistry.getConfigurator
test
public function getConfigurator(string $name): DatagridConfiguratorInterface { if (!isset($this->configurators[$name])) { $configurator = null; if (isset($this->lazyConfigurators[$name])) { $configurator = $this->lazyConfigurators[$name](); } ...
php
{ "resource": "" }
q264069
DatagridRegistry.hasConfigurator
test
public function hasConfigurator(string $name): bool { if (isset($this->configurators[$name])) { return true; } if (isset($this->lazyConfigurators[$name])) { return true; } return class_exists($name) && in_array(DatagridConfiguratorInterface::class, c...
php
{ "resource": "" }
q264070
WriterFactory.getWriterClassNameByFormat
test
public function getWriterClassNameByFormat($format) { $format = strtolower($format); foreach ($this->writers as $writer) { $class = get_class($writer); $name = strtolower(substr($class, strrpos($class, '\\') + 1)); if ($name == $format) { return ...
php
{ "resource": "" }
q264071
WriterFactory.getWriterFromContentNegotiation
test
protected function getWriterFromContentNegotiation(MediaType $contentType, array $supportedWriter = null) { if (empty($this->contentNegotiation)) { return null; } foreach ($this->contentNegotiation as $acceptedContentType => $writerClass) { if ($supportedWriter !== n...
php
{ "resource": "" }
q264072
DateTimeToLocalizedStringTransformer.transform
test
public function transform($dateTime) { if (null === $dateTime) { return ''; } if (!$dateTime instanceof \DateTime) { throw new TransformationFailedException('Expected a \DateTime.'); } // convert time to UTC before passing it to the formatter ...
php
{ "resource": "" }
q264073
DatagridView.init
test
public function init(DatagridInterface $datagrid) { if (null === $data = $datagrid->getData()) { throw new InvalidArgumentException('No data provided for the view.'); } $columns = $datagrid->getColumns(); foreach ($columns as $column) { $this->columns[$colum...
php
{ "resource": "" }
q264074
Processor.read
test
public function read($schema, Payload $payload, SchemaVisitorInterface $visitor = null) { $data = $this->parse($payload); $schema = $this->getSchema($schema); if ($visitor === null) { $visitor = new TypeVisitor(); } return $this->traverser->traverse( ...
php
{ "resource": "" }
q264075
Processor.parse
test
public function parse(Payload $payload) { $reader = $this->getReader($payload->getContentType(), $payload->getRwType(), $payload->getRwSupported()); $data = $reader->read($payload->getData()); $transformer = $payload->getTransformer(); if ($transformer === null) { $tr...
php
{ "resource": "" }
q264076
Processor.write
test
public function write(Payload $payload) { $data = $payload->getData(); $data = $this->transform($data); $writer = $this->getWriter($payload->getContentType(), $payload->getRwType(), $payload->getRwSupported()); return $writer->write($data); }
php
{ "resource": "" }
q264077
Processor.getReader
test
public function getReader($contentType, $readerType = null, array $supportedReader = null) { if ($readerType === null) { $reader = $this->config->getReaderFactory()->getReaderByContentType($contentType, $supportedReader); } else { $reader = $this->config->getReaderFactory()->...
php
{ "resource": "" }
q264078
Processor.getWriter
test
public function getWriter($contentType, $writerType = null, array $supportedWriter = null) { if ($writerType === null) { $writer = $this->config->getWriterFactory()->getWriterByContentType($contentType, $supportedWriter); } else { $writer = $this->config->getWriterFactory()->...
php
{ "resource": "" }
q264079
Laravel5._before
test
public function _before(\Codeception\TestCase $test) { $this->initializeLaravel(); if ($this->app['db'] && $this->config['cleanup']) { $this->app['db']->beginTransaction(); } }
php
{ "resource": "" }
q264080
Laravel5._after
test
public function _after(\Codeception\TestCase $test) { if ($this->app['db'] && $this->config['cleanup']) { $this->app['db']->rollback(); } if ($this->app['auth']) { $this->app['auth']->logout(); } if ($this->app['cache']) { $this->app['cac...
php
{ "resource": "" }
q264081
Laravel5._afterStep
test
public function _afterStep(\Codeception\Step $step) { \Illuminate\Support\Facades\Facade::clearResolvedInstances(); parent::_afterStep($step); }
php
{ "resource": "" }
q264082
Laravel5.initializeLaravel
test
protected function initializeLaravel() { $this->app = $this->bootApplication(); $this->app->instance('request', new Request()); $this->client = new LaravelConnector($this->app); $this->client->followRedirects(true); }
php
{ "resource": "" }
q264083
Laravel5.bootApplication
test
protected function bootApplication() { $projectDir = explode($this->config['packages'], \Codeception\Configuration::projectDir())[0]; $projectDir .= $this->config['root']; require $projectDir . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php'; \Illuminate\Support\ClassLoader::registe...
php
{ "resource": "" }
q264084
Laravel5.amOnRoute
test
public function amOnRoute($route, $params = []) { $domain = $this->app['routes']->getByName($route)->domain(); $absolute = ! is_null($domain); $url = $this->app['url']->route($route, $params, $absolute); $this->amOnPage($url); }
php
{ "resource": "" }
q264085
Laravel5.amOnAction
test
public function amOnAction($action, $params = []) { $namespacedAction = $this->actionWithNamespace($action); $domain = $this->app['routes']->getByAction($namespacedAction)->domain(); $absolute = ! is_null($domain); $url = $this->app['url']->action($action, $params, $absolute); ...
php
{ "resource": "" }
q264086
Laravel5.actionWithNamespace
test
protected function actionWithNamespace($action) { $rootNamespace = $this->getRootControllerNamespace(); if ($rootNamespace && ! (strpos($action, '\\') === 0)) { return $rootNamespace . '\\' . $action; } else { return trim($action, '\\'); } }
php
{ "resource": "" }
q264087
Laravel5.seeCurrentRouteIs
test
public function seeCurrentRouteIs($route, $params = array()) { $this->seeCurrentUrlEquals($this->app['url']->route($route, $params, false)); }
php
{ "resource": "" }
q264088
Laravel5.seeCurrentActionIs
test
public function seeCurrentActionIs($action, $params = array()) { $this->seeCurrentUrlEquals($this->app['url']->action($action, $params, false)); }
php
{ "resource": "" }
q264089
Laravel5.seeInSession
test
public function seeInSession($key, $value = null) { if (is_array($key)) { $this->seeSessionHasValues($key); return; } if (is_null($value)) { $this->assertTrue($this->app['session']->has($key)); } else { $this->assertEquals($value, $thi...
php
{ "resource": "" }
q264090
Laravel5.seeFormHasErrors
test
public function seeFormHasErrors() { $viewErrorBag = $this->app->make('view')->shared('errors'); $this->assertTrue(count($viewErrorBag) > 0); }
php
{ "resource": "" }
q264091
Laravel5.seeFormErrorMessage
test
public function seeFormErrorMessage($key, $errorMessage) { $viewErrorBag = $this->app['view']->shared('errors'); $this->assertEquals($errorMessage, $viewErrorBag->first($key)); }
php
{ "resource": "" }
q264092
Laravel5.amLoggedAs
test
public function amLoggedAs($user, $driver = null) { if ($user instanceof Authenticatable) { $this->app['auth']->driver($driver)->setUser($user); } else { $this->app['auth']->driver($driver)->attempt($user); } }
php
{ "resource": "" }
q264093
Laravel5.haveRecord
test
public function haveRecord($model, $attributes = array()) { $id = $this->app['db']->table($model)->insertGetId($attributes); if (!$id) { $this->fail("Couldn't insert record into table $model"); } return $id; }
php
{ "resource": "" }
q264094
NumberToLocalizedStringTransformer.transform
test
public function transform($value) { if (null === $value) { return ''; } if (!is_numeric($value)) { throw new TransformationFailedException('Expected a numeric.'); } $formatter = $this->getNumberFormatter(); $value = $formatter->format($value)...
php
{ "resource": "" }
q264095
NumberToLocalizedStringTransformer.getNumberFormatter
test
protected function getNumberFormatter($type = \NumberFormatter::DECIMAL) { $formatter = new \NumberFormatter(\Locale::getDefault(), $type); if (null !== $this->precision) { $formatter->setAttribute(\NumberFormatter::FRACTION_DIGITS, $this->precision); $formatter->setAttribut...
php
{ "resource": "" }
q264096
CurveArray.nest
test
public static function nest(array $data, $seperator = '_') { if (self::isAssoc($data)) { $result = new \stdClass(); foreach ($data as $key => $value) { if (($pos = strpos($key, $seperator)) !== false) { $subKey = substr($key, 0, $pos); ...
php
{ "resource": "" }
q264097
CurveArray.flatten
test
public static function flatten($data, $seperator = '_', $prefix = null, array &$result = null) { if ($result === null) { $result = array(); } if ($data instanceof \stdClass) { $data = (array) $data; } elseif (!is_array($data)) { throw new InvalidA...
php
{ "resource": "" }
q264098
CurveArray.objectify
test
public static function objectify(array $data) { if (self::isAssoc($data)) { $result = new \stdClass(); foreach ($data as $key => $value) { $result->{$key} = is_array($value) ? self::objectify($value) : $value; } return $result; } else ...
php
{ "resource": "" }
q264099
ResolvedColumnType.createColumn
test
public function createColumn(string $name, array $options = []): ColumnInterface { $options = $this->getOptionsResolver()->resolve($options); return $this->newColumn($name, $options); }
php
{ "resource": "" }