Permalink
Browse files

Modyllic_CodeBody -> Modyllic_Schema_CodeBody

  • Loading branch information...
1 parent 789554e commit 93704cc7bd8d34c1bdc2fb016d0a5b72fd25ac70 @iarna committed Apr 24, 2012
Showing with 39 additions and 31 deletions.
  1. +4 −31 Modyllic/Schema.php
  2. +35 −0 Modyllic/Schema/CodeBody.php
View
@@ -12,6 +12,7 @@
// Components
require_once "Modyllic/Schema/View.php";
require_once "Modyllic/Schema/Table.php";
+require_once "Modyllic/Schema/CodeBody.php";
/**
* A base class for various schema objects. Handles generic things like
@@ -220,38 +221,10 @@ function equal_to( $other ) {
}
-class Modyllic_CodeBody extends Modyllic_Diffable {
- public $body = "BEGIN\nEND";
- /**
- * @returns string Strips any comments from the body of the routine--
- * this allows the body to be compared to the one in the database,
- * which never has comments.
- */
- function _body_no_comments() {
- $stripped = $this->body;
- # Strip C style comments
- $stripped = preg_replace('{/[*].*?[*]/}s', '', $stripped);
- # Strip shell and SQL style comments
- $stripped = preg_replace('/(#|--).*/', '', $stripped);
- # Strip leading and trailing whitespace
- $stripped = preg_replace('/^[ \t]+|[ \t]+$/m', '', $stripped);
- # Collapse repeated newlines
- $stripped = preg_replace('/\n+/', "\n", $stripped);
- return $stripped;
- }
-
- function equal_to($other) {
- if ( get_class($other) != get_class($this) ) { return false; }
- if ( $this->_body_no_comments() != $other->_body_no_comments() ) { return false; }
- return true;
- }
-
-}
-
/**
* A collection of attributes describing an event
*/
-class Modyllic_Event extends Modyllic_CodeBody {
+class Modyllic_Event extends Modyllic_Schema_CodeBody {
public $name;
public $schedule;
public $preserve = false;
@@ -277,7 +250,7 @@ function equal_to($other) {
/**
* A collection of attributes describing an event
*/
-class Modyllic_Trigger extends Modyllic_CodeBody {
+class Modyllic_Trigger extends Modyllic_Schema_CodeBody {
public $name;
public $time;
public $event;
@@ -304,7 +277,7 @@ function equal_to($other) {
/**
* A collection of attributes describing a stored routine
*/
-class Modyllic_Routine extends Modyllic_CodeBody {
+class Modyllic_Routine extends Modyllic_Schema_CodeBody {
public $name;
public $args = array();
const ARGS_TYPE_DEFAULT = "LIST";
@@ -0,0 +1,35 @@
+<?php
+/**
+ * Copyright © 2012 Online Buddies, Inc. - All Rights Reserved
+ *
+ * @package Modyllic
+ * @author bturner@online-buddies.com
+ */
+
+class Modyllic_Schema_CodeBody extends Modyllic_Diffable {
+ public $body = "BEGIN\nEND";
+ /**
+ * @returns string Strips any comments from the body of the routine--
+ * this allows the body to be compared to the one in the database,
+ * which never has comments.
+ */
+ function _body_no_comments() {
+ $stripped = $this->body;
+ # Strip C style comments
+ $stripped = preg_replace('{/[*].*?[*]/}s', '', $stripped);
+ # Strip shell and SQL style comments
+ $stripped = preg_replace('/(#|--).*/', '', $stripped);
+ # Strip leading and trailing whitespace
+ $stripped = preg_replace('/^[ \t]+|[ \t]+$/m', '', $stripped);
+ # Collapse repeated newlines
+ $stripped = preg_replace('/\n+/', "\n", $stripped);
+ return $stripped;
+ }
+
+ function equal_to($other) {
+ if ( get_class($other) != get_class($this) ) { return false; }
+ if ( $this->_body_no_comments() != $other->_body_no_comments() ) { return false; }
+ return true;
+ }
+
+}

0 comments on commit 93704cc

Please sign in to comment.