| Conditions | 1 |
| Paths | 1 |
| Total Lines | 65 |
| Code Lines | 63 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 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 | public function display() { |
||
| 33 | ?> |
||
| 34 | |||
| 35 | <div class="row"> |
||
| 36 | <div class="col-12"> |
||
| 37 | <div class="card" style="max-width:720px"> |
||
| 38 | <div class="card-body"> |
||
| 39 | <?php $this->display_range_selector(); ?> |
||
| 40 | <canvas id="getpaid-chartjs-earnings"></canvas> |
||
| 41 | </div> |
||
| 42 | </div> |
||
| 43 | </div> |
||
| 44 | </div> |
||
| 45 | |||
| 46 | <script> |
||
| 47 | |||
| 48 | window.addEventListener( 'DOMContentLoaded', function() { |
||
| 49 | |||
| 50 | var ctx = document.getElementById( 'getpaid-chartjs-earnings' ).getContext('2d'); |
||
| 51 | |||
| 52 | var myChart = new Chart(ctx, { |
||
| 53 | type: 'bar', |
||
| 54 | data: { |
||
| 55 | labels: ['Red', 'Blue', 'Yellow', 'Green', 'Purple', 'Orange'], |
||
| 56 | datasets: [{ |
||
| 57 | label: '# of Votes', |
||
| 58 | data: [12, 19, 3, 5, 2, 3], |
||
| 59 | backgroundColor: [ |
||
| 60 | 'rgba(255, 99, 132, 0.2)', |
||
| 61 | 'rgba(54, 162, 235, 0.2)', |
||
| 62 | 'rgba(255, 206, 86, 0.2)', |
||
| 63 | 'rgba(75, 192, 192, 0.2)', |
||
| 64 | 'rgba(153, 102, 255, 0.2)', |
||
| 65 | 'rgba(255, 159, 64, 0.2)' |
||
| 66 | ], |
||
| 67 | borderColor: [ |
||
| 68 | 'rgba(255, 99, 132, 1)', |
||
| 69 | 'rgba(54, 162, 235, 1)', |
||
| 70 | 'rgba(255, 206, 86, 1)', |
||
| 71 | 'rgba(75, 192, 192, 1)', |
||
| 72 | 'rgba(153, 102, 255, 1)', |
||
| 73 | 'rgba(255, 159, 64, 1)' |
||
| 74 | ], |
||
| 75 | borderWidth: 1 |
||
| 76 | }] |
||
| 77 | }, |
||
| 78 | options: { |
||
| 79 | scales: { |
||
| 80 | yAxes: [{ |
||
| 81 | ticks: { |
||
| 82 | beginAtZero: true |
||
| 83 | } |
||
| 84 | }] |
||
| 85 | } |
||
| 86 | } |
||
| 87 | }); |
||
| 88 | |||
| 89 | }); |
||
| 90 | |||
| 91 | </script> |
||
| 92 | |||
| 93 | <?php |
||
| 94 | |||
| 95 | wp_enqueue_script( 'chart-js', WPINV_PLUGIN_URL . 'assets/js/chart.bundle.min.js', array( 'jquery' ), '2.9.4', true ); |
||
| 96 | wp_enqueue_style( 'chart-js', WPINV_PLUGIN_URL . 'assets/css/chart.min.css', array(), '2.9.4' ); |
||
| 97 | |||
| 189 |