Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Intoduce native php enums #248

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@
"ext-curl": "*",
"ext-simplexml": "*",
"ext-mbstring": "*",
"ext-json": "*",
"marc-mabe/php-enum": "^v4.7.0"
"ext-json": "*"
},
"require-dev": {
"phpunit/phpunit": "^10.5",
Expand Down
6 changes: 3 additions & 3 deletions src/BigBlueButton.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class BigBlueButton
* @deprecated This property has been replaced by property in UrlBuilder-class.
* User property via $this->getUrlBuilder()->setHashingAlgorithm() and $this->getUrlBuilder()->getHashingAlgorithm().
*/
protected string $hashingAlgorithm;
protected HashingAlgorithm $hashingAlgorithm;

/**
* @var array<int, mixed>
Expand Down Expand Up @@ -493,13 +493,13 @@ public function setTimeOut(int $TimeOutInSeconds): self
return $this;
}

public function setHashingAlgorithm(string $hashingAlgorithm): void
public function setHashingAlgorithm(HashingAlgorithm $hashingAlgorithm): void
{
$this->hashingAlgorithm = $hashingAlgorithm;
$this->getUrlBuilder()->setHashingAlgorithm($hashingAlgorithm);
}

public function getHashingAlgorithm(string $hashingAlgorithm): string
public function getHashingAlgorithm(): HashingAlgorithm
{
$this->hashingAlgorithm = $this->getUrlBuilder()->getHashingAlgorithm();

Expand Down
8 changes: 5 additions & 3 deletions src/Core/Attendee.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,15 @@

namespace BigBlueButton\Core;

use BigBlueButton\Enum\Role;

class Attendee
{
private string $userId;

private string $fullName;

private string $role;
private Role $role;

private bool $isPresenter;

Expand All @@ -47,7 +49,7 @@ public function __construct(\SimpleXMLElement $xml)
{
$this->userId = $xml->userID->__toString();
$this->fullName = $xml->fullName->__toString();
$this->role = $xml->role->__toString();
$this->role = Role::from($xml->role->__toString());
$this->isPresenter = 'true' === $xml->isPresenter->__toString();
$this->isListeningOnly = 'true' === $xml->isListeningOnly->__toString();
$this->hasJoinedVoice = 'true' === $xml->hasJoinedVoice->__toString();
Expand All @@ -71,7 +73,7 @@ public function getFullName(): string
return $this->fullName;
}

public function getRole(): string
public function getRole(): Role
{
return $this->role;
}
Expand Down
48 changes: 23 additions & 25 deletions src/Enum/Feature.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,30 +20,28 @@

namespace BigBlueButton\Enum;

use MabeEnum\Enum;

class Feature extends Enum
enum Feature: string
{
public const BREAKOUT_ROOMS = 'breakoutRooms';
public const CAMERA_AS_CONTENT = 'cameraAsContent';
public const CAPTIONS = 'captions';
public const CHAT = 'chat';
public const CUSTOM_VIRTUAL_BACKGROUNDS = 'customVirtualBackgrounds';
public const DOWNLOAD_PRESENTATION_CONVERTED_TO_PDF = 'downloadPresentationConvertedToPdf';
public const DOWNLOAD_PRESENTATION_ORIGINAL_FILE = 'downloadPresentationOriginalFile';
public const DOWNLOAD_PRESENTATION_WITH_ANNOTATIONS = 'downloadPresentationWithAnnotations';
public const EXTERNAL_VIDEOS = 'externalVideos';
public const IMPORT_PRESENTATION_WITH_ANNOTATIONS_FROM_BREAKOUT_ROOMS = 'importPresentationWithAnnotationsFromBreakoutRooms';
public const IMPORT_SHARED_NOTES_FROM_BREAKOUT_ROOMS = 'importSharedNotesFromBreakoutRooms';
public const LAYOUTS = 'layouts';
public const LEARNING_DASHBOARD = 'learningDashboard';
public const LEARNING_DASHBOARD_DOWNLOAD_SESSION_DATA = 'learningDashboardDownloadSessionData';
public const LIVE_TRANSCRIPTION = 'liveTranscription';
public const POLLS = 'polls';
public const PRESENTATION = 'presentation';
public const SCREENSHARE = 'screenshare';
public const SHARED_NOTES = 'sharedNotes';
public const SNAPSHOT_OF_CURRENT_SLIDE = 'snapshotOfCurrentSlide';
public const TIMER = 'timer';
public const VIRTUAL_BACKGROUNDS = 'virtualBackgrounds';
case BREAKOUT_ROOMS = 'breakoutRooms';
case CAMERA_AS_CONTENT = 'cameraAsContent';
case CAPTIONS = 'captions';
case CHAT = 'chat';
case CUSTOM_VIRTUAL_BACKGROUNDS = 'customVirtualBackgrounds';
case DOWNLOAD_PRESENTATION_CONVERTED_TO_PDF = 'downloadPresentationConvertedToPdf';
case DOWNLOAD_PRESENTATION_ORIGINAL_FILE = 'downloadPresentationOriginalFile';
case DOWNLOAD_PRESENTATION_WITH_ANNOTATIONS = 'downloadPresentationWithAnnotations';
case EXTERNAL_VIDEOS = 'externalVideos';
case IMPORT_PRESENTATION_WITH_ANNOTATIONS_FROM_BREAKOUT_ROOMS = 'importPresentationWithAnnotationsFromBreakoutRooms';
case IMPORT_SHARED_NOTES_FROM_BREAKOUT_ROOMS = 'importSharedNotesFromBreakoutRooms';
case LAYOUTS = 'layouts';
case LEARNING_DASHBOARD = 'learningDashboard';
case LEARNING_DASHBOARD_DOWNLOAD_SESSION_DATA = 'learningDashboardDownloadSessionData';
case LIVE_TRANSCRIPTION = 'liveTranscription';
case POLLS = 'polls';
case PRESENTATION = 'presentation';
case SCREENSHARE = 'screenshare';
case SHARED_NOTES = 'sharedNotes';
case SNAPSHOT_OF_CURRENT_SLIDE = 'snapshotOfCurrentSlide';
case TIMER = 'timer';
case VIRTUAL_BACKGROUNDS = 'virtualBackgrounds';
}
16 changes: 8 additions & 8 deletions src/Enum/GuestPolicy.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@

namespace BigBlueButton\Enum;

use MabeEnum\Enum;

// @ref : https://github.com/bigbluebutton/bigbluebutton/blob/5189abb225247290d1954e10827853d5fc022b66/bbb-common-web/src/main/java/org/bigbluebutton/api/domain/GuestPolicy.java
class GuestPolicy extends Enum
/**
* @ref : https://github.com/bigbluebutton/bigbluebutton/blob/5189abb225247290d1954e10827853d5fc022b66/bbb-common-web/src/main/java/org/bigbluebutton/api/domain/GuestPolicy.java
*/
enum GuestPolicy: string
{
public const ALWAYS_ACCEPT = 'ALWAYS_ACCEPT';
public const ALWAYS_DENY = 'ALWAYS_DENY';
public const ASK_MODERATOR = 'ASK_MODERATOR';
public const ALWAYS_ACCEPT_AUTH = 'ALWAYS_ACCEPT_AUTH';
case ALWAYS_ACCEPT = 'ALWAYS_ACCEPT';
case ALWAYS_DENY = 'ALWAYS_DENY';
case ASK_MODERATOR = 'ASK_MODERATOR';
case ALWAYS_ACCEPT_AUTH = 'ALWAYS_ACCEPT_AUTH';
}
12 changes: 5 additions & 7 deletions src/Enum/HashingAlgorithm.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,10 @@

namespace BigBlueButton\Enum;

use MabeEnum\Enum;

class HashingAlgorithm extends Enum
enum HashingAlgorithm: string
{
public const SHA_1 = 'sha1';
public const SHA_256 = 'sha256';
public const SHA_512 = 'sha512';
public const SHA_384 = 'sha384';
case SHA_1 = 'sha1';
case SHA_256 = 'sha256';
case SHA_384 = 'sha384';
case SHA_512 = 'sha512';
}
12 changes: 5 additions & 7 deletions src/Enum/MeetingLayout.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,10 @@

namespace BigBlueButton\Enum;

use MabeEnum\Enum;

class MeetingLayout extends Enum
enum MeetingLayout: string
{
public const CUSTOM_LAYOUT = 'CUSTOM_LAYOUT';
public const SMART_LAYOUT = 'SMART_LAYOUT';
public const PRESENTATION_FOCUS = 'PRESENTATION_FOCUS';
public const VIDEO_FOCUS = 'VIDEO_FOCUS';
case CUSTOM_LAYOUT = 'CUSTOM_LAYOUT';
case SMART_LAYOUT = 'SMART_LAYOUT';
case PRESENTATION_FOCUS = 'PRESENTATION_FOCUS';
case VIDEO_FOCUS = 'VIDEO_FOCUS';
}
8 changes: 3 additions & 5 deletions src/Enum/Role.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,8 @@

namespace BigBlueButton\Enum;

use MabeEnum\Enum;

class Role extends Enum
enum Role: string
{
public const MODERATOR = 'MODERATOR';
public const VIEWER = 'VIEWER';
case MODERATOR = 'MODERATOR';
case VIEWER = 'VIEWER';
}
72 changes: 35 additions & 37 deletions src/Enum/UserData.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,57 +20,55 @@

namespace BigBlueButton\Enum;

use MabeEnum\Enum;

class UserData extends Enum
enum UserData: string
{
// Application settings
public const ASK_FOR_FEEDBACK_ON_LOGOUT = 'bbb_ask_for_feedback_on_logout';
public const AUTO_JOIN_AUDIO = 'bbb_auto_join_audio';
public const CLIENT_TITLE = 'bbb_client_title';
public const FORCE_LISTEN_ONLY = 'bbb_force_listen_only';
public const LISTEN_ONLY_MODE = 'bbb_listen_only_mode';
public const SKIP_CHECK_AUDIO = 'bbb_skip_check_audio';
public const SKIP_CHECK_AUDIO_ON_FIRST_JOIN = 'bbb_skip_check_audio_on_first_join';
public const OVERRIDE_DEFAULT_LOCALE = 'bbb_override_default_locale';
public const HIDE_PRESENTATION_ON_JOIN = 'bbb_hide_presentation_on_join';
public const DIRECT_LEAVE_BUTTON = 'bbb_direct_leave_button';
case ASK_FOR_FEEDBACK_ON_LOGOUT = 'bbb_ask_for_feedback_on_logout';
case AUTO_JOIN_AUDIO = 'bbb_auto_join_audio';
case CLIENT_TITLE = 'bbb_client_title';
case FORCE_LISTEN_ONLY = 'bbb_force_listen_only';
case LISTEN_ONLY_MODE = 'bbb_listen_only_mode';
case SKIP_CHECK_AUDIO = 'bbb_skip_check_audio';
case SKIP_CHECK_AUDIO_ON_FIRST_JOIN = 'bbb_skip_check_audio_on_first_join';
case OVERRIDE_DEFAULT_LOCALE = 'bbb_override_default_locale';
case HIDE_PRESENTATION_ON_JOIN = 'bbb_hide_presentation_on_join';
case DIRECT_LEAVE_BUTTON = 'bbb_direct_leave_button';

// Branding settings
public const DISPLAY_BRANDING_AREA = 'bbb_display_branding_area';
case DISPLAY_BRANDING_AREA = 'bbb_display_branding_area';

// Shortcut settings
public const SHORTCUTS = 'bbb_shortcuts';
case SHORTCUTS = 'bbb_shortcuts';

// Kurento settings (WebRTC media server)
public const AUTO_SHARE_WEBCAM = 'bbb_auto_share_webcam';
public const PREFERRED_CAMERA_PROFILE = 'bbb_preferred_camera_profile';
public const ENABLE_VIDEO = 'bbb_enable_video';
public const RECORD_VIDEO = 'bbb_record_video';
public const SKIP_VIDEO_PREVIEW = 'bbb_skip_video_preview';
public const SKIP_VIDEO_PREVIEW_ON_FIRST_JOIN = 'bbb_skip_video_preview_on_first_join';
public const MIRROR_OWN_WEBCAM = 'bbb_mirror_own_webcam';
public const FULLAUDIO_BRIDGE = 'bbb_fullaudio_bridge';
public const TRANSPARENT_LISTEN_ONLY = 'bbb_transparent_listen_only';
case AUTO_SHARE_WEBCAM = 'bbb_auto_share_webcam';
case PREFERRED_CAMERA_PROFILE = 'bbb_preferred_camera_profile';
case ENABLE_VIDEO = 'bbb_enable_video';
case RECORD_VIDEO = 'bbb_record_video';
case SKIP_VIDEO_PREVIEW = 'bbb_skip_video_preview';
case SKIP_VIDEO_PREVIEW_ON_FIRST_JOIN = 'bbb_skip_video_preview_on_first_join';
case MIRROR_OWN_WEBCAM = 'bbb_mirror_own_webcam';
case FULLAUDIO_BRIDGE = 'bbb_fullaudio_bridge';
case TRANSPARENT_LISTEN_ONLY = 'bbb_transparent_listen_only';

// Presentation settings
public const FORCE_RESTORE_PRESENTATION_ON_NEW_EVENTS = 'bbb_force_restore_presentation_on_new_events';
case FORCE_RESTORE_PRESENTATION_ON_NEW_EVENTS = 'bbb_force_restore_presentation_on_new_events';

// Whiteboard settings
public const MULTI_USER_PEN_ONLY = 'bbb_multi_user_pen_only';
public const PRESENTER_TOOLS = 'bbb_presenter_tools';
public const MULTI_USER_TOOLS = 'bbb_multi_user_tools';
case MULTI_USER_PEN_ONLY = 'bbb_multi_user_pen_only';
case PRESENTER_TOOLS = 'bbb_presenter_tools';
case MULTI_USER_TOOLS = 'bbb_multi_user_tools';

// Theming & Styling settings
public const CUSTOM_STYLE = 'bbb_custom_style';
public const CUSTOM_STYLE_URL = 'bbb_custom_style_url';
case CUSTOM_STYLE = 'bbb_custom_style';
case CUSTOM_STYLE_URL = 'bbb_custom_style_url';

// Layout settings
public const AUTO_SWAP_LAYOUT = 'bbb_auto_swap_layout';
public const HIDE_PRESENTATION = 'bbb_hide_presentation';
public const SHOW_PARTICIPANTS_ON_LOGIN = 'bbb_show_participants_on_login';
public const SHOW_PUBLIC_CHAT_ON_LOGIN = 'bbb_show_public_chat_on_login';
public const HIDE_NAV_BAR = 'bbb_hide_nav_bar';
public const HIDE_ACTIONS_BAR = 'bbb_hide_actions_bar';
public const DEFAULT_LAYOUT = 'bbb_default_layout';
case AUTO_SWAP_LAYOUT = 'bbb_auto_swap_layout';
case HIDE_PRESENTATION = 'bbb_hide_presentation';
case SHOW_PARTICIPANTS_ON_LOGIN = 'bbb_show_participants_on_login';
case SHOW_PUBLIC_CHAT_ON_LOGIN = 'bbb_show_public_chat_on_login';
case HIDE_NAV_BAR = 'bbb_hide_nav_bar';
case HIDE_ACTIONS_BAR = 'bbb_hide_actions_bar';
case DEFAULT_LAYOUT = 'bbb_default_layout';
}
Loading