Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,9 @@ Thumbs.db
# Composer
# =========================
/vendor/
composer.lock
composer.lock

# =========================
# Build / Tooling artifacts
# =========================
/.build/
95 changes: 64 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,19 @@
</h1>

<p>
<a href="https://github.com/The-FireHub-Project/Core-Standard/commits/develop/">
<a href="https://github.com/The-FireHub-Project/Core-Standard/commits/architecture/value-object-system/">
<img
src="https://img.shields.io/github/last-commit/The-FireHub-Project/Core-Standard/develop?style=flat&logo=github&logoColor=959da5&label=last%20commit%20(branch)&labelColor=31373e"
src="https://img.shields.io/github/last-commit/The-FireHub-Project/Core-Standard/architecture/value-object-system?style=flat&logo=github&logoColor=959da5&label=last%20commit%20(branch)&labelColor=31373e"
alt="GitHub last commit (branch)"
/></a>
<a href="https://github.com/The-FireHub-Project/Core-Standard/commits/develop/">
<a href="https://github.com/The-FireHub-Project/Core-Standard/commits/architecture/value-object-system/">
<img
src="https://img.shields.io/github/commit-activity/m/The-FireHub-Project/Core-Standard/develop?style=flat&logo=github&logoColor=959da5&label=commit%20activity%20(branch)&labelColor=31373e"
src="https://img.shields.io/github/commit-activity/m/The-FireHub-Project/Core-Standard/architecture/value-object-system?style=flat&logo=github&logoColor=959da5&label=commit%20activity%20(branch)&labelColor=31373e"
alt="GitHub activity (branch)"
/></a>
<a href="https://github.com/The-FireHub-Project/Core-Standard/compare/master...develop/">
<a href="https://github.com/The-FireHub-Project/Core-Standard/compare/develop...architecture/value-object-system/">
<img
src="https://img.shields.io/github/commits-difference/The-FireHub-Project/Core-Standard?base=master&head=develop&style=flat&logo=github&logoColor=959da5&label=ahead%20master&labelColor=31373e"
src="https://img.shields.io/github/commits-difference/The-FireHub-Project/Core-Standard?base=develop&head=architecture/value-object-system&style=flat&logo=github&logoColor=959da5&label=ahead%20develop&labelColor=31373e"
alt="GitHub commit difference between two branches"
/></a>
</p>
Expand All @@ -45,47 +45,80 @@ Standard provides the base classes, kernel, domain layer, and minimal runtime ut

---

## <img src="https://raw.githubusercontent.com/The-FireHub-Project/the-firehub-project.github.io/master/resources/graphics/icons/firehub.svg" width="15" alt="FireHub Icon"> Development Branch
## <img src="https://raw.githubusercontent.com/The-FireHub-Project/the-firehub-project.github.io/master/resources/graphics/icons/firehub.svg" width="15" alt="FireHub Icon"> Core Value Object System – Development Branch

⚠️ **This is the `develop` branch**
⚠️ **This is the `development` branch**

- Unstable
- APIs may change without notice
- Not intended for production use

### Related

- Milestone: **Development v1**
- Target Release: **v0.0.0**
- Repository: FireHub Core Standard

### Pull request

<p>
<a href="https://github.com/The-FireHub-Project/Core-Standard/pull/2/">
<img
src="https://img.shields.io/github/pulls/detail/title/The-FireHub-Project/Core-Standard/2?style=flat&logo=github&logoColor=959da5&label=title&labelColor=31373e"
alt="GitHub pull request title"
/></a>
<a href="https://github.com/The-FireHub-Project/Core-Standard/pull/2/">
<img
src="https://img.shields.io/github/pulls/detail/author/The-FireHub-Project/Core-Standard/2?style=flat&logo=github&logoColor=959da5&labelColor=31373e"
alt="GitHub pull request author"
/></a>
<a href="https://github.com/The-FireHub-Project/Core-Standard/pull/2/">
<img
src="https://img.shields.io/github/pulls/detail/age/The-FireHub-Project/Core-Standard/2?style=flat&logo=github&logoColor=959da5&labelColor=31373e"
alt="GitHub pull request created"
/></a>
<a href="https://github.com/The-FireHub-Project/Core-Standard/pull/2/">
<img
src="https://img.shields.io/github/pulls/detail/comments/The-FireHub-Project/Core-Standard/2?style=flat&logo=github&logoColor=959da5&labelColor=31373e"
alt="GitHub pull request comments"
/></a>
</p>

### Milestone

<p>
<a href="https://github.com/The-FireHub-Project/Core-Standard/milestone/1/">
<img
src="https://img.shields.io/github/milestones/progress-percent/The-FireHub-Project/Core-Standard/1?style=flat&logo=github&logoColor=959da5&labelColor=31373e"
alt="GitHub milestone details"
/></a>
</p>

## <img src="https://raw.githubusercontent.com/The-FireHub-Project/the-firehub-project.github.io/master/resources/graphics/icons/firehub.svg" width="15" alt="FireHub Icon"> Branch Purpose

The `develop` branch is the **primary integration branch** for all ongoing development.
This branch defines the **Core Value Object System** for the FireHub ecosystem.

It serves as the staging area where:
- Feature branches are merged
- Bug fixes are integrated
- Experimental work is stabilized
- Code is prepared for upcoming releases
It establishes the foundational rules for how immutable, strongly typed data structures are represented across:

All **release branches** are created **from `develop`**.
- Core Standard
- Core Professional
- Core Enterprise
- Runtime Foundation (consumers only)

## Stability Guarantee
## <img src="https://raw.githubusercontent.com/The-FireHub-Project/the-firehub-project.github.io/master/resources/graphics/icons/firehub.svg" width="15" alt="FireHub Icon"> Architectural Goal

❌ No backward compatibility guarantee
❌ APIs may change without notice
❌ Behavior may be incomplete or inconsistent
❌ Breaking changes are expected
Introduce a **unified Value Object model** that:

This branch is intended **only for contributors and advanced testers**.
- Eliminates primitive obsession
- Enforces immutability by design
- Provides consistent equality semantics
- Acts as a base language construct for the FireHub Core

## <img src="https://raw.githubusercontent.com/The-FireHub-Project/the-firehub-project.github.io/master/resources/graphics/icons/firehub.svg" width="15" alt="FireHub Icon"> Composer Usage (Not Recommended)
## <img src="https://raw.githubusercontent.com/The-FireHub-Project/the-firehub-project.github.io/master/resources/graphics/icons/firehub.svg" width="15" alt="FireHub Icon"> Core Concept

For internal testing only:
A Value Object in FireHub is:

```json
{
"require": {
"the-firehub-project/core-standard": "dev-develop"
}
}
```
⚠️ Never use dev-develop in production.
> An immutable, identity-less object defined entirely by its value.

## <img src="https://raw.githubusercontent.com/The-FireHub-Project/the-firehub-project.github.io/master/resources/graphics/icons/firehub.svg" width="15" alt="FireHub Icon"> Authors and Contributors

Expand Down
101 changes: 101 additions & 0 deletions src/type/firehub.ValueObject.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
<?php declare(strict_types = 1);

/**
* This file is part of the FireHub Project ecosystem
*
* @author Danijel Galić <danijel.galic@outlook.com>
* @copyright 2026-present The FireHub Project - All rights reserved
* @license https://opensource.org/license/Apache-2-0 Apache License, Version 2.0
*
* @php-version >=8.2
* @package Core
*/

namespace FireHub\Core\Type;

/**
* ### Base Value Object
*
* Defines the base abstraction for all Value Objects within the FireHub Core ecosystem.
*
* The ValueObject serves as a fundamental immutable contract for representing identity-less data structures based
* purely on their value semantics. It enforces consistency across the system by ensuring that all derived Value Objects
* follow strict immutability rules and structural equality behavior.
* @since 1.0.0
*
* @template TValue
*/
abstract readonly class ValueObject {

/**
* ### Returns the raw value of the Value Object
*
* Provides the underlying scalar or composite value represented by this Value Object.
*
* This value is used for structural comparison and domain-level equality checks.
* @since 1.0.0
*
* @return TValue Raw VO value.
*/
abstract public function value ():mixed;

/**
* ### Determines structural equality between two Value Objects
*
* Compares this Value Object with another instance of the same type using strict
* class comparison and value equality semantics.
* @since 1.0.0
*
* @uses \FireHub\Core\Type\ValueObject::sameAs() To compare the VO types.
* @uses \FireHub\Core\Type\ValueObject::value() To compare the VO values.
*
* @param self<TValue> $other <p>
* The Value Object to compare against.
* </p>
*
* @return bool True if the VOs are equal, false otherwise.
*/
final public function equals (self $other):bool {

return $this->sameAs($other)
&& $this->value() === $other->value();

}

/**
* ### Checks strict identity equality of a Value Object type
*
* Ensures both objects are of the same concrete class without comparing values.
* @since 1.0.0
*
* @param \FireHub\Core\Type\ValueObject<TValue> $other <p>
* The Value Object to compare against.
* </p>
*
* @return bool True if the objects are of the same type, false otherwise.
*/
final public function sameAs (self $other):bool {

return static::class === $other::class;

}
Comment thread
danijelgalic marked this conversation as resolved.

/**
* ### Enforces an invariant condition for the Value Object
* @since 1.0.0
*
* @param callable():bool $condition <p>
* The validation condition to evaluate.
* </p>
* @param callable():\Exception $exception <p>
Comment thread
danijelgalic marked this conversation as resolved.
* Exception to be thrown when the condition fails.
* </p>
* @return void
*/
final protected function guard (callable $condition, callable $exception):void {

if ($condition() === false) throw $exception();

}

}