Mercurial > hg > rc1
comparison vendor/pear/console_commandline/Console/CommandLine/Action/StoreInt.php @ 0:1e000243b222
vanilla 1.3.3 distro, I hope
author | Charlie Root |
---|---|
date | Thu, 04 Jan 2018 15:50:29 -0500 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:1e000243b222 |
---|---|
1 <?php | |
2 | |
3 /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ | |
4 | |
5 /** | |
6 * This file is part of the PEAR Console_CommandLine package. | |
7 * | |
8 * PHP version 5 | |
9 * | |
10 * LICENSE: This source file is subject to the MIT license that is available | |
11 * through the world-wide-web at the following URI: | |
12 * http://opensource.org/licenses/mit-license.php | |
13 * | |
14 * @category Console | |
15 * @package Console_CommandLine | |
16 * @author David JEAN LOUIS <izimobil@gmail.com> | |
17 * @copyright 2007 David JEAN LOUIS | |
18 * @license http://opensource.org/licenses/mit-license.php MIT License | |
19 * @version CVS: $Id$ | |
20 * @link http://pear.php.net/package/Console_CommandLine | |
21 * @since File available since release 0.1.0 | |
22 * @filesource | |
23 */ | |
24 | |
25 /** | |
26 * Required by this class. | |
27 */ | |
28 require_once 'Console/CommandLine/Action.php'; | |
29 | |
30 /** | |
31 * Class that represent the StoreInt action. | |
32 * | |
33 * The execute method store the value of the option entered by the user as an | |
34 * integer in the result option array entry, if the value passed is not an | |
35 * integer an Exception is raised. | |
36 * | |
37 * @category Console | |
38 * @package Console_CommandLine | |
39 * @author David JEAN LOUIS <izimobil@gmail.com> | |
40 * @copyright 2007 David JEAN LOUIS | |
41 * @license http://opensource.org/licenses/mit-license.php MIT License | |
42 * @version Release: @package_version@ | |
43 * @link http://pear.php.net/package/Console_CommandLine | |
44 * @since Class available since release 0.1.0 | |
45 */ | |
46 class Console_CommandLine_Action_StoreInt extends Console_CommandLine_Action | |
47 { | |
48 // execute() {{{ | |
49 | |
50 /** | |
51 * Executes the action with the value entered by the user. | |
52 * | |
53 * @param mixed $value The option value | |
54 * @param array $params An array of optional parameters | |
55 * | |
56 * @return string | |
57 * @throws Console_CommandLine_Exception | |
58 */ | |
59 public function execute($value = false, $params = array()) | |
60 { | |
61 if (!is_numeric($value)) { | |
62 include_once 'Console/CommandLine/Exception.php'; | |
63 throw Console_CommandLine_Exception::factory( | |
64 'OPTION_VALUE_TYPE_ERROR', | |
65 array( | |
66 'name' => $this->option->name, | |
67 'type' => 'int', | |
68 'value' => $value | |
69 ), | |
70 $this->parser | |
71 ); | |
72 } | |
73 $this->setResult((int)$value); | |
74 } | |
75 // }}} | |
76 } |