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


PHP Option::getName方法代码示例

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


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

示例1: offsetSet

 /**
  * Set a new option.
  *
  * @param   string  $name    No use here, we use option name.
  * @param   Option  $option  The option object to set in this set.
  *
  * @return  void
  *
  * @since   1.0
  */
 public function offsetSet($name, $option)
 {
     $name = $option->getName();
     $aliases = $option->getAlias();
     $this->setAlias($aliases, $name);
     parent::offsetSet($name, $option);
 }
开发者ID:beingsane,项目名称:quickcontent,代码行数:17,代码来源:OptionSet.php

示例2: addOption

 /**
  * @param string|Option $name
  * @param float|null $price
  * @param StockItem|null $item
  */
 public function addOption($name, $price = null, StockItem $item = null)
 {
     if (!$name instanceof Option) {
         $name = (string) $name;
         if (empty($name)) {
             throw new \InvalidArgumentException('option name cannot be empty');
         }
         $name = new Option($name, $price, $item);
         unset($price, $item);
     }
     if (null !== $this->_findOption($name->getName()) || in_array($name->getStockItem(), $this->_getStockItems(), true)) {
         throw new \InvalidArgumentException('cannot add option with the same name twice');
     }
     $this->options[] = $name;
 }
开发者ID:jacques-sounvi,项目名称:addressbook,代码行数:20,代码来源:ConfigurableProduct.php

示例3: registerOption

 protected function registerOption(Option $opt)
 {
     $registered = FALSE;
     foreach (array('short', 'long') as $prefix) {
         if (($name = $opt->{'get' . lcfirst($prefix) . 'Name'}()) === NULL) {
             continue;
         }
         $registered = TRUE;
         if (isset($this->{$prefix . 'Opts'}[$name])) {
             throw new OptionAlreadyRegisteredException($name, $prefix === 'long');
         }
         $this->{$prefix . 'Opts'}[$name] = $opt;
     }
     if ($registered === FALSE) {
         throw new InvalidArgumentException("Either short or long option name must be set for option '{$opt->getName()}'.");
     }
 }
开发者ID:mbohuslavek,项目名称:php-options,代码行数:17,代码来源:Options.php

示例4: offsetSet

 /**
  * Set a new option.
  *
  * @param   string  $name    No use here, we use option name.
  * @param   Option  $option  The option object to set in this set.
  *
  * @return  void
  *
  * @since   2.0
  */
 public function offsetSet($name, $option)
 {
     $name = $option->getName();
     $this->options[$name] = $option;
 }
开发者ID:rokite,项目名称:windwalker,代码行数:15,代码来源:OptionSet.php

示例5: triggerOption

 /**
  * @param $option
  * @param string $value
  */
 public function triggerOption(Option $option, $value = '')
 {
     if ($option->getName() == 'help') {
         $this->outputHelp();
     } elseif ($option->getName() == 'version') {
         $this->outputVersion();
     } else {
         $this->createProperty($option->getName(), $value);
     }
 }
开发者ID:lijinma,项目名称:commander,代码行数:14,代码来源:Commander.php

示例6: addOption

 /**
  * 添加一个选项
  * @param Option $option 选项
  * @throws \LogicException
  * @api
  */
 public function addOption(Option $option)
 {
     if (isset($this->options[$option->getName()]) && !$option->equals($this->options[$option->getName()])) {
         throw new \LogicException(sprintf('An option named "%s" already exists.', $option->getName()));
     }
     if ($option->getShortcut()) {
         foreach (explode('|', $option->getShortcut()) as $shortcut) {
             if (isset($this->shortcuts[$shortcut]) && !$option->equals($this->options[$this->shortcuts[$shortcut]])) {
                 throw new \LogicException(sprintf('An option with shortcut "%s" already exists.', $shortcut));
             }
         }
     }
     $this->options[$option->getName()] = $option;
     if ($option->getShortcut()) {
         foreach (explode('|', $option->getShortcut()) as $shortcut) {
             $this->shortcuts[$shortcut] = $option->getName();
         }
     }
 }
开发者ID:Lofanmi,项目名称:think,代码行数:25,代码来源:Definition.php

示例7: testGetName

 /**
  * @covers Phossa\Console\Option::getName
  */
 public function testGetName()
 {
     $this->assertEquals('user', $this->object->getName());
 }
开发者ID:phossa,项目名称:phossa-console,代码行数:7,代码来源:OptionTest.php

示例8: addOption

 /**
  * Add an Option object.
  *
  * @param Option $option An Option object
  */
 public function addOption(Option $option)
 {
     if (isset($this->options[$option->getName()])) {
         throw new \LogicException(sprintf('An option named "%s" already exist.', $option->getName()));
     } else {
         if (isset($this->shortcuts[$option->getShortcut()])) {
             throw new \LogicException(sprintf('An option with shortcut "%s" already exist.', $option->getShortcut()));
         }
     }
     $this->options[$option->getName()] = $option;
     if ($option->getShortcut()) {
         $this->shortcuts[$option->getShortcut()] = $option->getName();
     }
 }
开发者ID:vjousse,项目名称:symfony,代码行数:19,代码来源:Definition.php

示例9: equals

 /**
  * 检查所给选项是否是当前这个
  * @param Option $option
  * @return bool
  */
 public function equals(Option $option)
 {
     return $option->getName() === $this->getName() && $option->getShortcut() === $this->getShortcut() && $option->getDefault() === $this->getDefault() && $option->isArray() === $this->isArray() && $option->isValueRequired() === $this->isValueRequired() && $option->isValueOptional() === $this->isValueOptional();
 }
开发者ID:Lofanmi,项目名称:think,代码行数:9,代码来源:Option.php

示例10: Option

 function test_getIdsFromNames()
 {
     //arrange
     $name = "peanut-free";
     $test_option = new Option($name);
     $test_option->save();
     $name2 = "soy-free";
     $test_option2 = new Option($name2);
     $test_option2->save();
     //act
     $suitable_options_names = array($test_option->getName(), $test_option2->getName());
     $result = Option::getIdsFromNames($suitable_options_names);
     //assert
     $this->assertEquals([$test_option->getId(), $test_option2->getId()], $result);
 }
开发者ID:ben-pritchard,项目名称:allergen_avoider,代码行数:15,代码来源:OptionTest.php


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