for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Data;
class CSVDataTable extends DataTable
{
/**
* @param string $file The csv file
*/
public function __construct($file)
$this->data = array_map('str_getcsv', file($file));
data
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
class MyClass { } $x = new MyClass(); $x->foo = true;
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:
class MyClass { public $foo; } $x = new MyClass(); $x->foo = true;
$titles = array_shift($this->data);
$count = count($this->data);
for($i = 0; $i < $count; $i++)
$this->data[$i] = array_combine($titles, $this->data[$i]);
}
public function count($filter = false)
if($filter)
$res = $this->data;
$res = $filter->filter_array($res);
filter_array
$filter
boolean
Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.
return count($res);
return count($this->data);
public function read($filter = false, $select = false, $count = false, $skip = false, $sort = false, $params = false)
if($filter !== false)
return $res;
public function create($data)
throw new \Exception('CSVDataTable is read only');
public function update($filter, $data)
public function delete($filter)
/* vim: set tabstop=4 shiftwidth=4 expandtab: */
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: