PhpBrew\Build::getState PHP Méthode

getState() public méthode

public getState ( )
    public function getState()
    {
        if ($this->state) {
            return $this->state;
        }
        if ($path = $this->getStateFile()) {
            if (file_exists($path)) {
                return $this->state = intval(file_get_contents($path)) || self::STATE_NONE;
            }
        }
        return self::STATE_NONE;
    }

Usage Example

Exemple #1
0
 public function run(Build $build, $targets = array())
 {
     if ($build->getState() >= Build::STATE_BUILD) {
         $this->info("===> Already built, skipping...");
         return;
     }
     $this->info("===> Building...");
     $cmd = new CommandBuilder('make');
     $cmd->setAppendLog(true);
     $cmd->setLogPath($build->getBuildLogPath());
     $cmd->setStdout($this->options->{'stdout'});
     if (!empty($targets)) {
         foreach ($targets as $t) {
             $cmd->addArg($t);
         }
     }
     if ($this->options->nice) {
         $cmd->nice($this->options->nice);
     }
     if ($makeJobs = $this->options->{'jobs'}) {
         $cmd->addArg("-j{$makeJobs}");
     }
     $this->debug($cmd->getCommand());
     if (!$this->options->dryrun) {
         $startTime = microtime(true);
         $code = $cmd->execute();
         if ($code != 0) {
             throw new SystemCommandException('Make failed.', $build, $build->getBuildLogPath());
         }
         $buildTime = round((microtime(true) - $startTime) / 60, 1);
         $this->info("Build finished: {$buildTime} minutes.");
     }
     $build->setState(Build::STATE_BUILD);
 }
All Usage Examples Of PhpBrew\Build::getState