public static function getBWDisplayValue($value) { $bits = []; for ($i = 1; $i <= $value; $i = $i * 2) { if ($i & $value) { $bits[] = static::getDisplayValue($i); } } return Arrays::toList($bits); }
public function getDescription() { $policy = $this->_dataNodeLink('policy', null, 'Traffic Blocking Policy'); $return = 'Affiliate ' . $policy; if ($this->policy->resource) { $return .= ' for ' . $this->_dataNodeLink('policy', 'resource'); } // Extras $extras = []; if ($this->redirectUrl) { $extras[] = ' a redirect URL of "' . $this->redirectUrl . '"'; } if ($this->blockMessage) { $extras[] = ' a message of "' . $this->blockMessage . '"'; } if ($extras) { $return .= ' with ' . Arrays::toList($extras, ', ', ' and '); } return $return . ' was created'; }
/** * Similar to the standard implode method, but allowing the last item to be * stuck with a separate glue e.g. apple , pear & grape * * @param array $pieces * @param string $glue * @param string $finalGlue * * @return string * * @deprecated */ function implode_list(array $pieces = [], $glue = ' , ', $finalGlue = ' & ') { return \Packaged\Helpers\Arrays::toList($pieces, $glue, $finalGlue); }
public function testToList() { $expectations = [[[1, 2, 3, 4, 5], ",", "&", "1,2,3,4&5"], [[1, 2], ",", "&", "1&2"], [[1], ",", "&", "1"]]; foreach ($expectations as $expect) { $this->assertEquals($expect[3], Arrays::toList($expect[0], $expect[1], $expect[2])); } }
public function getDescription() { $desc = 'Remaining Balance'; if ($this->runDate) { if ($this->dueStartDate < 1 || $this->commissionsCount == 0) { $reasons = []; if ($this->credits > 0) { $reasons[] = 'Account Adjustment'; } if ($this->reserves > 0) { $reasons[] = 'Reserve Payment'; } $desc = Arrays::toList($reasons); } else { $desc = date('jS M Y', $this->dueStartDate) . ' - ' . date('jS M Y', $this->dueEndDate); } } return $desc; }