Skip to content

Commit

Permalink
Remove the no longer needed temp vars
Browse files Browse the repository at this point in the history
  • Loading branch information
rosier committed Dec 9, 2024
1 parent a872fdf commit 268bc12
Showing 1 changed file with 6 additions and 15 deletions.
21 changes: 6 additions & 15 deletions src/DataFixtures/AppFixtures.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,8 @@ private function loadPosts(ObjectManager $manager): void
$post->addTag(...$tags);

foreach (range(1, 5) as $i) {
/** @var User $commentAuthor */
$commentAuthor = $this->getReference('john_user', User::class);

$comment = new Comment();
$comment->setAuthor($commentAuthor);
$comment->setAuthor($this->getReference('john_user', User::class));
$comment->setContent($this->getRandomText(random_int(255, 512)));
$comment->setPublishedAt(new \DateTimeImmutable('now + '.$i.'seconds'));

Expand Down Expand Up @@ -140,18 +137,14 @@ private function getPostData(): array

foreach ($this->getPhrases() as $i => $title) {
// $postData = [$title, $slug, $summary, $content, $publishedAt, $author, $tags, $comments];

/** @var User $user */
$user = $this->getReference(['jane_admin', 'tom_admin'][0 === $i ? 0 : random_int(0, 1)], User::class);

$posts[] = [
$title,
$this->slugger->slug($title)->lower(),
$this->getRandomText(),
$this->getPostContent(),
(new \DateTimeImmutable('now - '.$i.'days'))->setTime(random_int(8, 17), random_int(7, 49), random_int(0, 59)),
// Ensure that the first post is written by Jane Doe to simplify tests
$user,
$this->getReference(['jane_admin', 'tom_admin'][0 === $i ? 0 : random_int(0, 1)], User::class),
$this->getRandomTags(),
];
}
Expand Down Expand Up @@ -262,11 +255,9 @@ private function getRandomTags(): array
shuffle($tagNames);
$selectedTags = \array_slice($tagNames, 0, random_int(2, 4));

return array_map(function ($tagName) {
/** @var Tag $tag */
$tag = $this->getReference('tag-'.$tagName, Tag::class);

return $tag;
}, $selectedTags);
return array_map(
fn ($tagName) => $this->getReference('tag-'.$tagName, Tag::class),
$selectedTags
);
}
}

0 comments on commit 268bc12

Please sign in to comment.