__construct()
36: public function __construct() {
37: $this->stats = array (
38: array (
39: 'Controllers' => $this->labels,
40: 'Helpers' => $this->labels,
41: 'Models' => $this->labels,
43: 'Plugins' => $this->labels
44: ),
45: array (
46: 'Integrations tests' => $this->labels,
47: 'Functional tests' => $this->labels,
48: 'Unit tests' => $this->labels
49: )
50: );
51: }
File: lib/support/statistics.php, #line 36
include_dir($path, $label)
57: public function include_dir($path, $label) {
58: $this->stats_for_dir(APP_ROOT . $path, $label);
59: $this->report = array_merge($this->stats[0], $this->stats[1]);
60: $this->total_code = $this->stats[0];
61: $this->total_test = $this->stats[1];
62: }
File: lib/support/statistics.php, #line 57
stats_for_dir($path, $label)
68: public function stats_for_dir($path, $label) {
70: $this->subpaths = array ();
72: $dh = dir($path);
74: while ($entry = $dh->read()) {
76: if ($entry == '.' || $entry == '..' || $entry == '.svn')
77: continue;
78: if (preg_match($this->patern, $path)) {
79:
80: }
81: $this->stats_for_file($path . '/' . $entry, $label);
82: }
84: $dh->close();
85:
87: foreach ($this->subpaths as $path) {
89: $this->stats_for_dir($path, $label);
90: }
91: }
File: lib/support/statistics.php, #line 68
stats_for_file($path, $label)
97: public function stats_for_file($path, $label) {
98: if (is_dir($path)) {
99: $this->subpaths[] = $path;
100: } else {
101: $file = file($path);
102: foreach ($file as $line) {
103: if (preg_match($this->test_patern, $path)) {
104: $append_to_stats = 1;
105: }
106: elseif (preg_match($this->patern, $path)) {
107: $append_to_stats = 0;
108: }
109:
110: if (!preg_match($this->phptag_patern, trim($line))) {
111: $this->stats[$append_to_stats][$label]['Lines'] += 1;
112: }
113: if (!preg_match($this->code_patern, trim($line)) && trim($line) != '') {
114: $this->stats[$append_to_stats][$label]['LOC'] += 1;
115: }
116: if (preg_match($this->comment_patern, trim($line)) && trim($line) != '') {
117: $this->stats[$append_to_stats][$label]['COM'] += 1;
118: }
119: if (preg_match($this->method_patern, trim($line))) {
120: $this->stats[$append_to_stats][$label]['Methods'] += 1;
121: }
122: if (preg_match($this->class_patern, trim($line))) {
123: $this->stats[$append_to_stats][$label]['Classes'] += 1;
124: }
125: }
126: }
127: }
File: lib/support/statistics.php, #line 97
print_report()
134: public function print_report() {
135: echo "+--------------------+-------+-------+-------+---------+---------+-----+-------+n";
136: echo "| Name | Lines | LOC | COM | Classes | Methods | M/C | LOC/M |n";
137: echo "+--------------------+-------+-------+-------+---------+---------+-----+-------+n";
138:
139: foreach ($this->report as $name => $stats) {
140: $this->report_line($name, $stats);
141: }
142:
143: echo "+--------------------+-------+-------+-------+---------+---------+-----+-------+n";
144:
145: $this->report_line('Total', $this->sum_stats($this->report));
146:
147: echo "+--------------------+-------+-------+-------+---------+---------+-----+-------+n";
148:
149: $total_code = $this->sum_stats($this->total_code);
150: $total_test = $this->sum_stats($this->total_test);
151: $cotr = $total_test['LOC'] / $total_code['LOC'];
152:
153: echo "tCode LOC: " . $total_code['LOC'] .
154: "t Test LOC: " . $total_test['LOC'] .
155: "t Code to Test Ratio: 1:" . sprintf("%.1f", $cotr) . "n";
156: }
File: lib/support/statistics.php, #line 134
report_line($name, $stats)
163: public function report_line($name, $stats) {
164: $active_support = new ActiveSupport;
165: if ($stats['Classes'] != 0)
166: $stats['M/C'] = $stats['Methods'] / $stats['Classes'];
167: if ($stats['Methods'] != 0)
168: $stats['LOC/M'] = $stats['LOC'] / $stats['Methods'];
169:
170: echo "| " . $active_support->rjust($name, 18) . " " .
171: "| " . $active_support->ljust($stats['Lines'], 5) . " " .
172: "| " . $active_support->ljust($stats['LOC'], 5) . " " .
173: "| " . $active_support->ljust($stats['COM'], 5) . " " .
174: "| " . $active_support->ljust($stats['Classes'], 7) . " " .
175: "| " . $active_support->ljust($stats['Methods'], 7) . " " .
176: "| " . $active_support->ljust(floor($stats['M/C']), 3) . " " .
177: "| " . $active_support->ljust(floor($stats['LOC/M']), 5) . " |n";
178: }
File: lib/support/statistics.php, #line 163
sum_stats($stats)
186: public function sum_stats($stats) {
187: $sum = array ();
188: foreach ($this->labels as $label => $int) {
189: foreach ($stats as $name => $attr) {
190: $sum[$label] += $attr[$label];
191: }
192: }
193: return $sum;
194: }
File: lib/support/statistics.php, #line 186
