/usr/share/php/propel/parser/PropelParser.php is in php-propel-runtime 1.6.9-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 | <?php
/**
* This file is part of the Propel package.
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @license MIT License
*/
/**
* Base class for all parsers. A parser converts data from and to an associative array.
*
* @author Francois Zaninotto (Propel)
* @author Jonathan H. Wage <jwage@mac.com> (Doctrine_Parser)
* @package propel.runtime.parser
*/
abstract class PropelParser
{
/**
* Converts data from an associative array to the parser format.
*
* Override in the parser driver.
*
* @param array $array Source data to convert
* @return mixed Converted data, depending on the parser format
*/
abstract public function fromArray($array);
/**
* Converts data from the parser format to an associative array.
*
* Override in the parser driver.
*
* @param mixed $data Source data to convert, depending on the parser format
* @return array Converted data
*/
abstract public function toArray($data);
public function listFromArray($data)
{
return $this->fromArray($data);
}
public function listToArray($data)
{
return $this->toArray($data);
}
/**
* Loads data from a file. Executes PHP code blocks in the file.
*
* @param string $path Path to the file to load
*
* @return string The file content processed by PHP
*
* @throws PropelException
*/
public function load($path)
{
if (!file_exists($path)) {
throw new PropelException(sprintf('File "%s" does not exist or is unreadable', $path));
}
ob_start();
include($path);
$contents = ob_get_clean();
return $contents;
}
/**
* Dumps data to a file, or to STDOUT if no filename is given
*
* @param string $data The file content
* @param string $path Path of the file to create
*
* @return int|null If path given, the written bytes, null otherwise.
*/
public function dump($data, $path = null)
{
if ($path !== null) {
return file_put_contents($path, $data);
} else {
echo $data;
}
}
/**
* Factory for getting an instance of a subclass of PropelParser
*
* @param string $type Parser type, amon 'XML', 'YAML', 'JSON', and 'CSV'
*
* @return PropelParser A PropelParser subclass instance
*
* @throws PropelException
*/
public static function getParser($type = 'XML')
{
$class = sprintf('Propel%sParser', $type);
if (!class_exists($class)) {
throw new PropelException(sprintf('Unknown parser class "%s"', $class));
}
return new $class;
}
}
|