| Conditions | 1 |
| Paths | 1 |
| Total Lines | 51 |
| 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 |
||
| 32 | function __construct() |
||
|
|
|||
| 33 | { |
||
| 34 | parent::__construct(); |
||
| 35 | $this->initVar('id', XOBJ_DTYPE_INT, null, false); |
||
| 36 | $this->initVar('userid', XOBJ_DTYPE_TXTBOX, null, false, 255); |
||
| 37 | $this->initVar('regdate', XOBJ_DTYPE_INT, 0, true); |
||
| 38 | $this->initVar('username', XOBJ_DTYPE_TXTBOX, null, false, 255); |
||
| 39 | $this->initVar('userimage', XOBJ_DTYPE_TXTBOX, null, false, 255); |
||
| 40 | $this->initVar('realname', XOBJ_DTYPE_TXTBOX, null, false, 255); |
||
| 41 | $this->initVar('gender', XOBJ_DTYPE_TXTBOX, null, false, 255); |
||
| 42 | $this->initVar('intingender', XOBJ_DTYPE_ARRAY, null, false, 255); |
||
| 43 | $this->initVar('relationship', XOBJ_DTYPE_TXTBOX, null, false, 255); |
||
| 44 | $this->initVar('partner', XOBJ_DTYPE_TXTBOX, null, false, 255); |
||
| 45 | $this->initVar('searchrelat', XOBJ_DTYPE_ARRAY, null, false, 255); |
||
| 46 | $this->initVar('birthday', XOBJ_DTYPE_TXTBOX, null, false, 255); |
||
| 47 | $this->initVar('birthplace', XOBJ_DTYPE_TXTBOX, null, false, 255); |
||
| 48 | $this->initVar('birthplace_lat', XOBJ_DTYPE_TXTBOX, null, false, 255); |
||
| 49 | $this->initVar('birthplace_lng', XOBJ_DTYPE_TXTBOX, null, false, 255); |
||
| 50 | $this->initVar('birthplace_country', XOBJ_DTYPE_TXTBOX, null, false, 255); |
||
| 51 | $this->initVar('politic', XOBJ_DTYPE_TXTBOX, null, false, 255); |
||
| 52 | $this->initVar('religion', XOBJ_DTYPE_TXTBOX, null, false, 255); |
||
| 53 | $this->initVar('emailtype', XOBJ_DTYPE_ARRAY, null, false, 255); |
||
| 54 | $this->initVar('screenname_type', XOBJ_DTYPE_ARRAY, null, false, 255); |
||
| 55 | $this->initVar('screenname', XOBJ_DTYPE_ARRAY, null, false, 255); |
||
| 56 | $this->initVar('mobile', XOBJ_DTYPE_TXTBOX, null, false, 255); |
||
| 57 | $this->initVar('phone', XOBJ_DTYPE_TXTBOX, null, false, 255); |
||
| 58 | $this->initVar('adress', XOBJ_DTYPE_TXTBOX, null, false, 255); |
||
| 59 | $this->initVar('present_city', XOBJ_DTYPE_TXTBOX, null, false, 255); |
||
| 60 | $this->initVar('present_lat', XOBJ_DTYPE_TXTBOX, null, false, 255); |
||
| 61 | $this->initVar('present_lng', XOBJ_DTYPE_TXTBOX, null, false, 255); |
||
| 62 | $this->initVar('present_country', XOBJ_DTYPE_TXTBOX, null, false, 255); |
||
| 63 | $this->initVar('website', XOBJ_DTYPE_TXTBOX, null, false, 255); |
||
| 64 | $this->initVar('interests', XOBJ_DTYPE_TXTBOX, null, false, 255); |
||
| 65 | $this->initVar('music', XOBJ_DTYPE_TXTBOX, null, false, 255); |
||
| 66 | $this->initVar('tvshow', XOBJ_DTYPE_TXTBOX, null, false, 255); |
||
| 67 | $this->initVar('movie', XOBJ_DTYPE_TXTBOX, null, false, 255); |
||
| 68 | $this->initVar('books', XOBJ_DTYPE_TXTBOX, null, false, 255); |
||
| 69 | $this->initVar('aboutme', XOBJ_DTYPE_TXTBOX, null, false, 255); |
||
| 70 | $this->initVar('school_type', XOBJ_DTYPE_ARRAY, null, false, 255); |
||
| 71 | $this->initVar('school', XOBJ_DTYPE_ARRAY, null, false, 255); |
||
| 72 | $this->initVar('schoolstart', XOBJ_DTYPE_ARRAY, null, false, 255); |
||
| 73 | $this->initVar('schoolstop', XOBJ_DTYPE_ARRAY, null, false, 255); |
||
| 74 | $this->initVar('employer', XOBJ_DTYPE_ARRAY, null, false, 255); |
||
| 75 | $this->initVar('position', XOBJ_DTYPE_ARRAY, null, false, 255); |
||
| 76 | $this->initVar('jobstart', XOBJ_DTYPE_ARRAY, null, false, 255); |
||
| 77 | $this->initVar('jobstop', XOBJ_DTYPE_ARRAY, null, false, 255); |
||
| 78 | $this->initVar('description', XOBJ_DTYPE_ARRAY, null, false, 255); |
||
| 79 | $this->initVar('friends', XOBJ_DTYPE_INT, 0, false); |
||
| 80 | $this->initVar('followers', XOBJ_DTYPE_INT, 0, false); |
||
| 81 | $this->initVar('admin_flag', XOBJ_DTYPE_INT, 0, false); |
||
| 82 | } |
||
| 83 | } |
||
| 84 |
Adding explicit visibility (
private,protected, orpublic) is generally recommend to communicate to other developers how, and from where this method is intended to be used.