Skip to content

Commit

Permalink
Merge pull request #521 from defstudio/fix-517
Browse files Browse the repository at this point in the history
[Fix] breaking change on minor version
  • Loading branch information
fabio-ivona authored Feb 15, 2024
2 parents 51e57e3 + 751f59a commit a4158a3
Showing 1 changed file with 14 additions and 23 deletions.
37 changes: 14 additions & 23 deletions src/Concerns/SendsAttachments.php
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,8 @@ public function thumbnail(string $path): self
$telegraph = clone $this;

if (File::exists($path)) {
$maxSizeKb = config('telegraph.attachments.thumbnail.max_size_kb', 200);

assert(is_float($maxSizeKb));
/* @phpstan-ignore-next-line */
$maxSizeKb = floatval(config('telegraph.attachments.thumbnail.max_size_kb', 200));

if (($size = $telegraph->fileSizeInKb($path)) > $maxSizeKb) {
throw FileException::thumbnailSizeExceeded($size, $maxSizeKb);
Expand Down Expand Up @@ -293,10 +292,8 @@ public function dice(string $emoji = null): self
protected function attachPhoto(self $telegraph, string $path, ?string $filename): void
{
if (File::exists($path)) {

$maxSizeInMb = config('telegraph.attachments.photo.max_size_mb', 10);

assert(is_float($maxSizeInMb));
/* @phpstan-ignore-next-line */
$maxSizeInMb = floatval(config('telegraph.attachments.photo.max_size_mb', 10));

if (($size = $telegraph->fileSizeInMb($path)) > $maxSizeInMb) {
throw FileException::photoSizeExceeded($size, $maxSizeInMb);
Expand All @@ -313,9 +310,8 @@ protected function attachPhoto(self $telegraph, string $path, ?string $filename)
throw FileException::invalidPhotoSize($totalLength, $heightWidthSumPx);
}

$maxRatio = config('telegraph.attachments.photo.max_ratio', 20);

assert(is_float($maxRatio));
/* @phpstan-ignore-next-line */
$maxRatio = floatval(config('telegraph.attachments.photo.max_ratio', 20));

if (($ratio = $height / $width) > $maxRatio || $ratio < (1 / $maxRatio)) {
throw FileException::invalidPhotoRatio($ratio, $maxRatio);
Expand All @@ -331,9 +327,8 @@ protected function attachPhoto(self $telegraph, string $path, ?string $filename)
protected function attachAnimation(self $telegraph, string $path, ?string $filename): void
{
if (File::exists($path)) {
$maxSizeMb = config('telegraph.attachments.animation.max_size_mb', 50);

assert(is_float($maxSizeMb));
/* @phpstan-ignore-next-line */
$maxSizeMb = floatval(config('telegraph.attachments.animation.max_size_mb', 50));

if (($size = $telegraph->fileSizeInMb($path)) > $maxSizeMb) {
throw FileException::documentSizeExceeded($size, $maxSizeMb);
Expand All @@ -352,9 +347,8 @@ protected function attachAnimation(self $telegraph, string $path, ?string $filen
protected function attachVideo(self $telegraph, string $path, ?string $filename): void
{
if (File::exists($path)) {
$maxSizeMb = config('telegraph.attachments.video.max_size_mb', 50);

assert(is_float($maxSizeMb));
/* @phpstan-ignore-next-line */
$maxSizeMb = floatval(config('telegraph.attachments.video.max_size_mb', 50));

if (($size = $telegraph->fileSizeInMb($path)) > $maxSizeMb) {
throw FileException::documentSizeExceeded($size, $maxSizeMb);
Expand All @@ -380,10 +374,8 @@ protected function attachVideo(self $telegraph, string $path, ?string $filename)
protected function attachAudio(self $telegraph, string $path, ?string $filename): void
{
if (File::exists($path)) {

$maxSizeMb = config('telegraph.attachments.audio.max_size_mb', 50);

assert(is_float($maxSizeMb));
/* @phpstan-ignore-next-line */
$maxSizeMb = floatval(config('telegraph.attachments.audio.max_size_mb', 50));

if (($size = $telegraph->fileSizeInMb($path)) > $maxSizeMb) {
throw FileException::documentSizeExceeded($size, $maxSizeMb);
Expand All @@ -407,9 +399,8 @@ protected function attachDocument(self $telegraph, string $path, ?string $filena
{
if (File::exists($path)) {

$maxSizeMb = config('telegraph.attachments.document.max_size_mb', 50);

assert(is_float($maxSizeMb));
/* @phpstan-ignore-next-line */
$maxSizeMb = floatval(config('telegraph.attachments.document.max_size_mb', 50));

if (($size = $telegraph->fileSizeInMb($path)) > $maxSizeMb) {
throw FileException::documentSizeExceeded($size, $maxSizeMb);
Expand Down

0 comments on commit a4158a3

Please sign in to comment.