original_string: public function label($fieldName, $text = null, array $options = [])
      {
          if ($text === null) {
              $text = $fieldName;
              if (substr($text, -5) === '._ids') {
                  $text = substr($text, 0, -5);
              }
              if (strpos($text, '.') !== false) {
                  $fieldElements = explode('.', $text);
                  $text = array_pop($fieldElements);
              }
              if (substr($text, -3) === '_id') {
                  $text = substr($text, 0, -3);
              }
              $text = __(Inflector::humanize(Inflector::underscore($text)));
          }
  
          if (isset($options['for'])) {
              $labelFor = $options['for'];
              unset($options['for']);
          } else {
              $labelFor = $this->_domId($fieldName);
          }
          $attrs = $options + [
              'for' => $labelFor,
              'text' => $text,
          ];
          if (isset($options['input'])) {
              if (is_array($options['input'])) {
                  $attrs = $options['input'] + $attrs;
              }
  
              return $this->widget('nestingLabel', $attrs);
          }
  
          return $this->widget('label', $attrs);
      }
code: public function label($fieldName, $text = null, array $options = [])
      {
          if ($text === null) {
              $text = $fieldName;
              if (substr($text, -5) === '._ids') {
                  $text = substr($text, 0, -5);
              }
              if (strpos($text, '.') !== false) {
                  $fieldElements = explode('.', $text);
                  $text = array_pop($fieldElements);
              }
              if (substr($text, -3) === '_id') {
                  $text = substr($text, 0, -3);
              }
              $text = __(Inflector::humanize(Inflector::underscore($text)));
          }
  
          if (isset($options['for'])) {
              $labelFor = $options['for'];
              unset($options['for']);
          } else {
              $labelFor = $this->_domId($fieldName);
          }
          $attrs = $options + [
              'for' => $labelFor,
              'text' => $text,
          ];
          if (isset($options['input'])) {
              if (is_array($options['input'])) {
                  $attrs = $options['input'] + $attrs;
              }
  
              return $this->widget('nestingLabel', $attrs);
          }
  
          return $this->widget('label', $attrs);
      }
code_tokens: public function label ( $ fieldName , $ text = null , array $ options = [ ] ) { if ( $ text === null ) { $ text = $ fieldName ; if ( substr ( $ text , - 5 ) === '._ids' ) { $ text = substr ( $ text , 0 , - 5 ) ; } if ( strpos ( $ text , '.' ) !== false ) { $ fieldElements = explode ( '.' , $ text ) ; $ text = array_pop ( $ fieldElements ) ; } if ( substr ( $ text , - 3 ) === '_id' ) { $ text = substr ( $ text , 0 , - 3 ) ; } $ text = __ ( Inflector :: humanize ( Inflector :: underscore ( $ text ) ) ) ; } if ( isset ( $ options [ 'for' ] ) ) { $ labelFor = $ options [ 'for' ] ; unset ( $ options [ 'for' ] ) ; } else { $ labelFor = $ this -> _domId ( $ fieldName ) ; } $ attrs = $ options + [ 'for' => $ labelFor , 'text' => $ text , ] ; if ( isset ( $ options [ 'input' ] ) ) { if ( is_array ( $ options [ 'input' ] ) ) { $ attrs = $ options [ 'input' ] + $ attrs ; } return $ this -> widget ( 'nestingLabel' , $ attrs ) ; } return $ this -> widget ( 'label' , $ attrs ) ; }
docstring: Returns a formatted LABEL element for HTML forms.
  
  Will automatically generate a `for` attribute if one is not provided.
  
  ### Options
  
  - `for` - Set the for attribute, if its not defined the for attribute
  will be generated from the $fieldName parameter using
  FormHelper::_domId().
  - `escape` - Set to `false` to turn off escaping of label text.
  Defaults to `true`.
  
  Examples:
  
  The text and for attribute are generated off of the fieldname
  
  ```
  echo $this->Form->label('published');
  <label for="PostPublished">Published</label>
  ```
  
  Custom text:
  
  ```
  echo $this->Form->label('published', 'Publish');
  <label for="published">Publish</label>
  ```
  
  Custom attributes:
  
  ```
  echo $this->Form->label('published', 'Publish', [
  'for' => 'post-publish'
  ]);
  <label for="post-publish">Publish</label>
  ```
  
  Nesting an input tag:
  
  ```
  echo $this->Form->label('published', 'Publish', [
  'for' => 'published',
  'input' => $this->text('published'),
  ]);
  <label for="post-publish">Publish <input type="text" name="published"></label>
  ```
  
  If you want to nest inputs in the labels, you will need to modify the default templates.
  
  @param string $fieldName This should be "modelname.fieldname"
  @param string|null $text Text that will appear in the label field. If
  $text is left undefined the text will be inflected from the
  fieldName.
  @param array $options An array of HTML attributes.
  @return string The formatted LABEL element
  @link https://book.cakephp.org/3.0/en/views/helpers/form.html#creating-labels
docstring_tokens: Returns a formatted LABEL element for HTML forms .