CakePHP
  • Documentation
    • Book
    • API
    • Videos
    • Logos & Trademarks
  • Business Solutions
  • Swag
  • Road Trip
  • Team
  • Community
    • Community
    • Team
    • Issues (Github)
    • YouTube Channel
    • Get Involved
    • Bakery
    • Featured Resources
    • Newsletter
    • Certification
    • My CakePHP
    • CakeFest
    • Facebook
    • Twitter
    • Help & Support
    • Forum
    • Stack Overflow
    • IRC
    • Slack
    • Paid Support
CakePHP

C CakePHP 3.8 Red Velvet API

  • Overview
  • Tree
  • Deprecated
  • Version:
    • 3.8
      • 3.8
      • 3.7
      • 3.6
      • 3.5
      • 3.4
      • 3.3
      • 3.2
      • 3.1
      • 3.0
      • 2.10
      • 2.9
      • 2.8
      • 2.7
      • 2.6
      • 2.5
      • 2.4
      • 2.3
      • 2.2
      • 2.1
      • 2.0
      • 1.3
      • 1.2

Namespaces

  • Cake
    • Auth
      • Storage
    • Cache
      • Engine
    • Collection
      • Iterator
    • Command
    • Console
      • Exception
    • Controller
      • Component
      • Exception
    • Core
      • Configure
        • Engine
      • Exception
      • Retry
    • Database
      • Driver
      • Exception
      • Expression
      • Schema
      • Statement
      • Type
    • Datasource
      • Exception
    • Error
      • Middleware
    • Event
      • Decorator
    • Filesystem
    • Form
    • Http
      • Client
        • Adapter
        • Auth
      • Cookie
      • Exception
      • Middleware
      • Session
    • I18n
      • Formatter
      • Middleware
      • Parser
    • Log
      • Engine
    • Mailer
      • Exception
      • Transport
    • Network
      • Exception
    • ORM
      • Association
      • Behavior
        • Translate
      • Exception
      • Locator
      • Rule
    • Routing
      • Exception
      • Filter
      • Middleware
      • Route
    • Shell
      • Helper
      • Task
    • TestSuite
      • Fixture
      • Stub
    • Utility
      • Exception
    • Validation
    • View
      • Exception
      • Form
      • Helper
      • Widget
  • None

Classes

  • ConsoleInput
  • ConsoleOutput
  • Response
 1: <?php
 2: /**
 3:  * CakePHP :  Rapid Development Framework (https://cakephp.org)
 4:  * Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
 5:  *
 6:  * Licensed under The MIT License
 7:  * For full copyright and license information, please see the LICENSE.txt
 8:  * Redistributions of files must retain the above copyright notice.
 9:  *
10:  * @copyright     Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
11:  * @link          https://cakephp.org CakePHP Project
12:  * @license       https://opensource.org/licenses/mit-license.php MIT License
13:  */
14: namespace Cake\TestSuite\Stub;
15: 
16: use Cake\Console\ConsoleInput as ConsoleInputBase;
17: use Cake\Console\Exception\ConsoleException;
18: use NumberFormatter;
19: 
20: /**
21:  * Stub class used by the console integration harness.
22:  *
23:  * This class enables input to be stubbed and have exceptions
24:  * raised when no answer is available.
25:  */
26: class ConsoleInput extends ConsoleInputBase
27: {
28:     /**
29:      * Reply values for ask() and askChoice()
30:      *
31:      * @var array
32:      */
33:     protected $replies = [];
34: 
35:     /**
36:      * Current message index
37:      *
38:      * @var int
39:      */
40:     protected $currentIndex = -1;
41: 
42:     /**
43:      * Constructor
44:      *
45:      * @param string[] $replies A list of replies for read()
46:      */
47:     public function __construct(array $replies)
48:     {
49:         parent::__construct();
50: 
51:         $this->replies = $replies;
52:     }
53: 
54:     /**
55:      * Read a reply
56:      *
57:      * @return mixed The value of the reply
58:      */
59:     public function read()
60:     {
61:         $this->currentIndex += 1;
62: 
63:         if (!isset($this->replies[$this->currentIndex])) {
64:             $total = count($this->replies);
65:             $formatter = new NumberFormatter('en', NumberFormatter::ORDINAL);
66:             $nth = $formatter->format($this->currentIndex + 1);
67: 
68:             $replies = implode(', ', $this->replies);
69:             $message = "There are no more input replies available. This is the {$nth} read operation, " .
70:                 "only {$total} replies were set. The provided replies are: {$replies}";
71:             throw new ConsoleException($message);
72:         }
73: 
74:         return $this->replies[$this->currentIndex];
75:     }
76: 
77:     /**
78:      * Check if data is available on stdin
79:      *
80:      * @param int $timeout An optional time to wait for data
81:      * @return bool True for data available, false otherwise
82:      */
83:     public function dataAvailable($timeout = 0)
84:     {
85:         return true;
86:     }
87: }
88: 
Follow @CakePHP
#IRC
OpenHub
Rackspace
  • Business Solutions
  • Showcase
  • Documentation
  • Book
  • API
  • Videos
  • Logos & Trademarks
  • Community
  • Team
  • Issues (Github)
  • YouTube Channel
  • Get Involved
  • Bakery
  • Featured Resources
  • Newsletter
  • Certification
  • My CakePHP
  • CakeFest
  • Facebook
  • Twitter
  • Help & Support
  • Forum
  • Stack Overflow
  • IRC
  • Slack
  • Paid Support

Generated using CakePHP API Docs