/** * @test * @dataProvider dataArrToString * * @param string $expected * @param array $array * @param string $separator * @param string $prefix * @param string $suffix */ public function testToString($expected, array $array, $separator = ' ', $prefix = '', $suffix = '') { // WHEN $actual = Arr::toString($array, $separator, $prefix, $suffix); //THEN $this->assertEquals($expected, $actual); }
public function testToString() { $datas = [[[], ''], [['1'], '1'], [['1', '2'], '1 2']]; foreach ($datas as $data) { $this->assertEquals($data[1], \Ark4ne\Support\Arr::toString($data[0])); } }
/** * @return string * @throws \Ark4ne\Processes\Exception\OSUnknownException */ private function optsToString() { $options = ''; if (count($this->options)) { $opts = []; foreach ($this->options as $key => $opt) { if (is_null($opt)) { $opts[] = $key; } else { $opts[] = $key . '="' . Manager::os()->escapeQuoteCli(Str::fromVar($opt)) . '"'; } } $options = trim(Arr::toString($opts, ' --', '--')); } return $options; }