Indentation fixes

This commit is contained in:
Oliver Davies 2017-11-14 18:26:01 +00:00
parent aaf09e61c1
commit cdf588bc47
2 changed files with 36 additions and 35 deletions

View file

@ -54,10 +54,10 @@ class FormatTalksExtension extends Twig_Extension
public function getUpcoming($talks, array $eventData = [])
{
return $this->format($talks, $eventData)
->filter(function ($talk) {
return $talk['event']['date'] >= $this->today;
})
->sortBy('event.date');
->filter(function ($talk) {
return $talk['event']['date'] >= $this->today;
})
->sortBy('event.date');
}
/**
@ -72,10 +72,10 @@ class FormatTalksExtension extends Twig_Extension
public function getPast($talks, array $eventData = [])
{
return $this->format($talks, $eventData)
->filter(function ($talk) {
return $talk['event']['date'] < $this->today;
})
->sortByDesc('event.date');
->filter(function ($talk) {
return $talk['event']['date'] < $this->today;
})
->sortByDesc('event.date');
}
/**
@ -93,12 +93,13 @@ class FormatTalksExtension extends Twig_Extension
// Build an associative array with the talk, as well as the
// specified event data (e.g. date and time) as well as the shared
// event data (e.g. event name and website).
return collect($talk['events'])->map(function ($event) use ($talk, $event_data) {
$event = collect($event);
$event = $event->merge($event_data->get($event->get('event')))->all();
return collect($talk['events'])
->map(function ($event) use ($talk, $event_data) {
$event = collect($event);
$event = $event->merge($event_data->get($event->get('event')))->all();
return compact('event', 'talk');
});
return compact('event', 'talk');
});
});
}

View file

@ -28,32 +28,32 @@ class FormatTalksTest extends TestCase
public function testFormat()
{
$event_data = [
'event-a' => [
'name' => 'Event A',
'location' => 'Somewhere',
'website' => 'http://event-a.com',
],
'event-b' => [
'name' => 'Event B',
'location' => 'Somewhere else',
'website' => 'http://event-b.com',
],
];
'event-a' => [
'name' => 'Event A',
'location' => 'Somewhere',
'website' => 'http://event-a.com',
],
'event-b' => [
'name' => 'Event B',
'location' => 'Somewhere else',
'website' => 'http://event-b.com',
],
];
$talks = [
[
'title' => 'Talk A',
'events' => [
['event' => 'event-a', 'date' => '2018-01-01', 'time' => '09:00'],
['event' => 'event-b', 'date' => '2018-01-30', 'time' => '12:00'],
],
[
'title' => 'Talk A',
'events' => [
['event' => 'event-a', 'date' => '2018-01-01', 'time' => '09:00'],
['event' => 'event-b', 'date' => '2018-01-30', 'time' => '12:00'],
],
[
'title' => 'Talk B',
'events' => [
['event' => 'event-b', 'date' => '2018-01-31', 'time' => '17:00'],
],
],
[
'title' => 'Talk B',
'events' => [
['event' => 'event-b', 'date' => '2018-01-31', 'time' => '17:00'],
],
],
];
$results = $this->extension->format($talks, $event_data)->all();