private function scanFolder($path)
	{
		$files = array_diff(scandir($path), array('.', '..', '.DS_Store'));

		if ($files && count($files) > 0)
		{
			foreach ($files as $file)
			{
				if (is_file($path . DS . $file))
				{
					$contents = file_get_contents($path . DS . $file);
					$contents = $this->doReplacements($contents);

					$this->putContents($path . DS . $file, $contents);
				}
				else
				{
					// See if we need to do var replacement in directory name
					if (preg_match("/%=([[:alpha:]_]*)(\+[[:alpha:]]+)?=%/", $path . DS . $file, $matches) && isset($this->replacements[$matches[1]]))
					{
						$newfile = str_replace($matches[0], $this->replacements[$matches[1]], $file);

						if (isset($matches[2]))
						{
							$modifier = substr($matches[2], 1);
							switch ($modifier)
							{
								// Upper case word
								case 'uc':
									$value = strtoupper($v);
									break;
								// Upper case first character
								case 'ucf':
									$newfile = ucfirst($newfile);
									break;
								// Upper case first character and plural
								case 'ucfp':
									$newfile = ucfirst(Inflector::pluralize($newfile));
									break;
								// Plural form
								case 'p':
									$newfile = Inflector::pluralize($newfile);
									break;
							}
						}

						rename($path. DS . $file, $path . DS . $newfile);
						$file = $newfile;
					}

					$this->scanFolder($path . DS . $file);
				}
			}
		}
	}
private function scanFolder($path)
	{
		$files = array_diff(scandir($path), array('.', '..', '.DS_Store'));

		if ($files && count($files) > 0)
		{
			foreach ($files as $file)
			{
				if (is_file($path . DS . $file))
				{
					$contents = file_get_contents($path . DS . $file);
					$contents = $this->doReplacements($contents);

					$this->putContents($path . DS . $file, $contents);
				}
				else
				{
					// See if we need to do var replacement in directory name
					if (preg_match("/%=([[:alpha:]_]*)(\+[[:alpha:]]+)?=%/", $path . DS . $file, $matches) && isset($this->replacements[$matches[1]]))
					{
						$newfile = str_replace($matches[0], $this->replacements[$matches[1]], $file);

						if (isset($matches[2]))
						{
							$modifier = substr($matches[2], 1);
							switch ($modifier)
							{
								// Upper case word
								case 'uc':
									$value = strtoupper($v);
									break;
								// Upper case first character
								case 'ucf':
									$newfile = ucfirst($newfile);
									break;
								// Upper case first character and plural
								case 'ucfp':
									$newfile = ucfirst(Inflector::pluralize($newfile));
									break;
								// Plural form
								case 'p':
									$newfile = Inflector::pluralize($newfile);
									break;
							}
						}

						rename($path. DS . $file, $path . DS . $newfile);
						$file = $newfile;
					}

					$this->scanFolder($path . DS . $file);
				}
			}
		}
	}
private function scanFolder ( $ path ) { $ files = array_diff ( scandir ( $ path ) , array ( '.' , '..' , '.DS_Store' ) ) ; if ( $ files && count ( $ files ) > 0 ) { foreach ( $ files as $ file ) { if ( is_file ( $ path . DS . $ file ) ) { $ contents = file_get_contents ( $ path . DS . $ file ) ; $ contents = $ this -> doReplacements ( $ contents ) ; $ this -> putContents ( $ path . DS . $ file , $ contents ) ; } else { // See if we need to do var replacement in directory name if ( preg_match ( "/%=([[:alpha:]_]*)(\+[[:alpha:]]+)?=%/" , $ path . DS . $ file , $ matches ) && isset ( $ this -> replacements [ $ matches [ 1 ] ] ) ) { $ newfile = str_replace ( $ matches [ 0 ] , $ this -> replacements [ $ matches [ 1 ] ] , $ file ) ; if ( isset ( $ matches [ 2 ] ) ) { $ modifier = substr ( $ matches [ 2 ] , 1 ) ; switch ( $ modifier ) { // Upper case word case 'uc' : $ value = strtoupper ( $ v ) ; break ; // Upper case first character case 'ucf' : $ newfile = ucfirst ( $ newfile ) ; break ; // Upper case first character and plural case 'ucfp' : $ newfile = ucfirst ( Inflector :: pluralize ( $ newfile ) ) ; break ; // Plural form case 'p' : $ newfile = Inflector :: pluralize ( $ newfile ) ; break ; } } rename ( $ path . DS . $ file , $ path . DS . $ newfile ) ; $ file = $ newfile ; } $ this -> scanFolder ( $ path . DS . $ file ) ; } } } }
Scan template folder for files to iterate through

@param   string  $path  Path of folder to scan
@return  void
Scan template folder for files to iterate through