Skip to content

Commit

Permalink
Use internal variable
Browse files Browse the repository at this point in the history
  • Loading branch information
laoneo committed Sep 29, 2021
1 parent 47dd968 commit ec8b4c8
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,36 +20,48 @@
*/
class FetchMediaFileEvent extends AbstractEvent
{
/**
* @var \stdClass
* @since __DEPLOY_VERSION__
*/
private $file;

/**
* Constructor.
*
* @param string $name The event name.
* @param array $arguments The event arguments.
*
* @throws \BadMethodCallException
* @param string $name The event name.
* @param \stdClass $file The file.
*
* @since __DEPLOY_VERSION__
*/
public function __construct($name, array $arguments = array())
public function __construct($name, \stdClass $file)
{
parent::__construct($name, $arguments);
parent::__construct($name, []);

// Check for required arguments
if (!\array_key_exists('file', $arguments) || !is_object($arguments['file']))
{
throw new \BadMethodCallException("Argument 'file' of event $name is not of the expected type");
}
$this->file = $file;
}

/**
* Returns the event file.
*
* @return stdClass
* @return \stdClass
*
* @since __DEPLOY_VERSION__
*/
public function getFile(): \stdClass
{
return $this->arguments['file'];
return $this->file;
}

/**
* Sets the event file.
*
* @param \stdClass $file The file.
*
* @since __DEPLOY_VERSION__
*/
public function setFile(\stdClass $file): void
{
$this->file = $file;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,38 +18,50 @@
*
* @since __DEPLOY_VERSION__
*/
class FetchMediaFileUrlEvent extends AbstractEvent
class FetchMediaUrlUrlEvent extends AbstractEvent
{
/**
* @var string
* @since __DEPLOY_VERSION__
*/
private $url;

/**
* Constructor.
*
* @param string $name The event name.
* @param array $arguments The event arguments.
*
* @throws \BadMethodCallException
* @param string $name The event name.
* @param string $url The url.
*
* @since __DEPLOY_VERSION__
*/
public function __construct($name, array $arguments = array())
public function __construct($name, string $url)
{
parent::__construct($name, $arguments);
parent::__construct($name, []);

// Check for required arguments
if (!\array_key_exists('url', $arguments) || !is_string($arguments['url']))
{
throw new \BadMethodCallException("Argument 'url' of event $name is not of the expected type");
}
$this->url = $url;
}

/**
* Returns the event url.
*
* @return string
* @return stdClass
*
* @since __DEPLOY_VERSION__
*/
public function getUrl(): string
{
return $this->arguments['url'];
return $this->url;
}

/**
* Sets the event url.
*
* @param stdClass
*
* @since __DEPLOY_VERSION__
*/
public function setUrl(string $url)
{
$this->url = $url;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,25 +20,25 @@
*/
class FetchMediaFilesEvent extends AbstractEvent
{
/**
* @var array
* @since __DEPLOY_VERSION__
*/
private $files;

/**
* Constructor.
*
* @param string $name The event name.
* @param array $arguments The event arguments.
*
* @throws \BadMethodCallException
* @param string $name The event name.
* @param \stdClass $files The files.
*
* @since __DEPLOY_VERSION__
*/
public function __construct($name, array $arguments = array())
public function __construct($name, array $files)
{
parent::__construct($name, $arguments);
parent::__construct($name, []);

// Check for required arguments
if (!\array_key_exists('files', $arguments) || !is_array($arguments['files']))
{
throw new \BadMethodCallException("Argument 'files' of event $name is not of the expected type");
}
$this->files = $files;
}

/**
Expand All @@ -50,6 +50,18 @@ public function __construct($name, array $arguments = array())
*/
public function getFiles(): array
{
return $this->arguments['files'];
return $this->files;
}

/**
* Sets the event files.
*
* @param array
*
* @since __DEPLOY_VERSION__
*/
public function setFiles(array $files)
{
$this->files = $files;
}
}

0 comments on commit ec8b4c8

Please sign in to comment.