Reformatting the Event class.

This commit is contained in:
Ilya Bakhlin 2021-12-25 22:41:03 +01:00
parent 11e11add72
commit f8cb0c50a4
2 changed files with 63 additions and 26 deletions

View file

@ -1,37 +1,74 @@
<?php declare(strict_types=1); <?php
declare(strict_types = 1);
namespace Chandler\Eventing\Events; namespace Chandler\Eventing\Events;
/**
* @package Chandler\Eventing\Events
*/
class Event class Event
{ {
protected $data; /**
* @var float
*/
protected $code; protected $code;
protected $time;
/**
* @var string
*/
protected $data;
/**
* @var bool
*/
protected $pristine = true; protected $pristine = true;
function __construct($data = "", float $code = 0) /**
* @var int
*/
protected $time;
/**
* @return float
*/
public function getCode(): float
{
return $this->code;
}
/**
* @return string
*/
public function getData(): string
{
return $this->data;
}
/**
* @return int
*/
public function getTime(): int
{
return $this->time;
}
/**
* @return bool
*/
public function isTainted(): bool
{
return !$this->pristine;
}
/**
* @param string $data
* @param float $code
*/
public function __construct(string $data = "", float $code = 0.0)
{ {
$this->data = $data; $this->data = $data;
$this->code = $code; $this->code = $code;
$this->time = time(); $this->time = time();
} }
function getData()
{
return $this->data;
}
function getCode()
{
return $this->code;
}
function getTime()
{
return $this->time;
}
function isTainted()
{
return !$this->pristine;
}
} }

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<phpunit bootstrap="vendor/autoload.php" cacheResultFile="tests/cache/result.txt" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"> <phpunit bootstrap="vendor/autoload.php" cacheResultFile="tests/cache/result.json" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd">
<coverage cacheDirectory="tests/cache" processUncoveredFiles="true"> <coverage cacheDirectory="tests/cache" processUncoveredFiles="true">
<include> <include>
<file>chandler/Eventing/Events/Event.php</file> <file>chandler/Eventing/Events/Event.php</file>