/**
  * Constructeur d'objet personne.
  *
  * @param string $nom Le nom de la liste.
  */
 public function __construct(Election $election, $nuance, $nom)
 {
     \Assert\that($nom)->string();
     $this->election = $election;
     $this->nom = $nom;
     $this->nuance = (string) $nuance;
 }
 /**
  * Validate the existence of a mandatory parameter.
  *
  * @param \stdClass $description
  * @param string $parameter
  *
  * @return void
  */
 protected function validateMandatoryProperty(\stdClass $description, $parameter)
 {
     \Assert\that($parameter)->string()->notEmpty();
     if (isset($description->{$parameter}) === false) {
         throw InvalidDescriptionException::missingMandatoryParameter($parameter);
     }
 }
Пример #3
0
 public function init()
 {
     parent::init();
     \Assert\that($this->attribute, 'replace.attribute')->notEmpty()->inArray(Item::dataAttributes());
     \Assert\that($this->search, 'replace.search')->notEmpty()->string();
     \Assert\that($this->replace, 'replace.replace')->notEmpty()->string();
 }
Пример #4
0
 /**
  * @param $newName
  */
 public function changeName($newName)
 {
     \Assert\that($newName)->notEmpty()->string();
     if ($newName != $this->name) {
         $this->recordThat(UserWasRenamed::occur($this->uuid->toString(), ['new_name' => $newName, 'old_name' => $this->name]));
     }
 }
Пример #5
0
 /**
  * Checking input parameters for working with API BPM
  * @param $collection
  * @param $format
  */
 public function checkStartParameters($collection, $format)
 {
     $collection = ucfirst($collection);
     $format = mb_strtolower($format);
     \Assert\that($collection, 'The first parameter expects a string to the type of collection has BPM')->string();
     Assertion::regex($format, '~^json$|^xml$~', 'Expects parameter json or xml');
 }
Пример #6
0
 /**
  * @param int $amount
  * @param string $currency
  */
 public function __construct(int $amount, string $currency)
 {
     \Assert\that($amount)->notEmpty();
     \Assert\that($currency)->regex('/[A-Z]{3}/');
     $this->amount = $amount;
     $this->currency = $currency;
 }
Пример #7
0
 public function bla(Operand ...$numbers)
 {
     \Assert\that(count($numbers))->min(2);
     return array_reduce($numbers, function (Operand $carry, Operand $new) {
         return new Operand($carry->value() + $new->value());
     }, new Operand(0));
 }
Пример #8
0
 /**
  * @param int $timeout
  */
 public function wait($timeout = 0)
 {
     if (isset($this->timeout)) {
         throw new \LogicException('Timeout is already set');
     }
     \Assert\that($timeout)->integer('Timeout must be integer');
     $this->timeout = $timeout;
 }
Пример #9
0
 /**
  * Executes a command.
  * When no working directory is passed, the project directory is used.
  *
  * @param string $command The command line to run
  * @param string $cwd     The working directory
  *
  * @return int Exit code
  */
 public function exec($command, $cwd = '/')
 {
     \Assert\that($command)->string()->notEmpty();
     \Assert\that($cwd)->string()->notEmpty();
     $command = sprintf('cd %s && %s', $cwd, $command);
     $this->logger->debug(sprintf("Executing command '%s'", $command));
     return $this->getServer()->getSession()->getExec()->run($command);
 }
Пример #10
0
 /**
  * Constructeur d'objet Echeance.
  *
  * @param DateTime $date       La date de l'échance.
  * @param string   $type       Le type de l'échéance.
  * @param bool     $secondTour Si l'échéance est un second tour.
  */
 public function __construct(\DateTime $date, $type, $secondTour = self::PREMIER_TOUR)
 {
     \Assert\that((int) $type)->inArray(array(self::MUNICIPALES, self::CANTONALES, self::REGIONALES, self::LEGISLATIVES, self::PRESIDENTIELLE, self::EUROPEENNES));
     \Assert\that($secondTour)->boolean();
     $this->date = $date;
     $this->type = (int) $type;
     $this->secondTour = (bool) $secondTour;
 }
Пример #11
0
 /**
  * __construct()
  *
  * @param string $baseDirectory Base directory
  * @param int    $rotate        The amount of project copies to keep
  */
 public function __construct($baseDirectory, $rotate = 10)
 {
     \Assert\that($baseDirectory)->directory()->writeable();
     \Assert\that($rotate)->integer()->min(1);
     $this->baseDirectory = realpath($baseDirectory);
     $this->copies = $rotate;
     $this->logger = new NullLogger();
 }
Пример #12
0
 public function __construct($value)
 {
     try {
         \Assert\that($value)->numeric()->min(0);
         $this->value = $value;
     } catch (AssertionInvalidArgumentException $exception) {
         throw new InvalidArgumentException($value, array('number'));
     }
 }
Пример #13
0
 public function __construct($value)
 {
     try {
         \Assert\that($value)->integerish()->min(0);
         $this->value = (int) $value;
     } catch (AssertionInvalidArgumentException $exception) {
         throw new InvalidArgumentException($value, array('natural'));
     }
 }
Пример #14
0
 /**
  * Constructor.
  *
  * @param string|null $phone
  * @param string|null $twitterId
  * @param string|null $facebookId
  */
 public function __construct($phone = null, $twitterId = null, $facebookId = null)
 {
     \Assert\that($phone)->nullOr()->string()->notEmpty();
     \Assert\that($twitterId)->nullOr()->string()->notEmpty();
     \Assert\that($facebookId)->nullOr()->string()->notEmpty();
     $this->phone = $phone;
     $this->twitterId = $twitterId;
     $this->facebookId = $facebookId;
 }
 /**
  * Constructor.
  *
  * @param string $name
  * @param string $type
  * @param Tip[] $tips
  */
 public function __construct($name, $type, array $tips)
 {
     \Assert\that($name)->string()->notEmpty();
     \Assert\that($type)->string()->notEmpty();
     Assertion::allIsInstanceOf($tips, Tip::class);
     $this->name = $name;
     $this->type = $type;
     $this->tips = $tips;
 }
 /**
  * Constructor.
  *
  * @param string $name
  * @param string $type
  * @param Photo[] $photos
  */
 public function __construct($name, $type, array $photos)
 {
     \Assert\that($name)->string()->notEmpty();
     \Assert\that($type)->string()->notEmpty();
     Assertion::allIsInstanceOf($photos, Photo::class);
     $this->name = $name;
     $this->type = $type;
     $this->photos = $photos;
 }
 /**
  * Constructeur d'objet ArronissementCommunal.
  *
  * @param Commune $commune La commune de l'arrondissement.
  * @param int     $code    Le code de l'arrondissement. On suit la
  *                         convention 056AR01 pour le 1er
  *                         arrondissement de Paris, 05SR07 pour le
  *                         secteur 7 de Marseille.
  * @param string  $nom     Le nom de l'arrondissement.
  */
 public function __construct(Commune $commune, $code, $nom)
 {
     \Assert\that((string) $code)->maxLength(10);
     \Assert\that($nom)->string()->maxLength(255, 'Le nom de l\'arrondissement ne peut dépasser 255 caractères.');
     $this->commune = $commune;
     $commune->addArrondissement($this);
     $this->code = $code;
     $this->nom = $nom;
 }
Пример #18
0
 /**
  * Instancie un objet VoteInfo.
  *
  * @param int $inscrits Le nombre d'inscrits.
  * @param int $votants  Le nombre de votants.
  * @param int $exprimes Le nombre d'exprimes.
  */
 public function __construct($inscrits, $votants, $exprimes)
 {
     \Assert\that((int) $inscrits)->nullOr()->integer()->min($votants)->min($exprimes);
     \Assert\that((int) $votants)->nullOr()->integer()->max($inscrits)->min($exprimes);
     \Assert\that((int) $exprimes)->nullOr()->integer()->max($votants)->max($inscrits);
     $this->inscrits = $inscrits;
     $this->votants = $votants;
     $this->exprimes = $exprimes;
 }
Пример #19
0
 /**
  * @param string $firstName
  * @param string $lastName
  * @param string $email
  */
 public function __construct(string $firstName, string $lastName, string $email)
 {
     \Assert\that($firstName)->notEmpty();
     \Assert\that($lastName)->notEmpty();
     \Assert\that($email)->notEmpty()->email();
     $this->firstName = $firstName;
     $this->lastName = $lastName;
     $this->email = $email;
 }
Пример #20
0
 /**
  * Constructeur d'objet Commune.
  *
  * @param Departement $departement Le département de la commune.
  * @param int         $code        Le code INSEE de la commune.
  * @param string      $nom         Le nom de la commune.
  */
 public function __construct(Departement $departement, $code, $nom)
 {
     \Assert\that((string) $code)->maxLength(10);
     \Assert\that($nom)->string()->maxLength(255, 'Le nom de la commune ne peut dépasser 255 caractères.');
     $this->arrondissements = new ArrayCollection();
     $this->departement = $departement;
     $departement->addCommune($this);
     $this->code = $code;
     $this->nom = $nom;
 }
Пример #21
0
 /**
  * Constructeur d'objet département.
  *
  * @param string $code Le code de la région.
  * @param string $nom  Le nom de la région.
  */
 public function __construct(Pays $pays, $code, $nom)
 {
     \Assert\that((string) $code)->string()->maxLength(4, 'Le code de la région ne peut dépasser 4 caractères.');
     \Assert\that($nom)->string()->maxLength(255, 'Le nom de la région ne peut dépasser 255 caractères.');
     $this->pays = $pays;
     $pays->addRegion($this);
     $this->code = (string) $code;
     $this->nom = $nom;
     $this->departements = new ArrayCollection();
 }
 /**
  * @param string $address
  * @param string $city
  * @param string $zip
  * @param Country $country
  */
 public function __construct(string $address, string $city, string $zip, Country $country)
 {
     \Assert\that($address)->notEmpty();
     \Assert\that($city)->notEmpty();
     \Assert\that($zip)->notEmpty();
     $this->address = $address;
     $this->city = $city;
     $this->zip = $zip;
     $this->country = $country;
 }
 /**
  * Constructor.
  *
  * @param Identifier $identifier
  * @param string $name
  * @param boolean $isPrimary
  */
 public function __construct(Identifier $identifier, $name, $iconUrl, $isPrimary)
 {
     \Assert\that($name)->string()->notEmpty();
     Assertion::boolean($isPrimary);
     Assertion::url($iconUrl);
     $this->identifier = $identifier;
     $this->name = $name;
     $this->iconUrl = $iconUrl;
     $this->isPrimary = $isPrimary;
 }
Пример #24
0
 /**
  * @param Number ...$numbers
  * @return Number
  */
 public function bla(Operand ...$numbers)
 {
     \Assert\that(count($numbers))->min(2);
     return array_reduce(array_reverse($numbers), function (Operand $carry = null, Operand $new) {
         if (is_null($carry)) {
             return $new;
         }
         return new Operand($carry->value() - $new->value());
     });
 }
 /**
  * Constructor.
  *
  * @param string $clientId
  * @param string $clientSecret
  * @param string|null $basePath
  */
 public function __construct($clientId, $clientSecret, $basePath = null)
 {
     \Assert\that($clientId)->string()->notEmpty();
     \Assert\that($clientSecret)->string()->notEmpty();
     if ($basePath !== null) {
         Assertion::url($basePath);
         $this->basePath = rtrim($basePath, '/');
     }
     $this->clientId = $clientId;
     $this->clientSecret = $clientSecret;
 }
 /**
  * Constructeur d'objet département.
  *
  * @param Region $region La région du département.
  * @param string $code   Le code du département.
  * @param string $nom    Le nom du département.
  */
 public function __construct(Region $region, $code, $nom)
 {
     \Assert\that((string) $code)->string()->maxLength(4, 'Le code du département ne peut dépasser 4 caractères.');
     \Assert\that($nom)->string()->maxLength(255, 'Le nom du déparement de peut dépasser 255 caractères.');
     $this->code = (string) $code;
     $this->nom = $nom;
     $this->region = $region;
     $region->addDepartement($this);
     $this->communes = new ArrayCollection();
     $this->circonscriptionsLegislatives = new ArrayCollection();
 }
Пример #27
0
 /**
  * Constructor.
  *
  * @param int $checkins
  * @param int $users
  * @param int $tips
  * @param int $visits
  */
 public function __construct($checkins, $users, $tips, $visits)
 {
     \Assert\that($checkins)->integer()->greaterOrEqualThan(0);
     \Assert\that($users)->integer()->greaterOrEqualThan(0);
     \Assert\that($tips)->integer()->greaterOrEqualThan(0);
     \Assert\that($visits)->integer()->greaterOrEqualThan(0);
     $this->checkins = $checkins;
     $this->users = $users;
     $this->tips = $tips;
     $this->visits = $visits;
 }
Пример #28
0
 /**
  * Constructor.
  *
  * @param Identifier $identifier
  * @param string $text
  * @param string $type
  */
 public function __construct(Identifier $identifier, $text, $type, $agreeCount, $disagreeCount)
 {
     \Assert\that($text)->string()->notEmpty();
     \Assert\that($type)->string()->notEmpty();
     Assertion::integer($agreeCount);
     Assertion::integer($disagreeCount);
     $this->identifier = $identifier;
     $this->text = $text;
     $this->type = $type;
     $this->agreeCount = $agreeCount;
     $this->disagreeCount = $disagreeCount;
 }
 /**
  * Constructor.
  *
  * @param string $address
  * @param Coordinates $coordinates
  * @param string $postalCode
  * @param string $city
  * @param string $state
  * @param string $country
  */
 public function __construct($address = null, Coordinates $coordinates = null, $postalCode = null, $city = null, $state = null, $country = null)
 {
     \Assert\that($address)->nullOr()->string()->notEmpty();
     \Assert\that($postalCode)->nullOr()->string()->notEmpty();
     \Assert\that($city)->nullOr()->string()->notEmpty();
     \Assert\that($state)->nullOr()->string()->notEmpty();
     \Assert\that($country)->nullOr()->string()->notEmpty();
     $this->address = $address;
     $this->coordinates = $coordinates;
     $this->postalCode = $postalCode;
     $this->city = $city;
     $this->state = $state;
     $this->country = $country;
 }
Пример #30
0
 /**
  * Constructor.
  *
  * @param Identifier         $identifier
  * @param string             $name
  * @param Category[]         $categories
  * @param Tip\TipGroup[]     $tipGroups
  * @param Photo\PhotoGroup[] $photosGroups
  * @param Contact            $contact
  * @param Location           $location
  * @param Detail             $details
  */
 public function __construct(Identifier $identifier, $name, array $categories, array $tipGroups, array $photosGroups, Contact $contact, Location $location, Detail $details)
 {
     \Assert\that($name)->string()->notEmpty();
     Assertion::allIsInstanceOf($categories, Category::class);
     Assertion::allIsInstanceOf($tipGroups, Tip\TipGroup::class);
     Assertion::allIsInstanceOf($photosGroups, Photo\PhotoGroup::class);
     $this->identifier = $identifier;
     $this->name = $name;
     $this->categories = $categories;
     $this->tipGroups = $tipGroups;
     $this->photoGroups = $photosGroups;
     $this->contact = $contact;
     $this->location = $location;
     $this->details = $details;
 }