/** * Command Parser * * @return mixed */ private function parseCommand() { /** * Cleaning */ if ($this->command[1] == 'clear:all') { $this->clear('sessions'); $this->clear('logs'); return die("\nall trash cleared.\n"); } elseif ($this->command[1] == 'clear:sessions') { $this->clear('sessions'); return die("\nsessions directory cleared.\n"); } elseif ($this->command[1] == 'clear:logs') { $this->clear('logs'); return die("\nlogs directory cleared.\n"); } elseif ($this->command[1] == 'clear:backups') { $this->clear('backups'); return die("\nbackups directory cleared.\n"); } elseif ($this->command[1] == 'create:model') { if (isset($this->command[2])) { $option = isset($this->command[3]) ? $this->command[3] : strtolower($this->command[2]); return $this->createModel($this->command[2], $option); } else { die("\ntoo few arguments, create:model expects [name], [table] is optional\n"); } } elseif ($this->command[1] == 'create:controller') { if (isset($this->command[2])) { $option = isset($this->command[3]) ? $this->command[3] : null; return $this->createController($this->command[2], $option); } else { die("\ntoo few arguments, create:controller expects [name], [empty] is optional\n"); } } elseif ($this->command[1] == 'create:migration') { if (isset($this->command[2]) && isset($this->command[3])) { return $this->createMigration($this->command[2], $this->command[3]); } else { die("\ntoo few arguments, create:migration expects [name] [table]\n"); } } elseif ($this->command[1] == 'create:request') { if (isset($this->command[2])) { return $this->createRequest($this->command[2]); } else { die("\ncreate:request expects parameter [name]\n"); } } elseif ($this->command[1] == 'create:process') { if (isset($this->command[2])) { return $this->createProcess($this->command[2]); } else { die("\ncreate:process expects parameter [name]\n"); } } elseif ($this->command[1] == 'create:seeder') { if (isset($this->command[2]) && isset($this->command[3])) { return $this->createSeeder($this->command[2], $this->command[3]); } else { die("\ntoo few arguments, create:seeder expects [name] [table]\n"); } } elseif ($this->command[1] == 'create:key') { return die("\n" . Hash::generateSalt() . "\n"); } elseif ($this->command[1] == 'db:migrate') { return $this->migrate('up'); } elseif ($this->command[1] == 'db:rollback') { return $this->migrate('down'); } elseif ($this->command[1] == 'db:table:up') { return $this->tableMigration($this->command[2], 'up'); } elseif ($this->command[1] == 'db:table:down') { return $this->tableMigration($this->command[2], 'down'); } elseif ($this->command[1] == 'db:backup') { return $this->backup(); } elseif ($this->command[1] == 'db:restore') { return $this->restore(); } elseif ($this->command[1] == 'db:seed') { return $this->seed(); } elseif ($this->command[1] == 'hash:encode') { if (!isset($this->command[2])) { die("\nhash:verify expects [data]\n"); } return die("\n" . Hash::encode(trim($this->command[2], ' '))); } elseif ($this->command[1] == 'hash:verify') { if (!isset($this->command[2]) || !isset($this->command[3])) { die("\ntoo few arguments, hash:verify expects [data] and [hashed] value\n"); } return Hash::verify($this->command[2], $this->command[3]) ? die("\ntrue\n") : die("\nfalse\n"); } elseif ($this->command[1] == 'cipher:encrypt') { if (!isset($this->command[2])) { die("\ncipher:encrypt expects [string]\n"); } return die("\n" . Cipher::encrypt($this->command[2]) . "\n"); } elseif ($this->command[1] == 'cipher:decrypt') { if (!isset($this->command[2])) { die("\ncipher:encrypt expects [string]\n"); } return die("\n" . Cipher::decrypt($this->command[2]) . "\n"); } else { die("\nerror: unknown command '{$this->command[1]}' type 'help' for information.\n"); } }
/** * Compare string to hashed string * * @param $string * @param $hashed * @return mixed */ function hash_verify($string, $hashed) { return Hash::verify($string, $hashed); }