• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Assert\Assertion类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中Assert\Assertion的典型用法代码示例。如果您正苦于以下问题:PHP Assertion类的具体用法?PHP Assertion怎么用?PHP Assertion使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: setName

 /**
  * @param string $name
  */
 protected function setName($name)
 {
     Assertion::string($name);
     Assertion::notBlank($name);
     $this->attributes['name'] = $name;
     $this->name = $name;
 }
开发者ID:comphppuebla,项目名称:easy-forms,代码行数:10,代码来源:Element.php


示例2: __construct

 public function __construct($templateId, $id)
 {
     Assertion::notEmpty($templateId);
     Assertion::string($id);
     $this->id = $id;
     $this->templateId = $templateId;
 }
开发者ID:mathielen,项目名称:report-write-engine,代码行数:7,代码来源:ReportConfig.php


示例3: generate

 /**
  * @param int $width
  * @param int $height
  * @param array $shipSizes
  * @return Fields
  */
 public static function generate($width, $height, array $shipSizes)
 {
     Assertion::integer($width);
     Assertion::integer($height);
     Assertion::allInteger($shipSizes);
     $elements = [];
     for ($y = 0; $y < $height; $y++) {
         for ($x = 0; $x < $width; $x++) {
             $elements[] = Field::generate($x, $y);
         }
     }
     $fields = Fields::create($elements);
     foreach ($shipSizes as $shipSize) {
         $attempts = 0;
         while (true) {
             if ($attempts == static::MAX_ATTEMPTS) {
                 throw new CannotPlaceShipOnGridException();
             }
             $direction = mt_rand(0, 1) == 0 ? 'right' : 'below';
             $spot = Coords::create(mt_rand(0, $width - 1), mt_rand(0, $height - 1));
             $endPoint = static::validEndpoint($fields, $spot, $shipSize, $direction);
             if ($endPoint === null) {
                 $attempts++;
                 continue;
             }
             // If we end up here the ship can fit at the determined spot
             $fields->place(Ship::create($spot, $endPoint));
             break;
         }
     }
     return $fields;
 }
开发者ID:WeCamp,项目名称:flyingliquourice,代码行数:38,代码来源:FieldsGenerator.php


示例4: __construct

 /**
  * Construct.
  *
  * @param TransitionHandlerFactory $handlerFactory  The transition handler factory.
  * @param StateRepository          $stateRepository The state repository.
  * @param Workflow[]               $workflows       The set of managed workflows.
  */
 public function __construct(TransitionHandlerFactory $handlerFactory, StateRepository $stateRepository, $workflows = array())
 {
     Assertion::allIsInstanceOf($workflows, 'Netzmacht\\Workflow\\Flow\\Workflow');
     $this->workflows = $workflows;
     $this->handlerFactory = $handlerFactory;
     $this->stateRepository = $stateRepository;
 }
开发者ID:netzmacht,项目名称:workflow,代码行数:14,代码来源:WorkflowManager.php


示例5: getKeys

 /**
  * @return \Jose\Object\JWKInterface[]
  */
 public function getKeys()
 {
     $content = json_decode($this->getContent(), true);
     Assertion::isArray($content, 'Invalid content.');
     Assertion::keyExists($content, 'keys', 'Invalid content.');
     return (new JWKSet($content))->getKeys();
 }
开发者ID:spomky-labs,项目名称:jose,代码行数:10,代码来源:JKUJWKSet.php


示例6: createRoute

 /**
  * Create Route.
  *
  * Creates a Route object from an array of comma separated coordinates,
  * e.g. ['52.54628,13.30841', '51.476780,0.000479', ...].
  *
  * @param string[] $arrayOfCommaSeparatedCoordinates
  * @return Route
  */
 public function createRoute($arrayOfCommaSeparatedCoordinates)
 {
     $coordinates = [];
     foreach ($arrayOfCommaSeparatedCoordinates as $item) {
         $valueArray = explode(',', $item);
         if (2 != count($valueArray)) {
             if (!is_null($this->logger)) {
                 $this->logger->error(sprintf('"%s" are not valid coordinates.', $item));
             }
             continue;
         }
         try {
             Assertion::allNumeric($valueArray);
         } catch (AssertionFailedException $e) {
             if (!is_null($this->logger)) {
                 $this->logger->error(sprintf('Given coordinates "%s" are invalid. %s', $item, $e->getMessage()));
                 continue;
             }
         }
         $lat = (double) $valueArray[0];
         $long = (double) $valueArray[1];
         try {
             $coordinate = new Coordinate($lat, $long);
         } catch (\DomainException $e) {
             if (!is_null($this->logger)) {
                 $this->logger->error(sprintf('Given coordinates "%s" are invalid. %s', $item, $e->getMessage()));
             }
             continue;
         }
         $coordinates[] = $coordinate;
     }
     $route = new Route();
     $route->setInputRoute($coordinates);
     return $route;
 }
开发者ID:MetaSyntactical,项目名称:google-directions-client,代码行数:44,代码来源:RouteFactory.php


示例7: __construct

 /**
  * Create a new Setting
  * 
  * @param NotificationId $id
  * @param User $user
  * @param string $key
  * @return void
  */
 public function __construct(SettingId $id, User $user, $key)
 {
     Assertion::string($key);
     $this->setId($id);
     $this->setUser($user);
     $this->setKey($key);
 }
开发者ID:kfuchs,项目名称:cribbb,代码行数:15,代码来源:Setting.php


示例8: findById

 /**
  * @param int $id
  *
  * @throws SubjectNotFoundException
  *
  * @return JusticeRecord|false
  */
 public function findById($id)
 {
     Assertion::integer($id);
     $crawler = $this->client->request('GET', sprintf(self::URL_SUBJECTS, $id));
     $detailUrl = $this->extractDetailUrlFromCrawler($crawler);
     if (false === $detailUrl) {
         return false;
     }
     $people = [];
     $crawler = $this->client->request('GET', $detailUrl);
     $crawler->filter('.aunp-content .div-table')->each(function (Crawler $table) use(&$people) {
         $title = $table->filter('.vr-hlavicka')->text();
         try {
             if ('jednatel: ' === $title) {
                 $person = JusticeJednatelPersonParser::parseFromDomCrawler($table);
                 $people[$person->getName()] = $person;
             } elseif ('Společník: ' === $title) {
                 $person = JusticeSpolecnikPersonParser::parseFromDomCrawler($table);
                 $people[$person->getName()] = $person;
             }
         } catch (\Exception $e) {
         }
     });
     return new JusticeRecord($people);
 }
开发者ID:dfridrich,项目名称:ares,代码行数:32,代码来源:Justice.php


示例9: __construct

 /**
  * @param float $minPrice
  * @param float $maxPrice
  */
 public function __construct($minPrice = 0.0, $maxPrice = 0.0)
 {
     Assertion::numeric($minPrice);
     Assertion::numeric($maxPrice);
     $this->minPrice = (double) $minPrice;
     $this->maxPrice = (double) $maxPrice;
 }
开发者ID:GerDner,项目名称:luck-docker,代码行数:11,代码来源:PriceCondition.php


示例10: __construct

 /**
  * AddUserToGroup constructor.
  *
  * @param string $userName
  * @param string $groupId
  */
 public function __construct($userName = '', $groupId = '')
 {
     Assertion::notEmpty($userName, 'Username is a required field to add a user to a group');
     Assertion::notEmpty($groupId, 'Group id is a required field to add a user to a group');
     $this->userName = $userName;
     $this->groupId = $groupId;
 }
开发者ID:arnovr,项目名称:owncloud-provisioning-api-client,代码行数:13,代码来源:AddUserToGroup.php


示例11: normalize

 /**
  * @param string $messageName
  * @return string
  */
 public static function normalize($messageName)
 {
     Assertion::notEmpty($messageName);
     Assertion::string($messageName);
     $search = array(static::MESSAGE_NAME_PREFIX, "-", "\\", "/", " ");
     return strtolower(str_replace($search, "", $messageName));
 }
开发者ID:prooph,项目名称:processing,代码行数:11,代码来源:MessageNameUtils.php


示例12: checkerParameter

 /**
  * {@inheritdoc}
  */
 public function checkerParameter(ClientInterface $client, array &$parameters)
 {
     if (false === array_key_exists('response_mode', $parameters)) {
         return;
     }
     Assertion::true($this->isResponseModeParameterInAuthorizationRequestAllowed(), 'The parameter "response_mode" is not allowed.');
 }
开发者ID:spomky-labs,项目名称:oauth2-server-library,代码行数:10,代码来源:ResponseModeParameterChecker.php


示例13: populatePayload

 /**
  * @param \Jose\Object\JWSInterface $jws
  * @param array                     $data
  */
 private static function populatePayload(JWSInterface &$jws, array $data)
 {
     $is_encoded = null;
     foreach ($jws->getSignatures() as $signature) {
         if (null === $is_encoded) {
             $is_encoded = self::isPayloadEncoded($signature);
         }
         Assertion::eq($is_encoded, self::isPayloadEncoded($signature), 'Foreign payload encoding detected. The JWS cannot be loaded.');
     }
     if (array_key_exists('payload', $data)) {
         $payload = $data['payload'];
         $jws = $jws->withAttachedPayload();
         $jws = $jws->withEncodedPayload($payload);
         if (false !== $is_encoded) {
             $payload = Base64Url::decode($payload);
         }
         $json = json_decode($payload, true);
         if (null !== $json && !empty($payload)) {
             $payload = $json;
         }
         $jws = $jws->withPayload($payload);
     } else {
         $jws = $jws->withDetachedPayload();
     }
 }
开发者ID:spomky-labs,项目名称:jose,代码行数:29,代码来源:JWSLoader.php


示例14: setValue

 /**
  * @param mixed $value
  */
 protected function setValue($value)
 {
     //We use the string assertion first
     parent::setValue($value);
     //and then check, if we really got an item class
     Assertion::implementsInterface($value, 'Prooph\\Processing\\Type\\Type');
 }
开发者ID:prooph,项目名称:processing,代码行数:10,代码来源:ItemClass.php


示例15: fromString

 public static function fromString($uuid)
 {
     Assertion::uuid($uuid);
     $patientId = new static();
     $patientId->id = $uuid;
     return $patientId;
 }
开发者ID:arnovr,项目名称:workshop_noback,代码行数:7,代码来源:PatientId.php


示例16: unserialize

 /**
  * @param  \stdClass $obj
  * @param  array     $context
  * @return TwitterEvent
  */
 public function unserialize($obj, array $context = [])
 {
     Assertion::true($this->canUnserialize($obj), 'object is not unserializable');
     $createdAt = new \DateTimeImmutable($obj->created_at);
     Assertion::eq(new \DateTimeZone('UTC'), $createdAt->getTimezone());
     return TwitterEvent::create($obj->event, $this->userSerializer->unserialize($obj->source), isset($obj->target) ? $this->userSerializer->unserialize($obj->target) : null, isset($obj->target_object) ? $this->targetSerializer->unserialize($obj->target_object) : null, $createdAt);
 }
开发者ID:remi-san,项目名称:twitter,代码行数:12,代码来源:TwitterEventSerializer.php


示例17: __construct

 /**
  * @param $name
  */
 public function __construct($name)
 {
     Assertion::string($name, 'StreamName must be a string');
     Assertion::notEmpty($name, 'StreamName must not be empty');
     Assertion::maxLength($name, 200, 'StreamName should not be longer than 200 chars');
     $this->name = $name;
 }
开发者ID:prooph,项目名称:event-store,代码行数:10,代码来源:StreamName.php


示例18: __construct

 /**
  * @param string $field
  * @param string $operator
  * @param string|array $value ['min' => 1, 'max' => 10] for between operator
  */
 public function __construct($field, $operator, $value)
 {
     Assertion::string($field);
     $this->field = $field;
     $this->value = $value;
     $this->operator = $operator;
 }
开发者ID:GerDner,项目名称:luck-docker,代码行数:12,代码来源:ProductAttributeCondition.php


示例19: __construct

 /**
  * @param $text
  */
 public function __construct($text)
 {
     Assertion::string($text);
     Assertion::minLength($text, 1);
     Assertion::maxLength($text, 1000);
     $this->text = $text;
 }
开发者ID:vincecore,项目名称:sharemonkey,代码行数:10,代码来源:Text.php


示例20: __construct

 public function __construct($name, $set)
 {
     Assertion::string($name);
     Assertion::boolean($set);
     $this->name = $name;
     $this->set = $set;
 }
开发者ID:luisbrito,项目名称:Phraseanet,代码行数:7,代码来源:FlagStatement.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Asset\AssetCollection类代码示例发布时间:2022-05-23
下一篇:
PHP AspectMock\Test类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap