The
data_get
function retrieves a value from a nested array or object using "dot" notation:<?php $data = ['products' => ['desk' => ['price' => 100]]];
$price = data_get($data, 'products.desk.price');
<?php function getProperty($name)
{
return data_get($this->getProperties(), $name);
}
function storeSet($key, $value)
<?php $value = $this->{Utils::beforeFirstDot($name)};
if (Utils::containsDots($name)) {
return data_get($value, Utils::afterFirstDot($name));
}
return $value;
<?php $propertyName = $property->afterLast('.');
$objectName = $property->beforeLast('.');
$object = data_get($freshInstance, $objectName, null);
if (is_object($object)) {
$isInitialized = (new \ReflectionProperty($object, (string) $propertyName))->isInitialized($object);
<?php continue;
}
data_set($this, $property, data_get($freshInstance, $property));
}
}
<?php throw new \Exception('Can\'t set the value of a non-property attribute.');
}
return data_get($this->component->all(), $this->levelName);
}
function setValue($value)
<?php static function replaceDynamicPlaceholders($event, $component)
{
return preg_replace_callback('/\{(.*)\}/U', function ($matches) use ($component) {
return data_get($component, $matches[1], function () use ($matches) {
throw new \Exception('Unable to evaluate dynamic event name placeholder: '.$matches[0]);
});
}, $event);
}
}
<?php $assertionSuffix = '.';
if (empty($params)) {
$test = collect(data_get($this->effects, 'dispatches'))->contains('name', '=', $value);
} elseif (isset($params[0]) && ! is_string($params[0]) && is_callable($params[0])) {
$event = collect(data_get($this->effects, 'dispatches'))->first(function ($item) use ($value) {
return $item['name'] === $value;
<?php if (empty($params)) {
$test = collect(data_get($this->effects, 'dispatches'))->contains('name', '=', $value);
} elseif (isset($params[0]) && ! is_string($params[0]) && is_callable($params[0])) {
$event = collect(data_get($this->effects, 'dispatches'))->first(function ($item) use ($value) {
return $item['name'] === $value;
});
<?php $test = $event && $params[0]($event['name'], $event['params']);
} else {
$test = (bool) collect(data_get($this->effects, 'dispatches'))->first(function ($item) use ($value, $params) {
$commonParams = array_intersect_key($item['params'], $params);
ksort($commonParams);
<?php {
$name = app(ComponentRegistry::class)->getName($target);
return (bool) collect(data_get($this->effects, 'dispatches'))->first(function ($item) use ($name, $value) {
return $item['name'] === $value
&& $item['to'] === $name;
});
<?php {
public function assertFileDownloaded($filename = null, $content = null, $contentType = null)
{
$downloadEffect = data_get($this->effects, 'download');
if ($filename) {
PHPUnit::assertEquals(
<?php if ($filename) {
PHPUnit::assertEquals(
$filename,
data_get($downloadEffect, 'name')
);
} else {
PHPUnit::assertNotNull($downloadEffect);
<?php }
if ($content) {
$downloadedContent = data_get($this->effects, 'download.content');
PHPUnit::assertEquals(
$content,
<?php if ($contentType) {
PHPUnit::assertEquals(
$contentType,
data_get($this->effects, 'download.contentType')
);
}
<?php public function assertNoFileDownloaded()
{
$downloadEffect = data_get($this->effects, 'download');
PHPUnit::assertNull($downloadEffect);