| Conditions | 6 |
| Paths | 8 |
| Total Lines | 16 |
| Code Lines | 11 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 29 | public static function getInputName($model, $attribute, $formName = null) |
||
| 30 | { |
||
| 31 | $formName = null === $formName ? $model->formName() : $formName; |
||
| 32 | if (!preg_match(static::$attributeRegex, $attribute, $matches)) { |
||
| 33 | throw new InvalidArgumentException('Attribute name must contain word characters only.'); |
||
| 34 | } |
||
| 35 | $prefix = $matches[1]; |
||
| 36 | $attribute = $matches[2]; |
||
| 37 | $suffix = $matches[3]; |
||
| 38 | if ($formName === '' && $prefix === '') { |
||
| 39 | return $attribute . $suffix; |
||
| 40 | } elseif ($formName !== '') { |
||
| 41 | return $formName . $prefix . '[' . $attribute . ']' . $suffix; |
||
| 42 | } |
||
| 43 | |||
| 44 | throw new InvalidArgumentException(get_class($model) . '::formName() cannot be empty for tabular inputs.'); |
||
| 45 | } |
||
| 47 |