Workhours
extends DataType
in package
implements
Complex
Weekly workhours grouped by weekday.
Legacy ma_daten.v_az_* semantics from master:
- values
> 0mean a configured working day with hours - value
0means a configured working day without hours - values
< 0mean the weekday is disabled and should be treated as absent
Tags
Table of Contents
Interfaces
- Complex
- A ValueObject that has a complex Value such as Date or Money which cannot be represented directly as a string and is thus returned from a DomainObject as is
Constants
- DISABLED_DAY : mixed = -1.0
- EMPTY_DAY : mixed = 0.0
Properties
- $value : mixed
Methods
- __construct() : mixed
- The constructor is normally called from the DomainObject when instatiated.
- __toString() : string
- Make sure to overwrite this method in the implementations
- defaultValidators() : array<string|int, mixed>
- Overwrite this message if a DataType needs validation methods that are always applied
- equals() : mixed
- Compares the internal value with the $compare argument
- fromWorkhours() : self
- Creates a Workhours value object from raw workhours input.
- ifExists() : callable
- in() : mixed
- Stores the weekly workhours and converts every day value to Decimal.
- isComplex() : bool
- Marks workhours as a complex value object.
- isConfiguredOn() : bool
- Returns whether the weekday is configured at all.
- isConfiguredValue() : bool
- Returns whether a raw workhours value represents a configured weekday.
- isDisabledDay() : bool
- Returns whether the weekday is explicitly disabled.
- isEmptyDay() : bool
- Returns whether the weekday is configured without explicit hours.
- isWorkedDay() : bool
- Returns whether the weekday is configured with explicit hours.
- length() : callable
- maxLength() : callable
- minLength() : callable
- notBlank() : callable
- NotBlank
- notNull() : callable
- NotNull
- on() : Decimal
- Returns the workhours configured for one weekday.
- oneOf() : callable
- out() : array<string|int, mixed>
- Returns the stored workhours in scalar form, grouped by weekday.
- required() : callable
- unique() : callable
- not implemented - remove?
- value() : array<string|int, mixed>
- Returns the stored weekday to Decimal map.
- weekdays() : array<string|int, mixed>
- Returns the supported weekday identifiers for workhours.
Constants
DISABLED_DAY
public
mixed
DISABLED_DAY
= -1.0
EMPTY_DAY
public
mixed
EMPTY_DAY
= 0.0
Properties
$value
protected
mixed
$value
The internal value of the DataType
Methods
__construct()
The constructor is normally called from the DomainObject when instatiated.
public
__construct([mixde $value = null ]) : mixed
Parameters
- $value : mixde = null
__toString()
Make sure to overwrite this method in the implementations
public
__toString() : string
Return values
string —The string representation of the DataType
defaultValidators()
Overwrite this message if a DataType needs validation methods that are always applied
public
static defaultValidators() : array<string|int, mixed>
Return values
array<string|int, mixed>equals()
Compares the internal value with the $compare argument
public
equals(DataType|mixed $compare) : mixed
Remember that you get a DomainObject when using the DomainObjects values, thus comparison can have
undesired results, use the equals method to compare ValueObjects
This has to be overwritten in the descendants to get the desired comparison behaviour
Parameters
- $compare : DataType|mixed
-
The value to be compared
fromWorkhours()
Creates a Workhours value object from raw workhours input.
public
static fromWorkhours(array<string|int, mixed> $workhours) : self
Parameters
- $workhours : array<string|int, mixed>
Return values
selfifExists()
public
static ifExists(callable $test) : callable
Parameters
- $test : callable
Return values
callable —Returns a predicate that tests a value using $test if it exists.
in()
Stores the weekly workhours and converts every day value to Decimal.
public
in(mixed $value) : mixed
Parameters
- $value : mixed
isComplex()
Marks workhours as a complex value object.
public
isComplex() : bool
Return values
boolisConfiguredOn()
Returns whether the weekday is configured at all.
public
isConfiguredOn(string $weekday) : bool
Parameters
- $weekday : string
Return values
boolisConfiguredValue()
Returns whether a raw workhours value represents a configured weekday.
public
static isConfiguredValue(mixed $hours) : bool
This helper exists for mapper-level checks before a Workhours object is created.
Parameters
- $hours : mixed
Return values
boolisDisabledDay()
Returns whether the weekday is explicitly disabled.
public
isDisabledDay(string $weekday) : bool
Parameters
- $weekday : string
Return values
boolisEmptyDay()
Returns whether the weekday is configured without explicit hours.
public
isEmptyDay(string $weekday) : bool
Parameters
- $weekday : string
Return values
boolisWorkedDay()
Returns whether the weekday is configured with explicit hours.
public
isWorkedDay(string $weekday) : bool
Parameters
- $weekday : string
Return values
boollength()
public
static length(int $n) : callable
Parameters
- $n : int
Return values
callable —Returns a predicate that tests if its argument is of length $n.
maxLength()
public
static maxLength(int $n) : callable
Parameters
- $n : int
Return values
callable —Returns a predicate that tests if its argument is of length $n or less.
minLength()
public
static minLength(int $n) : callable
Parameters
- $n : int
Return values
callable —Returns a predicate that tests if its argument is of length $n or greater.
notBlank()
NotBlank
public
static notBlank() : callable
Return values
callablenotNull()
NotNull
public
static notNull() : callable
Return values
callableon()
Returns the workhours configured for one weekday.
public
on(string $weekday) : Decimal
Parameters
- $weekday : string
Return values
DecimaloneOf()
public
static oneOf(mixed $lst) : callable
Parameters
- $lst : mixed
Return values
callable —Returns a predicate that test if it's argument is one of several elements.
out()
Returns the stored workhours in scalar form, grouped by weekday.
public
out() : array<string|int, mixed>
Return values
array<string|int, mixed>required()
public
static required() : callable
Return values
callable —Returns a predicate that tests for the existence of it's argument.
unique()
not implemented - remove?
public
static unique() : callable
Return values
callable —Returns a predicate that tests if it's argument is unique in it's environment.
value()
Returns the stored weekday to Decimal map.
public
value() : array<string|int, mixed>
Return values
array<string|int, mixed>weekdays()
Returns the supported weekday identifiers for workhours.
public
static weekdays() : array<string|int, mixed>