Skip to content

Commit ec8b4c8

Browse files
committed
Use internal variable
1 parent 47dd968 commit ec8b4c8

File tree

3 files changed

+75
-39
lines changed

3 files changed

+75
-39
lines changed

administrator/components/com_media/src/Event/FetchMediaFileEvent.php

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,36 +20,48 @@
2020
*/
2121
class FetchMediaFileEvent extends AbstractEvent
2222
{
23+
/**
24+
* @var \stdClass
25+
* @since __DEPLOY_VERSION__
26+
*/
27+
private $file;
28+
2329
/**
2430
* Constructor.
2531
*
26-
* @param string $name The event name.
27-
* @param array $arguments The event arguments.
28-
*
29-
* @throws \BadMethodCallException
32+
* @param string $name The event name.
33+
* @param \stdClass $file The file.
3034
*
3135
* @since __DEPLOY_VERSION__
3236
*/
33-
public function __construct($name, array $arguments = array())
37+
public function __construct($name, \stdClass $file)
3438
{
35-
parent::__construct($name, $arguments);
39+
parent::__construct($name, []);
3640

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

4444
/**
4545
* Returns the event file.
4646
*
47-
* @return stdClass
47+
* @return \stdClass
4848
*
4949
* @since __DEPLOY_VERSION__
5050
*/
5151
public function getFile(): \stdClass
5252
{
53-
return $this->arguments['file'];
53+
return $this->file;
54+
}
55+
56+
/**
57+
* Sets the event file.
58+
*
59+
* @param \stdClass $file The file.
60+
*
61+
* @since __DEPLOY_VERSION__
62+
*/
63+
public function setFile(\stdClass $file): void
64+
{
65+
$this->file = $file;
5466
}
5567
}

administrator/components/com_media/src/Event/FetchMediaFileUrlEvent.php

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,38 +18,50 @@
1818
*
1919
* @since __DEPLOY_VERSION__
2020
*/
21-
class FetchMediaFileUrlEvent extends AbstractEvent
21+
class FetchMediaUrlUrlEvent extends AbstractEvent
2222
{
23+
/**
24+
* @var string
25+
* @since __DEPLOY_VERSION__
26+
*/
27+
private $url;
28+
2329
/**
2430
* Constructor.
2531
*
26-
* @param string $name The event name.
27-
* @param array $arguments The event arguments.
28-
*
29-
* @throws \BadMethodCallException
32+
* @param string $name The event name.
33+
* @param string $url The url.
3034
*
3135
* @since __DEPLOY_VERSION__
3236
*/
33-
public function __construct($name, array $arguments = array())
37+
public function __construct($name, string $url)
3438
{
35-
parent::__construct($name, $arguments);
39+
parent::__construct($name, []);
3640

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

4444
/**
4545
* Returns the event url.
4646
*
47-
* @return string
47+
* @return stdClass
4848
*
4949
* @since __DEPLOY_VERSION__
5050
*/
5151
public function getUrl(): string
5252
{
53-
return $this->arguments['url'];
53+
return $this->url;
54+
}
55+
56+
/**
57+
* Sets the event url.
58+
*
59+
* @param stdClass
60+
*
61+
* @since __DEPLOY_VERSION__
62+
*/
63+
public function setUrl(string $url)
64+
{
65+
$this->url = $url;
5466
}
5567
}

administrator/components/com_media/src/Event/FetchMediaFilesEvent.php

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,25 +20,25 @@
2020
*/
2121
class FetchMediaFilesEvent extends AbstractEvent
2222
{
23+
/**
24+
* @var array
25+
* @since __DEPLOY_VERSION__
26+
*/
27+
private $files;
28+
2329
/**
2430
* Constructor.
2531
*
26-
* @param string $name The event name.
27-
* @param array $arguments The event arguments.
28-
*
29-
* @throws \BadMethodCallException
32+
* @param string $name The event name.
33+
* @param \stdClass $files The files.
3034
*
3135
* @since __DEPLOY_VERSION__
3236
*/
33-
public function __construct($name, array $arguments = array())
37+
public function __construct($name, array $files)
3438
{
35-
parent::__construct($name, $arguments);
39+
parent::__construct($name, []);
3640

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

4444
/**
@@ -50,6 +50,18 @@ public function __construct($name, array $arguments = array())
5050
*/
5151
public function getFiles(): array
5252
{
53-
return $this->arguments['files'];
53+
return $this->files;
54+
}
55+
56+
/**
57+
* Sets the event files.
58+
*
59+
* @param array
60+
*
61+
* @since __DEPLOY_VERSION__
62+
*/
63+
public function setFiles(array $files)
64+
{
65+
$this->files = $files;
5466
}
5567
}

0 commit comments

Comments
 (0)