Skip to content

Commit

Permalink
secund proble
Browse files Browse the repository at this point in the history
  • Loading branch information
gibmyx committed Oct 28, 2020
1 parent e0ec55e commit 5c7c763
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 8 deletions.
5 changes: 5 additions & 0 deletions .idea/php.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion .idea/refactory.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion App/DB/ApiService.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

final class ApiService
{
public function get(): array
public function getPosts(): array
{
return [
['id' => 1, 'nombre' => 'post', 'descripcion' => 'probado', 'published' => true],
Expand Down
4 changes: 2 additions & 2 deletions App/Origin/Origin_1.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

class Origin_1
{
public function excecute()
public function excecute(): array
{
$posts = ApiService::get();
$posts = ApiService::getPosts();

if (!empty($posts)) {
$result = [];
Expand Down
11 changes: 10 additions & 1 deletion App/Refactory/Refactory_1.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,17 @@

class Refactory_1
{
public function excecute()
public function excecute(): array
{
return array_filter(
$this->getPosts(), function ($post) {
return !empty($post['published']);
});
}

protected function getPosts() : array
{
return ApiService::getPosts();
}

}
31 changes: 28 additions & 3 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,36 @@


use App\Origin\Origin_1;
use App\Refactory\Refactory_1;


//Ejercicio 1
//Example 1, Origin
$origin_1 = new Origin_1();
$post = $origin_1->excecute();
echo "<h1>Posts Publicados " . count($post) ."</h1>";
echo "<h1>(Origin) Posts Publicados " . count($post) ."</h1>";
echo var_dump($post);
exit;
exit;

//Example 1, Refactory
$refactory_1 = new Refactory_1();
$post = $refactory_1->excecute();
echo "<h1>(Refactory) Posts Publicados " . count($post) ."</h1>";
echo var_dump($post);
exit;

















0 comments on commit 5c7c763

Please sign in to comment.