Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Making some changes - wanted one last commit before full changes
- Loading branch information
Showing
4 changed files
with
128 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?PHP | ||
|
||
interface PluginBsdImporterInterface | ||
{ | ||
|
||
protected $requiredHeaders = array(); | ||
|
||
public function setHeaders(); | ||
|
||
public function getHeaders(); | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,103 @@ | ||
<?PHP | ||
|
||
interface PluginBsdImporter { | ||
|
||
abstract PluginBsdImporter implements PluginBsdImporterInterface | ||
{ | ||
|
||
protected $requiredHeaders = array(); | ||
protected $requiredFields = array(); | ||
|
||
/** | ||
* | ||
* @param array $headers | ||
*/ | ||
public function setHeaders(array $headers) | ||
{ | ||
$this->requiredHeaders = $headers; | ||
} | ||
|
||
public function getHeaders() | ||
{ | ||
return $this->requiredHeaders; | ||
} | ||
|
||
/** | ||
* | ||
* hooray for magic!! | ||
* | ||
* @param string $method | ||
* @param mixed $arguments | ||
* @return mixed | ||
*/ | ||
public function __call($method, $arguments) | ||
{ | ||
try { | ||
$verb = substr($method, 0, 3); | ||
if (in_array($verb, array('set', 'get'))) { | ||
$name = substr($method, 3); | ||
} | ||
|
||
if (method_exists($this, $verb)) { | ||
if (property_exists($this, $name)) { | ||
return call_user_func_array(array($this, $verb), array_merge(array($name), $arguments)); | ||
} elseif (property_exists($this, lcfirst($name))) { | ||
return call_user_func_array(array($this, $verb), array_merge(array(lcfirst($name)), $arguments)); | ||
} else { | ||
throw new Exception("Variable ($name) Not Found"); | ||
} | ||
} else { | ||
throw new Exception("Function ($verb) Not Defined"); | ||
} | ||
} catch (Exception $e) { | ||
printf("You done yucked up!"); | ||
var_dump($e); | ||
} | ||
} | ||
|
||
/** | ||
* | ||
* standard getter | ||
* | ||
* @param string $fieldName | ||
* @return mixed | ||
*/ | ||
public function get($fieldName) | ||
{ | ||
if (!property_exists($this, $fieldName)) { | ||
trigger_error("Variable ($fieldName) Not Found", E_USER_ERROR); | ||
} | ||
|
||
return $this->$fieldName; | ||
} | ||
|
||
/** | ||
* standard setter | ||
* | ||
* @param string $fieldName | ||
* @param mixed $value | ||
* @return boolean | ||
*/ | ||
public function set($fieldName, $value) | ||
{ | ||
if (!property_exists($this, $fieldName)) { | ||
trigger_error("Variable ($fieldName) Not Found", E_USER_ERROR); | ||
} | ||
|
||
public function setHeaders() { } | ||
$this->$fieldName = $value; | ||
return true; | ||
} | ||
|
||
public function getHeaders() { } | ||
/** | ||
* | ||
* For some reason there is no lcfirst function but there | ||
* is a ucfirst... oh well that's fixed. :) | ||
* | ||
* @param string $string | ||
* @return string | ||
*/ | ||
public function lcfirst($string) | ||
{ | ||
$string{0} = strtolower($string{0}); | ||
return $string; | ||
} | ||
|
||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,5 @@ | ||
<?PHP | ||
|
||
abstract class PluginBsdImporterCsv implements PluginBsdImporter | ||
class PluginBsdImporterCsv extends PluginBsdImporter | ||
{ | ||
protected $requiredHeaders = array(); | ||
|
||
/** | ||
* | ||
* @param array $headers | ||
*/ | ||
public function setHeaders(array $headers) | ||
{ | ||
$this->requiredHeaders = $headers; | ||
} | ||
|
||
public function getHeaders() | ||
{ | ||
return $this->requiredHeaders; | ||
} | ||
|
||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters