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


PHP Contract::metOrThrow方法代码示例

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


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

示例1: testB

 public function testB()
 {
     $testValue1 = 100;
     $testValue2 = 'red';
     $testValue3 = array('name' => 'John Smith', 'age' => 30);
     $contract = new Contract(array('test1' => array('data' => $testValue1, 'definition' => 'integer'), 'test2' => array('data' => $testValue2, 'definition' => array('length' => 3, 'in' => array('red', 'green', 'blue'))), 'test3' => array('data' => $testValue3, 'definition' => array('arraylist', 'element' => array('age' => array('integer', 'lessThan' => 29), 'name' => array('alpha', 'in' => array('John Doe', 'Jane Smith')))))));
     $contract->metOrThrow();
 }
开发者ID:jeisc,项目名称:PHP-Contract,代码行数:8,代码来源:Array_Notation.php

示例2: filterByValidUser

 public function filterByValidUser($usersData)
 {
     /* Before filtering the data, establish the agreement for the method parameters. */
     $contract = new Contract();
     $contract->term('usersData')->arraylist();
     $contract->metOrThrow();
     /* Users data must be an array of elements, each element an array itself, with an id, name, registered date, and active boolean true.
        Allowed fields to be returned are the defined elements: id, name, registered, active. */
     $contract->term('usersData')->elements()->arraylist()->element('id')->id()->end()->element('name')->optional()->alpha()->end()->element('registered')->datetime()->end()->element('active')->boolean()->equals(true)->end();
     $filteredData = $contract->term('usersData')->data();
     return $filteredData;
 }
开发者ID:jeisc,项目名称:PHP-Contract,代码行数:12,代码来源:Filter.php

示例3: createUser

 public function createUser($userId, $userData)
 {
     /* Define Contract Requirements for Model Data */
     $contract = new Contract();
     $contract->term('userId')->id();
     $contract->term('userData')->arraylist()->element('type')->in(array('member', 'administrator'))->end()->element('username')->alphaNumeric()->length(8, 16)->end()->element('name')->required()->end()->element('address')->required()->end()->element('city')->required()->end()->element('state')->length(2)->end()->element('zip')->length(5, 10)->end()->element('country')->required()->end()->element('email')->email()->end()->element('phone')->phone()->end()->element('fax')->optional()->phone()->end()->element('photo')->optional()->file()->end()->element('website')->optional()->url()->end()->element('registered')->datetime()->end()->element('active')->boolean()->end();
     $contract->metOrThrow();
     /* Follow w/ Basic MySQL Query */
     $rows = array();
     /* $select = "SELECT * FROM user WHERE id = {$userId}";
     		while($row = mysql_query($select)) $rows[] = $row; */
     return $rows;
 }
开发者ID:jeisc,项目名称:PHP-Contract,代码行数:13,代码来源:Model.php

示例4: children

 public function children($data)
 {
     $contract = new Contract();
     $contract->term('data/outer/inner')->arraylist()->element('number')->integer()->end()->element('letter')->alpha()->end();
     $contract->metOrThrow();
 }
开发者ID:jeisc,项目名称:PHP-Contract,代码行数:6,代码来源:Find.php


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