| Conditions | 12 |
| Paths | 40 |
| Total Lines | 37 |
| Code Lines | 18 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php defined('SYSPATH') OR die('No direct script access.'); |
||
| 47 | protected function _default(Jam_Validated $model, $value) |
||
| 48 | { |
||
| 49 | $return = FALSE; |
||
| 50 | |||
| 51 | $value = $this->run_filters($model, $value); |
||
| 52 | |||
| 53 | $min = NULL; |
||
| 54 | $max = NULL; |
||
| 55 | |||
| 56 | if (is_array($value)) |
||
| 57 | { |
||
| 58 | $min = $value[0]; |
||
| 59 | $max = $value[1]; |
||
| 60 | } |
||
| 61 | |||
| 62 | if (is_string($value) AND strstr($value, '|')) |
||
| 63 | { |
||
| 64 | $min = isset(explode('|', $value)[0]) ? explode('|', $value)[0] : NULL; |
||
| 65 | $max = isset(explode('|', $value)[1]) ? explode('|', $value)[1] : NULL; |
||
| 66 | } |
||
| 67 | |||
| 68 | // Convert empty values to NULL, if needed |
||
| 69 | if ($this->convert_empty AND (empty($min) OR empty($max))) |
||
| 70 | { |
||
| 71 | $value = $this->empty_value; |
||
| 72 | $return = TRUE; |
||
| 73 | } |
||
| 74 | |||
| 75 | // Allow NULL values to pass through untouched by the field |
||
| 76 | if ($this->allow_null AND ($min === NULL OR $max === NULL)) |
||
| 77 | { |
||
| 78 | $value = NULL; |
||
| 79 | $return = TRUE; |
||
| 80 | } |
||
| 81 | |||
| 82 | return array($value, $return); |
||
| 83 | } |
||
| 84 | } |
||
| 85 |