Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
RTippin committed Sep 12, 2021
2 parents ccd2702 + 3f4cf66 commit d6f4632
Show file tree
Hide file tree
Showing 9 changed files with 95 additions and 69 deletions.
6 changes: 3 additions & 3 deletions src/Bots/FakerBot.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@ private function sendInvalidSelectionMessage(): void
}

/**
* @param string $command
* @param int $count
* @param int $delay
* @param string $command
* @param int $count
* @param int $delay
*/
private function handleCommand(string $command, int $count, int $delay): void
{
Expand Down
14 changes: 7 additions & 7 deletions src/Commands/BaseFakerCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ abstract class BaseFakerCommand extends Command
protected ProgressBar $bar;

/**
* @param MessengerFaker $faker
* @param MessengerFaker $faker
*/
public function __construct(MessengerFaker $faker)
{
Expand Down Expand Up @@ -88,7 +88,7 @@ protected function getOptions(): array
/**
* Set the thread on our faker instance when the command is loaded.
*
* @param int|null $loadMessageCount
* @param int|null $loadMessageCount
* @return bool
*/
protected function setupFaker(?int $loadMessageCount = null): bool
Expand Down Expand Up @@ -123,7 +123,7 @@ protected function setupFaker(?int $loadMessageCount = null): bool
/**
* Output the thread found action message.
*
* @param string $message
* @param string $message
*/
protected function outputThreadMessage(string $message): void
{
Expand All @@ -134,7 +134,7 @@ protected function outputThreadMessage(string $message): void
/**
* Start the progress bar for this command.
*
* @param bool $useFaker
* @param bool $useFaker
*/
protected function startProgressBar(bool $useFaker = true): void
{
Expand All @@ -151,7 +151,7 @@ protected function startProgressBar(bool $useFaker = true): void
/**
* Finish the progress bar.
*
* @param bool $useFaker
* @param bool $useFaker
*/
protected function finishProgressBar(bool $useFaker = true): void
{
Expand All @@ -166,7 +166,7 @@ protected function finishProgressBar(bool $useFaker = true): void
/**
* Out put the final message.
*
* @param string $message
* @param string $message
*/
protected function outputFinalMessage(string $message): void
{
Expand All @@ -177,7 +177,7 @@ protected function outputFinalMessage(string $message): void
/**
* Output our exception message.
*
* @param Throwable $e
* @param Throwable $e
*/
protected function outputExceptionMessage(Throwable $e): void
{
Expand Down
2 changes: 1 addition & 1 deletion src/Commands/RandomCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ private function getRandomCommand(): string
}

/**
* @param string $command
* @param string $command
* @return array
*/
private function getCommandOptions(string $command): array
Expand Down
3 changes: 2 additions & 1 deletion src/FakerEvents.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ private function startMessage(): void
/**
* Messages ended.
*
* @param bool $isFinal
* @param bool $isFinal
*
* @throws Throwable
*/
private function endMessage(bool $isFinal): void
Expand Down
27 changes: 14 additions & 13 deletions src/FakerFiles.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@
trait FakerFiles
{
/**
* @param bool $local
* @param string|null $url
* @param bool $local
* @param string|null $url
* @return array
*
* @throws Exception
*/
private function getImage(bool $local, ?string $url): array
Expand All @@ -34,21 +35,20 @@ private function getImage(bool $local, ?string $url): array
$name = $file->getFilename();
} else {
$name = uniqid();
$file = '/tmp/'.$name;
file_put_contents($file,
Http::timeout(30)->get(is_null($url)
? config('messenger-faker.default_image_url')
: $url
)->body()
$file = sys_get_temp_dir().DIRECTORY_SEPARATOR.$name;
file_put_contents(
$file,
Http::timeout(30)->get($url ?: config('messenger-faker.default_image_url'))->body()
);
}

return [new UploadedFile($file, $name), $file];
}

/**
* @param string|null $url
* @param string|null $url
* @return array
*
* @throws Exception
*/
private function getDocument(?string $url): array
Expand All @@ -59,7 +59,7 @@ private function getDocument(?string $url): array

if (! is_null($url)) {
$name = uniqid();
$file = '/tmp/'.$name;
$file = sys_get_temp_dir().DIRECTORY_SEPARATOR.$name;
file_put_contents($file, Http::timeout(30)->get($url)->body());
} else {
$path = config('messenger-faker.paths.documents');
Expand All @@ -77,8 +77,9 @@ private function getDocument(?string $url): array
}

/**
* @param string|null $url
* @param string|null $url
* @return array
*
* @throws Exception
*/
private function getAudio(?string $url): array
Expand All @@ -89,7 +90,7 @@ private function getAudio(?string $url): array

if (! is_null($url)) {
$name = uniqid();
$file = '/tmp/'.$name;
$file = sys_get_temp_dir().DIRECTORY_SEPARATOR.$name;
file_put_contents($file, Http::timeout(30)->get($url)->body());
} else {
$path = config('messenger-faker.paths.audio');
Expand All @@ -107,7 +108,7 @@ private function getAudio(?string $url): array
}

/**
* @param string $file
* @param string $file
*/
private function unlinkFile(string $file): void
{
Expand Down
46 changes: 27 additions & 19 deletions src/FakerSystemMessages.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,10 @@ private function getAllowedTypesGroup(): array

/**
* Messages started.
* @param int|null $type
*
* @param int|null $type
* @return array
*
* @throws Exception
*/
private function generateSystemMessage(?int $type): array
Expand All @@ -68,8 +70,9 @@ private function generateSystemMessage(?int $type): array
}

/**
* @param int|null $type
* @param int|null $type
* @return int
*
* @throws Exception
*/
private function getType(?int $type): int
Expand All @@ -90,9 +93,10 @@ private function getType(?int $type): int
}

/**
* @param int $type
* @param Participant $participant
* @param int $type
* @param Participant $participant
* @return array
*
* @throws Exception
*/
private function makeBody(int $type, Participant $participant): array
Expand All @@ -119,7 +123,7 @@ private function makeBody(int $type, Participant $participant): array
}

/**
* @param Participant $participant
* @param Participant $participant
* @return array
*/
private function makeJoinedWithInvite(Participant $participant): array
Expand All @@ -128,7 +132,7 @@ private function makeJoinedWithInvite(Participant $participant): array
}

/**
* @param Participant $participant
* @param Participant $participant
* @return array
*/
private function makeVideoCall(Participant $participant): array
Expand All @@ -148,7 +152,7 @@ private function makeVideoCall(Participant $participant): array
}

/**
* @param Participant $participant
* @param Participant $participant
* @return array
*/
private function makeGroupAvatarChanged(Participant $participant): array
Expand All @@ -157,7 +161,7 @@ private function makeGroupAvatarChanged(Participant $participant): array
}

/**
* @param Participant $participant
* @param Participant $participant
* @return array
*/
private function makeThreadArchived(Participant $participant): array
Expand All @@ -166,7 +170,7 @@ private function makeThreadArchived(Participant $participant): array
}

/**
* @param Participant $participant
* @param Participant $participant
* @return array
*/
private function makeGroupCreated(Participant $participant): array
Expand All @@ -175,7 +179,7 @@ private function makeGroupCreated(Participant $participant): array
}

/**
* @param Participant $participant
* @param Participant $participant
* @return array
*/
private function makeGroupRenamed(Participant $participant): array
Expand All @@ -184,8 +188,9 @@ private function makeGroupRenamed(Participant $participant): array
}

/**
* @param Participant $participant
* @param Participant $participant
* @return array
*
* @throws Exception
*/
private function makeParticipantDemoted(Participant $participant): array
Expand All @@ -203,8 +208,9 @@ private function makeParticipantDemoted(Participant $participant): array
}

/**
* @param Participant $participant
* @param Participant $participant
* @return array
*
* @throws Exception
*/
private function makeParticipantPromoted(Participant $participant): array
Expand All @@ -222,7 +228,7 @@ private function makeParticipantPromoted(Participant $participant): array
}

/**
* @param Participant $participant
* @param Participant $participant
* @return array
*/
private function makeGroupLeft(Participant $participant): array
Expand All @@ -231,8 +237,9 @@ private function makeGroupLeft(Participant $participant): array
}

/**
* @param Participant $participant
* @param Participant $participant
* @return array
*
* @throws Exception
*/
private function makeRemovedFromGroup(Participant $participant): array
Expand All @@ -250,8 +257,9 @@ private function makeRemovedFromGroup(Participant $participant): array
}

/**
* @param Participant $participant
* @param Participant $participant
* @return array
*
* @throws Exception
*/
private function makeParticipantsAdded(Participant $participant): array
Expand All @@ -269,7 +277,7 @@ private function makeParticipantsAdded(Participant $participant): array
}

/**
* @param Participant $participant
* @param Participant $participant
* @return array
*/
private function makeBotAdded(Participant $participant): array
Expand All @@ -278,7 +286,7 @@ private function makeBotAdded(Participant $participant): array
}

/**
* @param Participant $participant
* @param Participant $participant
* @return array
*/
private function makeBotRenamed(Participant $participant): array
Expand All @@ -287,7 +295,7 @@ private function makeBotRenamed(Participant $participant): array
}

/**
* @param Participant $participant
* @param Participant $participant
* @return array
*/
private function makeBotAvatarChanged(Participant $participant): array
Expand All @@ -296,7 +304,7 @@ private function makeBotAvatarChanged(Participant $participant): array
}

/**
* @param Participant $participant
* @param Participant $participant
* @return array
*/
private function makeBotRemoved(Participant $participant): array
Expand Down
Loading

0 comments on commit d6f4632

Please sign in to comment.