Upgrade to 4.1.1

This commit is contained in:
Bastian Allgeier
2024-02-26 11:15:36 +01:00
parent 9345fc1a0b
commit 2e8aa1ed80
20 changed files with 123 additions and 171 deletions

View File

@@ -105,6 +105,14 @@ trait FileModifications
]);
}
/**
* Sharpens the image
*/
public function sharpen(int $amount = 50): FileVersion|File|Asset
{
return $this->thumb(['sharpen' => $amount]);
}
/**
* Create a srcset definition for the given sizes
* Sizes can be defined as a simple array. They can

View File

@@ -62,10 +62,11 @@ enum LicenseStatus: string
/**
* Returns the dialog according to the status
*/
public function dialog(): string
public function dialog(): string|null
{
return match ($this) {
static::Missing => 'registration',
static::Demo => null,
default => 'license'
};
}

View File

@@ -277,6 +277,15 @@ class File
if (is_array($rules['mime'] ?? null) === true) {
$mime = $this->mime();
// the MIME type could not be determined, but matching
// to it was requested explicitly
if ($mime === null) {
throw new Exception([
'key' => 'file.mime.missing',
'data' => ['filename' => $this->filename()]
]);
}
// determine if any pattern matches the MIME type;
// once any pattern matches, `$carry` is `true` and the rest is skipped
$matches = array_reduce(

View File

@@ -306,6 +306,7 @@ class Remote
* Decode the response content
*
* @param bool $array decode as array or object
* @psalm-return ($array is true ? array|null : stdClass|null)
*/
public function json(bool $array = true): array|stdClass|null
{

View File

@@ -35,7 +35,7 @@ class Panel
/**
* Normalize a panel area
*/
public static function area(string $id, array|string $area): array
public static function area(string $id, array $area): array
{
$area['id'] = $id;
$area['label'] ??= $id;

View File

@@ -488,7 +488,16 @@ class Str
return $string;
}
return static::substr($string, 0, mb_strrpos(static::substr($string, 0, $chars), ' ')) . $rep;
// shorten the string to the specified number of characters,
// but make sure to not cut off in the middle of a word
$excerpt = static::substr($string, 0, $chars);
$cutoff = mb_strrpos($excerpt, ' ');
if ($cutoff !== false) {
$excerpt = static::substr($string, 0, $cutoff);
}
return $excerpt . $rep;
}
/**