int() public static method

Smart convert any string to int
public static int ( string $value ) : integer
$value string
return integer
Esempio n. 1
0
 public function migrate()
 {
     try {
         $this->isOk();
         if (isset($this->params['auto'])) {
             print "Auto mode selected." . PHP_EOL;
             $params = new OdaPrepareReqSql();
             $params->sql = "SELECT `param_value`\n                    FROM `" . self::$config->BD_ENGINE->prefixTable . "api_tab_parametres`\n                    WHERE 1=1\n                    AND `param_name` = 'install_date'\n                ";
             $params->typeSQL = OdaLibBd::SQL_GET_ONE;
             $retour = $this->BD_ENGINE->reqODASQL($params);
             if ($retour->data) {
                 $installDate = $retour->data->param_value;
                 $compressInstallDate = Filter::int(Str::sub($installDate, 2, 2) . Str::sub($installDate, 5, 2) . Str::sub($installDate, 8, 2));
                 print "Install date is: " . $installDate . PHP_EOL;
                 $objects = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator('.' . DIRECTORY_SEPARATOR, \RecursiveDirectoryIterator::SKIP_DOTS), \RecursiveIteratorIterator::SELF_FIRST);
                 foreach ($objects as $folderPath => $object) {
                     if ($object->isDir()) {
                         $filePath = $folderPath . DIRECTORY_SEPARATOR . 'do.sql';
                         if (file_exists($filePath)) {
                             $banned_words = "-install -reworkModel -matrixRangApi";
                             if (!preg_match('~\\b(' . str_replace(' ', '|', $banned_words) . ')\\b~', $filePath) && preg_match('/[0-9]{2}(0[1-9]|1[0-2])(0[1-9]|[1-2][0-9]|3[0-1])/', $filePath)) {
                                 $patchDate = Filter::int(Str::sub($filePath, 6, 6));
                                 if ($patchDate > $compressInstallDate) {
                                     $this->exe($filePath);
                                 }
                             }
                         }
                     }
                 }
             } else {
                 print "No install_date retrieve." . PHP_EOL;
             }
         } else {
             print "Target mode selected." . PHP_EOL;
             if ($this->params['partial'] !== "all") {
                 $this->exe('.' . DIRECTORY_SEPARATOR . $this->params['target'] . DIRECTORY_SEPARATOR . $this->params['partial'] . DIRECTORY_SEPARATOR . $this->params['option'] . '.sql');
             } else {
                 $objects = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator('.' . DIRECTORY_SEPARATOR . $this->params['target'], \RecursiveDirectoryIterator::SKIP_DOTS), \RecursiveIteratorIterator::SELF_FIRST);
                 foreach ($objects as $name => $object) {
                     if ($object->isDir()) {
                         $this->exe($name . DIRECTORY_SEPARATOR . $this->params['option'] . '.sql');
                     }
                 }
             }
         }
         echo 'Success' . PHP_EOL;
         return $this;
     } catch (Exception $ex) {
         die($ex . '');
     }
 }
Esempio n. 2
0
 /**
  * Pixelate effect
  *
  * @param resource $image     Image GD resource
  * @param int      $blockSize Size in pixels of each resulting block
  */
 public static function pixelate($image, $blockSize = 10)
 {
     $blockSize = VarFilter::int($blockSize);
     imagefilter($image, IMG_FILTER_PIXELATE, $blockSize, true);
 }
Esempio n. 3
0
 /**
  * Overlay an image on top of another, works with 24-bit PNG alpha-transparency
  *
  * @param string|Image $overlay     An image filename or a Image object
  * @param string       $position    center|top|left|bottom|right|top left|top right|bottom left|bottom right
  * @param float|int    $opacity     Overlay opacity 0-1 or 0-100
  * @param int          $globOffsetX Horizontal offset in pixels
  * @param int          $globOffsetY Vertical offset in pixels
  *
  * @return $this
  * @throws Exception
  */
 public function overlay($overlay, $position = 'bottom right', $opacity = 0.4, $globOffsetX = 0, $globOffsetY = 0)
 {
     // Load overlay image
     if (!$overlay instanceof self) {
         $overlay = new self($overlay);
     }
     // Convert opacity
     $opacity = Helper::opacity($opacity);
     $globOffsetX = VarFilter::int($globOffsetX);
     $globOffsetY = VarFilter::int($globOffsetY);
     // Determine position
     list($xOffset, $yOffset) = Helper::getInnerCoords($position, array($this->_width, $this->_height), array($overlay->getWidth(), $overlay->getHeight()), array($globOffsetX, $globOffsetY));
     // Perform the overlay
     Helper::imageCopyMergeAlpha($this->_image, $overlay->getImage(), array($xOffset, $yOffset), array(0, 0), array($overlay->getWidth(), $overlay->getHeight()), $opacity);
     return $this;
 }
Esempio n. 4
0
File: Cache.php Progetto: jbzoo/less
 /**
  * @param int $newTTL In seconds (1 to 365 days)
  */
 public function setCacheTTL($newTTL)
 {
     $newTTL = Filter::int($newTTL);
     $newTTL = Vars::limit($newTTL, 1, 86400 * 365);
     $this->_cache_ttl = $newTTL;
 }
Esempio n. 5
0
 public function testApplySeveralRules()
 {
     $source = '127.0001 <img> some-<b>WORD</b> ' . "\t";
     $excepted = Filter::strip($source);
     $excepted = Filter::alias($excepted);
     $excepted = Filter::int($excepted);
     isSame($excepted, Filter::_($source, 'Strip, alias,int'));
 }
Esempio n. 6
0
 /**
  * @param $code
  */
 public function setCode($code)
 {
     $this['code'] = Filter::int($code);
 }