-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
19a8626
commit 330591d
Showing
3 changed files
with
50 additions
and
1 deletion.
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 |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace Genkgo\Xsl\Xsl\Node; | ||
|
||
use DOMElement; | ||
use Genkgo\Xsl\Xpath\Compiler; | ||
use Genkgo\Xsl\Xsl\ElementTransformerInterface; | ||
|
||
final class AttributeName implements ElementTransformerInterface | ||
{ | ||
/** | ||
* @var Compiler | ||
*/ | ||
private $xpathCompiler; | ||
|
||
/** | ||
* @param Compiler $compiler | ||
*/ | ||
public function __construct(Compiler $compiler) | ||
{ | ||
$this->xpathCompiler = $compiler; | ||
} | ||
|
||
/** | ||
* @param DOMElement $element | ||
* @return bool | ||
*/ | ||
public function supports(DOMElement $element): bool | ||
{ | ||
return $element->hasAttribute('name'); | ||
} | ||
|
||
/** | ||
* @param DOMElement $element | ||
*/ | ||
public function transform(DOMElement $element): void | ||
{ | ||
$element->setAttribute( | ||
'name', | ||
$this->xpathCompiler->compile( | ||
$element->getAttribute('name'), | ||
$element | ||
) | ||
); | ||
} | ||
} |
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