| Conditions | 1 |
| Paths | 1 |
| Total Lines | 73 |
| Code Lines | 46 |
| 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 |
||
| 16 | public function dataProviderObfuscate() |
||
| 17 | { |
||
| 18 | return array( |
||
| 19 | // string on data. |
||
| 20 | //@ObfuscateRequest(content="*") |
||
| 21 | array( |
||
| 22 | array('content' => 'foo'), |
||
| 23 | array('content' => '*'), |
||
| 24 | array('content' => 'XXX') |
||
| 25 | ), |
||
| 26 | //@ObfuscateRequest(content=".") |
||
| 27 | array( |
||
| 28 | array('content' => 'foobar'), |
||
| 29 | array('content' => '.'), |
||
| 30 | array('content' => 'XXXXXX') |
||
| 31 | ), |
||
| 32 | //@ObfuscateRequest() |
||
| 33 | array( |
||
| 34 | array('content' => 'foobar'), |
||
| 35 | array(), |
||
| 36 | array('content' => 'foobar') |
||
| 37 | ), |
||
| 38 | //@ObfuscateRequest(otherkey="*") |
||
| 39 | array( |
||
| 40 | array('content' => 'foobar'), |
||
| 41 | array('otherkey' => '*'), |
||
| 42 | array('content' => 'foobar') |
||
| 43 | ), |
||
| 44 | // array on data, simple patterns |
||
| 45 | //@ObfuscateRequest(content="*") |
||
| 46 | array( |
||
| 47 | array('content' => array('key1' => 'foo', 'key2' => 'bar')), |
||
| 48 | array('content' => '*'), |
||
| 49 | array('content' => 'X') |
||
| 50 | ), |
||
| 51 | //@ObfuscateRequest(content="key1") |
||
| 52 | array( |
||
| 53 | array('content' => array('key1' => 'foo', 'key2' => 'bar')), |
||
| 54 | array('content' => 'key1'), |
||
| 55 | array('content' => array('key1' => 'XXX', 'key2' => 'bar')) |
||
| 56 | ), |
||
| 57 | //@ObfuscateRequest(content={"key1"}) |
||
| 58 | array( |
||
| 59 | array('content' => array('key1' => array('foo' => 'pouet'), 'key2' => 'bar')), |
||
| 60 | array('content' => array('key1')), |
||
| 61 | array('content' => array('key1' => 'X', 'key2' => 'bar')) |
||
| 62 | ), |
||
| 63 | //@ObfuscateRequest(content={"key1", "key2"}) |
||
| 64 | array( |
||
| 65 | array('content' => array('key1' => array('foo' => 'pouet'), 'key2' => 'bar')), |
||
| 66 | array('content' => array('key1', 'key2')), |
||
| 67 | array('content' => array('key1' => 'X', 'key2' => 'XXX')) |
||
| 68 | ), |
||
| 69 | //@ObfuscateRequest(content={"key1[key2]"}) |
||
| 70 | array( |
||
| 71 | array('content' => array('key1' => array('key2' => 'pouet'), 'key2' => 'bar')), |
||
| 72 | array('content' => array('key1[key2]')), |
||
| 73 | array('content' => array('key1' => array('key2' => 'XXXXX'), 'key2' => 'bar')) |
||
| 74 | ), |
||
| 75 | //@ObfuscateRequest(content={"key1[key2][key3]"}) |
||
| 76 | array( |
||
| 77 | array('content' => array('key1' => array('key2' => array('key3' => 'foo')))), |
||
| 78 | array('content' => array('key1[key2][key3]')), |
||
| 79 | array('content' => array('key1' => array('key2' => array('key3' => 'XXX')))), |
||
| 80 | ), |
||
| 81 | //@ObfuscateRequest(content={"key1[*]"}) |
||
| 82 | array( |
||
| 83 | array('content' => array('key1' => array('key2' => array('key3' => 'foo')))), |
||
| 84 | array('content' => array('key1[*]')), |
||
| 85 | array('content' => array('key1' => 'X')), |
||
| 86 | ), |
||
| 87 | ); |
||
| 88 | } |
||
| 89 | |||
| 100 |
If you implement
__calland you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.This is often the case, when
__callis implemented by a parent class and only the child class knows which methods exist: