Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Files
F9503076
Command.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
Command.php
View Options
<?php
namespace
Keruald\Commands
;
use
Keruald\Commands\Display\Display
;
use
Keruald\Commands\Display\OutputDisplay
;
abstract
class
Command
{
/**
* @var int
*/
private
$argc
;
/**
* @var array
*/
private
$argv
;
/**
* @var \Keruald\Commands\Display\Display
*/
protected
$display
;
public
function
__construct
(
int
$argc
,
array
$argv
,
Display
$display
=
null
)
{
$this
->
argc
=
$argc
;
$this
->
argv
=
$argv
;
if
(
$display
===
null
)
{
$display
=
self
::
getDefaultDisplay
();
}
$this
->
display
=
$display
;
}
public
static
function
run
(
int
$argc
,
array
$argv
)
:
int
{
$command
=
new
static
(
$argc
,
$argv
);
return
$command
->
main
();
}
///
/// Getters and setters
///
public
function
getArgc
()
:
int
{
return
$this
->
argc
;
}
public
function
setArgc
(
int
$argc
)
:
Command
{
$this
->
argc
=
$argc
;
return
$this
;
}
public
function
getArgv
()
:
array
{
return
$this
->
argv
;
}
public
function
setArgv
(
array
$argv
)
:
Command
{
$this
->
argv
=
$argv
;
return
$this
;
}
public
function
getCommandName
()
:
string
{
return
$this
->
argv
[
0
]
??
""
;
}
public
function
getDisplay
()
:
Display
{
return
$this
->
display
;
}
public
function
setDisplay
(
Display
$display
)
:
Command
{
$this
->
display
=
$display
;
return
$this
;
}
///
/// Helper methods
///
private
static
function
getDefaultDisplay
()
:
Display
{
return
new
OutputDisplay
();
}
///
/// Methods to implement
///
public
abstract
function
main
()
:
int
;
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Sun, Jun 8, 00:20 (1 d, 3 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2669936
Default Alt Text
Command.php (1 KB)
Attached To
Mode
rKERUALD Keruald libraries development repository
Attached
Detach File
Event Timeline
Log In to Comment