public function test_srcNotExists()
 {
     /** === Test Data === */
     $src = 'file_is_not_exists';
     $vars = ['var1' => '21'];
     $tmpl = new Template();
     $tmpl->setSource($src);
     /** === Setup Mocks === */
     $expected = self::CLAZZ . ": <error>Cannot open source template ({$src}).</error>";
     $this->mIo->shouldReceive('writeError')->once()->with($expected);
     /** === Call and asserts  === */
     $proc = new Handler($vars, $this->mIo);
     $proc->process($tmpl);
 }
 public function process(Config\Template $tmpl)
 {
     /* process template if condition is not set or condition is valid */
     if ($tmpl->getCondition() == null || $this->conditionValidator->isValid($tmpl->getCondition(), $this->vars)) {
         /* load source file */
         if (is_file($tmpl->getSource())) {
             $content = file_get_contents($tmpl->getSource());
             /* replace all vars by values */
             if (is_array($this->vars)) {
                 foreach ($this->vars as $key => $value) {
                     $content = str_replace('${' . $key . '}', $value, $content);
                 }
             }
             /* save destination file */
             if (is_file($tmpl->getDestination()) && !$tmpl->isCanRewrite()) {
                 $this->io->write(__CLASS__ . ": <comment>Destination file '{$tmpl->getDestination()}' is already exist and cannot be rewrote (rewrite = false).</comment>");
             } else {
                 $this->fileSaver->save($tmpl->getDestination(), $content);
                 $this->io->write(__CLASS__ . ": <info>Destination file '{$tmpl->getDestination()}' is created from source template '{$tmpl->getSource()}'.</info>");
             }
         } else {
             $this->io->writeError(__CLASS__ . ": <error>Cannot open source template ({$tmpl->getSource()}).</error>");
         }
     } else {
         /* there is wrong condition for template */
         $outSrc = $tmpl->getSource();
         $cond = $tmpl->getCondition();
         $outCond = '${' . $cond->getVar() . '}' . $cond->getOperation() . $cond->getValue();
         $this->io->write(__CLASS__ . ": <comment>Skip processing of the template ({$outSrc}) because condition ({$outCond}) is 'false'.</comment>");
     }
 }