Exemple #1
0
 /**
  * Setter for the total_results field on this ApiPager.
  * 
  * @param integer $total_results
  * @throws Exception if $total_results is not an unsigned integer
  */
 public function setTotalResults($total_results)
 {
     $this->total_results = \Altumo\Validation\Numerics::assertUnsignedInteger($total_results);
 }
 /**
  * Setter for the flags field on this \sfAltumoPlugin\Api\ApiFieldMap.
  * 
  * @param integer $flags
  */
 public function setFlags($flags)
 {
     $flags = \Altumo\Validation\Numerics::assertUnsignedInteger($flags);
     $this->flags = $flags;
     $this->validateFlags();
 }
 /**
  * Enables testing mode, which means this Message will NOT be sent to the
  * recipients specified by "To". This Message will be sent to
  * $reroute_messages_to instead.
  * 
  * @param string $reroute_messages_to
  *   // phone numnber to reroute message to.
  * 
  * @return \sfAltumoPlugin\Phone\TextMessage
  */
 public function setTestingModeRerouteToNumber($reroute_messages_to)
 {
     $this->testing_mode_reroute_messages_to = \Altumo\Validation\Numerics::assertUnsignedInteger($reroute_messages_to, '$reroute_messages_to expects a phone number.');
     return $this;
 }
Exemple #4
0
 /**
  * Throws an exception if this is not a string (or castable as one) or is not
  * with the string length range provided.
  * Returns the string if it was cast as one.
  * 
  * @param mixed $string
  * @param integer $min_length
  * @param integer $max_length
  * @param string $exception_message  
  *   //custom Exception message to throw. 
  *     If null, default message will be used.
  * 
  * @throws Exception //if argument passed is not a string
  * @throws Exception //if the string length was not within the provided range
  * @return string
  */
 public static function assertStringAndLength($string, $min_length = null, $max_length = null, $exception_message = null)
 {
     if (!is_string($string)) {
         if (is_null($exception_message)) {
             $exception_message = 'Value passed is not a string.';
         }
         throw new \Exception($exception_message);
     }
     $length = strlen($string);
     if (!is_null($min_length)) {
         $min_length = \Altumo\Validation\Numerics::assertUnsignedInteger($min_length);
         if ($length < $min_length) {
             if (is_null($exception_message)) {
                 $exception_message = 'String length was less than the minimum allowed length ( ' . $min_length . ' ).';
             }
             throw new \Exception($exception_message);
         }
     }
     if (!is_null($max_length)) {
         $max_length = \Altumo\Validation\Numerics::assertUnsignedInteger($max_length);
         if ($length > $max_length) {
             if (is_null($exception_message)) {
                 $exception_message = 'String length was greater than the maximum allowed length ( ' . $max_length . ' ).';
             }
             throw new \Exception($exception_message);
         }
     }
     return $string;
 }
Exemple #5
0
 /**
  * Sends a SIGKILL (9) to the process_id (pid) given.
  * 
  * 
  * @param int $process_id    // system pid to kill
  * 
  * @returns true if process was killed, false otherwise.
  */
 public static function killProcess($process_id)
 {
     $process_id = \Altumo\Validation\Numerics::assertUnsignedInteger($process_id, '$process_id expects unsinged integer');
     $result = \Altumo\Utils\Shell::runWithPipedOutput("kill -9 {$process_id}");
     return $result == 0;
 }