Created
April 5, 2011 03:44
-
-
Save danilo04/902981 to your computer and use it in GitHub Desktop.
Par
parser
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
<?php | |
class RelojEntry { | |
protected $numReloj; | |
protected $userId; | |
protected $date; | |
public function __set($name, $value) { | |
$this->$name = $value; | |
} | |
public function __get($name) { | |
return $this->$name; | |
} | |
} | |
class Reloj extends AppModel { | |
public $useTable = null; | |
protected $_contentRows = null; | |
protected $_entries = array(); | |
public function loadFile($path) { | |
if (!file_exists($path)) { | |
return false; | |
} | |
$this->_contentRows = file($path); | |
} | |
public function getContentRows() { | |
return $this->_contentRows; | |
} | |
public function parseEntries() { | |
foreach ($this->getContentRows() as $row) { | |
$entry = new RelojEntry(); | |
$columns = explode(",", $row); | |
$entry->numReloj = trim($columns[0]); | |
$entry->userId = trim($columns[3]); | |
$entry->date = trim($columns[9]) . '-' . trim($columns[8]) . '-' trim($columns[7]) . ' ' . | |
trim($columns[5]) . ':' . trim($columns[6]) . ':00'; | |
$this->_entrys[] = $entry; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment