The
collect
function creates a collection instance from the given value:<?php $collection = collect(['taylor', 'abigail']);
<?php {
$file = (new ReflectionClass($this->testCase))->getFilename();
$line = collect($this->e->getTrace())
->first(function ($entry) use ($file) {
return ($entry['file'] ?? '') === $file;
})['line'];
<?php public function mount()
{
$this->collection = collect(['â']);
$this->recursiveCollection = collect(['â', ['â']]);
$this->model = Model::find(1);
$this->modelCollection = Model::all();
<?php public function mount()
{
$this->collection = collect(['â']);
$this->recursiveCollection = collect(['â', ['â']]);
$this->model = Model::find(1);
$this->modelCollection = Model::all();
}
<?php public function mount()
{
$this->things = collect('foo');
$this->unorderedKeyedThings = collect([
2 => 'foo',
1 => 'bar',
<?php public function mount()
{
$this->things = collect('foo');
$this->unorderedKeyedThings = collect([
2 => 'foo',
1 => 'bar',
]);
}
public function addBar()
<?php static function getPublicProperties($target, $filter = null)
{
return collect((new \ReflectionObject($target))->getProperties())
->filter(function ($property) {
return $property->isPublic() && ! $property->isStatic() && $property->isDefault();
})
<?php public function getPublicPropertyTypes($component)
{
return collect(Utils::getPublicPropertiesDefinedOnSubclass($component))
->map(function ($value, $name) use ($component) {
return Reflector::getParameterClassName(new \ReflectionProperty($component, $name));
});
<?php public function render()
{
$this->name = collect(['prop', $this->parent->value, $this->child->value])->implode(':');
return app('view')->make('show-name-with-this');
}
<?php public function render()
{
$this->name = collect(['prop', $this->parent->value, $this->child->value])->implode(':');
return app('view')->make('show-name-with-this');
}
<?php static function stringifyHtmlAttributes($attributes)
{
return collect($attributes)
->mapWithKeys(function ($value, $key) {
return [$key => static::escapeStringForHtml($value)];
})->map(function ($value, $key) {
<?php public static function getComputedProperties($target)
{
return collect(static::getComputedPropertyNames($target))
->mapWithKeys(function ($property) use ($target) {
return [$property => static::getComputedProperty($target, $property)];
})
<?php {
$methodNames = SyntheticUtils::getPublicMethodsDefinedBySubClass($target);
return collect($methodNames)
->filter(function ($method) {
return str($method)->startsWith('get')
&& str($method)->endsWith('Property');
<?php public function classPath()
{
return $this->baseClassPath.collect()
->concat($this->directories)
->push($this->classFile())
->implode('/');
<?php {
return empty($this->directories)
? $this->baseClassNamespace
: $this->baseClassNamespace.'\\'.collect()
->concat($this->directories)
->map([Str::class, 'studly'])
->implode('\\');
<?php public function viewPath()
{
return $this->baseViewPath.collect()
->concat($this->directories)
->map([Str::class, 'kebab'])
->push($this->viewFile())