Commit: ebc6aad6a710937df3dca6d56c7d85d5426c7aaf
Author: David Persson | Date: 2009-12-03 12:21:00 +0100
diff --git a/config/phpca_lithium_standard.ini b/config/phpca_lithium_standard.ini
index aa0b3db..3dfaf07 100644
--- a/config/phpca_lithium_standard.ini
+++ b/config/phpca_lithium_standard.ini
@@ -25,6 +25,7 @@ additional_rules= extensions/phpca/Rule
[NoAlternativeSyntaxStatementsRule]
[NoShutupOperatorsRule]
; [MethodsMustHaveVisibilityOperatorRule]
+[OneClassPerFileRule]
[MaximumLineLengthRule]
line_length = 100
diff --git a/extensions/phpca/Rule/OneClassPerFileRule.php b/extensions/phpca/Rule/OneClassPerFileRule.php
new file mode 100644
index 0000000..b8b28d3
--- /dev/null
+++ b/extensions/phpca/Rule/OneClassPerFileRule.php
@@ -0,0 +1,32 @@
+<?php
+
+namespace spriebsch\PHPca\Rule;
+
+/**
+ * Ensures there is only one class declared per file.
+ */
+class OneClassPerFileRule extends Rule
+{
+ /**
+ * Performs the rule check.
+ *
+ * @returns null
+ */
+ protected function doCheck()
+ {
+ $count = 0;
+
+ while ($this->file->seekTokenId(T_CLASS)) {
+ $count++;
+ $token = $this->file->current();
+
+ if ($count > 1) {
+ $this->addViolation('More than one class declared in file', $token);
+ }
+
+ $this->file->seekToken($token);
+ $this->file->next();
+ }
+ }
+}
+?>
\ No newline at end of file