| Conditions | 3 |
| Paths | 3 |
| Total Lines | 78 |
| Code Lines | 27 |
| 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 |
||
| 50 | public function __construct($header, $line1, $line2) |
||
| 51 | { |
||
| 52 | if (!$this->Good_Elements($line1, $line2)) { |
||
| 53 | throw new Predict_Exception('Invalid TLE contents'); |
||
| 54 | } |
||
| 55 | |||
| 56 | $this->header = $header; |
||
| 57 | $this->line1 = $line1; |
||
| 58 | $this->line2 = $line2; |
||
| 59 | |||
| 60 | /** Decode Card 1 **/ |
||
| 61 | /* Satellite's catalogue number */ |
||
| 62 | $this->catnr = (int) substr($line1, 2, 5); |
||
| 63 | |||
| 64 | /* International Designator for satellite */ |
||
| 65 | $this->idesg = substr($line1, 9, 8); |
||
| 66 | |||
| 67 | /* Epoch time; this is the complete, unconverted epoch. */ |
||
| 68 | /* Replace spaces with 0 before casting, as leading spaces are allowed */ |
||
| 69 | $this->epoch = (float) str_replace(' ', '0', substr($line1, 18, 14)); |
||
| 70 | |||
| 71 | /* Now, convert the epoch time into year, day |
||
| 72 | and fraction of day, according to: |
||
| 73 | |||
| 74 | YYDDD.FFFFFFFF |
||
| 75 | */ |
||
| 76 | |||
| 77 | // Adjust for 2 digit year through 2056 |
||
| 78 | $this->epoch_year = (int) substr($line1, 18, 2); |
||
| 79 | if ($this->epoch_year > 56) { |
||
| 80 | $this->epoch_year = $this->epoch_year + 1900; |
||
| 81 | } else { |
||
| 82 | $this->epoch_year = $this->epoch_year + 2000; |
||
| 83 | } |
||
| 84 | |||
| 85 | /* Epoch day */ |
||
| 86 | $this->epoch_day = (int) substr($line1, 20, 3); |
||
| 87 | |||
| 88 | /* Epoch fraction of day */ |
||
| 89 | $this->epoch_fod = (float) substr($line1, 23, 9); |
||
| 90 | |||
| 91 | |||
| 92 | /* Satellite's First Time Derivative */ |
||
| 93 | $this->xndt2o = (float) substr($line1, 33, 10); |
||
| 94 | |||
| 95 | /* Satellite's Second Time Derivative */ |
||
| 96 | $this->xndd6o = (float) (substr($line1, 44, 1) . '.' . substr($line1, 45, 5) . 'E' . substr($line1, 50, 2)); |
||
| 97 | |||
| 98 | /* Satellite's bstar drag term |
||
| 99 | FIXME: How about buff[0] ???? |
||
| 100 | */ |
||
| 101 | $this->bstar = (float) (substr($line1, 53, 1) . '.' . substr($line1, 54, 5) . 'E' . substr($line1, 59, 2)); |
||
| 102 | |||
| 103 | /* Element Number */ |
||
| 104 | $this->elset = (int) substr($line1, 64, 4); |
||
| 105 | |||
| 106 | /** Decode Card 2 **/ |
||
| 107 | /* Satellite's Orbital Inclination (degrees) */ |
||
| 108 | $this->xincl = (float) substr($line2, 8, 8); |
||
| 109 | |||
| 110 | /* Satellite's RAAN (degrees) */ |
||
| 111 | $this->xnodeo = (float) substr($line2, 17, 8); |
||
| 112 | |||
| 113 | /* Satellite's Orbital Eccentricity */ |
||
| 114 | $this->eo = (float) ('.' . substr($line2, 26, 7)); |
||
| 115 | |||
| 116 | /* Satellite's Argument of Perigee (degrees) */ |
||
| 117 | $this->omegao = (float) substr($line2, 34, 8); |
||
| 118 | |||
| 119 | /* Satellite's Mean Anomaly of Orbit (degrees) */ |
||
| 120 | $this->xmo = (float) substr($line2, 43, 8); |
||
| 121 | |||
| 122 | /* Satellite's Mean Motion (rev/day) */ |
||
| 123 | $this->xno = (float) substr($line2, 52, 11); |
||
| 124 | |||
| 125 | /* Satellite's Revolution number at epoch */ |
||
| 126 | $this->revnum = (float) substr($line2, 63, 5); |
||
| 127 | } |
||
| 128 | |||
| 233 |