ali-eltaweel/computed-properties

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

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

1.0.1 2025-06-20 17:10 UTC

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);
    }
}