Pop\Data\Data::parseData PHP Méthode

parseData() public méthode

Parse the data stream and return a file data stream.
public parseData ( string $to, array $options = null ) : mixed
$to string
$options array
Résultat mixed
    public function parseData($to, array $options = null)
    {
        $to = strtolower($to);
        $types = array('csv', 'html', 'json', 'sql', 'xml', 'yaml');
        if (!in_array($to, $types)) {
            throw new Exception('That data type is not supported.');
        }
        $class = 'Pop\\Data\\Type\\' . ucfirst($to);
        if ($to == 'sql') {
            $this->file = $class::encode($this->data, $this->table, $this->idQuote);
        } else {
            if ($to == 'xml') {
                $this->file = $class::encode($this->data, $this->table, $this->pma);
            } else {
                if ($to == 'html') {
                    $this->file = $class::encode($this->data, $options);
                } else {
                    $this->file = $class::encode($this->data);
                }
            }
        }
        return $this->file;
    }

Usage Example

Exemple #1
0
 public function testParseData()
 {
     $ary = array(array('name' => 'Test1', 'email' => '*****@*****.**'), array('name' => 'Test2', 'email' => '*****@*****.**'));
     $d = new Data($ary);
     $d->setTable('users')->setIdQuote('`');
     $this->assertContains('INSERT INTO `users` (`name`, `email`) VALUES', $d->parseData('sql'));
     $this->assertContains('<name>Test1</name>', $d->parseData('xml'));
     $this->assertContains('Test1,[email protected]', $d->parseData('csv'));
 }
All Usage Examples Of Pop\Data\Data::parseData