factory() public static method

Static method to instantiate the data object and return itself to facilitate chaining methods together.
public static factory ( string $data ) : Data
$data string
return Data
コード例 #1
0
 /**
  * Export method
  *
  * @return void
  */
 public function export()
 {
     $user = new Model\User();
     $user->getExport($this->request->getPath(1), $this->request->getQuery('sort'), $this->request->getQuery('page'));
     if (isset($user->userRows[0])) {
         $userRows = $user->userRows;
         foreach ($userRows as $key => $value) {
             foreach ($value as $k => $v) {
                 if (is_array($v)) {
                     $userRows[$key]->{$k} = implode('|', $v);
                 }
             }
         }
         \Pop\Data\Data::factory($userRows)->writeData($_SERVER['HTTP_HOST'] . '_' . $user->userType . '_' . date('Y-m-d') . '.csv', true, true);
     } else {
         Response::redirect($this->request->getBasePath() . '/index/' . $this->request->getPath(1));
     }
 }
コード例 #2
0
ファイル: DataTest.php プロジェクト: nicksagona/PopPHP
 public function testWriteDataException()
 {
     $this->setExpectedException('Pop\\Data\\Exception');
     $ary = array(array('name' => 'Test1', 'email' => '*****@*****.**'), array('name' => 'Test2', 'email' => '*****@*****.**'));
     $d = Data::factory($ary)->writeData(__DIR__ . '/../tmp/datatest.txt');
 }