public function testExplode() { $explode = _String::explode('.'); $data = 'a.b.c'; $this->assertInstanceOf(StringExplode::class, $explode); $this->assertInstanceOf(AbstractArray::class, $explode); $this->assertEquals(['a', 'b', 'c'], $explode($data)); }
/** * @param string $delimiter * @return CollectionNodeInterface */ public function explode(string $delimiter) { return $this->then(_String::explode($delimiter)); }
public function testExplode() { $before = _String::explode('.'); $this->assertEquals($before('a.b')[0], 'a'); $this->assertEquals($before('a.b')[1], 'b'); }
<?php use Hurl\Node\Statics\_Array; use Hurl\Node\Statics\_Comparator; use Hurl\Node\Statics\_Node; use Hurl\Node\Statics\_String; require_once __DIR__ . '/vendor/autoload.php'; $fromHex = _Node::init(function ($data) { return hexdec($data); }); var_dump($fromHex('a')); //int(10) $explode = _String::explode('.'); var_dump($explode('a.b')); $chain = $explode->implode('-'); var_dump($chain('a.b')); $map = $explode->map($fromHex)->implode('.'); var_dump($map('a.b')); $sort = _Array::sort(function ($a, $b) { return $a - $b; }); var_dump($sort([2, 5, 3, 4, 1])); //array(5) { // [0]=> // int(1) // [1]=> // int(2) // [2]=> // int(3) // [3]=> // int(4)