Skip to content

Commit 351b21a

Browse files
Padronização de código e adequações as PSR-1 e 2
1 parent 2d3b824 commit 351b21a

File tree

8 files changed

+229
-240
lines changed

8 files changed

+229
-240
lines changed

src/Conector/Wmi.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,13 @@ public function conectar($host, $usuario = null, $senha = null, $porta = 135, $t
4646
if (!$socket = @fsockopen($host, $porta, $errno, $errstr, $timeout)) {
4747
// @see https://msdn.microsoft.com/en-us/library/windows/desktop/ms740668(v=vs.85).aspx
4848
$dic = [
49-
10056 => "Já existe uma conexão socket aberta para o host <b>{$host}</b>!",
50-
10057 => "Não foi possível conectar ao socket na chamada do host <b>{$host}</b>!",
51-
10060 => "Time Out na chamada do host <b>{$host}</b>!",
52-
10061 => "O host <b>{$host}</b> recusou a conexão!",
53-
];
49+
110 => "Time Out ao tentar se conectar ao destino: <b>{$host}</b>",
50+
113 => "Não existem rotas para o destino: <b>{$host}</b>",
51+
10056 => "Já existe uma conexão socket aberta para o host <b>{$host}</b>",
52+
10057 => "Não foi possível conectar ao socket na chamada do host <b>{$host}</b>",
53+
10060 => "Time Out ao tentar se conectar ao destino: <b>{$host}</b>",
54+
10061 => "Conexão recusada pelo destino: <b>{$host}</b>"
55+
];
5456

5557
$mensagem = (array_key_exists($errno, $dic)) ? strtr($errno, $dic) : $errstr;
5658

src/Sistema/Cpu.php

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,14 @@ public function __construct(Conector $conexao)
5454
public function detalhes()
5555
{
5656
foreach ($this->cpu as $c) {
57-
5857
$cpu[$c->DeviceID] = [
59-
'nome' => $c->Name,
60-
'arquitetura' => $c->DataWidth,
61-
'mhz' => $c->CurrentClockSpeed,
62-
'nucleos' => $c->NumberOfCores,
63-
'processadoresLogicos' => $c->NumberOfLogicalProcessors,
64-
'cargaDoProcessador' => $c->LoadPercentage
65-
];
58+
'nome' => $c->Name,
59+
'arquitetura' => $c->DataWidth,
60+
'mhz' => $c->CurrentClockSpeed,
61+
'nucleos' => $c->NumberOfCores,
62+
'processadoresLogicos' => $c->NumberOfLogicalProcessors,
63+
'cargaDoProcessador' => $c->LoadPercentage
64+
];
6665
}
6766

6867
return $cpu;

src/Sistema/DiscoRigido.php

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -70,14 +70,13 @@ public function capacidade()
7070
public function espacoLivre()
7171
{
7272
foreach ($this->particoes as $p) {
73-
7473
$total = Transformar::converterBytes($p->FreeSpace);
7574
$percentual = sprintf("%0.2f%%", (100 * $p->FreeSpace / $p->Size));
7675

7776
$particao[$p->Caption] = [
78-
'total' => $total,
79-
'percentual' => $percentual
80-
];
77+
'total' => $total,
78+
'percentual' => $percentual
79+
];
8180
}
8281

8382
return $particao;
@@ -91,14 +90,13 @@ public function espacoLivre()
9190
public function espacoUtilizado()
9291
{
9392
foreach ($this->particoes as $p) {
94-
9593
$total = Transformar::converterBytes($p->Size - $p->FreeSpace);
9694
$percentual = sprintf("%0.2f%%", (100 * ($p->Size - $p->FreeSpace) / $p->Size));
9795

9896
$particao[$p->Caption] = [
99-
'total' => $total,
100-
'percentual' => $percentual
101-
];
97+
'total' => $total,
98+
'percentual' => $percentual
99+
];
102100
}
103101

104102
return $particao;
@@ -112,19 +110,18 @@ public function espacoUtilizado()
112110
public function detalhes()
113111
{
114112
foreach ($this->particoes as $p) {
115-
116113
$capacidade = $this->capacidade();
117114
$livre = $this->espacoLivre();
118115
$utilizado = $this->espacoUtilizado();
119116

120117
$particao[$p->Caption] = [
121-
'capacidade' => $capacidade[$p->Caption],
122-
'espacoLivre' => $livre[$p->Caption]['total'],
123-
'percentualLivre' => $livre[$p->Caption]['percentual'],
124-
'espacoUtilizado' => $utilizado[$p->Caption]['total'],
125-
'percentualUtilizado' => $utilizado[$p->Caption]['percentual'],
126-
'sistemaDeArquivo' => $p->FileSystem
127-
];
118+
'capacidade' => $capacidade[$p->Caption],
119+
'espacoLivre' => $livre[$p->Caption]['total'],
120+
'percentualLivre' => $livre[$p->Caption]['percentual'],
121+
'espacoUtilizado' => $utilizado[$p->Caption]['total'],
122+
'percentualUtilizado' => $utilizado[$p->Caption]['percentual'],
123+
'sistemaDeArquivo' => $p->FileSystem
124+
];
128125
}
129126

130127
return $particao;

src/Sistema/IpMac.php

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -55,16 +55,15 @@ public function __construct(Conector $conexao)
5555
public function detalhes()
5656
{
5757
foreach ($this->ipMac as $ipMac) {
58-
5958
$interface[$ipMac->InterfaceIndex] = [
60-
'interfaceDeRede' => $ipMac->Description,
61-
'hostName' => $ipMac->DNSHostName,
62-
'ipv4' => (string) $ipMac->IPAddress[0],
63-
'ipv6' => (string) $ipMac->IPAddress[1],
64-
'ipSubnet' => (string) $ipMac->IPSubnet[0],
65-
'dominio' => $ipMac->DNSDomain,
66-
'dhcp' => ($ipMac->DHCPEnabled) ? 'Ativo' : 'Inativo',
67-
];
59+
'interfaceDeRede' => $ipMac->Description,
60+
'hostName' => $ipMac->DNSHostName,
61+
'ipv4' => (string) $ipMac->IPAddress[0],
62+
'ipv6' => (string) $ipMac->IPAddress[1],
63+
'ipSubnet' => (string) $ipMac->IPSubnet[0],
64+
'dominio' => $ipMac->DNSDomain,
65+
'dhcp' => ($ipMac->DHCPEnabled) ? 'Ativo' : 'Inativo',
66+
];
6867
}
6968

7069
return $interface;

src/Sistema/MemoriaRam.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,9 @@ public function memoriaUtilizada()
7474
$total = $this->memoriaTotal(true);
7575

7676
return [
77-
'utilizado' => Transformar::converterBytes($total - $livre['livre']),
78-
'percentualUtilizado' => sprintf("%0.2f%%", (($total - $livre['livre']) * 100 / $total))
79-
];
77+
'utilizado' => Transformar::converterBytes($total - $livre['livre']),
78+
'percentualUtilizado' => sprintf("%0.2f%%", (($total - $livre['livre']) * 100 / $total))
79+
];
8080
}
8181

8282
/**
@@ -103,11 +103,11 @@ public function detalhes()
103103
$utilizada = $this->memoriaUtilizada();
104104

105105
return [
106-
'livre' => $livre['livre'],
107-
'percentualLivre' => $livre['percentualLivre'],
108-
'utilizado' => $utilizada['utilizado'],
109-
'percentualUtilizado' => $utilizada['percentualUtilizado'],
110-
'memoriaTotal' => $this->memoriaTotal()
111-
];
106+
'livre' => $livre['livre'],
107+
'percentualLivre' => $livre['percentualLivre'],
108+
'utilizado' => $utilizada['utilizado'],
109+
'percentualUtilizado' => $utilizada['percentualUtilizado'],
110+
'memoriaTotal' => $this->memoriaTotal()
111+
];
112112
}
113113
}

src/Sistema/Processos.php

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class Processos implements ProcessosInterface
2929
/**
3030
* Critério de busca
3131
*
32-
* @var string|int|null
32+
* @var string|null
3333
*/
3434
private $criterio;
3535

@@ -75,7 +75,6 @@ function __construct(Conector $conexao, $filtro = null)
7575
public function killProcesso()
7676
{
7777
if($this->criterio != null) {
78-
7978
foreach ($this->instancia as $s) {
8079
$retorno[] = $s->Terminate();
8180
}
@@ -95,14 +94,14 @@ public function killProcesso()
9594
public function alterarPrioridade($prioridade = null)
9695
{
9796
$resultado = [
98-
0 => 'Alteração efetuada com sucesso',
99-
2 => 'Acesso negado',
100-
3 => 'Privilégio insuficiente',
101-
8 => 'Erro desconhecido',
102-
9 => 'Caminho não encontrado',
103-
21 => 'Parâmetro inválido',
104-
'22-4294967295' => 'Retorno desconhecido'
105-
];
97+
0 => 'Alteração efetuada com sucesso',
98+
2 => 'Acesso negado',
99+
3 => 'Privilégio insuficiente',
100+
8 => 'Erro desconhecido',
101+
9 => 'Caminho não encontrado',
102+
21 => 'Parâmetro inválido',
103+
'22-4294967295' => 'Retorno desconhecido'
104+
];
106105

107106
/*
108107
* @see https://msdn.microsoft.com/en-us/library/aa393587(v=vs.85).aspx
@@ -118,7 +117,6 @@ public function alterarPrioridade($prioridade = null)
118117
$prioridadeExiste = in_array($prioridade, ['64', '16384', '32', '32768', '128', '256']);
119118

120119
if($this->criterio != null && $prioridadeExiste) {
121-
122120
foreach ($this->instancia as $s) {
123121
$retorno = [$s->setPriority($prioridade) => strtr($s->setPriority($prioridade), $resultado)];
124122
}
@@ -135,14 +133,13 @@ public function alterarPrioridade($prioridade = null)
135133
public function detalhes()
136134
{
137135
foreach ($this->instancia as $p) {
138-
139136
$processo[$p->ProcessId] = [
140-
"nome" => $p->Name,
141-
"Priority" => $p->Priority,
142-
"memoriaTotal" => Transformar::converterBytes($p->WorkingSetSize),
143-
"inicioDoProcesso" => Transformar::converterTimestamp($p->CreationDate),
144-
"path" => $p->ExecutablePath
145-
];
137+
"nome" => $p->Name,
138+
"Priority" => $p->Priority,
139+
"memoriaTotal" => Transformar::converterBytes($p->WorkingSetSize),
140+
"inicioDoProcesso" => Transformar::converterTimestamp($p->CreationDate),
141+
"path" => $p->ExecutablePath
142+
];
146143
}
147144

148145
return (isset($processo)) ? $processo : null;

0 commit comments

Comments
 (0)