59 lines
1.2 KiB
PHP
59 lines
1.2 KiB
PHP
|
<?php
|
||
|
|
||
|
class ExampleClass
|
||
|
{
|
||
|
/**
|
||
|
* @var array
|
||
|
*/
|
||
|
private $data;
|
||
|
|
||
|
/**
|
||
|
* ExampleClass constructor.
|
||
|
*/
|
||
|
public function __construct()
|
||
|
{
|
||
|
$this->data = [];
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Sets a value in the data array
|
||
|
*
|
||
|
* @param string $key
|
||
|
* @param mixed $value
|
||
|
* @return void
|
||
|
*/
|
||
|
public function set(string $key, mixed $value): void
|
||
|
{
|
||
|
$this->data[$key] = $value;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Gets a value from the data array
|
||
|
*
|
||
|
* @param string $key
|
||
|
* @return mixed
|
||
|
*/
|
||
|
public function get(string $key): mixed
|
||
|
{
|
||
|
return $this->data[$key];
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Checks if a key exists in the data array
|
||
|
*
|
||
|
* @param string $key
|
||
|
* @return bool
|
||
|
*/
|
||
|
public function exists(string $key): bool
|
||
|
{
|
||
|
return isset($this->data[$key]);
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* @return void
|
||
|
*/
|
||
|
public function clear(): void
|
||
|
{
|
||
|
$this->data = [];
|
||
|
}
|
||
|
}
|