Skip to content

Commit bca527f

Browse files
author
Chris Jacobsen Work
committed
Code cleanup
1 parent f2e2767 commit bca527f

File tree

2 files changed

+40
-33
lines changed

2 files changed

+40
-33
lines changed
Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,15 @@
2424
* THE SOFTWARE.
2525
*/
2626

27-
namespace App\Api;
27+
namespace App\Api\Windows;
2828

2929
/**
3030
* Description of WindowsCommand
3131
*
3232
* @author cjacobsen
3333
*/
3434

35+
use System\App\WindowsLogger;
3536
use System\Core;
3637

3738
class WindowsCommand
@@ -53,48 +54,48 @@ public function getHostname()
5354
return $this->hostname;
5455
}
5556

56-
public function getCmd()
57+
public function setHostname($hostname)
5758
{
58-
return $this->cmd;
59+
$this->hostname = $hostname;
60+
return $this;
5961
}
6062

61-
public function getResponse()
63+
public function getCmd()
6264
{
63-
return $this->response;
65+
return $this->cmd;
6466
}
6567

66-
public function getReturnCode()
68+
public function setCmd($cmd)
6769
{
68-
return $this->returnCode;
70+
$this->cmd = $cmd;
71+
return $this;
6972
}
7073

71-
public function getLogger()
74+
public function getResponse()
7275
{
73-
return $this->logger;
76+
return $this->response;
7477
}
7578

76-
public function setHostname($hostname)
79+
public function setResponse($response)
7780
{
78-
$this->hostname = $hostname;
81+
$this->response = $response;
7982
return $this;
8083
}
8184

82-
public function setCmd($cmd)
85+
public function getReturnCode()
8386
{
84-
$this->cmd = $cmd;
85-
return $this;
87+
return $this->returnCode;
8688
}
8789

88-
public function setResponse($response)
90+
public function setReturnCode($returnCode)
8991
{
90-
$this->response = $response;
92+
$this->returnCode = $returnCode;
9193
return $this;
9294
}
9395

94-
public function setReturnCode($returnCode)
96+
public function getLogger()
9597
{
96-
$this->returnCode = $returnCode;
97-
return $this;
98+
return $this->logger;
9899
}
99100

100101
public function setLogger($logger)
Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
* THE SOFTWARE.
2525
*/
2626

27-
namespace App\Api;
27+
namespace App\Api\Windows;
2828

2929
/**
3030
* Description of WindowsRM
@@ -40,15 +40,14 @@ class WindowsRM
4040

4141
/**
4242
*
43-
* @var AppLogger
43+
* @var WindowsRM
4444
*/
45-
private $logger;
46-
45+
public static $instance;
4746
/**
4847
*
49-
* @var WindowsRM
48+
* @var AppLogger
5049
*/
51-
public static $instance;
50+
private $logger;
5251

5352
function __construct()
5453
{
@@ -73,6 +72,13 @@ public static function get()
7372
return self::$instance;
7473
}
7574

75+
public static function reboot(string $destination)
76+
{
77+
$cmd = new WindowsCommand();
78+
$cmd->setCmd('shutdown -r -m ' . $destination . ' -t 60');
79+
AppLogger::get()->info('Rebooting ' . $destination);
80+
}
81+
7682
public function testConnection($computer)
7783
{
7884
$this->logger->info("Testing connection to $computer");
@@ -94,14 +100,6 @@ public function testConnection($computer)
94100
//return $this->portReachable($computer, 5985);
95101
}
96102

97-
public function rebootWorkstation($hostname)
98-
{
99-
100-
$cmd = new WindowsCommand();
101-
$cmd->setCmd("shutdown /r /t 30")
102-
->setHostname($hostname);
103-
}
104-
105103
public function DNSLookup($hostname)
106104
{
107105
$record = dns_get_record($hostname);
@@ -127,4 +125,12 @@ private function portReachable($host, $port)
127125
//echo PHP_EOL;
128126
}
129127

128+
public function rebootWorkstation($hostname)
129+
{
130+
131+
$cmd = new WindowsCommand();
132+
$cmd->setCmd("shutdown /r /t 30")
133+
->setHostname($hostname);
134+
}
135+
130136
}

0 commit comments

Comments
 (0)