| 1 |
<?php |
| 2 |
|
| 3 |
namespace Shellbox\Command; |
| 4 |
|
| 5 |
trait UserDataTrait { |
| 6 |
/** @var array */ |
| 7 |
private $userData = []; |
| 8 |
|
| 9 |
/** |
| 10 |
* Set some data on the object. This will not be transmitted to the server |
| 11 |
* or otherwise used. |
| 12 |
* |
| 13 |
* @since 4.1.0 |
| 14 |
* @param string $name |
| 15 |
* @param mixed $value |
| 16 |
* @return $this |
| 17 |
*/ |
| 18 |
public function userData( string $name, $value ) { |
| 19 |
$this->userData[$name] = $value; |
| 20 |
return $this; |
| 21 |
} |
| 22 |
|
| 23 |
/** |
| 24 |
* Get data which was previously set. |
| 25 |
* |
| 26 |
* @since 4.1.0 |
| 27 |
* @param string $name |
| 28 |
* @return mixed|null |
| 29 |
*/ |
| 30 |
public function getUserData( string $name ) { |
| 31 |
return $this->userData[$name] ?? null; |
| 32 |
} |
| 33 |
|
| 34 |
} |