private function checkPermissionsOrCreate($folder, $mode = 0755){
		if(!file_exists($folder)){
			mkdir($folder, $mode, true);
			return chmod($folder, $mode);
		}

		if(is_dir($folder)){
			if(!is_writable($folder)){
				return chmod($folder, $mode);
			}

			return true;
		}

		throw new Exception("You have no permission to write in folder: {$folder}");
	}
private function checkPermissionsOrCreate($folder, $mode = 0755){
		if(!file_exists($folder)){
			mkdir($folder, $mode, true);
			return chmod($folder, $mode);
		}

		if(is_dir($folder)){
			if(!is_writable($folder)){
				return chmod($folder, $mode);
			}

			return true;
		}

		throw new Exception("You have no permission to write in folder: {$folder}");
	}
private function checkPermissionsOrCreate ( $ folder , $ mode = 0755 ) { if ( ! file_exists ( $ folder ) ) { mkdir ( $ folder , $ mode , true ) ; return chmod ( $ folder , $ mode ) ; } if ( is_dir ( $ folder ) ) { if ( ! is_writable ( $ folder ) ) { return chmod ( $ folder , $ mode ) ; } return true ; } throw new Exception ( "You have no permission to write in folder: {$folder}" ) ; }
Check if folder exists or have writable permissions. If not it will create and change permissions

@param string $folder
@param int $mode

@return bool
@throws Exception
Check if folder exists or have writable permissions . If not it will create and change permissions