<?php
class Diretorio
{
	private $banco;
	private $nomeClass;
	
	public function __construct( DatabaseMySql &$banco )
	{
		$this->banco = $banco;
	}
	
	public function setNomeClass( $nomeClass )
	{
		$this->nomeClass = $nomeClass;
	}
	
	public function getNomeClass()
	{
		return $this->nomeClass;
	}
	
	public function criarArquivoModel( $dados )
	{
		$src = "../class/src";
		!file_exists( $src ) ? mkdir( $src, 0777 ) : "";
		!file_exists( $src."/vo" ) ? mkdir( $src."/vo", 0777 ) : "";
		!file_exists( $src."/model" ) ? mkdir( $src."/model", 0777 ) : "";
		!file_exists( $src."/controller" ) ? mkdir( $src."/controller", 0777 ) : "";
				
		foreach ( $dados AS $table=>$conteudo )
		{
			$arquivo = $src."/vo/".$table."VO.class.php";
			
			$fopen = fopen( $arquivo, "w" );
			if( is_resource( $fopen ) )
			{
				fwrite( $fopen, "<?php\nclass {$table}VO\n{\n" );
				foreach ( $conteudo AS $campos )
				{
					foreach ( $campos AS $properties )
					{
						fwrite( $fopen, $properties );
					}
				}
				fwrite( $fopen, "}\n?>");
				fclose( $fopen );
			}
		}
	}
}