PHP Class Ipalaus\Geonames\Commands\ImportCommand

Inheritance: extends Illuminate\Console\Command
Show file Open project: ipalaus/geonames

Protected Properties

Property Type Description
$archive ZipArchive File archive instance.
$config array Configuration options.
$description string The console command description.
$filesystem Illuminate\Filesystem\Filesystem Filesystem implementation.
$importer Ipalaus\Geonames\Importer Importer instance.
$name string The console command name.

Public Methods

Method Description
__construct ( Ipalaus\Geonames\Importer $importer, Illuminate\Filesystem\Filesystem $filesystem, array $config ) : void Create a new console command instance.
fire ( ) : void Execute the console command.
getFiles ( ) : array Get the files to download.
runProcess ( Process $process ) : Process Run a given process.

Protected Methods

Method Description
downloadFile ( string $url, string $path, $filename ) : void Download a file from a remote URL to a given path.
extractZip ( string $path, string $filename ) : string Given a zip archive, extract a the file and remove the original.
fileExists ( string $path, string $filename ) : boolean Checks if a file already exists on a path. If the file contains .zip in the name we will also check for matches with .txt.
getOptions ( ) : array Get the console command options.
getPath ( ) : string Return the working path.
makeProcess ( string $command ) : Process Create a process with the given command.
seedCommand ( string $class, $extra = '' ) : void Run a seed coman in a separate process.
setCountry ( string $country ) : void Sets the name file to a specific country.
setDevelopment ( ) : void Sets the names file for a ligher version for development. We also ignore the alternate names.

Method Details

__construct() public method

Create a new console command instance.
public __construct ( Ipalaus\Geonames\Importer $importer, Illuminate\Filesystem\Filesystem $filesystem, array $config ) : void
$importer Ipalaus\Geonames\Importer
$filesystem Illuminate\Filesystem\Filesystem
$config array
return void

downloadFile() protected method

Download a file from a remote URL to a given path.
protected downloadFile ( string $url, string $path, $filename ) : void
$url string
$path string
return void

extractZip() protected method

Given a zip archive, extract a the file and remove the original.
protected extractZip ( string $path, string $filename ) : string
$path string
$filename string
return string

fileExists() protected method

Checks if a file already exists on a path. If the file contains .zip in the name we will also check for matches with .txt.
protected fileExists ( string $path, string $filename ) : boolean
$path string
$filename string
return boolean

fire() public method

Execute the console command.
public fire ( ) : void
return void

getFiles() public method

Get the files to download.
public getFiles ( ) : array
return array

getOptions() protected method

Get the console command options.
protected getOptions ( ) : array
return array

getPath() protected method

Return the working path.
protected getPath ( ) : string
return string

makeProcess() protected method

Create a process with the given command.
protected makeProcess ( string $command ) : Process
$command string
return Symfony\Component\Process\Process

runProcess() public method

Run a given process.
public runProcess ( Process $process ) : Process
$process Symfony\Component\Process\Process
return Symfony\Component\Process\Process

seedCommand() protected method

Run a seed coman in a separate process.
protected seedCommand ( string $class, $extra = '' ) : void
$class string
return void

setCountry() protected method

Sets the name file to a specific country.
protected setCountry ( string $country ) : void
$country string
return void

setDevelopment() protected method

Sets the names file for a ligher version for development. We also ignore the alternate names.
protected setDevelopment ( ) : void
return void

Property Details

$archive protected property

File archive instance.
protected ZipArchive $archive
return ZipArchive

$config protected property

Configuration options.
protected array $config
return array

$description protected property

The console command description.
protected string $description
return string

$filesystem protected property

Filesystem implementation.
protected Filesystem,Illuminate\Filesystem $filesystem
return Illuminate\Filesystem\Filesystem

$importer protected property

Importer instance.
protected Importer,Ipalaus\Geonames $importer
return Ipalaus\Geonames\Importer

$name protected property

The console command name.
protected string $name
return string