Skip to content

Commit

Permalink
Upgraded code base for php8.1
Browse files Browse the repository at this point in the history
  • Loading branch information
juniwalk committed Sep 5, 2022
1 parent 5d83353 commit 9111898
Show file tree
Hide file tree
Showing 7 changed files with 87 additions and 241 deletions.
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
},

"require": {
"php": ">=8.0",
"php": ">=8.1",
"doctrine/orm": "^2.0|^3.0",
"juniwalk/utils": "^1.0"
"juniwalk/utils": ">=1.0.5"
},

"suggest": {
Expand Down
44 changes: 5 additions & 39 deletions src/Chronicler.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,80 +8,52 @@
namespace JuniWalk\Nestor;

use JuniWalk\Nestor\Entity\Record;
use JuniWalk\Nestor\Enums\Type;
use JuniWalk\Nestor\Exceptions\RecordFailedException;
use Doctrine\DBAL\DBALException;
use Doctrine\ORM\EntityManagerInterface as EntityManager;
use Doctrine\ORM\ORMException;

final class Chronicler
{
/** @var EntityManager */
private $entityManager;

/** @var string */
private $entityName;


/**
* @param string $entityName
* @param EntityManager $entityManager
* @throws RecordNotValidException
*/
public function __construct(
string $entityName,
EntityManager $entityManager
private readonly string $entityName,
private readonly EntityManager $entityManager,
) {
if (!is_subclass_of($entityName, Record::class)) {
throw new RecordNotValidException;
}

$this->entityManager = $entityManager;
$this->entityName = $entityName;
}


/**
* @return string
*/
public function getEntityName(): string
{
return $this->entityName;
}


/**
* @param string $event
* @param string $message
* @param mixed[] $params
* @return void
*/
public function log(string $event, string $message, iterable $params = []): void
{
$record = $this->createRecord($event, $message, $params)
->withType('log');
->withType(Type::Log);

$this->record($record->create());
}


/**
* @param string $event
* @param string $message
* @param mixed[] $params
* @return void
*/
public function todo(string $event, string $message, iterable $params = []): void
{
$record = $this->createRecord($event, $message, $params)
->withType('todo');
->withType(Type::Todo);

$this->record($record->create());
}


/**
* @param Record $record
* @return void
* @throws RecordFailedException
*/
public function record(Record $record): void
Expand All @@ -96,12 +68,6 @@ public function record(Record $record): void
}


/**
* @param string $event
* @param string $message
* @param mixed[] $params
* @return RecordBuilder
*/
public function createRecord(string $event, string $message, iterable $params = []): RecordBuilder
{
return (new RecordBuilder($this))
Expand Down
4 changes: 0 additions & 4 deletions src/DI/NestorExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@

final class NestorExtension extends CompilerExtension
{
/**
* @return Schema
*/
public function getConfigSchema(): Schema
{
return Expect::structure([
Expand All @@ -26,7 +23,6 @@ public function getConfigSchema(): Schema


/**
* @return void
* @throws RecordNotValidException
*/
public function loadConfiguration()
Expand Down
Loading

0 comments on commit 9111898

Please sign in to comment.