ali-eltaweel/computed-properties

There is no license information available for the latest version (1.0.0) of this package.

A PHP library for computed properties.

1.0.0 2025-06-15 17:22 UTC

This package is auto-updated.

Last update: 2025-06-15 17:23:42 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);
    }
}