koine/delegator

将方法委托给对象

dev-master 2015-06-29 09:54 UTC

This package is not auto-updated.

Last update: 2020-01-10 15:13:59 UTC


README

PHP 简单方法委托。

代码信息

Build Status Coverage Status Code Climate Scrutinizer Code Quality

包信息

Latest Stable Version Total Downloads Latest Unstable Version License Dependency Status

使用方法

<?php

class City
{
    protected $state;
    protected $name;

    public function __construct($name, $state)
    {
        $this->name = $name;
        $this->state = $state;
    }

    public function getStateName()
    {
        $delegator = new \Koine\MethodDelegator;

        $delegator->method('getName')->to($this->state);

        return $delegator->delegate();
    }
}

class State
{
    protected $name;

    public function __construct($name)
    {
        $this->name = $name;
    }

    public function getName()
    {
        return $this->name;
    }
}

$state = new State('Some State');
$city  = new City('Some City', $state);

$city->getStateName(); // Some State

安装

通过 Composer

将库添加到您的 composer.json 文件中的 requirements 键。

{
    // composer.json
    // [..]
    require: {
        // append this line to your requirements
        "koine/delegator": "dev-master"
    }
}

替代安装

  • 了解 composer。您不应该寻找替代安装。这是值得的。相信我 ;-)
  • 按照 这些说明 进行操作

问题/特性建议

这里 是问题跟踪器。

贡献

只有通过 TDD 的代码会被接受。请遵循 PSR-2 代码标准

  1. 分支它
  2. 创建您的特性分支(git checkout -b my-new-feature
  3. 提交您的更改(git commit -am 'Add some feature'
  4. 推送到分支(git push origin my-new-feature
  5. 创建新的 Pull Request

如何运行测试

phpunit --configuration tests/phpunit.xml

要检查代码标准,运行

phpcs --standard=PSR2 lib
phpcs --standard=PSR2 tests

许可

MIT

作者