當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。