| Conditions | 1 |
| Paths | 1 |
| Total Lines | 68 |
| Code Lines | 54 |
| 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 |
||
| 20 | public function setUp() |
||
| 21 | { |
||
| 22 | $this->zone = new Zone('example.com.'); |
||
| 23 | $this->zone->setDefaultTtl(3600); |
||
| 24 | |||
| 25 | $soa = new ResourceRecord(); |
||
| 26 | $soa->setName('@'); |
||
| 27 | $soa->setRdata(Factory::Soa( |
||
| 28 | 'example.com.', |
||
| 29 | 'post.example.com.', |
||
| 30 | '2014110501', |
||
| 31 | 3600, |
||
| 32 | 14400, |
||
| 33 | 604800, |
||
| 34 | 3600 |
||
| 35 | )); |
||
| 36 | |||
| 37 | $ns1 = new ResourceRecord(); |
||
| 38 | $ns1->setName('@'); |
||
| 39 | $ns1->setRdata(Factory::Ns('ns1.nameserver.com.')); |
||
| 40 | |||
| 41 | $ns2 = new ResourceRecord(); |
||
| 42 | $ns2->setName('@'); |
||
| 43 | $ns2->setRdata(Factory::Ns('ns2.nameserver.com.')); |
||
| 44 | |||
| 45 | $a = new ResourceRecord(); |
||
| 46 | $a->setName('sub.domain'); |
||
| 47 | $a->setRdata(Factory::A('192.168.1.42')); |
||
| 48 | $a->setComment('This is a local ip.'); |
||
| 49 | |||
| 50 | $a6 = new ResourceRecord(); |
||
| 51 | $a6->setName('ipv6.domain'); |
||
| 52 | $a6->setRdata(Factory::Aaaa('::1')); |
||
| 53 | $a6->setComment('This is an IPv6 domain.'); |
||
| 54 | |||
| 55 | $mx1 = new ResourceRecord(); |
||
| 56 | $mx1->setName('@'); |
||
| 57 | $mx1->setRdata(Factory::Mx(10, 'mail-gw1.example.net.')); |
||
| 58 | |||
| 59 | $mx2 = new ResourceRecord(); |
||
| 60 | $mx2->setName('@'); |
||
| 61 | $mx2->setRdata(Factory::Mx(20, 'mail-gw2.example.net.')); |
||
| 62 | |||
| 63 | $mx3 = new ResourceRecord(); |
||
| 64 | $mx3->setName('@'); |
||
| 65 | $mx3->setRdata(Factory::Mx(30, 'mail-gw3.example.net.')); |
||
| 66 | |||
| 67 | $loc = new ResourceRecord(); |
||
| 68 | $loc->setName('canberra'); |
||
| 69 | $loc->setRdata(Factory::Loc( |
||
| 70 | -35.3075, //Lat |
||
| 71 | 149.1244, //Lon |
||
| 72 | 500, //Alt |
||
| 73 | 20.12, //Size |
||
| 74 | 200.3, //HP |
||
| 75 | 300.1 //VP |
||
| 76 | )); |
||
| 77 | $loc->setComment('This is Canberra'); |
||
| 78 | |||
| 79 | $this->zone->addResourceRecord($soa); |
||
| 80 | $this->zone->addResourceRecord($ns1); |
||
| 81 | $this->zone->addResourceRecord($ns2); |
||
| 82 | $this->zone->addResourceRecord($a); |
||
| 83 | $this->zone->addResourceRecord($a6); |
||
| 84 | $this->zone->addResourceRecord($mx1); |
||
| 85 | $this->zone->addResourceRecord($mx2); |
||
| 86 | $this->zone->addResourceRecord($mx3); |
||
| 87 | $this->zone->addResourceRecord($loc); |
||
| 88 | } |
||
| 103 |