本文整理汇总了PHP中Khill\Lavacharts\Utils::nonEmptyString方法的典型用法代码示例。如果您正苦于以下问题:PHP Utils::nonEmptyString方法的具体用法?PHP Utils::nonEmptyString怎么用?PHP Utils::nonEmptyString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Khill\Lavacharts\Utils
的用法示例。
在下文中一共展示了Utils::nonEmptyString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: set
/**
* Sets the callback for an event.
*
* @access public
* @param string $event
* @param string $callback
* @throws \Khill\Lavacharts\Exceptions\InvalidEvent
* @throws \Khill\Lavacharts\Exceptions\InvalidEventCallback
*/
public function set($event, $callback)
{
$this->validEvent($event);
if (Utils::nonEmptyString($callback) === false) {
throw new InvalidEventCallback($callback);
}
$this->events[$event] = $callback;
}
示例2: __construct
/**
* Builds the Event object.
*
* @param string $c Name of Javascript callback function.
* @throws InvalidConfigValue
* @return Event
*/
public function __construct($c)
{
if (Utils::nonEmptyString($c)) {
$this->callback = $c;
} else {
throw new InvalidConfigValue('an Event', 'string');
}
}
示例3: __construct
/**
* Builds a new Filter Object.
*
* Takes either a column label or a column index to filter. The options object will be
* created internally, so no need to set defaults. The child filter objects will set them.
*
* @param string|int $columnLabelOrIndex
* @param array $config Array of options to set.
* @throws \Khill\Lavacharts\Exceptions\InvalidConfigValue
*/
public function __construct($columnLabelOrIndex, $config = [])
{
if (Utils::nonEmptyString($columnLabelOrIndex) === false && is_int($columnLabelOrIndex) === false) {
throw new InvalidConfigValue(static::TYPE . '->' . __FUNCTION__, 'string|int');
}
if (is_string($columnLabelOrIndex) === true) {
$config = array_merge($config, ['filterColumnLabel' => $columnLabelOrIndex]);
}
if (is_int($columnLabelOrIndex) === true) {
$config = array_merge($config, ['filterColumnIndex' => $columnLabelOrIndex]);
}
$this->options = new Options($config);
}
示例4: parseString
/**
* Parses a datetime string with or without a datetime format.
*
* Uses Carbon to create the values for the DateCell.
*
*
* @param string $dateTimeString
* @param string $dateTimeFormat
* @return \Khill\Lavacharts\DataTables\Cells\Cell
* @throws \Khill\Lavacharts\Exceptions\FailedCarbonParsing
* @throws \Khill\Lavacharts\Exceptions\InvalidDateTimeFormat
* @throws \Khill\Lavacharts\Exceptions\InvalidDateTimeString
*/
public static function parseString($dateTimeString, $dateTimeFormat = '')
{
if (Utils::nonEmptyString($dateTimeString) === false) {
throw new InvalidDateTimeString($dateTimeString);
}
if (gettype($dateTimeFormat) != 'string') {
throw new InvalidDateTimeFormat($dateTimeFormat);
}
if (Utils::nonEmptyString($dateTimeFormat) === false) {
$carbon = Carbon::parse($dateTimeString);
} else {
$carbon = Carbon::createFromFormat($dateTimeFormat, $dateTimeString);
}
return new DateCell($carbon);
}
示例5: checkChart
/**
* Simple true/false test if a chart exists.
*
* @param string $type Type of chart to store.
* @param string $label Identifying label of a chart to check.
*
* @return bool
*/
public function checkChart($type, $label)
{
if (Utils::nonEmptyString($type) && Utils::nonEmptyString($label)) {
if (array_key_exists($type, $this->charts)) {
if (array_key_exists($label, $this->charts[$type])) {
return true;
} else {
return false;
}
} else {
return false;
}
} else {
return false;
}
}
示例6: create
/**
* Creates a new column object.
*
* @access public
* @since 3.0.0
* @param string $type Type of column to create.
* @param string $label A label for the column.
* @param \Khill\Lavacharts\DataTables\Formats\Format $format Column formatter for the data.
* @param string $role A role for the column to play.
* @return \Khill\Lavacharts\DataTables\Columns\Column
* @throws \Khill\Lavacharts\Exceptions\InvalidColumnRole
* @throws \Khill\Lavacharts\Exceptions\InvalidColumnType
*/
public static function create($type, $label = '', Format $format = null, $role = '')
{
if (Utils::nonEmptyStringInArray($type, self::$TYPES) === false) {
throw new InvalidColumnType($type, self::$TYPES);
}
$columnArgs = [$type];
if (Utils::nonEmptyString($label) === true) {
$columnArgs[] = $label;
} else {
$columnArgs[] = '';
}
if ($format !== null) {
$columnArgs[] = $format;
} else {
$columnArgs[] = null;
}
if (is_string($role) === false || $role != '' && in_array($role, self::$ROLES, true) === false) {
throw new InvalidColumnRole($role, self::$ROLES);
}
$columnArgs[] = $role;
$column = new \ReflectionClass('\\Khill\\Lavacharts\\DataTables\\Columns\\Column');
return $column->newInstanceArgs($columnArgs);
}
示例7: getChartJs
/**
* Checks the Chart for DataTable and builds the Javascript code block
*
* Build the script block for the actual chart and passes it back to
* output function of the calling chart object. If there are any
* events defined, they will be automatically be attached to the chart and
* pulled from the callbacks folder.
*
* @access public
*
* @uses Chart
* @param Chart $chart Chart object to render.
* @param string $elementId HTML element id to output the chart into.
* @throws DataTableNotFound
* @throws InvalidElementId
*
* @return string Javascript code block.
*/
public function getChartJs(Chart $chart, $elementId = null)
{
if (isset($chart->datatable) === false) {
throw new DataTableNotFound($chart);
}
if (Utils::nonEmptyString($elementId) === false) {
throw new InvalidElementId($elementId);
}
$this->chart = $chart;
$this->elementId = $elementId;
return $this->buildChartJs();
}
示例8: checkChart
/**
* Simple true/false test if a chart exists.
*
* @param string $type Type of chart to check.
* @param \Khill\Lavacharts\Values\Label $label Identifying label of a chart to check.
* @return boolean
*/
public function checkChart($type, Label $label)
{
if (Utils::nonEmptyString($type) === false) {
return false;
}
if (array_key_exists($type, $this->charts) === false) {
return false;
}
return array_key_exists((string) $label, $this->charts[$type]);
}
示例9: jsonSerialize
/**
* Custom json serialization of the column.
*
* @access public
* @return array
*/
public function jsonSerialize()
{
$values = ['type' => $this->type];
if (Utils::nonEmptyString($this->label) === true) {
$values['label'] = $this->label;
}
if (Utils::nonEmptyString($this->role) === true) {
$values['p'] = ['role' => $this->role];
}
return $values;
}
示例10: viewWindowMode
/**
* Specifies how to scale the axis to render the values within
* the chart area. The following string values are supported:
*
* 'pretty' - Scale the values so that the maximum and minimum
* data values are rendered a bit inside the left and right of the chart area.
* 'maximized' - Scale the values so that the maximum and minimum
* data values touch the left and right of the chart area.
* 'explicit' - Specify the left and right scale values of the chart area.
* Data values outside these values will be cropped. You must specify an
* axis.viewWindow array describing the maximum and minimum values to show.
*
* This option is only supported for a continuous axis.
*
* @param string $viewMode
* @throws InvalidConfigValue
* @return Axis
*/
public function viewWindowMode($viewMode)
{
$values = array('pretty', 'maximized', 'explicit');
if (Utils::nonEmptyString($viewMode) && in_array($viewMode, $values)) {
$this->viewWindowMode = $viewMode;
} else {
throw $this->invalidConfigValue(__FUNCTION__, 'string', 'with a value of ' . Utils::arrayToPipedString($values));
}
return $this;
}
示例11: testWithBadTypes
/**
* @dataProvider nonStringProvider
*/
public function testWithBadTypes($badTypes)
{
$this->assertFalse(Utils::nonEmptyString($badTypes));
}
示例12: setStringOption
/**
* Sets the value of a string option.
*
* @param string $option Option to set.
* @param string $value Value of the option.
* @return \Khill\Lavacharts\JsonConfig
* @throws \Khill\Lavacharts\Exceptions\InvalidConfigValue
* @throws \Khill\Lavacharts\Exceptions\InvalidOption
*/
protected function setStringOption($option, $value)
{
if (Utils::nonEmptyString($value) === false) {
throw new InvalidConfigValue(static::TYPE . '->' . $option, 'string');
}
$this->options->set($option, $value);
return $this;
}
示例13: parseDate
/**
* Either passes the Carbon instance or parses a datetime string.
*
* @param Carbon|string $date
* @return string Javscript date declaration
*/
private function parseDate($date)
{
if (is_a($date, 'Carbon\\Carbon')) {
$carbonDate = $date;
} elseif (Utils::nonEmptyString($date)) {
try {
if (Utils::nonEmptyString($this->dateTimeFormat)) {
$carbonDate = Carbon::createFromFormat($this->dateTimeFormat, $date);
} else {
$carbonDate = Carbon::parse($date);
}
} catch (\Exception $e) {
throw new InvalidDate();
}
} else {
throw new InvalidDate();
}
return $this->carbonToJsString($carbonDate);
//return $carbonDate->toIso8601String();
}
示例14: get
/**
* Get the value of a set option.
*
* @access public
* @param string $option Name of option.
* @return mixed
* @throws \Khill\Lavacharts\Exceptions\InvalidOption
*/
public function get($option)
{
if (Utils::nonEmptyString($option) === false) {
throw new InvalidOption($option, $this->options);
}
if (array_key_exists($option, $this->values) === false) {
return null;
} else {
return $this->values[$option];
}
}
示例15: suffix
/**
* Sets the string suffix for the value.
*
* @param string $s
* @throws InvalidConfigValue
* @return NumberFormat
*/
public function suffix($s)
{
if (Utils::nonEmptyString($s)) {
$this->suffix = $s;
} else {
throw new InvalidConfigValue(__FUNCTION__, 'string');
}
return $this;
}