ORIENT/vendor/wikimedia/less.php/lib/Less/Tree/Attribute.php

50 lines
937 B
PHP
Raw Normal View History

2021-04-08 08:08:59 +00:00
<?php
/**
2023-02-27 04:39:19 +00:00
* @private
2021-04-08 08:08:59 +00:00
*/
2023-02-27 04:39:19 +00:00
class Less_Tree_Attribute extends Less_Tree {
2021-04-08 08:08:59 +00:00
public $key;
public $op;
public $value;
public $type = 'Attribute';
2023-02-27 04:39:19 +00:00
public function __construct( $key, $op, $value ) {
2021-04-08 08:08:59 +00:00
$this->key = $key;
$this->op = $op;
$this->value = $value;
}
2023-02-27 04:39:19 +00:00
public function compile( $env ) {
$key_obj = is_object( $this->key );
$val_obj = is_object( $this->value );
2021-04-08 08:08:59 +00:00
2023-02-27 04:39:19 +00:00
if ( !$key_obj && !$val_obj ) {
2021-04-08 08:08:59 +00:00
return $this;
}
return new Less_Tree_Attribute(
2023-02-27 04:39:19 +00:00
$key_obj ? $this->key->compile( $env ) : $this->key,
2021-04-08 08:08:59 +00:00
$this->op,
2023-02-27 04:39:19 +00:00
$val_obj ? $this->value->compile( $env ) : $this->value );
2021-04-08 08:08:59 +00:00
}
2023-02-27 04:39:19 +00:00
/**
* @see Less_Tree::genCSS
*/
public function genCSS( $output ) {
2021-04-08 08:08:59 +00:00
$output->add( $this->toCSS() );
}
2023-02-27 04:39:19 +00:00
public function toCSS() {
2021-04-08 08:08:59 +00:00
$value = $this->key;
2023-02-27 04:39:19 +00:00
if ( $this->op ) {
2021-04-08 08:08:59 +00:00
$value .= $this->op;
2023-02-27 04:39:19 +00:00
$value .= ( is_object( $this->value ) ? $this->value->toCSS() : $this->value );
2021-04-08 08:08:59 +00:00
}
return '[' . $value . ']';
}
2023-02-27 04:39:19 +00:00
}