Skip to content

Commit

Permalink
Changed type generation to PSR
Browse files Browse the repository at this point in the history
  • Loading branch information
TiiFuchs committed May 10, 2022
1 parent a731fc6 commit 87e2788
Show file tree
Hide file tree
Showing 132 changed files with 5,009 additions and 5,134 deletions.
105 changes: 52 additions & 53 deletions src/Telegram/Animation.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,66 +11,65 @@
*/
class Animation extends \Tii\Telepath\Type
{
/** Identifier for this file, which can be used to download or reuse the file */
public string $file_id;
/** Identifier for this file, which can be used to download or reuse the file */
public string $file_id;

/** Unique identifier for this file, which is supposed to be the same over time and for different bots. Can't be used to download or reuse the file. */
public string $file_unique_id;
/** Unique identifier for this file, which is supposed to be the same over time and for different bots. Can't be used to download or reuse the file. */
public string $file_unique_id;

/** Video width as defined by sender */
public int $width;
/** Video width as defined by sender */
public int $width;

/** Video height as defined by sender */
public int $height;
/** Video height as defined by sender */
public int $height;

/** Duration of the video in seconds as defined by sender */
public int $duration;
/** Duration of the video in seconds as defined by sender */
public int $duration;

/** Optional. Animation thumbnail as defined by sender */
public ?PhotoSize $thumb = null;
/** Optional. Animation thumbnail as defined by sender */
public ?PhotoSize $thumb = null;

/** Optional. Original animation filename as defined by sender */
public ?string $file_name = null;
/** Optional. Original animation filename as defined by sender */
public ?string $file_name = null;

/** Optional. MIME type of the file as defined by sender */
public ?string $mime_type = null;
/** Optional. MIME type of the file as defined by sender */
public ?string $mime_type = null;

/** Optional. File size in bytes */
public ?int $file_size = null;
/** Optional. File size in bytes */
public ?int $file_size = null;


/**
* @param string $file_id Identifier for this file, which can be used to download or reuse the file
* @param string $file_unique_id Unique identifier for this file, which is supposed to be the same over time and for different bots. Can't be used to download or reuse the file.
* @param int $width Video width as defined by sender
* @param int $height Video height as defined by sender
* @param int $duration Duration of the video in seconds as defined by sender
* @param PhotoSize $thumb Optional. Animation thumbnail as defined by sender
* @param string $file_name Optional. Original animation filename as defined by sender
* @param string $mime_type Optional. MIME type of the file as defined by sender
* @param int $file_size Optional. File size in bytes
*/
public static function make(
string $file_id,
string $file_unique_id,
int $width,
int $height,
int $duration,
?PhotoSize $thumb = null,
?string $file_name = null,
?string $mime_type = null,
?int $file_size = null
): static {
return new static([
'file_id' => $file_id,
'file_unique_id' => $file_unique_id,
'width' => $width,
'height' => $height,
'duration' => $duration,
'thumb' => $thumb,
'file_name' => $file_name,
'mime_type' => $mime_type,
'file_size' => $file_size,
]);
}
/**
* @param string $file_id Identifier for this file, which can be used to download or reuse the file
* @param string $file_unique_id Unique identifier for this file, which is supposed to be the same over time and for different bots. Can't be used to download or reuse the file.
* @param int $width Video width as defined by sender
* @param int $height Video height as defined by sender
* @param int $duration Duration of the video in seconds as defined by sender
* @param PhotoSize $thumb Optional. Animation thumbnail as defined by sender
* @param string $file_name Optional. Original animation filename as defined by sender
* @param string $mime_type Optional. MIME type of the file as defined by sender
* @param int $file_size Optional. File size in bytes
*/
public static function make(
string $file_id,
string $file_unique_id,
int $width,
int $height,
int $duration,
?PhotoSize $thumb = null,
?string $file_name = null,
?string $mime_type = null,
?int $file_size = null
): static {
return new static([
'file_id' => $file_id,
'file_unique_id' => $file_unique_id,
'width' => $width,
'height' => $height,
'duration' => $duration,
'thumb' => $thumb,
'file_name' => $file_name,
'mime_type' => $mime_type,
'file_size' => $file_size,
]);
}
}
105 changes: 52 additions & 53 deletions src/Telegram/Audio.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,66 +11,65 @@
*/
class Audio extends \Tii\Telepath\Type
{
/** Identifier for this file, which can be used to download or reuse the file */
public string $file_id;
/** Identifier for this file, which can be used to download or reuse the file */
public string $file_id;

/** Unique identifier for this file, which is supposed to be the same over time and for different bots. Can't be used to download or reuse the file. */
public string $file_unique_id;
/** Unique identifier for this file, which is supposed to be the same over time and for different bots. Can't be used to download or reuse the file. */
public string $file_unique_id;

/** Duration of the audio in seconds as defined by sender */
public int $duration;
/** Duration of the audio in seconds as defined by sender */
public int $duration;

/** Optional. Performer of the audio as defined by sender or by audio tags */
public ?string $performer = null;
/** Optional. Performer of the audio as defined by sender or by audio tags */
public ?string $performer = null;

/** Optional. Title of the audio as defined by sender or by audio tags */
public ?string $title = null;
/** Optional. Title of the audio as defined by sender or by audio tags */
public ?string $title = null;

/** Optional. Original filename as defined by sender */
public ?string $file_name = null;
/** Optional. Original filename as defined by sender */
public ?string $file_name = null;

/** Optional. MIME type of the file as defined by sender */
public ?string $mime_type = null;
/** Optional. MIME type of the file as defined by sender */
public ?string $mime_type = null;

/** Optional. File size in bytes */
public ?int $file_size = null;
/** Optional. File size in bytes */
public ?int $file_size = null;

/** Optional. Thumbnail of the album cover to which the music file belongs */
public ?PhotoSize $thumb = null;
/** Optional. Thumbnail of the album cover to which the music file belongs */
public ?PhotoSize $thumb = null;


/**
* @param string $file_id Identifier for this file, which can be used to download or reuse the file
* @param string $file_unique_id Unique identifier for this file, which is supposed to be the same over time and for different bots. Can't be used to download or reuse the file.
* @param int $duration Duration of the audio in seconds as defined by sender
* @param string $performer Optional. Performer of the audio as defined by sender or by audio tags
* @param string $title Optional. Title of the audio as defined by sender or by audio tags
* @param string $file_name Optional. Original filename as defined by sender
* @param string $mime_type Optional. MIME type of the file as defined by sender
* @param int $file_size Optional. File size in bytes
* @param PhotoSize $thumb Optional. Thumbnail of the album cover to which the music file belongs
*/
public static function make(
string $file_id,
string $file_unique_id,
int $duration,
?string $performer = null,
?string $title = null,
?string $file_name = null,
?string $mime_type = null,
?int $file_size = null,
?PhotoSize $thumb = null
): static {
return new static([
'file_id' => $file_id,
'file_unique_id' => $file_unique_id,
'duration' => $duration,
'performer' => $performer,
'title' => $title,
'file_name' => $file_name,
'mime_type' => $mime_type,
'file_size' => $file_size,
'thumb' => $thumb,
]);
}
/**
* @param string $file_id Identifier for this file, which can be used to download or reuse the file
* @param string $file_unique_id Unique identifier for this file, which is supposed to be the same over time and for different bots. Can't be used to download or reuse the file.
* @param int $duration Duration of the audio in seconds as defined by sender
* @param string $performer Optional. Performer of the audio as defined by sender or by audio tags
* @param string $title Optional. Title of the audio as defined by sender or by audio tags
* @param string $file_name Optional. Original filename as defined by sender
* @param string $mime_type Optional. MIME type of the file as defined by sender
* @param int $file_size Optional. File size in bytes
* @param PhotoSize $thumb Optional. Thumbnail of the album cover to which the music file belongs
*/
public static function make(
string $file_id,
string $file_unique_id,
int $duration,
?string $performer = null,
?string $title = null,
?string $file_name = null,
?string $mime_type = null,
?int $file_size = null,
?PhotoSize $thumb = null
): static {
return new static([
'file_id' => $file_id,
'file_unique_id' => $file_unique_id,
'duration' => $duration,
'performer' => $performer,
'title' => $title,
'file_name' => $file_name,
'mime_type' => $mime_type,
'file_size' => $file_size,
'thumb' => $thumb,
]);
}
}
31 changes: 15 additions & 16 deletions src/Telegram/BotCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,21 @@
*/
class BotCommand extends \Tii\Telepath\Type
{
/** Text of the command; 1-32 characters. Can contain only lowercase English letters, digits and underscores. */
public string $command;
/** Text of the command; 1-32 characters. Can contain only lowercase English letters, digits and underscores. */
public string $command;

/** Description of the command; 1-256 characters. */
public string $description;
/** Description of the command; 1-256 characters. */
public string $description;


/**
* @param string $command Text of the command; 1-32 characters. Can contain only lowercase English letters, digits and underscores.
* @param string $description Description of the command; 1-256 characters.
*/
public static function make(string $command, string $description): static
{
return new static([
'command' => $command,
'description' => $description,
]);
}
/**
* @param string $command Text of the command; 1-32 characters. Can contain only lowercase English letters, digits and underscores.
* @param string $description Description of the command; 1-256 characters.
*/
public static function make(string $command, string $description): static
{
return new static([
'command' => $command,
'description' => $description,
]);
}
}
29 changes: 14 additions & 15 deletions src/Telegram/BotCommandScope.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,19 @@
*/
abstract class BotCommandScope extends \Tii\Telepath\Type
{
/** Scope type */
public string $type;
/** Scope type */
public string $type;


public static function factory(array $data): static
{
return match($data['type']) {
'default' => new BotCommandScopeDefault($data)
'all_private_chats' => new BotCommandScopeAllPrivateChats($data)
'all_group_chats' => new BotCommandScopeAllGroupChats($data)
'all_chat_administrators' => new BotCommandScopeAllChatAdministrators($data)
'chat' => new BotCommandScopeChat($data)
'chat_administrators' => new BotCommandScopeChatAdministrators($data)
'chat_member' => new BotCommandScopeChatMember($data)
};
}
public static function factory(array $data): static
{
return match($data['type']) {
'default' => new BotCommandScopeDefault($data)
'all_private_chats' => new BotCommandScopeAllPrivateChats($data)
'all_group_chats' => new BotCommandScopeAllGroupChats($data)
'all_chat_administrators' => new BotCommandScopeAllChatAdministrators($data)
'chat' => new BotCommandScopeChat($data)
'chat_administrators' => new BotCommandScopeChatAdministrators($data)
'chat_member' => new BotCommandScopeChatMember($data)
};
}
}
15 changes: 7 additions & 8 deletions src/Telegram/BotCommandScopeAllChatAdministrators.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,12 @@
*/
class BotCommandScopeAllChatAdministrators extends BotCommandScope
{
/** Scope type, must be all_chat_administrators */
public string $type = 'all_chat_administrators';
/** Scope type, must be all_chat_administrators */
public string $type = 'all_chat_administrators';


public static function make(): static
{
return new static([
]);
}
public static function make(): static
{
return new static([
]);
}
}
15 changes: 7 additions & 8 deletions src/Telegram/BotCommandScopeAllGroupChats.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,12 @@
*/
class BotCommandScopeAllGroupChats extends BotCommandScope
{
/** Scope type, must be all_group_chats */
public string $type = 'all_group_chats';
/** Scope type, must be all_group_chats */
public string $type = 'all_group_chats';


public static function make(): static
{
return new static([
]);
}
public static function make(): static
{
return new static([
]);
}
}
15 changes: 7 additions & 8 deletions src/Telegram/BotCommandScopeAllPrivateChats.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,12 @@
*/
class BotCommandScopeAllPrivateChats extends BotCommandScope
{
/** Scope type, must be all_private_chats */
public string $type = 'all_private_chats';
/** Scope type, must be all_private_chats */
public string $type = 'all_private_chats';


public static function make(): static
{
return new static([
]);
}
public static function make(): static
{
return new static([
]);
}
}
Loading

0 comments on commit 87e2788

Please sign in to comment.