ali-eltaweel / computed-properties
A PHP library for computed properties.
Installs: 78
Dependents: 3
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/ali-eltaweel/computed-properties
Requires
- php: ^8.1
- ali-eltaweel/attr-action: ^1.0.0
This package is auto-updated.
Last update: 2025-10-20 17:49:01 UTC
README
Installation
Install computed-properties via Composer:
composer require ali-eltaweel/computed-properties
Usage
Declaring Computed Properties
use Lang\{ Annotations\Computes, ComputedProperties }; class User { use ComputedProperties; #[Computes('fullName')] public function getFullName(): string { return $this->firstName . ' ' . $this->lastName; } }
Dynamic Properties
use Lang\{ Annotations\Computes, ComputedProperties }; class Config { use ComputedProperties; private array $config; #[Computes(provider: 'getConfigKeys')] public function getConfigValue(string $key) { return $this->config[$key]; } function getConfigKeys(): array { return array_keys($this->config); } }