Skip to content

Commit

Permalink
not ready but looks good
Browse files Browse the repository at this point in the history
  • Loading branch information
patrykbaszak committed Jul 28, 2024
1 parent a1da495 commit 358718b
Show file tree
Hide file tree
Showing 155 changed files with 2,293 additions and 184 deletions.
56 changes: 56 additions & 0 deletions src/Blueprint/Domain/Blueprint.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?php

declare(strict_types=1);

namespace PBaszak\UltraMapper\Blueprint\Domain;

use PBaszak\UltraMapper\Blueprint\Domain\Events\BlueprintCreated;
use PBaszak\UltraMapper\Blueprint\Domain\Identity\BlueprintId;
use PBaszak\UltraMapper\Shared\Domain\ObjectTypes\AggregateRoot;

final class Blueprint extends AggregateRoot
{
private function __construct(
private BlueprintId $id,
/** @var array<class-string, ClassBlueprint> */
private array $classBlueprints = [],
) {
}

/**
* @param BlueprintId $id
* @param array<class-string, ClassBlueprint> $classBlueprints
*/
public static function create(BlueprintId $id, array $classBlueprints): static
{
$blueprint = new static($id, $classBlueprints);

$blueprint->raise(
new BlueprintCreated($id)
);

return $blueprint;
}

/**
* @param BlueprintId $id
* @param array<class-string, ClassBlueprint> $classBlueprints
*/
public static function recreate(BlueprintId $id, array $classBlueprints): static
{
return new static($id, $classBlueprints);
}

public function id(): BlueprintId
{
return $this->id;
}

/**
* @return array<class-string, ClassBlueprint>
*/
public function classBlueprints(): array
{
return $this->classBlueprints;
}
}
56 changes: 56 additions & 0 deletions src/Blueprint/Domain/Entities/ClassBlueprint.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?php

declare(strict_types=1);

namespace PBaszak\UltraMapper\Blueprint\Domain\Entities;

use PBaszak\UltraMapper\Blueprint\Domain\Events\BlueprintCreated;
use PBaszak\UltraMapper\Blueprint\Domain\Identity\BlueprintId;
use PBaszak\UltraMapper\Shared\Domain\ObjectTypes\AggregateRoot;

final class ClassBlueprint extends AggregateRoot
{
private function __construct(
private BlueprintId $id,
/** @var array<string, PropertyBlueprint> */
private array $propertyBlueprints = [],
) {
}

/**
* @param BlueprintId $id
* @param array<string, PropertyBlueprint> $propertyBlueprints
*/
public static function create(BlueprintId $id, array $propertyBlueprints): static
{
$blueprint = new static($id, $propertyBlueprints);

$blueprint->raise(
new BlueprintCreated($id)
);

return $blueprint;
}

/**
* @param BlueprintId $id
* @param array<string, PropertyBlueprint> $propertyBlueprints
*/
public static function recreate(BlueprintId $id, array $propertyBlueprints): static
{
return new static($id, $propertyBlueprints);
}

public function id(): BlueprintId
{
return $this->id;
}

/**
* @return array<string, PropertyBlueprint>
*/
public function propertyBlueprints(): array
{
return $this->propertyBlueprints;
}
}
38 changes: 38 additions & 0 deletions src/Blueprint/Domain/Entities/PropertyBlueprint.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php

declare(strict_types=1);

namespace PBaszak\UltraMapper\Blueprint\Domain\Entities;

use PBaszak\UltraMapper\Blueprint\Domain\Events\BlueprintCreated;
use PBaszak\UltraMapper\Blueprint\Domain\Identity\BlueprintId;
use PBaszak\UltraMapper\Shared\Domain\ObjectTypes\AggregateRoot;

final class PropertyBlueprint extends AggregateRoot
{
private function __construct(
private BlueprintId $id,
) {
}

public static function create(BlueprintId $id): static
{
$blueprint = new static($id);

$blueprint->raise(
new BlueprintCreated($id)
);

return $blueprint;
}

public static function recreate(BlueprintId $id): static
{
return new static($id);
}

public function id(): BlueprintId
{
return $this->id;
}
}
20 changes: 20 additions & 0 deletions src/Blueprint/Domain/Events/BlueprintCreated.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

declare(strict_types=1);

namespace PBaszak\UltraMapper\Blueprint\Domain\Events;

use PBaszak\UltraMapper\Shared\Domain\Identity\Identifier;
use PBaszak\UltraMapper\Shared\Domain\ObjectTypes\Event;

final readonly class BlueprintCreated extends Event
{
public const EVENT_NAME = 'blueprint_created';
public const EVENT_VERSION = 1;

public function __construct(
public readonly Identifier $id
) {
parent::__construct($id, self::EVENT_NAME, self::EVENT_VERSION);
}
}
11 changes: 11 additions & 0 deletions src/Blueprint/Domain/Identity/BlueprintId.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

declare(strict_types=1);

namespace PBaszak\UltraMapper\Blueprint\Domain\Identity;

use PBaszak\UltraMapper\Shared\Domain\Identity\Identifier;

final class BlueprintId extends Identifier
{
}
38 changes: 38 additions & 0 deletions src/Build/Domain/Build.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php

declare(strict_types=1);

namespace PBaszak\UltraMapper\Build\Domain;

use PBaszak\UltraMapper\Build\Domain\Events\BuildCreated;
use PBaszak\UltraMapper\Build\Domain\Identity\BuildId;
use PBaszak\UltraMapper\Shared\Domain\ObjectTypes\AggregateRoot;

final class Build extends AggregateRoot
{
private function __construct(
private BuildId $id,
) {
}

public static function create(BuildId $id): static
{
$build = new static($id);

$build->raise(
new BuildCreated($id)
);

return $build;
}

public static function recreate(BuildId $id): static
{
return new static($id);
}

public function id(): BuildId
{
return $this->id;
}
}
20 changes: 20 additions & 0 deletions src/Build/Domain/Events/BuildCreated.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

declare(strict_types=1);

namespace PBaszak\UltraMapper\Build\Domain\Events;

use PBaszak\UltraMapper\Shared\Domain\Identity\Identifier;
use PBaszak\UltraMapper\Shared\Domain\ObjectTypes\Event;

final readonly class BuildCreated extends Event
{
public const EVENT_NAME = 'build_created';
public const EVENT_VERSION = 1;

public function __construct(
public readonly Identifier $id
) {
parent::__construct($id, self::EVENT_NAME, self::EVENT_VERSION);
}
}
11 changes: 11 additions & 0 deletions src/Build/Domain/Identity/BuildId.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

declare(strict_types=1);

namespace PBaszak\UltraMapper\Build\Domain\Identity;

use PBaszak\UltraMapper\Shared\Domain\Identity\Identifier;

final class BuildId extends Identifier
{
}
20 changes: 20 additions & 0 deletions src/Mapper/Domain/Events/MapperCreated.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

declare(strict_types=1);

namespace PBaszak\UltraMapper\Mapper\Domain\Events;

use PBaszak\UltraMapper\Shared\Domain\Identity\Identifier;
use PBaszak\UltraMapper\Shared\Domain\ObjectTypes\Event;

final readonly class MapperCreated extends Event
{
public const EVENT_NAME = 'mapper_created';
public const EVENT_VERSION = 1;

public function __construct(
public readonly Identifier $id
) {
parent::__construct($id, self::EVENT_NAME, self::EVENT_VERSION);
}
}
11 changes: 11 additions & 0 deletions src/Mapper/Domain/Identity/MapperId.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

declare(strict_types=1);

namespace PBaszak\UltraMapper\Mapper\Domain\Identity;

use PBaszak\UltraMapper\Shared\Domain\Identity\Identifier;

final class MapperId extends Identifier
{
}
38 changes: 38 additions & 0 deletions src/Mapper/Domain/Mapper.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php

declare(strict_types=1);

namespace PBaszak\UltraMapper\Mapper\Domain;

use PBaszak\UltraMapper\Mapper\Domain\Events\MapperCreated;
use PBaszak\UltraMapper\Mapper\Domain\Identity\MapperId;
use PBaszak\UltraMapper\Shared\Domain\ObjectTypes\AggregateRoot;

final class Mapper extends AggregateRoot
{
private function __construct(
private MapperId $id,
) {
}

public static function create(MapperId $id): static
{
$mapper = new static($id);

$mapper->raise(
new MapperCreated($id)
);

return $mapper;
}

public static function recreate(MapperId $id): static
{
return new static($id);
}

public function id(): MapperId
{
return $this->id;
}
}
Loading

0 comments on commit 358718b

Please sign in to comment.