<?php $t = new \ebi\FlowHelper(); $str = "あいうえお12345かきくけこ"; eq("あいう", $t->trim_width($str, 7)); $t = new \ebi\FlowHelper(); $str = "あいうえお12345かきくけこ"; eq("あいう...", $t->trim_width($str, 7, "...")); $t = new \ebi\FlowHelper(); $str = "あいうえお12345かきくけこ"; eq("あいうえお123...", $t->trim_width($str, 13, "...")); $t = new \ebi\FlowHelper(); $str = "あいうえお12345かきくけこ"; eq("あいうえお12345かきくけこ", $t->trim_width($str, 50, "...")); $t = new \ebi\FlowHelper(); $str = "あいうえお12345かきくけこ"; eq("あいうえお12345かきくけこ", $t->trim_width($str, 30, "..."));
<?php $t = new \ebi\FlowHelper(); $time = time(); eq(date("YmdHis", $time), $t->date_format("YmdHis", $time));
<?php $t = new \ebi\FlowHelper(); eq("a bc d ef g ", $t->one_liner("a\nbc\r\n\r\n\n\rd<br>ef<br /><br />g<br>")); eq("abcdefg", $t->one_liner("a\nbc\r\n\r\n\n\rd<br>ef<br /><br />g<br>", "")); eq("a-bc----d-ef--g-", $t->one_liner("a\nbc\r\n\r\n\n\rd<br>ef<br /><br />g<br>", "-"));
<?php /** * \ebi\FlowHelper::build_url */ $t = new \ebi\FlowHelper(); eq('?A=1&B=2&C=3', $t->build_url(['A' => 1, 'B' => 2, 'C' => 3])); eq('http://localhost/abc?A=1&B=2&C=3', $t->build_url('http://localhost/abc', ['A' => 1, 'B' => 2, 'C' => 3])); eq('http://localhost/abc?hoge=1&A=1&B=2&C=3', $t->build_url('http://localhost/abc?hoge=1', ['A' => 1, 'B' => 2, 'C' => 3])); eq('http://localhost/abc?hoge=1&xyz=ABC&A=1&B=2&C=3', $t->build_url('http://localhost/abc?hoge=1&xyz=', 'ABC', ['A' => 1, 'B' => 2, 'C' => 3]));
<?php $t = new \ebi\FlowHelper(); eq('on', $t->cond_switch(true, 'on', 'off')); eq('off', $t->cond_switch(false, 'on', 'off')); eq('off', $t->cond_switch('', 'on', 'off')); eq('off', $t->cond_switch(0, 'on', 'off')); eq('off', $t->cond_switch(false, 'on', 'off')); eq('off', $t->cond_switch([], 'on', 'off')); eq('on', $t->cond_switch('1', 'on', 'off')); eq('on', $t->cond_switch(1, 'on', 'off')); eq('on', $t->cond_switch(true, 'on', 'off')); eq('on', $t->cond_switch(array(1), 'on', 'off'));
<?php $t = new \ebi\FlowHelper(); eq("123,456,789", $t->number_format("123456789")); eq("123,456,789.020", $t->number_format("123456789.02", 3)); eq("123,456,789", $t->number_format("123456789.02"));
<?php $t = new \ebi\FlowHelper(); eq("00005", $t->zerofill(5, 5)); eq("5", $t->zerofill(5));