Exemplo n.º 1
0
 /**
  * Will generate the structure map within the specified root path.
  *
  * @return void
  */
 protected function generate()
 {
     // first of all we will get the version, so we will later know about changes made DURING indexing
     $this->version = $this->findVersion();
     // get the iterator over our project files and create a regex iterator to filter what we got
     $recursiveIterator = $this->getProjectIterator();
     $regexIterator = new \RegexIterator($recursiveIterator, '/^.+\\.php$/i', \RecursiveRegexIterator::GET_MATCH);
     // get the list of enforced files
     $enforcedFiles = $this->getEnforcedFiles();
     // if we got namespaces which are omitted from enforcement we have to mark them as such
     $omittedNamespaces = array();
     if ($this->config->hasValue('enforcement/omit')) {
         $omittedNamespaces = $this->config->getValue('enforcement/omit');
     }
     // iterator over our project files and add array based structure representations
     foreach ($regexIterator as $file) {
         // get the identifiers if any.
         $identifier = $this->findIdentifier($file[0]);
         // if we got an identifier we can build up a new map entry
         if ($identifier !== false) {
             // check if the file has contracts and if it should be enforced
             $hasContracts = $this->findContracts($file[0]);
             // create the entry
             $this->map[$identifier[1]] = array('cTime' => filectime($file[0]), 'identifier' => $identifier[1], 'path' => $file[0], 'type' => $identifier[0], 'hasContracts' => $hasContracts, 'enforced' => $this->isFileEnforced($file[0], $identifier[1], $hasContracts, $enforcedFiles, $omittedNamespaces));
         }
     }
     // save for later reuse.
     $this->save();
 }
Exemplo n.º 2
0
 /**
  * Test the unsetValue() method
  *
  * @return void
  *
  * @depends testHasValue
  */
 public function testUnsetValue()
 {
     // Get our config
     $config = new Config();
     // Unset some values and test if they do not exist anymore
     $this->assertTrue($config->hasValue('environment'));
     $config->unsetValue('environment');
     $this->assertFalse($config->hasValue('environment'));
     // Do the same for a more "complex" index
     $this->assertTrue($config->hasValue('enforcement/enforce-default-type-safety'));
     $config->unsetValue('enforcement/enforce-default-type-safety');
     $this->assertFalse($config->hasValue('enforcement/enforce-default-type-safety'));
 }