コード例 #1
0
 public function testExec()
 {
     $file_name = __DIR__ . '/test_facade.txt';
     $result = FileFacade::create()->addColumn('', 'id', 0, 2, new FInt(true))->addColumn('', 'c1', 2, 3, new FDouble())->addColumn('', 'c2', 5, 10, new FNumberString())->addColumn('', 'c3', 15, 5, new FString())->addColumn('', 'c4', 20, 10, new FEmail())->addColumn('', 'c5', 30, 19, new FDateTime())->exec($file_name);
     $expected = array(array('id' => 11, 'c1' => 2.4, 'c2' => '5678912323', 'c3' => 'abcdz', 'c4' => '*****@*****.**', 'c5' => new DateTime('2014-03-23 14:23:32')), array('id' => 11, 'c1' => 2.4, 'c2' => '5678912323', 'c3' => 'abcdz', 'c4' => '*****@*****.**', 'c5' => new DateTime('2014-03-23 14:23:32')), array('id' => 11, 'c1' => 2.4, 'c2' => '5678912323', 'c3' => 'abcdz', 'c4' => '*****@*****.**', 'c5' => new DateTime('2014-03-23 14:23:32')));
     $this->assertEquals($expected, $result);
 }
コード例 #2
0
ファイル: teste.php プロジェクト: paliari/php-text-object
       $cgcm_id    = (int)substr($reg, 18, 10);
       $nomraz     = utf8_encode(strtoupper(strtr((trim((string)substr($reg, 28, 60))), "'", "`")));
       $tippessoa  = substr($reg, 88, 1);
       $nomrua     = strtr(trim(substr($reg, 89, 60)), "'", "`");
       $numero     = (trim(substr($reg, 149, 10)));
       $comple     = strtr((trim(substr($reg, 159, 40))), "'", "`");
       $nombai     = strtr((trim(substr($reg, 199, 60))), "'", "`");
       $cidadeNome = strtr((trim(substr($reg, 259, 60))), "'", "`");
       $vinculo    = utf8_encode((trim(substr($reg, 319, 30))));
       $principal  = substr($reg, 349, 1) == 'S' ? 1 : 0;
       $percentual = (double)substr($reg, 350, 10) / 1000;
       $cpfcgc     = trim(substr($reg, 360, 14));
       $cep        = preg_replace('/[^0-9]/', '', trim(substr($reg, 374, 8)));
       $cep        = $cep > 0 ? str_pad($cep, 8, '0', STR_PAD_LEFT) : '';
       $fonres     = preg_replace('/[^0-9]/', '', trim(substr($reg, 382, 14)));
       $fonres     = $fonres > 0 ? str_pad($fonres, 10, '0', STR_PAD_LEFT) : '';
       $foncom     = preg_replace('/[^0-9]/', '', trim(substr($reg, 396, 14)));
       $foncom     = $foncom > 0 ? str_pad($foncom, 10, '0', STR_PAD_LEFT) : '';
       $foncel     = preg_replace('/[^0-9]/', '', trim(substr($reg, 410, 14)));
       $foncel     = $foncel > 0 ? str_pad($foncel, 10, '0', STR_PAD_LEFT) : '';
       $unifed     = substr($reg, 424, 2);
       $rg         = (trim(substr($reg, 426, 20)));
       $orgemi     = (trim(substr($reg, 446, 20)));
       $tipvin     = (int)substr($reg, 466, 2);
       $email      = (trim(substr($reg, 468, 100)));
       $tiprua     = (trim(substr($reg, 568, 5)));
*/
$file_name = 'tmp/cadimo_20140912.txt';
$ff = FileFacade::create(1)->addColumn('C', 'typReg', 0, 1, Types::STRING, true)->addColumn('C', 'tipOpe', 1, 1, Types::STRING, true)->addColumn('C', 'tipins', 2, 2, Types::INT, true)->addColumn('C', 'insmun', 4, 15, Types::INT, true)->addColumn('C', 'cgcm_id', 19, 10, Types::INT, true)->addColumn('C', 'nomraz', 29, 60, Types::STRING, true)->addColumn('C', 'tippessoa', 89, 1, Types::STRING, false)->addColumn('C', 'cpfcgc', 90, 14, Types::NUMBER_STRING, false)->addColumn('C', 'distrito', 104, 2, Types::INT, false)->addColumn('C', 'zona', 106, 3, Types::NUMBER_STRING, false)->addColumn('C', 'quadra', 109, 15, Types::NUMBER_STRING, false)->addColumn('C', 'data', 124, 15, Types::NUMBER_STRING, false)->addColumn('C', 'complelote', 139, 50, Types::STRING, false)->addColumn('C', 'tiprua', 189, 10, Types::STRING, false)->addColumn('C', 'nomrua', 199, 60, Types::STRING, false)->addColumn('C', 'numero', 259, 10, Types::STRING, false)->addColumn('C', 'nombai', 269, 50, Types::STRING, false)->addColumn('C', 'cidade', 319, 60, Types::STRING, false)->addColumn('C', 'excluido', 379, 1, Types::BOOL, false)->addColumn('C', 'datalt', 380, 8, Types::DATE_TIME, array('format' => 'Ymd'))->addColumn('C', 'unifed', 388, 2, Types::STRING)->addColumn('C', 'areatotal', 390, 15, Types::INT_2_DOUBLE)->addColumn('C', 'areautil', 405, 15, Types::INT_2_DOUBLE)->addColumn('C', 'areaprivativa', 420, 15, Types::INT_2_DOUBLE)->addColumn('C', 'areacomum', 435, 15, Types::INT_2_DOUBLE)->addColumn('C', 'areaconstruida', 450, 15, Types::INT_2_DOUBLE)->addColumn('C', 'codcondominio', 465, 10, Types::INT)->addColumn('C', 'condominio', 475, 100, Types::STRING)->addColumn('C', 'tipimo', 575, 1, Types::STRING)->addColumn('C', 'patrimonio', 576, 3, Types::INT)->addColumn('C', 'areaverde', 579, 15, Types::INT_2_DOUBLE)->addColumn('S', 'typReg', 0, 1, Types::STRING, true)->addColumn('S', 'tipins', 1, 2, Types::INT, true)->addColumn('S', 'insmun', 3, 15, Types::INT, true)->addColumn('S', 'cgcm_id', 18, 10, Types::INT, true)->addColumn('S', 'nomraz', 28, 60, Types::STRING, true)->addColumn('S', 'tippessoa', 88, 1, Types::STRING, true)->addColumn('S', 'nomrua', 89, 60, Types::STRING, false)->addColumn('S', 'numero', 149, 10, Types::STRING, false)->addColumn('S', 'comple', 159, 40, Types::STRING, false)->addColumn('S', 'nombai', 199, 60, Types::STRING, false)->addColumn('S', 'cidadeNome', 259, 60, Types::STRING, false)->addColumn('S', 'vinculo', 319, 30, Types::STRING, false)->addColumn('S', 'principal', 349, 1, Types::BOOL, false)->addColumn('S', 'percentual', 350, 10, Types::INT_2_DOUBLE, array('divisor' => 1000))->addColumn('S', 'cpfcgc', 360, 14, Types::NUMBER_STRING, false)->addColumn('S', 'fonres', 374, 14, Types::NUMBER_STRING, false)->addColumn('S', 'foncom', 396, 14, Types::NUMBER_STRING, false)->addColumn('S', 'foncel', 410, 14, Types::NUMBER_STRING, false)->addColumn('S', 'unifed', 424, 2, Types::STRING, false)->addColumn('S', 'rg', 426, 20, Types::STRING, false)->addColumn('S', 'orgemi', 446, 20, Types::STRING, false)->addColumn('S', 'tipvin', 466, 2, Types::INT, false)->addColumn('S', 'email', 468, 100, Types::STRING, false)->addColumn('S', 'tiprua', 568, 5, Types::STRING, false);
$result = $ff->exec($file_name);
var_export($result);