-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
# Conflicts: # composer.json
- Loading branch information
Showing
27 changed files
with
1,339 additions
and
461 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
.idea | ||
.idea | ||
vendor |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,33 @@ | ||
{ | ||
"name": "dlepera88-php/vilex", | ||
"version": "1.1.0", | ||
"license": "MIT", | ||
"authors": [ | ||
{"name": "Diego Lepera", "email": "dlepera88@gmail.com"} | ||
], | ||
"require": { | ||
"php": ">=7.1", | ||
"zendframework/zend-diactoros": "2.0.1" | ||
}, | ||
"require-dev": { | ||
"phpunit/phpunit": "^7.5" | ||
}, | ||
"suggest": { | ||
"dlepera88-php/dlx": "Micro-framework que utiliza a arquitetura Hexagonal (em desenvolvimento)", | ||
"dlepera88-php/painel-dlx": "Painel de administração" | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
"Vilex\\": "src/" | ||
"name": "dlepera88-php/vilex", | ||
"description": "Redenrizador de views.", | ||
"version": "2.1.0", | ||
"license": "MIT", | ||
"authors": [ | ||
{ | ||
"name": "Diego Lepera", | ||
"email": "dlepera88@gmail.com" | ||
} | ||
], | ||
"require": { | ||
"php": ">=7.1", | ||
"laminas/laminas-diactoros": "^2.0" | ||
}, | ||
"require-dev": { | ||
"phpunit/phpunit": "^7.5" | ||
}, | ||
"suggest": { | ||
"dlepera88-php/dlx": "Micro-framework que utiliza a arquitetura Hexagonal (em desenvolvimento)", | ||
"painel-dlx/painel-dlx": "Painel de administração" | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
"Vilex\\": "src/" | ||
} | ||
}, | ||
"autoload-dev": { | ||
"psr-4": { | ||
"Vilex\\Tests\\": "tests/" | ||
} | ||
} | ||
}, | ||
"autoload-dev": { | ||
"psr-4": { | ||
"Vilex\\Tests\\": "tests/" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
<?php | ||
/** | ||
* MIT License | ||
* | ||
* Copyright (c) 2018 PHP DLX | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in all | ||
* copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
* SOFTWARE. | ||
*/ | ||
|
||
namespace Vilex\Recursos; | ||
|
||
|
||
abstract class AbstractRecurso | ||
{ | ||
/** @var string */ | ||
private $src; | ||
|
||
/** @var string|null */ | ||
private $versao; | ||
|
||
/** | ||
* AbstractRecurso constructor. | ||
* @param string $src | ||
* @param string $versao | ||
*/ | ||
public function __construct(string $src, ?string $versao = null) | ||
{ | ||
$this->src = $src; | ||
$this->versao = $versao; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getSrc(): string | ||
{ | ||
return $this->src; | ||
} | ||
|
||
/** | ||
* @return string|null | ||
*/ | ||
public function getVersao(): ?string | ||
{ | ||
return $this->versao; | ||
} | ||
|
||
/** | ||
* Gerar TAG HTML desse recurso | ||
* @return string | ||
*/ | ||
abstract function getTagHtml(): string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
<?php | ||
/** | ||
* MIT License | ||
* | ||
* Copyright (c) 2018 PHP DLX | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in all | ||
* copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
* SOFTWARE. | ||
*/ | ||
|
||
namespace Vilex\Recursos; | ||
|
||
use Vilex\Services\Array2AtributosHtml; | ||
|
||
/** | ||
* Class Javascript | ||
* @package Vilex\Recursos | ||
* @covers JavascriptTest | ||
*/ | ||
class Javascript extends AbstractRecurso | ||
{ | ||
/** @var null|string */ | ||
private $type = null; | ||
|
||
/** | ||
* Javascript constructor. | ||
* @param string $src | ||
* @param string $versao | ||
* @param string|null $type | ||
*/ | ||
public function __construct(string $src, ?string $versao = null, ?string $type = null) | ||
{ | ||
parent::__construct($src, $versao); | ||
$this->type = $type; | ||
} | ||
|
||
/** | ||
* @return string|null | ||
*/ | ||
public function getType(): ?string | ||
{ | ||
return $this->type; | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
function getTagHtml(): string | ||
{ | ||
$tag_script = '<script %s></script>'; | ||
$src_com_versao = $this->getSrc(); | ||
|
||
if (!empty($this->getVersao())) { | ||
$src_com_versao .= "?{$this->getVersao()}"; | ||
} | ||
|
||
$atributos = ['src' => $src_com_versao]; | ||
|
||
if (!empty($this->getType())) { | ||
$atributos['type'] = $this->getType(); | ||
} | ||
|
||
$attr_html = (new Array2AtributosHtml())->execute($atributos); | ||
|
||
return sprintf($tag_script, $attr_html); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
<?php | ||
/** | ||
* MIT License | ||
* | ||
* Copyright (c) 2018 PHP DLX | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in all | ||
* copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
* SOFTWARE. | ||
*/ | ||
|
||
namespace Vilex\Recursos; | ||
|
||
use Vilex\Services\Array2AtributosHtml; | ||
|
||
/** | ||
* Class Stylesheet | ||
* @package Vilex\Recursos | ||
* @covers StylesheetTest | ||
*/ | ||
class Stylesheet extends AbstractRecurso | ||
{ | ||
/** @var string */ | ||
private $media = 'all'; | ||
|
||
/** | ||
* Stylesheet constructor. | ||
* @param string $src | ||
* @param string|null $versao | ||
* @param string $media | ||
*/ | ||
public function __construct(string $src, ?string $versao = null, string $media = 'all') | ||
{ | ||
parent::__construct($src, $versao); | ||
$this->media = $media; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getMedia(): string | ||
{ | ||
return $this->media; | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
function getTagHtml(): string | ||
{ | ||
$tag_link = '<link rel="stylesheet" %s>'; | ||
|
||
$src_com_versao = $this->getSrc(); | ||
|
||
if (!empty($this->getVersao())) { | ||
$src_com_versao .= "?{$this->getVersao()}"; | ||
} | ||
|
||
$atributos = ['href' => $src_com_versao]; | ||
|
||
if (!empty($this->getMedia())) { | ||
$atributos['media'] = $this->getMedia(); | ||
} | ||
|
||
$attr_html = (new Array2AtributosHtml())->execute($atributos); | ||
|
||
return sprintf($tag_link, $attr_html); | ||
} | ||
} |
Oops, something went wrong.