本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}
示例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;
}
示例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;
}
示例8: __construct
public function __construct(array $messages = [])
{
Assertion::classExists(MessageFormatter::class);
$this->messages = array_replace(self::BUILD_IN_MESSAGES, $messages);
}
示例9: testValidClass
public function testValidClass()
{
Assertion::classExists("\\Exception");
}
示例10: __construct
/**
* @param int|float|string $limit
*/
public function __construct($limit)
{
Assertion::classExists(Decimal::class);
Assertion::numeric($limit);
$this->limit = Decimal::fromString((string) $limit);
}
示例11: __invoke
public function __invoke(ContainerInterface $container, $requestedService)
{
Assertion::classExists($requestedService);
return new $requestedService($container->get(BookingService::class));
}
示例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];
}
示例13: __construct
public function __construct($command_class)
{
Assertion::classExists($command_class);
$this->command_class = $command_class;
$this->command_state = [];
}
示例14: validatePlugin
/**
* {@inheritdoc}
*/
public function validatePlugin($dataMapper)
{
Assertion::isInstanceOf($dataMapper, DataMapperInterface::class, 'Invalid data mapper');
Assertion::classExists($dataMapper->getEntityClass(), 'Invalid entity class');
}