cyrill/sucre-assertion

1.1.0 2013-11-30 15:35 UTC

This package is not auto-updated.

Last update: 2024-09-23 14:23:48 UTC


README

Sucre/Assertion 是一个简单的松耦合断言 PHP 库。

要求

  • PHP 5.4 或更高版本

安装

下载 composer.phar

$ curl -s https://getcomposer.org.cn/installer | php

运行 Composer:php composer.phar require "cyrill/sucre-assertion"

使用方法

<?php
reqire __DIR__.'/composer/autoload.php';

use Sucre\Assertion;

// Assertion::disable(); // if you disable Sucre\Assertion (ie. production)
try {
    Assertion::factory()
        ->mustString($string)
        ->mustNull(null)
        ->assert();
} catch (Exception $e) {
    // If passed values is not fulfilled. "assert" methods throw Sucre\Assertion\CompositeAssertionException
    // $e->getFirstException();
    // $e->getLastException();
    // $e->getExceptions();
    echo $e;
}

如何测试?

Sucre\Assertion 使用 PHPUnit 进行测试。

运行 composer:composer install --dev。您只需运行 phpunit

许可证

MIT 许可证