Skip to content

Commit

Permalink
Merge dad3fb0 into d5490b2
Browse files Browse the repository at this point in the history
  • Loading branch information
sualko committed Feb 10, 2021
2 parents d5490b2 + dad3fb0 commit 8b113c7
Show file tree
Hide file tree
Showing 31 changed files with 819 additions and 1,362 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ composer.phar
.php_cs.cache
cghooks.lock

.phpunit.result.cache
2 changes: 2 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@
},
"scripts": {
"test": "vendor/bin/phpunit",
"cs-fix": "vendor/bin/php-cs-fixer fix --allow-risky=yes",
"cs-test": "vendor/bin/php-cs-fixer fix --dry-run --allow-risky=yes",
"post-install-cmd": "vendor/bin/cghooks add --ignore-lock",
"post-update-cmd": "vendor/bin/cghooks update"
},
Expand Down
91 changes: 53 additions & 38 deletions src/BigBlueButton.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,13 @@
use BigBlueButton\Parameters\GetMeetingInfoParameters;
use BigBlueButton\Parameters\GetRecordingsParameters;
use BigBlueButton\Parameters\GetRecordingTextTracksParameters;
use BigBlueButton\Parameters\PutRecordingTextTrackParameters;
use BigBlueButton\Parameters\HooksCreateParameters;
use BigBlueButton\Parameters\HooksDestroyParameters;
use BigBlueButton\Parameters\IsMeetingRunningParameters;
use BigBlueButton\Parameters\JoinMeetingParameters;
use BigBlueButton\Parameters\PublishRecordingsParameters;
use BigBlueButton\Parameters\SetConfigXMLParameters;
use BigBlueButton\Parameters\UpdateRecordingsParameters;
use BigBlueButton\Responses\ApiVersionResponse;
use BigBlueButton\Responses\CreateMeetingResponse;
Expand All @@ -44,6 +46,7 @@
use BigBlueButton\Responses\GetMeetingsResponse;
use BigBlueButton\Responses\GetRecordingsResponse;
use BigBlueButton\Responses\GetRecordingTextTracksResponse;
use BigBlueButton\Responses\PutRecordingTextTrackResponse;
use BigBlueButton\Responses\HooksCreateResponse;
use BigBlueButton\Responses\HooksDestroyResponse;
use BigBlueButton\Responses\HooksListResponse;
Expand Down Expand Up @@ -205,7 +208,7 @@ public function setConfigXMLUrl()
}

/**
* @param $setConfigXMLParams
* @param SetConfigXMLParameters $setConfigXMLParams
*
* @return SetConfigXMLResponse
* @throws RuntimeException
Expand All @@ -220,7 +223,7 @@ public function setConfigXML($setConfigXMLParams)
}

/**
* @param $joinMeetingParams JoinMeetingParameters
* @param JoinMeetingParameters $joinMeetingParams
*
* @return string
*/
Expand All @@ -230,7 +233,7 @@ public function getJoinMeetingURL($joinMeetingParams)
}

/**
* @param $joinMeetingParams JoinMeetingParameters
* @param JoinMeetingParameters $joinMeetingParams
*
* @return JoinMeetingResponse
* @throws RuntimeException
Expand All @@ -243,7 +246,7 @@ public function joinMeeting($joinMeetingParams)
}

/**
* @param $endParams EndMeetingParameters
* @param EndMeetingParameters $endParams
*
* @return string
*/
Expand All @@ -253,7 +256,7 @@ public function getEndMeetingURL($endParams)
}

/**
* @param $endParams EndMeetingParameters
* @param EndMeetingParameters $endParams
*
* @return EndMeetingResponse
* @throws RuntimeException
Expand All @@ -265,15 +268,8 @@ public function endMeeting($endParams)
return new EndMeetingResponse($xml);
}

/* __________________ BBB MONITORING METHODS _________________ */
/* The methods in the following section support the following categories of the BBB API:
-- isMeetingRunning
-- getMeetings
-- getMeetingInfo
*/

/**
* @param $meetingParams IsMeetingRunningParameters
* @param IsMeetingRunningParameters $meetingParams
*
* @return string
*/
Expand All @@ -283,7 +279,7 @@ public function getIsMeetingRunningUrl($meetingParams)
}

/**
* @param $meetingParams
* @param IsMeetingRunningParameters $meetingParams
*
* @return IsMeetingRunningResponse
* @throws RuntimeException
Expand Down Expand Up @@ -315,7 +311,7 @@ public function getMeetings()
}

/**
* @param $meetingParams GetMeetingInfoParameters
* @param GetMeetingInfoParameters $meetingParams
*
* @return string
*/
Expand All @@ -325,7 +321,7 @@ public function getMeetingInfoUrl($meetingParams)
}

/**
* @param $meetingParams GetMeetingInfoParameters
* @param GetMeetingInfoParameters $meetingParams
*
* @return GetMeetingInfoResponse
* @throws RuntimeException
Expand All @@ -337,15 +333,8 @@ public function getMeetingInfo($meetingParams)
return new GetMeetingInfoResponse($xml);
}

/* __________________ BBB RECORDING METHODS _________________ */
/* The methods in the following section support the following categories of the BBB API:
-- getRecordings
-- publishRecordings
-- deleteRecordings
*/

/**
* @param $recordingsParams GetRecordingsParameters
* @param GetRecordingsParameters $recordingsParams
*
* @return string
*/
Expand All @@ -355,7 +344,7 @@ public function getRecordingsUrl($recordingsParams)
}

/**
* @param $recordingParams
* @param GetRecordingsParameters $recordingParams
*
* @return GetRecordingsResponse
* @throws RuntimeException
Expand All @@ -368,7 +357,7 @@ public function getRecordings($recordingParams)
}

/**
* @param $recordingParams PublishRecordingsParameters
* @param PublishRecordingsParameters $recordingParams
*
* @return string
*/
Expand All @@ -378,7 +367,7 @@ public function getPublishRecordingsUrl($recordingParams)
}

/**
* @param $recordingParams PublishRecordingsParameters
* @param PublishRecordingsParameters $recordingParams
*
* @return PublishRecordingsResponse
* @throws RuntimeException
Expand All @@ -391,7 +380,7 @@ public function publishRecordings($recordingParams)
}

/**
* @param $recordingParams DeleteRecordingsParameters
* @param DeleteRecordingsParameters $recordingParams
*
* @return string
*/
Expand All @@ -401,7 +390,7 @@ public function getDeleteRecordingsUrl($recordingParams)
}

/**
* @param $recordingParams DeleteRecordingsParameters
* @param DeleteRecordingsParameters $recordingParams
*
* @return DeleteRecordingsResponse
* @throws RuntimeException
Expand All @@ -414,7 +403,7 @@ public function deleteRecordings($recordingParams)
}

/**
* @param $recordingParams UpdateRecordingsParameters
* @param UpdateRecordingsParameters $recordingParams
*
* @return string
*/
Expand All @@ -424,7 +413,7 @@ public function getUpdateRecordingsUrl($recordingParams)
}

/**
* @param $recordingParams UpdateRecordingsParameters
* @param UpdateRecordingsParameters $recordingParams
*
* @return UpdateRecordingsResponse
* @throws RuntimeException
Expand All @@ -437,7 +426,7 @@ public function updateRecordings($recordingParams)
}

/**
* @param $getRecordingTextTracksParams GetRecordingTextTracksParameters
* @param GetRecordingTextTracksParameters $getRecordingTextTracksParams
*
* @return string
*/
Expand All @@ -447,7 +436,7 @@ public function getRecordingTextTracksUrl($getRecordingTextTracksParams)
}

/**
* @param $getRecordingTextTracksParams GetRecordingTextTracksParameters
* @param GetRecordingTextTracksParameters $getRecordingTextTracksParams
*
* @return GetRecordingTextTracksResponse
* @throws RuntimeException
Expand All @@ -459,10 +448,36 @@ public function getRecordingTextTracks($getRecordingTextTracksParams)
);
}

/* ____________________ WEB HOOKS METHODS ___________________ */
/**
* @param PutRecordingTextTrackParameters $putRecordingTextTrackParams
*
* @return string
*/
public function getPutRecordingTextTrackUrl($putRecordingTextTrackParams)
{
return $this->urlBuilder->buildUrl(ApiMethod::PUT_RECORDING_TEXT_TRACK, $putRecordingTextTrackParams->getHTTPQuery());
}

/**
* @param PutRecordingTextTrackParameters $putRecordingTextTrackParams
*
* @return PutRecordingTextTrackResponse
* @throws RuntimeException
*/
public function putRecordingTextTrack($putRecordingTextTrackParams)
{
$url = $this->getPutRecordingTextTrackUrl($putRecordingTextTrackParams);
$file = $putRecordingTextTrackParams->getFile();

return new PutRecordingTextTrackResponse(
$file === null ?
$this->processJsonResponse($url) :
$this->processJsonResponse($url, $file, $putRecordingTextTrackParams->getContentType())
);
}

/**
* @param $hookCreateParams HooksCreateParameters
* @param HooksCreateParameters $hookCreateParams
*
* @return string
*/
Expand All @@ -472,7 +487,7 @@ public function getHooksCreateUrl($hookCreateParams)
}

/**
* @param $hookCreateParams
* @param HooksCreateParameters $hookCreateParams
*
* @return HooksCreateResponse
*/
Expand Down Expand Up @@ -502,7 +517,7 @@ public function hooksList()
}

/**
* @param $hooksDestroyParams HooksDestroyParameters
* @param HooksDestroyParameters $hooksDestroyParams
*
* @return string
*/
Expand All @@ -512,7 +527,7 @@ public function getHooksDestroyUrl($hooksDestroyParams)
}

/**
* @param $hooksDestroyParams
* @param HooksDestroyParameters $hooksDestroyParams
*
* @return HooksDestroyResponse
*/
Expand Down
1 change: 1 addition & 0 deletions src/Core/ApiMethod.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ abstract class ApiMethod
const DELETE_RECORDINGS = 'deleteRecordings';
const UPDATE_RECORDINGS = 'updateRecordings';
const GET_RECORDING_TEXT_TRACKS = 'getRecordingTextTracks';
const PUT_RECORDING_TEXT_TRACK = 'putRecordingTextTrack';
const HOOKS_CREATE = 'hooks/create';
const HOOKS_LIST = 'hooks/list';
const HOOKS_DESTROY = 'hooks/destroy';
Expand Down
79 changes: 71 additions & 8 deletions src/Parameters/BaseParameters.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,81 @@
*/
abstract class BaseParameters
{
/**
* @param $array
*
* @return string
*/
protected function buildHTTPQuery($array)
protected $ignoreProperties = [];

public function __call(string $name, array $arguments)
{
if (!preg_match('/^(get|is|set)[A-Z]/', $name)) {
throw new \BadFunctionCallException($name . ' does not exist');
}
if (strpos($name, 'get') === 0) {
return $this->getter(\lcfirst(substr($name, 3)));
} elseif (strpos($name, 'is') === 0) {
return $this->booleanGetter(\lcfirst(substr($name, 2)));
} elseif (strpos($name, 'set') === 0) {
return $this->setter(lcfirst(substr($name, 3)), $arguments);
}
}

protected function getter($name)
{
return http_build_query(array_filter($array));
if (property_exists($this, $name)) {
return $this->$name;
} else {
throw new \BadFunctionCallException($name . ' is not a valid property');
}
}

protected function booleanGetter($name)
{
$value = $this->getter($name);

if (!\is_bool($this->$name) && $this->$name !== null) {
throw new \BadFunctionCallException($name . ' is not a boolean property');
}

return $value;
}

protected function setter($name, $arguments)
{
if (!property_exists($this, $name)) {
throw new \BadFunctionCallException($name . ' is not a valid property');
}

$this->$name = $arguments[0];

return $this;
}

protected function getProperties(): array
{
return array_filter(get_object_vars($this), function ($name) {
return $name !== 'ignoreProperties' && !\in_array($name, $this->ignoreProperties);
}, ARRAY_FILTER_USE_KEY);
}

protected function getHTTPQueryArray(): array
{
$properties = $this->getProperties();
$properties = array_filter($properties, function ($value) {
return $value !== null;
});

return array_map(function ($value) {
if (\is_bool($value)) {
return $value ? 'true' : 'false';
}

return $value;
}, $properties);
}

/**
* @return string
*/
abstract public function getHTTPQuery();
public function getHTTPQuery() //: string
{
return \http_build_query($this->getHTTPQueryArray());
}
}

0 comments on commit 8b113c7

Please sign in to comment.