/** * @param string $email * @param DateTime $validity * @return Invitation */ public function __construct($email, DateTime $validity) { $this->row = \LeanMapper\Result::createDetachedInstance()->getRow(); $this->setEmail($email); $this->setValidity($validity); $this->generateToken(); }
/** * @param Row|Traversable|array|null $arg * @throws InvalidArgumentException */ public function __construct($arg = null) { if ($arg instanceof Row) { if ($arg->isDetached()) { throw new InvalidArgumentException('It is not allowed to create entity ' . get_called_class() . ' from detached instance of LeanMapper\\Row.'); } $this->row = $arg; $this->mapper = $arg->getMapper(); } else { $this->row = Result::createDetachedInstance()->getRow(); foreach ($this->getCurrentReflection()->getEntityProperties() as $property) { if ($property->hasDefaultValue()) { $propertyName = $property->getName(); $this->set($propertyName, $property->getDefaultValue()); } } $this->initDefaults(); if ($arg !== null) { if (!is_array($arg) and !$arg instanceof Traversable) { $type = gettype($arg) !== 'object' ? gettype($arg) : 'instance of ' . get_class($arg); throw new InvalidArgumentException("Argument \$arg in " . get_called_class() . "::__construct must contain either null, array, instance of LeanMapper\\Row or instance of Traversable, {$type} given."); } $this->assign($arg); } } }
/** * @param int $year * @param int $month * @param User|int $user * @param string|null $description * @param string|null $hourlyWage * @return Listing */ public function __construct($year, $month, $user, $description = null, $hourlyWage = null) { $this->row = \LeanMapper\Result::createDetachedInstance()->getRow(); $this->setListingPeriod($year, $month); $this->setUser($user); $this->setDescription($description); $this->setHourlyWage($hourlyWage); }
/** * @param int $day * @param Listing $listing * @param WorkedHours $workedHours * @param Locality $locality * @param string|null $description * @param string|null $descOtherHours * @return ListingItem */ public function __construct($day, Listing $listing, WorkedHours $workedHours, Locality $locality, $description = null, $descOtherHours = null) { $this->row = \LeanMapper\Result::createDetachedInstance()->getRow(); $this->setDay($day); $this->setListing($listing); $this->setLocality($locality); $this->setDescription($description); $this->setWorkedTime($workedHours, $descOtherHours); }
/** * @param string $subject * @param string $message * @param string $author * @param \DateTime $sent If $sent is null, sent is set to current date * @return Message */ public function __construct($subject, $message, $author, DateTime $sent = null) { $this->row = \LeanMapper\Result::createDetachedInstance()->getRow(); $this->setSubject($subject); $this->setMessage($message); $this->setAuthor($author); if (is_null($sent)) { $sent = new DateTime(); } $this->setSent($sent); }
/** * @param string $username * @param string $password * @param string $email * @param string $ip * @param string $role * @param string|null $name * @return User */ public function __construct($username, $password, $email, $ip, $role = 'employee', $name = null) { $this->row = \LeanMapper\Result::createDetachedInstance()->getRow(); $this->setUsername($username); $this->setPassword($password); $this->setEmail($email); $this->setIp($ip); $this->setRole($role); $this->setName($name); $this->setLastIP($ip); $this->setLastLogin(new DateTime()); }
/** * @param \DateTime|InvoiceTime|int|string|null $workStart * @param \DateTime|InvoiceTime|int|string|null $workEnd * @param \DateTime|InvoiceTime|int|string|null $lunch * @param \DateTime|InvoiceTime|int|string|null null $otherHours */ public function __construct($workStart, $workEnd, $lunch, $otherHours = null) { $workStart = new InvoiceTime($workStart); $workEnd = new InvoiceTime($workEnd); $lunch = new InvoiceTime($lunch); $otherHours = new InvoiceTime($otherHours); if ($workStart->compare($workEnd) === 1) { throw new ShiftEndBeforeStartException('You cannot quit your shift before you even started!'); } $this->row = \LeanMapper\Result::createDetachedInstance()->getRow(); $this->row->workStart = $workStart->getTime(); $this->row->workEnd = $workEnd->getTime(); $this->row->lunch = $lunch->getTime(); $this->row->otherHours = $otherHours->getTime(); }
/** * @param string $localityName * @return Locality */ public function __construct($localityName) { $this->row = \LeanMapper\Result::createDetachedInstance()->getRow(); $this->setName($localityName); }
/** * @param Message $message * @param $recipient * @return UserMessage */ public function __construct(Message $message, $recipient) { $this->row = \LeanMapper\Result::createDetachedInstance()->getRow(); $this->setMessage($message); $this->setRecipient($recipient); }