當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Assert::isArray方法代碼示例

本文整理匯總了PHP中Puli\Manager\Assert\Assert::isArray方法的典型用法代碼示例。如果您正苦於以下問題:PHP Assert::isArray方法的具體用法?PHP Assert::isArray怎麽用?PHP Assert::isArray使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Puli\Manager\Assert\Assert的用法示例。


在下文中一共展示了Assert::isArray方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: generateNewInstance

 /**
  * {@inheritdoc}
  */
 public function generateNewInstance($varName, Method $targetMethod, GeneratorRegistry $generatorRegistry, array $options = array())
 {
     Assert::keyExists($options, 'root-dir', 'The "root-dir" option is missing.');
     $options = array_replace_recursive(self::$defaultOptions, $options);
     if (!isset($options['path'])) {
         $options['path'] = $targetMethod->getClass()->getDirectory() . '/path-mappings.json';
     }
     Assert::stringNotEmpty($options['path'], 'The "path" option should be a non-empty string. Got: %s');
     Assert::stringNotEmpty($options['root-dir'], 'The "root-dir" option should be a non-empty string. Got: %s');
     Assert::boolean($options['optimize'], 'The "optimize" option should be a boolean. Got: %s');
     Assert::isArray($options['change-stream'], 'The "change-stream" option should be an array. Got: %s');
     $path = Path::makeAbsolute($options['path'], $options['root-dir']);
     $relPath = Path::makeRelative($path, $targetMethod->getClass()->getDirectory());
     $relBaseDir = Path::makeRelative($options['root-dir'], $targetMethod->getClass()->getDirectory());
     $escPath = '__DIR__.' . var_export('/' . $relPath, true);
     $escBaseDir = $relBaseDir ? '__DIR__.' . var_export('/' . $relBaseDir, true) : '__DIR__';
     if ($options['optimize']) {
         $streamGenerator = $generatorRegistry->getServiceGenerator(GeneratorRegistry::CHANGE_STREAM, $options['change-stream']['type']);
         $streamOptions = $options['change-stream'];
         $streamOptions['root-dir'] = $options['root-dir'];
         $streamGenerator->generateNewInstance('stream', $targetMethod, $generatorRegistry, $streamOptions);
         $targetMethod->getClass()->addImport(new Import('Puli\\Repository\\OptimizedJsonRepository'));
         $targetMethod->addBody(sprintf('$%s = new OptimizedJsonRepository(%s, %s, false, $stream);', $varName, $escPath, $escBaseDir));
     } else {
         $targetMethod->getClass()->addImport(new Import('Puli\\Repository\\JsonRepository'));
         $targetMethod->addBody(sprintf('$%s = new JsonRepository(%s, %s, true);', $varName, $escPath, $escBaseDir));
     }
 }
開發者ID:xabbuh,項目名稱:manager,代碼行數:31,代碼來源:JsonRepositoryGenerator.php

示例2: generateNewInstance

 /**
  * {@inheritdoc}
  */
 public function generateNewInstance($varName, Method $targetMethod, GeneratorRegistry $generatorRegistry, array $options = array())
 {
     Assert::keyExists($options, 'root-dir', 'The "root-dir" option is missing.');
     $options = array_replace_recursive(self::$defaultOptions, $options);
     Assert::stringNotEmpty($options['root-dir'], 'The "root-dir" option should be a non-empty string. Got: %s');
     Assert::isArray($options['store'], 'The "store" option should be an array. Got: %s');
     if (!isset($options['store']['path'])) {
         $options['store']['path'] = $targetMethod->getClass()->getDirectory() . '/change-stream.json';
     }
     $kvsGenerator = $generatorRegistry->getServiceGenerator(GeneratorRegistry::KEY_VALUE_STORE, $options['store']['type']);
     $kvsOptions = $options['store'];
     $kvsOptions['root-dir'] = $options['root-dir'];
     $kvsGenerator->generateNewInstance('store', $targetMethod, $generatorRegistry, $kvsOptions);
     $targetMethod->getClass()->addImport(new Import('Puli\\Repository\\ChangeStream\\KeyValueStoreChangeStream'));
     $targetMethod->addBody(sprintf('$%s = new KeyValueStoreChangeStream($store);', $varName));
 }
開發者ID:sensorario,項目名稱:manager,代碼行數:19,代碼來源:KeyValueStoreChangeStreamGenerator.php

示例3: generateNewInstance

 /**
  * {@inheritdoc}
  */
 public function generateNewInstance($varName, Method $targetMethod, GeneratorRegistry $generatorRegistry, array $options = array())
 {
     Assert::keyExists($options, 'root-dir', 'The "root-dir" option is missing.');
     $options = array_replace_recursive(self::$defaultOptions, $options);
     Assert::stringNotEmpty($options['root-dir'], 'The "root-dir" option should be a non-empty string. Got: %s');
     Assert::isArray($options['store'], 'The "store" option should be an array. Got: %s');
     if (!isset($options['store']['path'])) {
         $options['store']['path'] = $targetMethod->getClass()->getDirectory() . '/bindings.json';
     }
     $kvsGenerator = $generatorRegistry->getServiceGenerator(GeneratorRegistry::KEY_VALUE_STORE, $options['store']['type']);
     $kvsOptions = $options['store'];
     $kvsOptions['root-dir'] = $options['root-dir'];
     $kvsGenerator->generateNewInstance('store', $targetMethod, $generatorRegistry, $kvsOptions);
     $targetMethod->getClass()->addImport(new Import('Puli\\Discovery\\KeyValueStoreDiscovery'));
     $targetMethod->getClass()->addImport(new Import('Puli\\Discovery\\Binding\\Initializer\\ResourceBindingInitializer'));
     $targetMethod->addBody(sprintf("\$%s = new KeyValueStoreDiscovery(\$store, array(\n    new ResourceBindingInitializer(\$repo),\n));", $varName));
 }
開發者ID:xabbuh,項目名稱:manager,代碼行數:20,代碼來源:KeyValueStoreDiscoveryGenerator.php


注:本文中的Puli\Manager\Assert\Assert::isArray方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。