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


PHP Assert::nullOrString方法代碼示例

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


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

示例1: __construct

 /**
  * Creates a new configuration file.
  *
  * @param string|null $path       The path where the configuration file is stored
  *                                or `null` if this configuration is not stored
  *                                on the file system.
  * @param Config      $baseConfig The configuration that the configuration will
  *                                inherit its values from.
  *
  * @throws InvalidArgumentException If the path is not a string or empty.
  */
 public function __construct($path = null, Config $baseConfig = null)
 {
     Assert::nullOrString($path, 'The path to the configuration file should be a string or null. Got: %s');
     Assert::nullOrNotEmpty($path, 'The path to the configuration file should not be empty.');
     // Inherit from default configuration
     $this->config = new Config($baseConfig);
     $this->path = $path;
 }
開發者ID:kormik,項目名稱:manager,代碼行數:19,代碼來源:ConfigFile.php

示例2: fromJson

 /**
  * {@inheritdoc}
  */
 public function fromJson($jsonData, array $options = array())
 {
     $path = isset($options['path']) ? $options['path'] : null;
     $baseConfig = isset($options['baseConfig']) ? $options['baseConfig'] : null;
     Assert::isInstanceOf($jsonData, 'stdClass');
     Assert::nullOrString($path, 'The "path" option should be null or a string. Got: %s');
     Assert::nullOrIsInstanceOf($baseConfig, 'Puli\\Manager\\Api\\Config\\Config', 'The "baseConfig" option should be null or an instance of %2$s. Got: %s');
     $moduleFile = new RootModuleFile(null, $path, $baseConfig);
     $this->addJsonToModuleFile($jsonData, $moduleFile);
     $this->addJsonToRootModuleFile($jsonData, $moduleFile);
     return $moduleFile;
 }
開發者ID:sensorario,項目名稱:manager,代碼行數:15,代碼來源:RootModuleFileConverter.php

示例3: __construct

 /**
  * Creates a binding type descriptor.
  *
  * @param string                       $name        The name of the type.
  * @param string|null                  $description A human-readable
  *                                                  description of the type.
  * @param BindingParameterDescriptor[] $parameters  The parameters.
  *
  * @see BindingType
  */
 public function __construct($name, $description = null, array $parameters = array())
 {
     Assert::typeName($name);
     Assert::nullOrString($description, 'The description must be a string or null. Got: %s');
     Assert::nullOrNotEmpty($description, 'The description must not be empty.');
     Assert::allIsInstanceOf($parameters, __NAMESPACE__ . '\\BindingParameterDescriptor');
     $this->name = $name;
     $this->description = $description;
     foreach ($parameters as $parameter) {
         $this->parameters[$parameter->getName()] = $parameter;
     }
 }
開發者ID:niklongstone,項目名稱:manager,代碼行數:22,代碼來源:BindingTypeDescriptor.php

示例4: __construct

 /**
  * Creates the parameter.
  *
  * @param string      $name         The parameter name.
  * @param int         $flags        A bitwise combination of the flag
  *                                  constants in this class.
  * @param null        $defaultValue The default value of the parameter. Must
  *                                  only be set for optional parameters.
  * @param string|null $description  A human-readable description.
  */
 public function __construct($name, $flags = self::OPTIONAL, $defaultValue = null, $description = null)
 {
     Assert::parameterName($name);
     Assert::nullOrInteger($flags, 'The parameter "$flags" must be an integer or null. Got: %s');
     Assert::nullOrParameterValue($defaultValue);
     Assert::nullOrString($description, 'The parameter description must be a string or null. Got: %s');
     Assert::nullOrNotEmpty($description, 'The parameter description must not be empty.');
     if ($flags & self::REQUIRED && null !== $defaultValue) {
         throw new RuntimeException('Required parameters cannot have default values.');
     }
     $this->name = $name;
     $this->flags = (int) $flags;
     $this->defaultValue = $defaultValue;
     $this->description = $description;
 }
開發者ID:puli,項目名稱:asset-plugin,代碼行數:25,代碼來源:InstallerParameter.php

示例5: fromJson

 /**
  * {@inheritdoc}
  */
 public function fromJson($jsonData, array $options = array())
 {
     $path = isset($options['path']) ? $options['path'] : null;
     $baseConfig = isset($options['baseConfig']) ? $options['baseConfig'] : null;
     Assert::isInstanceOf($jsonData, 'stdClass');
     Assert::nullOrString($path, 'The "path" option should be null or a string. Got: %s');
     Assert::nullOrIsInstanceOf($baseConfig, 'Puli\\Manager\\Api\\Config\\Config', 'The "baseConfig" option should be null or an instance of %2$s. Got: %s');
     $configFile = new ConfigFile($path, $baseConfig);
     $config = $configFile->getConfig();
     $jsonData = $this->objectsToArrays($jsonData);
     foreach ($jsonData as $key => $value) {
         $config->set($key, $value);
     }
     return $configFile;
 }
開發者ID:sensorario,項目名稱:manager,代碼行數:18,代碼來源:ConfigFileConverter.php

示例6: hasBindingType

 /**
  * {@inheritdoc}
  */
 public function hasBindingType($typeName, $packageName = null)
 {
     Assert::nullOrString($packageName, 'The package name must be a string or null. Got: %s');
     $this->assertPackagesLoaded();
     return $this->typeDescriptors->contains($typeName, $packageName);
 }
開發者ID:niklongstone,項目名稱:manager,代碼行數:9,代碼來源:DiscoveryManagerImpl.php

示例7: hasTypeDescriptor

 /**
  * {@inheritdoc}
  */
 public function hasTypeDescriptor($typeName, $moduleName = null)
 {
     Assert::nullOrString($moduleName, 'The module name must be a string or null. Got: %s');
     $this->assertModulesLoaded();
     return $this->typeDescriptors->contains($typeName, $moduleName);
 }
開發者ID:puli,項目名稱:manager,代碼行數:9,代碼來源:DiscoveryManagerImpl.php


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