2017 © Pedro Peláez
 

library compose

PHP function composer.

image

hvolschenk/compose

PHP function composer.

  • Wednesday, December 7, 2016
  • by hvolschenk
  • Repository
  • 1 Watchers
  • 0 Stars
  • 38 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

Compose

PHP function composition, (*1)

The composition can either be run directly from the static method or used as a trait in a class., (*2)

Directly


As a trait

With static methods

setValue($value);
    }

    public function getValue(): string {
      return $this->value;
    }

    private function setValue(string $value) {
      $this->value = self::composeValue($value);
    }

    private static function composeValue(string $value): string {
      return self::compose($value, ['addA', 'addB', 'addC']);
    }

    private static function addA(string $string) {
      return "{$string}a";
    }

    private static function addB(string $string) {
      return "{$string}b";
    }

    private static function addC(string $string) {
      return "{$string}c";
    }
  }

  $stringAdder = new StringAdder('Value');
  echo $stringAdder->getValue(); // ValueABC
?>

With non-static methods

setValue($value);
    }

    public function getValue(): string {
      return $this->value;
    }

    private function setValue(string $value) {
      $this->value = self::composeValue($value);
    }

    private function composeValue(string $value): string {
      return $this->composeNonStatic($value, ['addA', 'addB', 'addC']);
    }

    private function addA(string $string) {
      return "{$string}a{$this->separator}";
    }

    private function addB(string $string) {
      return "{$string}b{$this->separator}";
    }

    private function addC(string $string) {
      return "{$string}c{$this->separator}";
    }
  }

  $stringAdder = new StringAdder('Value');
  echo $stringAdder->getValue(); // ValueA.B.C.
?>

With static and non-static methods

setValue($value);
    }

    public function getValue(): string {
      return $this->value;
    }

    private function setValue(string $value) {
      $this->value = self::composeValue($value);
    }

    private function composeValue(string $value): string {
      return $this->composeMixed($value, [['self', 'addA'], ['self', 'addB'],
        [$this, 'addC']]);
    }

    private static function addA(string $string) {
      return "{$string}a";
    }

    private static function addB(string $string) {
      return "{$string}b";
    }

    private function addC(string $string) {
      return "{$string}c{$this->separator}";
    }
  }

  $stringAdder = new StringAdder('Value');
  echo $stringAdder->getValue(); // ValueABC.
?>

The Versions

07/12 2016

dev-master

9999999-dev https://github.com/hvolschenk/compose

PHP function composer.

  Sources   Download

MIT

The Requires

  • php ^7.0

 

php composer cli functions compose

07/12 2016

v1.2.0

1.2.0.0 https://github.com/hvolschenk/compose

PHP function composer.

  Sources   Download

MIT

The Requires

  • php ^7.0

 

php composer cli functions compose

05/12 2016

v1.1.0

1.1.0.0 https://github.com/hvolschenk/compose

PHP function composer.

  Sources   Download

MIT

The Requires

  • php ^7.0

 

php composer cli functions compose

17/11 2016

v1.0.0

1.0.0.0 https://github.com/hvolschenk/compose

PHP function composer.

  Sources   Download

MIT

The Requires

  • php ^7.0

 

php composer cli functions compose