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


PHP Assert\Assertion类代码示例

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


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


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