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


PHP Assertion::classExists方法代码示例

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


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

示例1: __construct

 /**
  * @param MappingInterface[] $mappings
  */
 public function __construct(array $mappings, string $className, callable $apply = null, callable $unapply = null)
 {
     foreach ($mappings as $mappingKey => $mapping) {
         Assertion::string($mappingKey);
         Assertion::isInstanceOf($mapping, MappingInterface::class);
         $this->mappings[$mappingKey] = $mapping->withPrefixAndRelativeKey($this->key, $mappingKey);
     }
     Assertion::classExists($className);
     if (null === $apply) {
         $apply = function (...$arguments) {
             return new $this->className(...array_values($arguments));
         };
     }
     if (null === $unapply) {
         $unapply = function ($value) {
             Assertion::isInstanceOf($value, $this->className);
             $values = [];
             $reflectionClass = new ReflectionClass($this->className);
             foreach ($reflectionClass->getProperties() as $property) {
                 /* @var $property ReflectionProperty */
                 $property->setAccessible(true);
                 $values[$property->getName()] = $property->getValue($value);
             }
             return $values;
         };
     }
     $this->className = $className;
     $this->apply = $apply;
     $this->unapply = $unapply;
 }
开发者ID:dasprid,项目名称:formidable,代码行数:33,代码来源:ObjectMapping.php

示例2: getCurrentRoute

 /**
  * Get current route parameters in array 
  * @return array (controller,action,parameters and _route)
  */
 function getCurrentRoute()
 {
     $ret = null;
     $inst = null;
     $url = null;
     if ($this->_request->get('url')) {
         $url = $this->_request->get('url');
     }
     $url = '/' . $url;
     $parameters = \Parameters::get('router');
     $classes = "GL\\Core\\Routing\\Router";
     if (isset($parameters["classes"])) {
         $classes = $parameters["classes"];
     }
     try {
         Assertion::classExists($classes);
         $inst = new $classes();
         $ret = $inst->route($url);
         $args = $inst->getArgs();
         $ret = array();
         $ret["controller"] = $inst->getController();
         $ret["action"] = $inst->getMethod();
         $ret["_route"] = $inst->getRoute();
         $ret = array_merge($ret, $args);
     } catch (AssertionFailedException $e) {
         $ret = null();
     }
     return $ret;
 }
开发者ID:kletellier,项目名称:mvc,代码行数:33,代码来源:RequestHelper.php

示例3: denormalize

 /**
  * {@inheritDoc}
  */
 public function denormalize($data, $class, $format = null, array $context = [])
 {
     Assertion::choicesNotEmpty($data, ['message', 'class', 'timestamp']);
     Assertion::classExists($data['class']);
     $envelope = new Envelope($this->aggregate->denormalize($data['message'], $data['class']));
     $this->forcePropertyValue($envelope, 'class', $data['class']);
     $this->forcePropertyValue($envelope, 'timestamp', $data['timestamp']);
     return $envelope;
 }
开发者ID:sheikhasadmuneer,项目名称:bernard,代码行数:12,代码来源:EnvelopeNormalizer.php

示例4: __construct

 /**
  * @param int|float|string $step
  * @param int|float|string|null $base
  */
 public function __construct($step, $base = null)
 {
     Assertion::classExists(Decimal::class);
     Assertion::numeric($step);
     $decimalStep = Decimal::fromString((string) $step);
     Assertion::true($decimalStep->comp(DecimalConstants::zero()) > 0);
     thatNullOr($base)->numeric();
     $this->step = $decimalStep;
     $this->base = null === $base ? DecimalConstants::zero() : Decimal::fromString((string) $base);
 }
开发者ID:dasprid,项目名称:formidable,代码行数:14,代码来源:StepNumberConstraint.php

示例5: support

 /**
  * Supported processing types can be given as processing prototypes or a list of type classes
  *
  * @param Prototype[]|array $processingTypes
  * @return ProcessingTypes
  */
 public static function support(array $processingTypes)
 {
     $prototypes = [];
     foreach ($processingTypes as $typeClassOrPrototype) {
         if ($typeClassOrPrototype instanceof Prototype) {
             $prototypes[] = $typeClassOrPrototype;
         } else {
             Assertion::string($typeClassOrPrototype);
             Assertion::classExists($typeClassOrPrototype);
             Assertion::implementsInterface($typeClassOrPrototype, Type::class);
             $prototypes[] = $typeClassOrPrototype::prototype();
         }
     }
     return new self($prototypes, false);
 }
开发者ID:prooph,项目名称:link-process-manager,代码行数:21,代码来源:ProcessingTypes.php

示例6: getRouterInstance

 private function getRouterInstance()
 {
     $parameters = \Parameters::get('router');
     $classes = "GL\\Core\\Routing\\Router";
     $inst = null;
     if (isset($parameters["classes"])) {
         $classes = $parameters["classes"];
     }
     try {
         Assertion::classExists($classes);
         $inst = new $classes();
     } catch (AssertionFailedException $e) {
         echo "Routing classes " . $classes . " does not exist";
         die;
     }
     return $inst;
 }
开发者ID:kletellier,项目名称:mvc,代码行数:17,代码来源:Application.php

示例7: __construct

 private function __construct($target, array $allowedTypes, $preferredType = null, array $metadata)
 {
     Assertion::notEmpty($target);
     Assertion::string($target);
     Assertion::notEmpty($allowedTypes);
     $this->assertMetadata($metadata);
     foreach ($allowedTypes as $allowedType) {
         Assertion::classExists($allowedType);
         Assertion::implementsInterface($allowedType, 'Prooph\\Processing\\Type\\Type');
     }
     if (!is_null($preferredType)) {
         Assertion::inArray($preferredType, $allowedTypes);
     }
     $this->target = $target;
     $this->allowedTypes = $allowedTypes;
     $this->preferredType = $preferredType;
     $this->metadata = $metadata;
 }
开发者ID:prooph,项目名称:processing,代码行数:18,代码来源:ProcessData.php

示例8: __construct

 public function __construct(array $messages = [])
 {
     Assertion::classExists(MessageFormatter::class);
     $this->messages = array_replace(self::BUILD_IN_MESSAGES, $messages);
 }
开发者ID:dasprid,项目名称:formidable,代码行数:5,代码来源:ErrorFormatter.php

示例9: testValidClass

 public function testValidClass()
 {
     Assertion::classExists("\\Exception");
 }
开发者ID:GerDner,项目名称:luck-docker,代码行数:4,代码来源:AssertTest.php

示例10: __construct

 /**
  * @param int|float|string $limit
  */
 public function __construct($limit)
 {
     Assertion::classExists(Decimal::class);
     Assertion::numeric($limit);
     $this->limit = Decimal::fromString((string) $limit);
 }
开发者ID:dasprid,项目名称:formidable,代码行数:9,代码来源:MaxNumberConstraint.php

示例11: __invoke

 public function __invoke(ContainerInterface $container, $requestedService)
 {
     Assertion::classExists($requestedService);
     return new $requestedService($container->get(BookingService::class));
 }
开发者ID:josecelano,项目名称:php-ddd-cargo-sample,代码行数:5,代码来源:BookingActionFactory.php

示例12: addResult

 /**
  * @param string $resultClass
  * @param string $resultRendererClass
  */
 public function addResult($resultClass, $resultRendererClass)
 {
     Assertion::classExists($resultClass);
     Assertion::classExists($resultRendererClass);
     $this->results[] = ['resultClass' => $resultClass, 'resultRendererClass' => $resultRendererClass];
 }
开发者ID:php-school,项目名称:php-workshop,代码行数:10,代码来源:Application.php

示例13: __construct

 public function __construct($command_class)
 {
     Assertion::classExists($command_class);
     $this->command_class = $command_class;
     $this->command_state = [];
 }
开发者ID:honeybee,项目名称:honeybee,代码行数:6,代码来源:CommandBuilder.php

示例14: validatePlugin

 /**
  * {@inheritdoc}
  */
 public function validatePlugin($dataMapper)
 {
     Assertion::isInstanceOf($dataMapper, DataMapperInterface::class, 'Invalid data mapper');
     Assertion::classExists($dataMapper->getEntityClass(), 'Invalid entity class');
 }
开发者ID:stefanotorresi,项目名称:thorr-persistence,代码行数:8,代码来源:DataMapperManager.php


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