当前位置: 首页>>代码示例>>PHP>>正文


PHP Expr::greaterThan方法代码示例

本文整理汇总了PHP中Webmozart\Expression\Expr::greaterThan方法的典型用法代码示例。如果您正苦于以下问题:PHP Expr::greaterThan方法的具体用法?PHP Expr::greaterThan怎么用?PHP Expr::greaterThan使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Webmozart\Expression\Expr的用法示例。


在下文中一共展示了Expr::greaterThan方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: or

<?php

use Webmozart\Expression\Expr;
use Webmozart\Expression\Logic\Disjunction;
$rulerz = (require __DIR__ . '/../bootstrap.php');
const REPETITIONS = 10000;
$dataset = [['name' => 'Joe', 'group' => 'guest', 'points' => 50], ['name' => 'Moe', 'group' => 'member', 'points' => 25], ['name' => 'Al', 'group' => 'guest', 'points' => 30], ['name' => 'Jane', 'group' => 'admin', 'points' => 75], ['name' => 'Jude', 'group' => 'vip', 'points' => 70], ['name' => 'Lucy', 'group' => 'vip', 'points' => 72]];
$rule = '(group = "guest" and points < 40) or (group = "vip" and points > 70)';
$bench = new Hoa\Bench\Bench();
$bench->rulerz->start();
foreach (range(0, REPETITIONS) as $i) {
    $rulerz->filter($dataset, $rule);
}
$bench->rulerz->stop();
// Expression
$firstPart = Expr::lessThan(40, 'points')->andEquals('guest', 'group');
$secondPart = Expr::greaterThan(70, 'points')->andEquals('vip', 'group');
$expr = new Disjunction([$firstPart, $secondPart]);
$bench->expression->start();
foreach (range(0, REPETITIONS) as $i) {
    $results = [];
    foreach ($dataset as $row) {
        if ($expr->evaluate($row)) {
            $results[] = $row;
        }
    }
}
$bench->expression->stop();
echo $bench;
开发者ID:K-Phoen,项目名称:rulerz-vs-expression,代码行数:29,代码来源:more_complex_rule.php

示例2: orGreaterThan

 public function orGreaterThan($value)
 {
     return $this->orX(Expr::greaterThan($value));
 }
开发者ID:webmozart,项目名称:expression,代码行数:4,代码来源:OrX.php

示例3: __construct

 public function __construct()
 {
     parent::__construct('getBookings', array(), Expr::count(Expr::greaterThan(0)));
 }
开发者ID:webmozart,项目名称:expression,代码行数:4,代码来源:HasPreviousBookings.php

示例4:

<?php

use Webmozart\Expression\Expr;
$rulerz = (require __DIR__ . '/../bootstrap.php');
const DATASET_SIZE = 100000;
$dataset = [];
foreach (range(0, DATASET_SIZE) as $i) {
    $dataset[] = ['name' => 'not relevant', 'points' => mt_rand(0, DATASET_SIZE)];
}
$rule = 'points > :points';
$bench = new Hoa\Bench\Bench();
$bench->rulerz->start();
$rulerz->filter($dataset, $rule, ['points' => DATASET_SIZE / 2]);
$bench->rulerz->stop();
// Expression
$expr = Expr::greaterThan(DATASET_SIZE / 2, 'points');
$bench->expression->start();
$results = [];
foreach ($dataset as $row) {
    if ($expr->evaluate($row)) {
        $results[] = $row;
    }
}
$bench->expression->stop();
echo $bench;
开发者ID:K-Phoen,项目名称:rulerz-vs-expression,代码行数:25,代码来源:big_dataset.php

示例5: andGreaterThan

 public function andGreaterThan($value)
 {
     return $this->andX(Expr::greaterThan($value));
 }
开发者ID:webmozart,项目名称:expression,代码行数:4,代码来源:AndX.php

示例6: testFilterCollection

 public function testFilterCollection()
 {
     $input = new ArrayObject(range(1, 10));
     $output = new ArrayObject(array_filter(range(1, 10), function ($i) {
         return $i > 4;
     }));
     $this->assertEquals($output, Expr::filter($input, Expr::greaterThan(4)));
 }
开发者ID:webmozart,项目名称:expression,代码行数:8,代码来源:ExprTest.php

示例7: foreach

<?php

use Webmozart\Expression\Expr;
$rulerz = (require __DIR__ . '/../bootstrap.php');
const REPETITIONS = 10000;
$dataset = [['name' => 'Joe', 'group' => 'guest', 'points' => 50], ['name' => 'Moe', 'group' => 'member', 'points' => 25], ['name' => 'Al', 'group' => 'guest', 'points' => 30], ['name' => 'Jane', 'group' => 'admin', 'points' => 75], ['name' => 'Jude', 'group' => 'vip', 'points' => 70], ['name' => 'Lucy', 'group' => 'vip', 'points' => 72]];
$rule = 'group = "guest" and points > 42';
$bench = new Hoa\Bench\Bench();
$bench->rulerz->start();
foreach (range(0, REPETITIONS) as $i) {
    $rulerz->filter($dataset, $rule);
}
$bench->rulerz->stop();
// Expression
$expr = Expr::greaterThan(42, 'points')->andEquals('guest', 'group');
$bench->expression->start();
foreach (range(0, REPETITIONS) as $i) {
    $results = [];
    foreach ($dataset as $row) {
        if ($expr->evaluate($row)) {
            $results[] = $row;
        }
    }
}
$bench->expression->stop();
echo $bench;
开发者ID:K-Phoen,项目名称:rulerz-vs-expression,代码行数:26,代码来源:simple_rule.php


注:本文中的Webmozart\Expression\Expr::greaterThan方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。