original_string: protected function _hourSelect($options, $context)
      {
          $options += [
              'name' => '',
              'val' => null,
              'format' => 24,
              'start' => null,
              'end' => null,
              'leadingZeroKey' => true,
              'leadingZeroValue' => false,
              'templateVars' => [],
          ];
          $is24 = $options['format'] == 24;
  
          $defaultStart = $is24 ? 0 : 1;
          $defaultEnd = $is24 ? 23 : 12;
          $options['start'] = max($defaultStart, $options['start']);
  
          $options['end'] = min($defaultEnd, $options['end']);
          if ($options['end'] === null) {
              $options['end'] = $defaultEnd;
          }
  
          if (!$is24 && $options['val'] > 12) {
              $options['val'] = sprintf('%02d', $options['val'] - 12);
          }
          if (!$is24 && in_array($options['val'], ['00', '0', 0], true)) {
              $options['val'] = 12;
          }
  
          if (empty($options['options'])) {
              $options['options'] = $this->_generateNumbers(
                  $options['start'],
                  $options['end'],
                  $options
              );
          }
  
          unset(
              $options['end'],
              $options['start'],
              $options['format'],
              $options['leadingZeroKey'],
              $options['leadingZeroValue']
          );
  
          return $this->_select->render($options, $context);
      }
code: protected function _hourSelect($options, $context)
      {
          $options += [
              'name' => '',
              'val' => null,
              'format' => 24,
              'start' => null,
              'end' => null,
              'leadingZeroKey' => true,
              'leadingZeroValue' => false,
              'templateVars' => [],
          ];
          $is24 = $options['format'] == 24;
  
          $defaultStart = $is24 ? 0 : 1;
          $defaultEnd = $is24 ? 23 : 12;
          $options['start'] = max($defaultStart, $options['start']);
  
          $options['end'] = min($defaultEnd, $options['end']);
          if ($options['end'] === null) {
              $options['end'] = $defaultEnd;
          }
  
          if (!$is24 && $options['val'] > 12) {
              $options['val'] = sprintf('%02d', $options['val'] - 12);
          }
          if (!$is24 && in_array($options['val'], ['00', '0', 0], true)) {
              $options['val'] = 12;
          }
  
          if (empty($options['options'])) {
              $options['options'] = $this->_generateNumbers(
                  $options['start'],
                  $options['end'],
                  $options
              );
          }
  
          unset(
              $options['end'],
              $options['start'],
              $options['format'],
              $options['leadingZeroKey'],
              $options['leadingZeroValue']
          );
  
          return $this->_select->render($options, $context);
      }
code_tokens: protected function _hourSelect ( $ options , $ context ) { $ options += [ 'name' => '' , 'val' => null , 'format' => 24 , 'start' => null , 'end' => null , 'leadingZeroKey' => true , 'leadingZeroValue' => false , 'templateVars' => [ ] , ] ; $ is24 = $ options [ 'format' ] == 24 ; $ defaultStart = $ is24 ? 0 : 1 ; $ defaultEnd = $ is24 ? 23 : 12 ; $ options [ 'start' ] = max ( $ defaultStart , $ options [ 'start' ] ) ; $ options [ 'end' ] = min ( $ defaultEnd , $ options [ 'end' ] ) ; if ( $ options [ 'end' ] === null ) { $ options [ 'end' ] = $ defaultEnd ; } if ( ! $ is24 && $ options [ 'val' ] > 12 ) { $ options [ 'val' ] = sprintf ( '%02d' , $ options [ 'val' ] - 12 ) ; } if ( ! $ is24 && in_array ( $ options [ 'val' ] , [ '00' , '0' , 0 ] , true ) ) { $ options [ 'val' ] = 12 ; } if ( empty ( $ options [ 'options' ] ) ) { $ options [ 'options' ] = $ this -> _generateNumbers ( $ options [ 'start' ] , $ options [ 'end' ] , $ options ) ; } unset ( $ options [ 'end' ] , $ options [ 'start' ] , $ options [ 'format' ] , $ options [ 'leadingZeroKey' ] , $ options [ 'leadingZeroValue' ] ) ; return $ this -> _select -> render ( $ options , $ context ) ; }
docstring: Generates a hour select
  
  @param array $options The options to generate an hour select with
  @param \Cake\View\Form\ContextInterface $context The current form context.
  @return string
docstring_tokens: Generates a hour select