_id stringlengths 2 7 | title stringlengths 3 151 | partition stringclasses 3
values | text stringlengths 83 13k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q246400 | FactoryGallery.createGallery | validation | private static function createGallery(String $body, int $order, String $photo, String $source, string $lead): \One\Model\Gallery
{
return new Gallery(
$body,
$order,
$photo,
$source,
$lead
);
} | php | {
"resource": ""
} |
q246401 | Article.getAttachmentByField | validation | public function getAttachmentByField(string $field): array
{
if (isset($this->attachment[$field])) {
return $this->attachment[$field];
}
return [];
} | php | {
"resource": ""
} |
q246402 | Article.attach | validation | public function attach(string $field, Model $item): self
{
$this->attachment[$field][] = $item;
return $this;
} | php | {
"resource": ""
} |
q246403 | Article.attachGallery | validation | public function attachGallery(Gallery $gallery): self
{
return $this->attach(
self::ATTACHMENT_FIELD_GALLERY,
$this->ensureOrder(
$gallery,
self::ATTACHMENT_FIELD_GALLERY
)
);
} | php | {
"resource": ""
} |
q246404 | EmailSenderSerializer.serialize | validation | public function serialize(EntityContract $entity, Collection $select = null)
{
$bag = parent::serialize($entity, $select);
// ...
return $bag;
} | php | {
"resource": ""
} |
q246405 | EmailSenderManager.send | validation | public function send(EmailSender $email, array $data = [])
{
$result = (new DataBuilderManager())->validateRaw($email->data_builder, $data);
dispatch(new SendEmail($email, $data, $this->getAgent()));
return $result;
} | php | {
"resource": ""
} |
q246406 | EmailSenderManager.render | validation | public function render(DataBuilder $data_builder, $parameters, array $data = [])
{
$parameters = $this->castParameters($parameters);
$tm = new TemplateManager();
$result = new Result();
try {
$bag = new Bag($parameters);
$bag->set('body', $tm->renderRaw('t... | php | {
"resource": ""
} |
q246407 | Model.filterUriInstance | validation | protected function filterUriInstance($uri): string
{
if ($uri instanceof UriInterface) {
return (string) $uri;
}
if (is_string($uri)) {
return (string) \One\createUriFromString($uri);
}
return '';
} | php | {
"resource": ""
} |
q246408 | Model.filterDateInstance | validation | protected function filterDateInstance($date): string
{
if (empty($date)) {
$date = new \DateTime('now', new \DateTimeZone('Asia/Jakarta'));
}
if (is_string($date) || is_int($date)) {
$date = new \DateTime($date, new \DateTimeZone('Asia/Jakarta'));
}
... | php | {
"resource": ""
} |
q246409 | Model.convertNonAscii | validation | private function convertNonAscii(string $string): string
{
$search = $replace = [];
// Replace Single Curly Quotes
$search[] = chr(226) . chr(128) . chr(152);
$replace[] = "'";
$search[] = chr(226) . chr(128) . chr(153);
$replace[] = "'";
// Replace Smart Do... | php | {
"resource": ""
} |
q246410 | Types.getTypeByValue | validation | public static function getTypeByValue($value)
{
if (is_int($value)) {
return self::TYPE_INT;
} elseif (is_string($value)) {
return self::TYPE_QSTRING;
} elseif (is_bool($value)) {
return self::TYPE_BOOL;
} elseif (self::isList($value)) {
... | php | {
"resource": ""
} |
q246411 | Types.getNameByType | validation | public static function getNameByType($type)
{
static $map = array(
self::TYPE_BOOL => 'Bool',
self::TYPE_INT => 'Int',
self::TYPE_UINT => 'UInt',
self::TYPE_QCHAR => 'QChar',
self::TYPE_QVARIANT_MAP => 'QVariantMap',
self::TYPE_QVARIANT... | php | {
"resource": ""
} |
q246412 | Photo.getAvailableRatios | validation | private function getAvailableRatios(): array
{
return [
self::RATIO_SQUARE,
self::RATIO_RECTANGLE,
self::RATIO_HEADLINE,
self::RATIO_VERTICAL,
self::RATIO_COVER,
];
} | php | {
"resource": ""
} |
q246413 | Yaml.setEncoder | validation | public function setEncoder(callable $encoder): Yaml
{
if (!is_callable($encoder)) {
throw new \InvalidArgumentException('The provided encoder must be callable.');
}
$this->encoder = $encoder;
return $this;
} | php | {
"resource": ""
} |
q246414 | FactoryArticle.createArticle | validation | public static function createArticle(String $title, string $body, string $source, string $uniqueId, int $typeId, int $categoryId, string $reporter, string $lead, string $tags, string $publishedAt, int $identifier): Article
{
return new Article(
$title,
$body,
$source,
... | php | {
"resource": ""
} |
q246415 | Collection.get | validation | public function get(string $key)
{
return isset($this->props[$key]) ? $this->props[$key] : null;
} | php | {
"resource": ""
} |
q246416 | Collection.set | validation | public function set(string $key, $value): self
{
if (! isset($this->props[$key])) {
throw new \Exception('Cannot add new property from set. Use add()');
}
$this->props[$key] = $value;
return $this;
} | php | {
"resource": ""
} |
q246417 | Collection.add | validation | public function add(string $key, $value): self
{
if (! array_key_exists($key, $this->props)) {
return $this->addNew($key, $value);
}
if (is_array($this->props[$key])) {
return $this->addArray($key, $value);
}
return $this->appendToArray($key, $value)... | php | {
"resource": ""
} |
q246418 | Collection.map | validation | public function map(\Closure $callback, $context = []): self
{
$collection = new static();
foreach ($this->props as $key => $value) {
$collection->add($key, $callback($value, $key, $context));
}
return $collection;
} | php | {
"resource": ""
} |
q246419 | Collection.filter | validation | public function filter(\Closure $callback): self
{
$collection = new static();
foreach ($this->props as $key => $value) {
if ($callback($value, $key)) {
$collection->add($key, $value);
}
}
return $collection;
} | php | {
"resource": ""
} |
q246420 | Collection.addNew | validation | private function addNew(string $key, $value): self
{
$this->props[$key] = $value;
return $this;
} | php | {
"resource": ""
} |
q246421 | Collection.addArray | validation | private function addArray(string $key, $value): self
{
$this->props[$key][] = $value;
return $this;
} | php | {
"resource": ""
} |
q246422 | Collection.appendToArray | validation | private function appendToArray(string $key, $value): self
{
$this->props[$key] = [$this->props[$key], $value];
return $this;
} | php | {
"resource": ""
} |
q246423 | Gallery.fillSource | validation | private function fillSource($source, $photo): string
{
if (! empty($source)) {
return $this->filterUriInstance($source);
}
return (string) $photo;
} | php | {
"resource": ""
} |
q246424 | FormatMapping.article | validation | public function article(string $singleJsonArticle): Article
{
if (json_decode($singleJsonArticle, true)) {
$dataArticle = json_decode($singleJsonArticle, true)['data'];
$article = new Article(
$this->filterString(
$this->getValue('title', $dataAr... | php | {
"resource": ""
} |
q246425 | FormatMapping.lookUp | validation | private function lookUp(array $articleConstant): array
{
$copyListAttributes = $this->listAttributes;
return array_map(function ($singleConst) use ($copyListAttributes) {
$res = $copyListAttributes[$singleConst];
return array_map(function ($str) use ($singleConst) {
... | php | {
"resource": ""
} |
q246426 | FormatMapping.generalAttachment | validation | private function generalAttachment(
Article $article,
array $attachmentConst,
array $attachmentype,
array $attributes,
array $dataArticle
): Article {
$numOfAttachments = count($attachmentConst);
for ($i = 0; $i < $numOfAttachments; $i++) {
$attac... | php | {
"resource": ""
} |
q246427 | FormatMapping.makeAttachmentObject | validation | private function makeAttachmentObject(string $attachmentType, array $attrReferences, array $item)
{
$attrValues = [];
foreach ($attrReferences as $attrReference) {
$attrValues[$attrReference] = $this->getValue($attrReference, $item);
}
switch ($attachmentType) {
... | php | {
"resource": ""
} |
q246428 | FormatMapping.createPhoto | validation | private function createPhoto(string $url, string $ratio, string $desc, string $info): \One\Model\Photo
{
return new Photo(
$url,
$ratio,
$this->handleString($desc),
$this->handleString($info)
);
} | php | {
"resource": ""
} |
q246429 | FormatMapping.createPage | validation | private function createPage(string $title, string $body, string $source, int $order, string $cover, string $lead): \One\Model\Page
{
return new Page(
$title,
$body,
$source,
$order,
$cover,
$lead
);
} | php | {
"resource": ""
} |
q246430 | FormatMapping.createVideo | validation | private function createVideo(string $body, string $source, int $order, string $cover, string $lead): \One\Model\Video
{
return new Video(
$body,
$source,
$order,
$cover,
$lead
);
} | php | {
"resource": ""
} |
q246431 | FormatMapping.filterString | validation | private function filterString($str): string
{
if (is_string($str) && strlen($str) > 0 && $str !== null) {
return $str;
}
throw new \Exception('String required', 1);
} | php | {
"resource": ""
} |
q246432 | FormatMapping.handleString | validation | private function handleString($str): string
{
return is_string($str) &&
strlen($str) > 0
&& $str !== null ? $str : '';
} | php | {
"resource": ""
} |
q246433 | Router.map | validation | public function map(array $methods, string $path, RequestHandlerInterface $handler): Route
{
return $this->routes[] = new Route($methods, $path, $handler);
} | php | {
"resource": ""
} |
q246434 | Router.dispatch | validation | public function dispatch(ServerRequestInterface $request): ServerRequestInterface
{
$dispatcher = simpleDispatcher([$this, 'addRoutes']);
$routeInfo = $dispatcher->dispatch($request->getMethod(), $request->getUri()->getPath());
if ($routeInfo[0] === Dispatcher::METHOD_NOT_ALLOWED) {
... | php | {
"resource": ""
} |
q246435 | Router.addRoutes | validation | public function addRoutes(RouteCollector $routeCollector): void
{
foreach ($this->routes as $index => $route) {
$routeCollector->addRoute($route->getMethods(), $route->getPath(), $index);
}
} | php | {
"resource": ""
} |
q246436 | Client.getMethodResult | validation | protected function getMethodResult($method, array $arguments)
{
if (!is_callable(['Elasticsearch\Client', $method])) {
trigger_error(
sprintf('Call to undefined or protected/private method %s::%s()', get_called_class(), $method),
E_USER_ERROR
);
... | php | {
"resource": ""
} |
q246437 | Client.addSearchResult | validation | public function addSearchResult($index, $type, array $documents)
{
$result = [
'took' => 5,
'timed_out' => false,
'_shards' => [ 'total' => 5, 'successful' => 5, 'failed' => 0 ],
'hits' => [
'total' => count($documents),
'max_sc... | php | {
"resource": ""
} |
q246438 | LumenServiceProvider.version | validation | protected function version()
{
$version = explode('(', $this->app->version());
if (isset($version[1])) {
return substr($version[1], 0, 3);
}
return null;
} | php | {
"resource": ""
} |
q246439 | Message.save | validation | public function save()
{
try
{
$connection = new Connection($this->buildConnectionOptions());
$connection->open();
$msg = new AMQPMessage($this->message, array('content_type' => $this->content_type, 'delivery_mode' => 2));
$connection->channel->basic_... | php | {
"resource": ""
} |
q246440 | BaseOptions.validateOptions | validation | public function validateOptions(array $options)
{
foreach ($options as $option => $value)
{
if (!in_array($option, $this->allowedOptions))
throw new InvalidOptionException("Option [$option] is not valid");
}
return $this;
} | php | {
"resource": ""
} |
q246441 | BaseOptions.setOptions | validation | public function setOptions(array $options)
{
//Validate options
$this->validateOptions($options);
//Set options
foreach ($options as $option => $value)
$this->$option = $value;
return $this;
} | php | {
"resource": ""
} |
q246442 | BaseOptions.buildConnectionOptions | validation | public function buildConnectionOptions()
{
//Default connection
$connection_name = $this->config->get("tail-settings.default");
//Check if set for this connection
if ($this->connection_name)
$connection_name = $this->connection_name;
$connectionOptions = $this->... | php | {
"resource": ""
} |
q246443 | Connection.open | validation | public function open()
{
try
{
$additionalConnectionOptions = array();
foreach (array('connection_timeout', 'read_write_timeout', 'keepalive', 'heartbeat') as $option) {
if (isset($this->$option)) {
$additionalConnectionOptions[$option] = $... | php | {
"resource": ""
} |
q246444 | Connection.close | validation | public function close()
{
if (isset($this->channel))
$this->channel->close();
if (isset($this->AMQPConnection))
$this->AMQPConnection->close();
} | php | {
"resource": ""
} |
q246445 | Ekko.isActiveURL | validation | public function isActiveURL($url, $output = "active")
{
if ($this->url->current() == $this->url->to($url)) {
return $output;
}
return null;
} | php | {
"resource": ""
} |
q246446 | Ekko.isActiveMatch | validation | public function isActiveMatch($string, $output = "active")
{
if (strpos($this->url->current(), $string) !== false) {
return $output;
}
return null;
} | php | {
"resource": ""
} |
q246447 | Ekko.areActiveRoutes | validation | public function areActiveRoutes(array $routeNames, $output = "active")
{
foreach ($routeNames as $routeName) {
if ($this->isActiveRoute($routeName, true)) {
return $output;
}
}
return null;
} | php | {
"resource": ""
} |
q246448 | Ekko.areActiveURLs | validation | public function areActiveURLs(array $urls, $output = "active")
{
foreach ($urls as $url) {
if ($this->isActiveURL($url, true)) {
return $output;
}
}
return null;
} | php | {
"resource": ""
} |
q246449 | Dispatcher.p | validation | public function p()
{
$args = func_get_args();
$node = $args[0];
if (null === $node) {
return;
}
$this->logger->trace('p'.$node->getType(), $node, $this->getMetadata()->getFullQualifiedNameClass());
$class = $this->getClass('p'.$node->getType());
... | php | {
"resource": ""
} |
q246450 | Dispatcher.convert | validation | public function convert(array $stmts, ClassMetadata $metadata, ClassCollector $classCollector, Logger $logger)
{
$this->metadata = $metadata;
$this->classCollector = $classCollector;
$this->logger = $logger;
return ltrim(str_replace("\n".self::noIndentToken, "\n", $this->pStmts($stm... | php | {
"resource": ""
} |
q246451 | CliFactory.getInstance | validation | public static function getInstance(OutputInterface $output)
{
$questionHelper = new QuestionHelper();
$application = new Application('PHP to Zephir Command Line Interface', 'Beta 0.2.1');
$application->getHelperSet()->set(new FormatterHelper(), 'formatter');
$application->getHelperSe... | php | {
"resource": ""
} |
q246452 | PrecPrinter.convert | validation | public function convert(Node $node, $parentPrecedence, $parentAssociativity, $childPosition)
{
$type = $node->getType();
if ($this->dispatcher->issetPrecedenceMap($type) === true) {
$childPrecedences = $this->dispatcher->getPrecedenceMap($type);
$childPrecedence = $childPrece... | php | {
"resource": ""
} |
q246453 | Injector.getConstant | validation | public function getConstant($name)
{
return $this->getBinding(ConstantBinding::TYPE, $name)
->getInstance($this, $name);
} | php | {
"resource": ""
} |
q246454 | Injector.getBinding | validation | private function getBinding($type, $name = null)
{
$binding = $this->findBinding($type, $name);
if (null === $binding) {
throw new BindingException('No binding for ' . $type . ' defined');
}
return $binding;
} | php | {
"resource": ""
} |
q246455 | Injector.findBinding | validation | private function findBinding($type, $name)
{
$bindingName = $this->bindingName($name);
if (null !== $bindingName && isset($this->index[$type . '#' . $bindingName])) {
return $this->index[$type . '#' . $bindingName];
}
if (isset($this->index[$type])) {
return ... | php | {
"resource": ""
} |
q246456 | Injector.getAnnotatedBinding | validation | private function getAnnotatedBinding(\ReflectionClass $class)
{
$annotations = annotationsOf($class);
if ($class->isInterface() && $annotations->contain('ImplementedBy')) {
return $this->bind($class->getName())
->to($this->findImplementation($annotations, $class->getN... | php | {
"resource": ""
} |
q246457 | App.createInstance | validation | public static function createInstance($className, $projectPath)
{
Runtime::reset();
self::$projectPath = $projectPath;
$binder = new Binder();
foreach (static::getBindingsForApp($className) as $bindingModule) {
if (is_string($bindingModule)) {
$bindingModu... | php | {
"resource": ""
} |
q246458 | App.getBindingsForApp | validation | protected static function getBindingsForApp($className)
{
$bindings = method_exists($className, '__bindings') ? $className::__bindings() : [];
if (!Runtime::initialized()) {
$bindings[] = static::runtime();
}
return $bindings;
} | php | {
"resource": ""
} |
q246459 | App.hostname | validation | protected static function hostname()
{
return function(Binder $binder)
{
if (DIRECTORY_SEPARATOR === '\\') {
$fq = php_uname('n');
if (isset($_SERVER['USERDNSDOMAIN'])) {
$fq .= '.' . $_SERVER['USERDNSDOMAIN'];
}
... | php | {
"resource": ""
} |
q246460 | Predicate.castFrom | validation | public static function castFrom($predicate)
{
if ($predicate instanceof self) {
return $predicate;
} elseif (is_callable($predicate)) {
return new CallablePredicate($predicate);
}
throw new \InvalidArgumentException(
'Given predicate is neithe... | php | {
"resource": ""
} |
q246461 | Rootpath.contains | validation | public function contains($path)
{
$realpath = realpath($path);
if (false === $realpath) {
return false;
}
return substr($realpath, 0, strlen($this->rootpath)) === $this->rootpath;
} | php | {
"resource": ""
} |
q246462 | Rootpath.sourcePathes | validation | public function sourcePathes()
{
$vendorPathes = [];
foreach (array_merge($this->loadPsr0Pathes(), $this->loadPsr4Pathes()) as $pathes) {
if (is_array($pathes)) {
$vendorPathes = array_merge($vendorPathes, $pathes);
} else {
$vendorPathes[] = $... | php | {
"resource": ""
} |
q246463 | PropertyBinding.hasProperty | validation | public function hasProperty($name)
{
if ($this->properties->containValue($this->environment, $name)) {
return true;
}
return $this->properties->containValue('config', $name);
} | php | {
"resource": ""
} |
q246464 | MultiBinding.getValueCreator | validation | protected function getValueCreator($value)
{
if (is_string($value) && class_exists($value)) {
return function($injector) use($value) { return $injector->getInstance($value); };
}
return function() use($value) { return $value; };
} | php | {
"resource": ""
} |
q246465 | MultiBinding.getProviderCreator | validation | protected function getProviderCreator($provider)
{
if (is_string($provider)) {
return function($injector, $name, $key) use($provider)
{
$providerInstance = $injector->getInstance($provider);
if (!($providerInstance instanceof Injec... | php | {
"resource": ""
} |
q246466 | MultiBinding.resolve | validation | private function resolve(Injector $injector, $type)
{
$resolved = [];
foreach ($this->getBindings() as $key => $bindingValue) {
$value = $bindingValue($injector, $this->name, $key);
if ($this->isTypeMismatch($type, $value)) {
$valueType = ((is_object($value)) ... | php | {
"resource": ""
} |
q246467 | MultiBinding.isTypeMismatch | validation | private function isTypeMismatch($type, $value)
{
if (!($type instanceof \ReflectionClass)) {
return false;
}
if (!is_object($value)) {
return true;
}
return !$type->isInstance($value);
} | php | {
"resource": ""
} |
q246468 | Binder.bindList | validation | public function bindList($name)
{
if (!isset($this->listBindings[$name])) {
$this->listBindings[$name] = $this->addBinding(new ListBinding($name));
}
return $this->listBindings[$name];
} | php | {
"resource": ""
} |
q246469 | Binder.createInjector | validation | public static function createInjector(callable ...$applyBindings)
{
$self = new self();
foreach ($applyBindings as $applyBinding) {
$applyBinding($self);
}
return $self->getInjector();
} | php | {
"resource": ""
} |
q246470 | Enum.forName | validation | public static function forName($name)
{
$enum = new \ReflectionClass(get_called_class());
try {
return $enum->getStaticPropertyValue($name);
} catch (\ReflectionException $re) {
throw new \InvalidArgumentException($re->getMessage());
}
} | php | {
"resource": ""
} |
q246471 | Enum.forValue | validation | public static function forValue($value)
{
$enumClass = new \ReflectionClass(get_called_class());
foreach ($enumClass->getStaticProperties() as $instance) {
if ($instance->value() === $value) {
return $instance;
}
}
throw new \InvalidArgumentEx... | php | {
"resource": ""
} |
q246472 | Enum.valuesOf | validation | public static function valuesOf()
{
$enum = new \ReflectionClass(get_called_class());
$values = [];
foreach ($enum->getStaticProperties() as $name => $instance) {
$values[$name] = $instance->value;
}
return $values;
} | php | {
"resource": ""
} |
q246473 | Enum.equals | validation | public function equals($compare)
{
if ($compare instanceof self) {
return (get_class($compare) === get_class($this) && $compare->name() === $this->name);
}
return false;
} | php | {
"resource": ""
} |
q246474 | AbstractExceptionHandler.handleException | validation | public function handleException(\Exception $exception)
{
if ($this->loggingEnabled) {
$this->exceptionLogger->log($exception);
}
if ('cgi' === $this->sapi) {
$this->header('Status: 500 Internal Server Error');
} else {
$this->header('HTTP/1.1 500 ... | php | {
"resource": ""
} |
q246475 | MapBinding.withEntry | validation | public function withEntry($key, $value)
{
$this->bindings[$key] = $this->getValueCreator($value);
return $this;
} | php | {
"resource": ""
} |
q246476 | MapBinding.withEntryFromProvider | validation | public function withEntryFromProvider($key, $provider)
{
$this->bindings[$key] = $this->getProviderCreator($provider);
return $this;
} | php | {
"resource": ""
} |
q246477 | DefaultInjectionProvider.get | validation | public function get($name = null)
{
$constructor = $this->class->getConstructor();
if (null === $constructor || $this->class->isInternal()) {
return $this->class->newInstance();
}
$params = $this->injectionValuesForMethod($constructor);
if (count($params) === 0) ... | php | {
"resource": ""
} |
q246478 | DefaultInjectionProvider.injectionValuesForMethod | validation | private function injectionValuesForMethod(\ReflectionMethod $method)
{
$paramValues = [];
$defaultName = $this->methodBindingName($method);
foreach ($method->getParameters() as $param) {
$type = $this->paramType($method, $param);
$name = $this->detectBindingName($pa... | php | {
"resource": ""
} |
q246479 | DefaultInjectionProvider.methodBindingName | validation | private function methodBindingName(\ReflectionMethod $method)
{
$annotations = annotationsOf($method);
if ($annotations->contain('List')) {
return $annotations->firstNamed('List')->getValue();
}
if ($annotations->contain('Map')) {
return $annotations->firstNa... | php | {
"resource": ""
} |
q246480 | DefaultInjectionProvider.paramType | validation | private function paramType(\ReflectionMethod $method, \ReflectionParameter $param)
{
$methodAnnotations = annotationsOf($method);
$paramAnnotations = annotationsOf($param);
$paramClass = $param->getClass();
if (null !== $paramClass) {
if ($methodAnnotations->conta... | php | {
"resource": ""
} |
q246481 | ExceptionLogger.log | validation | public function log(\Exception $exception)
{
$logData = date('Y-m-d H:i:s');
$logData .= $this->exceptionFields($exception);
$logData .= $this->fieldsForPrevious($exception->getPrevious());
error_log(
$logData . "\n",
3,
$this->getLogD... | php | {
"resource": ""
} |
q246482 | ExceptionLogger.exceptionFields | validation | private function exceptionFields(\Exception $exception)
{
return '|' . get_class($exception)
. '|' . $exception->getMessage()
. '|' . $exception->getFile()
. '|' . $exception->getLine();
} | php | {
"resource": ""
} |
q246483 | Imposter.getAutoloads | validation | public function getAutoloads(): array
{
if (empty($this->autoloads)) {
$this->autoloads = $this->configCollection->getAutoloads();
}
return $this->autoloads;
} | php | {
"resource": ""
} |
q246484 | Transformer.transform | validation | public function transform(string $target)
{
if ($this->filesystem->isFile($target)) {
$this->doTransform($target);
return;
}
$files = $this->filesystem->allFiles($target);
array_walk($files, function (SplFileInfo $file) {
$this->doTransform($fil... | php | {
"resource": ""
} |
q246485 | Transformer.prefixNamespace | validation | private function prefixNamespace(string $targetFile)
{
$pattern = sprintf(
'/%1$s\\s+(?!(%2$s)|(Composer(\\\\|;)))/',
'namespace',
$this->namespacePrefix
);
$replacement = sprintf('%1$s %2$s', 'namespace', $this->namespacePrefix);
$this->replace($... | php | {
"resource": ""
} |
q246486 | Transformer.replace | validation | private function replace(string $pattern, string $replacement, string $targetFile)
{
$this->filesystem->put(
$targetFile,
preg_replace(
$pattern,
$replacement,
$this->filesystem->get($targetFile)
)
);
} | php | {
"resource": ""
} |
q246487 | Filesystem.get | validation | public function get(string $path): string
{
if (! $this->isFile($path)) {
throw new RuntimeException('File does not exist at path ' . $path);
}
return file_get_contents($path);
} | php | {
"resource": ""
} |
q246488 | HasManyRelationship.get | validation | public function get()
{
$child = $this->childClassName;
$query = new QueryBuilder();
$query->filter(new ParentFilter($this->parent->getId()));
$collection = $child::search($query);
$collection->each(function (ElasticsearchModel $model) {
$model->setParent($this->p... | php | {
"resource": ""
} |
q246489 | HasManyRelationship.find | validation | public function find($id)
{
$child = $this->childClassName;
$model = $child::findWithParentId($id, $this->parent->getId());
if ($model) {
$model->setParent($this->parent);
}
return $model;
} | php | {
"resource": ""
} |
q246490 | HasManyRelationship.save | validation | public function save($child)
{
/** @var ElasticsearchModel[] $children */
$children = !is_array($child) ? [$child] : $child;
// @TODO: use bulk if count($children) > 1
foreach ($children as $child) {
$child->setParent($this->parent);
$child->save();
}
... | php | {
"resource": ""
} |
q246491 | Model.save | validation | public function save($columns = ['*'])
{
$columns = $columns ? (array)$columns : ['*'];
if ($this->saving() === false) {
return false;
}
$this->fillTimestamp();
$this->_dal->put($columns);
$this->_exist = true;
// self::cache()->put($id, $this... | php | {
"resource": ""
} |
q246492 | Model.delete | validation | public function delete()
{
if ($this->deleting() === false) {
return false;
}
$this->_dal->delete();
$this->_exist = false;
$cache = self::cache();
$cache->forget($this->getId());
if ($this->deleted() === false) {
return false;
... | php | {
"resource": ""
} |
q246493 | Model.findOrNew | validation | public static function findOrNew($id)
{
$model = static::find($id);
if (is_null($model)) {
$model = static::createInstance();
$model->setId($id);
}
return $model;
} | php | {
"resource": ""
} |
q246494 | Model.findOrFail | validation | public static function findOrFail($id, array $columns = ['*'], $parent = null)
{
$model = static::find($id, $columns, ['parent' => $parent]);
if (is_null($model)) {
throw new ModelNotFoundException(get_called_class(), $id);
}
return $model;
} | php | {
"resource": ""
} |
q246495 | Model.destroy | validation | public static function destroy($id)
{
$ids = is_array($id) ? $id : [$id];
foreach ($ids as $id) {
$model = static::find($id);
if (!is_null($model)) {
$model->delete();
}
}
} | php | {
"resource": ""
} |
q246496 | Paginationable.makePagination | validation | public function makePagination(QueryBuilder $query = null)
{
if (is_null($this->_position)) {
throw new Exception('To use Paginationable trait you must fill _position property in your model');
}
/** @var ElasticsearchModel $model */
$model = static::createInstance();
... | php | {
"resource": ""
} |
q246497 | Relationshipable.setParent | validation | public function setParent(ElasticsearchModel $parent)
{
$this->_parent = $parent;
$this->setParentId($parent->getId());
} | php | {
"resource": ""
} |
q246498 | ElasticsearchModel.search | validation | public static function search($query = [])
{
if ($query instanceof QueryBuilder) {
$query = $query->build();
}
$model = static::createInstance();
return $model->_dal->search($query);
} | php | {
"resource": ""
} |
q246499 | ElasticsearchModel.map | validation | public static function map($query = [], callable $callback = null, $limit = -1)
{
if ($query instanceof QueryBuilder) {
$query = $query->build();
}
$query['from'] = Arr::get($query, 'from', 0);
$query['size'] = Arr::get($query, 'size', 50);
$i = 0;
$mode... | php | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.