當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。