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

Improve parameter constructors #247

Open
wants to merge 7 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
14 changes: 4 additions & 10 deletions src/BigBlueButton.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class BigBlueButton
protected int $timeOut = 10;
protected string $jSessionId;

private UrlBuilder $urlBuilder;
protected UrlBuilder $urlBuilder;

/**
* @param null|array<string, mixed> $opts
Expand Down Expand Up @@ -302,11 +302,9 @@ public function getRecordingsUrl(GetRecordingsParameters $recordingsParams): str
}

/**
* @param mixed $recordingParams
*
* @throws BadResponseException|\RuntimeException
*/
public function getRecordings($recordingParams): GetRecordingsResponse
public function getRecordings(GetRecordingsParameters $recordingParams): GetRecordingsResponse
{
$xml = $this->processXmlResponse($this->getUrlBuilder()->getRecordingsUrl($recordingParams));

Expand Down Expand Up @@ -414,11 +412,9 @@ public function getHooksCreateUrl(HooksCreateParameters $hookCreateParams): stri
}

/**
* @param mixed $hookCreateParams
*
* @throws BadResponseException
*/
public function hooksCreate($hookCreateParams): HooksCreateResponse
public function hooksCreate(HooksCreateParameters $hookCreateParams): HooksCreateResponse
{
$xml = $this->processXmlResponse($this->getUrlBuilder()->getHooksCreateUrl($hookCreateParams));

Expand Down Expand Up @@ -452,11 +448,9 @@ public function getHooksDestroyUrl(HooksDestroyParameters $hooksDestroyParams):
}

/**
* @param mixed $hooksDestroyParams
*
* @throws BadResponseException
*/
public function hooksDestroy($hooksDestroyParams): HooksDestroyResponse
public function hooksDestroy(HooksDestroyParameters $hooksDestroyParams): HooksDestroyResponse
{
$xml = $this->processXmlResponse($this->getUrlBuilder()->getHooksDestroyUrl($hooksDestroyParams));

Expand Down
5 changes: 1 addition & 4 deletions src/Core/Track.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,7 @@ class Track

private string $source;

/**
* @param mixed $track
*/
public function __construct($track)
public function __construct(mixed $track)
{
$this->href = $track->href;
$this->kind = $track->kind;
Expand Down
4 changes: 2 additions & 2 deletions src/Parameters/BaseParameters.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ abstract class BaseParameters
abstract public function getHTTPQuery(): string;

/**
* @param mixed $array
* @param array<string, null|int|string> $array
*/
protected function buildHTTPQuery($array): string
protected function buildHTTPQuery(array $array): string
{
return str_replace(['%20', '!', "'", '(', ')', '*'], ['+', '%21', '%27', '%28', '%29', '%2A'], http_build_query(array_filter($array), '', '&', \PHP_QUERY_RFC3986));
}
Expand Down
38 changes: 10 additions & 28 deletions src/Parameters/CreateMeetingParameters.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ class CreateMeetingParameters extends MetaParameters
{
use DocumentableTrait;

private ?string $meetingId = null;
private string $meetingId;

private ?string $meetingName = null;
private string $meetingName;

/**
* @deprecated Password-string replaced by an Enum\Role-constant in JoinMeetingParameters::__construct()
Expand Down Expand Up @@ -177,11 +177,8 @@ class CreateMeetingParameters extends MetaParameters

/**
* CreateMeetingParameters constructor.
*
* @param mixed $meetingId
* @param mixed $meetingName
*/
public function __construct($meetingId = null, $meetingName = null)
public function __construct(string $meetingId, string $meetingName)
{
$this->meetingId = $meetingId;
$this->meetingName = $meetingName;
Expand Down Expand Up @@ -582,12 +579,9 @@ public function isVirtualBackgroundsDisabled(): ?bool
* Default: false
*
* @since 2.4.3
*
* @param mixed $virtualBackgroundsDisabled
*
* @deprecated Removed in 2.5, temporarily still handled, please transition to disabledFeatures.
*/
public function setVirtualBackgroundsDisabled($virtualBackgroundsDisabled): self
public function setVirtualBackgroundsDisabled(bool $virtualBackgroundsDisabled): self
{
$this->virtualBackgroundsDisabled = $virtualBackgroundsDisabled;

Expand Down Expand Up @@ -943,20 +937,14 @@ public function setAllowModsToEjectCameras(bool $allowModsToEjectCameras): self
return $this;
}

/**
* @param mixed $endCallbackUrl
*/
public function setEndCallbackUrl($endCallbackUrl): self
public function setEndCallbackUrl(string $endCallbackUrl): self
{
$this->addMeta('endCallbackUrl', $endCallbackUrl);

return $this;
}

/**
* @param mixed $recordingReadyCallbackUrl
*/
public function setRecordingReadyCallbackUrl($recordingReadyCallbackUrl): self
public function setRecordingReadyCallbackUrl(string $recordingReadyCallbackUrl): self
{
$this->addMeta('bbb-recording-ready-url', $recordingReadyCallbackUrl);

Expand Down Expand Up @@ -1055,11 +1043,9 @@ public function isBreakoutRoomsEnabled(): ?bool
*
* Default: true
*
* @param mixed $breakoutRoomsEnabled
*
* @deprecated Removed in 2.5, temporarily still handled, please transition to disabledFeatures.
*/
public function setBreakoutRoomsEnabled($breakoutRoomsEnabled): self
public function setBreakoutRoomsEnabled(bool $breakoutRoomsEnabled): self
{
$this->breakoutRoomsEnabled = $breakoutRoomsEnabled;

Expand Down Expand Up @@ -1143,10 +1129,8 @@ public function isAllowRequestsWithoutSession(): ?bool
* Default: false
*
* @since 2.4.3
*
* @param mixed $allowRequestsWithoutSession
*/
public function setAllowRequestsWithoutSession($allowRequestsWithoutSession): self
public function setAllowRequestsWithoutSession(bool $allowRequestsWithoutSession): self
{
$this->allowRequestsWithoutSession = $allowRequestsWithoutSession;

Expand Down Expand Up @@ -1350,11 +1334,9 @@ public function getBreakoutRoomsGroups(): array
}

/**
* @param mixed $id
* @param mixed $name
* @param mixed $roster
* @param array<int, string> $roster
*/
public function addBreakoutRoomsGroup($id, $name, $roster): self
public function addBreakoutRoomsGroup(mixed $id, string $name, array $roster): self
{
$this->breakoutRoomsGroups[] = ['id' => $id, 'name' => $name, 'roster' => $roster];

Expand Down
8 changes: 4 additions & 4 deletions src/Parameters/DeleteRecordingsParameters.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,19 @@
*/
class DeleteRecordingsParameters extends BaseParameters
{
private ?string $recordingId = null;
private string $recordingId;

public function __construct(?string $recordingId = null)
public function __construct(string $recordingId)
{
$this->recordingId = $recordingId;
}

public function getRecordingId(): ?string
public function getRecordingId(): string
{
return $this->recordingId;
}

public function setRecordingId(string $recordingId): DeleteRecordingsParameters
public function setRecordingId(string $recordingId): self
{
$this->recordingId = $recordingId;

Expand Down
2 changes: 1 addition & 1 deletion src/Parameters/DocumentableTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function getPresentations(): array
return $this->presentations;
}

public function addPresentation(string $nameOrUrl, ?string $content = null, ?string $filename = null, DocumentOptions $documentOptions = null): self
public function addPresentation(string $nameOrUrl, ?string $content = null, ?string $filename = null, ?DocumentOptions $documentOptions = null): self
{
$this->presentations[$nameOrUrl] = [
'content' => $content ? base64_encode($content) : null,
Expand Down
12 changes: 7 additions & 5 deletions src/Parameters/EndMeetingParameters.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,22 @@
*/
class EndMeetingParameters extends BaseParameters
{
private ?string $meetingId = null;
private string $meetingId;

/**
* The password of the moderator.
*
* @deprecated
*/
private ?string $password = null;
private ?string $password;

public function __construct(?string $meetingId = null, ?string $password = null)
public function __construct(string $meetingId, ?string $password = null)
{
$this->password = $password;
$this->meetingId = $meetingId;
}

public function getMeetingId(): ?string
public function getMeetingId(): string
{
return $this->meetingId;
}
Expand All @@ -61,7 +63,7 @@ public function getPassword(): ?string
/**
* @deprecated
*/
public function setPassword(string $password): self
public function setPassword(?string $password): self
{
$this->password = $password;

Expand Down
10 changes: 5 additions & 5 deletions src/Parameters/GetMeetingInfoParameters.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,18 @@
*/
class GetMeetingInfoParameters extends BaseParameters
{
private ?string $meetingId = null;
private string $meetingId;

private ?int $offset = null;

private ?int $limit = null;

public function __construct(?string $meetingId = null)
public function __construct(string $meetingId)
{
$this->meetingId = $meetingId;
}

public function getMeetingId(): ?string
public function getMeetingId(): string
{
return $this->meetingId;
}
Expand All @@ -53,7 +53,7 @@ public function getOffset(): ?int
return $this->offset;
}

public function setOffset(int $offset): self
public function setOffset(?int $offset): self
{
$this->offset = $offset;

Expand All @@ -65,7 +65,7 @@ public function getLimit(): ?int
return $this->limit;
}

public function setLimit(int $limit): self
public function setLimit(?int $limit): self
{
$this->limit = $limit;

Expand Down
6 changes: 3 additions & 3 deletions src/Parameters/GetRecordingTextTracksParameters.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,17 @@
*/
class GetRecordingTextTracksParameters extends MetaParameters
{
private ?string $recordId = null;
private string $recordId;

/**
* GetRecordingTextTracksParameters constructor.
*/
public function __construct(?string $recordId = null)
public function __construct(string $recordId)
{
$this->recordId = $recordId;
}

public function getRecordId(): ?string
public function getRecordId(): string
{
return $this->recordId;
}
Expand Down
6 changes: 3 additions & 3 deletions src/Parameters/InsertDocumentParameters.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ class InsertDocumentParameters extends BaseParameters
{
use DocumentableTrait;

private ?string $meetingId = null;
private string $meetingId;

public function __construct(?string $meetingId = null)
public function __construct(string $meetingId)
{
$this->meetingId = $meetingId;
}

public function getMeetingId(): ?string
public function getMeetingId(): string
{
return $this->meetingId;
}
Expand Down
6 changes: 3 additions & 3 deletions src/Parameters/IsMeetingRunningParameters.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@
*/
class IsMeetingRunningParameters extends BaseParameters
{
private ?string $meetingId = null;
private string $meetingId;

public function __construct(?string $meetingId = null)
public function __construct(string $meetingId)
{
$this->meetingId = $meetingId;
}

public function getMeetingId(): ?string
public function getMeetingId(): string
{
return $this->meetingId;
}
Expand Down
Loading