Skip to content

Commit 9dbf8b6

Browse files
committed
first commit
0 parents  commit 9dbf8b6

File tree

3 files changed

+93
-0
lines changed

3 files changed

+93
-0
lines changed

FormTable.php

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<?php
2+
3+
/**
4+
* Class FormTable
5+
*/
6+
abstract class FormTable
7+
{
8+
9+
/**
10+
* Primeira parte da tabela
11+
* @param integer $width
12+
* @param array $header
13+
* @author Tiago ACP
14+
* @return void
15+
*/
16+
private function htmlHeader(int $width,array $header)
17+
{
18+
$html = "<html>";
19+
$html .= "<head>";
20+
$html .= "</head>";
21+
$html .= "<body>";
22+
$html .= "<table style='width:".$width."%'";
23+
$html .= "<tr>";
24+
foreach($header as $item)
25+
$html .= "<th>".$item."</th>";
26+
$html .= "</tr>";
27+
return $html;
28+
}
29+
30+
/**
31+
* Retornar html com formato de tabela
32+
* @param integer $width
33+
* @param array $header
34+
* @param array $attribute
35+
* @author Tiago ACP
36+
* @return void
37+
*/
38+
public function html(int $width, array $header, array $attribute)
39+
{
40+
$html = $this->htmlHeader($width, $header);
41+
foreach($attribute as $item){
42+
$html .= "<tr>";
43+
foreach($item as $value)
44+
$html .= "<td>".$value."</td>" ;
45+
$html .= "</tr>";
46+
}
47+
$html .= "</table>";
48+
$html .= "</body>";
49+
$html .= "</html>";
50+
return $html;
51+
}
52+
53+
54+
55+
56+
}

User.php

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
require_once "./FormTable.php";
3+
4+
/**
5+
* Class User
6+
*/
7+
class User extends FormTable
8+
{
9+
10+
/**
11+
* Cabeçalho que será apresentado na tabela
12+
* @var array
13+
*/
14+
public $header = ['Nome','E-mail','Profissão','Setor','Situação','Sexo'];
15+
16+
/**
17+
* Conteúdo que será apresentado na tabela
18+
* @var array
19+
*/
20+
public $attribute = [
21+
['América','america@mail.com','Médica','Saúde','empregado','Feminino'],
22+
['Américo','americo@mail.com','Advogado','Jurídico','empregado','Masculino']
23+
];
24+
25+
26+
27+
}

index.php

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
require_once "./User.php";
3+
/****
4+
* @author Tiago ACP
5+
*
6+
* Testando algoritmo
7+
*/
8+
$user = new User();
9+
10+
echo $user->html(50,$user->header,$user->attribute);

0 commit comments

Comments
 (0)