LoginSignup
8
2

More than 5 years have passed since last update.

ゲッターPHP

Last updated at Posted at 2018-04-09

真・ゲッター 真・セッター

やるしかないと思った。

<?php

/**
 * すかさずPHPerオープンゲットでござるよ。
 * PHPerマジックメソッドで抽象化した後力ずくでimplodeするでござる。
 * いつだってPHPerの若い命は真っ赤に燃えているのでござるな。
 */

namespace 早乙女研究所\ゲッターロボ;

function  () {
    return ::class;
}

class  {
    const チェンジ!!      = '(チェンジ!!)';

    protected $ケッターマシーン     = null;

    public function __construct ($getter) {
        $this->ケッターマシーン = [
            basename(str_replace("\\", '/', static::class)),
            static::チェンジ!!,
            $getter
        ];
    }

    public function オープンゲット () {
        return static::class;
    }

    public static function ゲッター () {
        return new static(__FUNCTION__);
    }

    public function __call ($name, $args) {
        $this->ケッターマシーン[3]      = $name;
        return $this;
    }

    public function __toString () {
        return implode('', $this->ケッターマシーン);
    }
}

echo ()::ゲッター()->ロボ(), \PHP_EOL;
echo ()::ゲッター()->ロボ()->オープンゲット()::ゲッター()->ワン(), \PHP_EOL;
<?php

namespace 早乙女研究所\ゲッターロボ;

class  {
    const チェンジ!!      = '(チェンジ!!)';

    protected $ケッターマシーン     = null;

    public function __construct ($getter) {
        $this->ケッターマシーン = [
            basename(str_replace("\\", '/', static::class)),
            static::チェンジ!!,
            $getter
        ];
    }

    public function オープンゲット () {
        return static::class;
    }

    public function __get ($name) {
        $this->ケッターマシーン[3]  = $name;
        return $this;
    }

    public static function ゲッター () {
        return new static(__FUNCTION__);
    }

    public function __toString () {
        return implode('', $this->ケッターマシーン);
    }
}

echo ::ゲッター()->ロボ, \PHP_EOL;
echo ::ゲッター()->ロボ->オープンゲット()::ゲッター()->ツー, \PHP_EOL;
8
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
8
2