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


PHP Assert::integer方法代码示例

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


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

示例1: generateNewInstance

    /**
     * {@inheritdoc}
     */
    public function generateNewInstance($varName, Method $targetMethod, GeneratorRegistry $generatorRegistry, array $options = array())
    {
        $options = array_replace(self::$defaultOptions, $options);
        Assert::string($options['host'], 'The host must be a string. Got: %s');
        Assert::integer($options['port'], 'The port must be an integer. Got: %s');
        $escHost = var_export($options['host'], true);
        $escPort = var_export($options['port'], true);
        $targetMethod->getClass()->addImports(array(new Import('Redis'), new Import('Webmozart\\KeyValueStore\\PhpRedisStore')));
        $targetMethod->addBody(<<<EOF
\$client = new Redis();
\$client->connect({$escHost}, {$escPort});
\${$varName} = new PhpRedisStore(\$client);
EOF
);
    }
开发者ID:SenseException,项目名称:manager,代码行数:18,代码来源:PhpRedisStoreGenerator.php

示例2: generateNewInstance

    /**
     * {@inheritdoc}
     */
    public function generateNewInstance($varName, Method $targetMethod, GeneratorRegistry $generatorRegistry, array $options = array())
    {
        $options = array_replace(self::$defaultOptions, $options);
        Assert::stringNotEmpty($options['host'], 'The "host" option must be a non-empty string. Got: %s');
        Assert::integer($options['port'], 'The "port" option must be an integer. Got: %s');
        $escHost = var_export($options['host'], true);
        $escPort = var_export($options['port'], true);
        $targetMethod->getClass()->addImports(array(new Import('Predis\\Client'), new Import('Webmozart\\KeyValueStore\\PredisStore')));
        $targetMethod->addBody(<<<EOF
\$client = new Client(array(
    'host' => {$escHost},
    'port' => {$escPort},
));
\${$varName} = new PredisStore(\$client);
EOF
);
    }
开发者ID:xabbuh,项目名称:manager,代码行数:20,代码来源:PredisStoreGenerator.php

示例3: generateNewInstance

    /**
     * {@inheritdoc}
     */
    public function generateNewInstance($varName, Method $targetMethod, GeneratorRegistry $generatorRegistry, array $options = array())
    {
        Assert::keyExists($options, 'bucket', 'The "bucket" option is missing.');
        $options = array_replace(self::$defaultOptions, $options);
        Assert::string($options['bucket'], 'The bucket must be a string. Got: %s');
        Assert::string($options['host'], 'The host must be a string. Got: %s');
        Assert::integer($options['port'], 'The port must be an integer. Got: %s');
        $escBucket = var_export($options['bucket'], true);
        $escHost = var_export($options['host'], true);
        $escPort = var_export($options['port'], true);
        $targetMethod->getClass()->addImports(array(new Import('Basho\\Riak\\Riak'), new Import('Webmozart\\KeyValueStore\\RiakStore')));
        $targetMethod->addBody(<<<EOF
\$client = new Riak({$escHost}, {$escPort});
\${$varName} = new RiakStore({$escBucket}, \$client);
EOF
);
    }
开发者ID:niklongstone,项目名称:manager,代码行数:20,代码来源:RiakStoreGenerator.php

示例4: addRootBindingType

 /**
  * {@inheritdoc}
  */
 public function addRootBindingType(BindingTypeDescriptor $typeDescriptor, $flags = 0)
 {
     Assert::integer($flags, 'The argument $flags must be a boolean.');
     $this->assertPackagesLoaded();
     $this->emitWarningForDuplicateTypes();
     if (!($flags & self::OVERRIDE) && $this->typeDescriptors->contains($typeDescriptor->getName())) {
         throw DuplicateTypeException::forTypeName($typeDescriptor->getName());
     }
     $tx = new Transaction();
     try {
         $typeName = $typeDescriptor->getName();
         $syncBindingOps = array();
         foreach ($this->getUuidsByTypeName($typeName) as $uuid) {
             $syncBindingOp = $this->syncBindingUuid($uuid);
             $syncBindingOp->takeSnapshot();
             $syncBindingOps[] = $syncBindingOp;
         }
         $syncOp = $this->syncTypeName($typeName);
         $syncOp->takeSnapshot();
         $tx->execute($this->loadTypeDescriptor($typeDescriptor, $this->rootPackage));
         $tx->execute($this->addTypeDescriptorToPackageFile($typeDescriptor));
         $tx->execute($syncOp);
         foreach ($syncBindingOps as $syncBindingOp) {
             $tx->execute($syncBindingOp);
         }
         $this->saveRootPackageFile();
         $tx->commit();
     } catch (Exception $e) {
         $tx->rollback();
         throw $e;
     }
 }
开发者ID:niklongstone,项目名称:manager,代码行数:35,代码来源:DiscoveryManagerImpl.php

示例5: addRootPathMapping

 /**
  * {@inheritdoc}
  */
 public function addRootPathMapping(PathMapping $mapping, $flags = 0)
 {
     Assert::integer($flags, 'The argument $flags must be a boolean.');
     $this->assertMappingsLoaded();
     if (!($flags & self::OVERRIDE) && $this->rootPackageFile->hasPathMapping($mapping->getRepositoryPath())) {
         throw DuplicatePathMappingException::forRepositoryPath($mapping->getRepositoryPath(), $this->rootPackage->getName());
     }
     $tx = new Transaction();
     try {
         $syncOp = $this->syncRepositoryPath($mapping->getRepositoryPath());
         $syncOp->takeSnapshot();
         $tx->execute($this->loadPathMapping($mapping, $this->rootPackage));
         if (!($flags & self::IGNORE_FILE_NOT_FOUND)) {
             $this->assertNoLoadErrors($mapping);
         }
         $tx->execute($this->updateConflicts($mapping->listRepositoryPaths()));
         $tx->execute($this->overrideConflictingPackages($mapping));
         $tx->execute($this->updateConflicts());
         $tx->execute($this->addPathMappingToPackageFile($mapping));
         $tx->execute($syncOp);
         $this->saveRootPackageFile();
         $tx->commit();
     } catch (Exception $e) {
         $tx->rollback();
         throw $e;
     }
 }
开发者ID:niklongstone,项目名称:manager,代码行数:30,代码来源:RepositoryManagerImpl.php


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