Animation.php
1 year ago
Background.php
1 year ago
BackgroundImage.php
1 year ago
Border.php
2 years ago
BoxShadow.php
1 year ago
ColumnWidth.php
1 year ago
CustomHeight.php
1 year ago
CustomSize.php
4 years ago
Gap.php
1 year ago
Height.php
1 year ago
JustifyContent.php
1 year ago
MaxWidth.php
1 year ago
MultipleImage.php
1 year ago
ObjectCss.php
1 year ago
Opacity.php
1 year ago
Property.php
1 year ago
PropertyBase.php
1 year ago
Size.php
1 year ago
Stroke.php
1 year ago
TBLR.php
1 year ago
TextShadow.php
1 year ago
Transform.php
2 years ago
Transition.php
1 year ago
Typography.php
1 month ago
UnitValuePercentage.php
1 year ago
UnitValuePx.php
1 year ago
ValueProxy.php
4 years ago
Width.php
1 year ago
Property.php
71 lines
| 1 | <?php |
| 2 | |
| 3 | namespace Kubio\Core\StyleManager\Props; |
| 4 | use Kubio\Core\LodashBasic; |
| 5 | use function is_string; |
| 6 | |
| 7 | class Property { |
| 8 | public $properties = array(); |
| 9 | public $default; |
| 10 | public $value; |
| 11 | |
| 12 | public function __construct( $value, $default = array() ) { |
| 13 | $this->value = $value; |
| 14 | $this->default = $default; |
| 15 | } |
| 16 | |
| 17 | public function matchTypeOf( $types, $value ) { |
| 18 | foreach ( $types as $type_value ) { |
| 19 | $type = $type_value['type']; |
| 20 | switch ( $type ) { |
| 21 | case 'string': |
| 22 | if ( is_string( $value ) ) { |
| 23 | return $type; |
| 24 | } |
| 25 | break; |
| 26 | } |
| 27 | } |
| 28 | } |
| 29 | |
| 30 | public function resolveProperties() { |
| 31 | $resolved = array(); |
| 32 | foreach ( $this->properties as $key => $property ) { |
| 33 | if ( $key == 'anyOf' ) { |
| 34 | |
| 35 | } |
| 36 | if ( isset( $property['type'] ) ) { |
| 37 | $resolved[ $key ] = $this->createProperty( $property, $this->value[] ); |
| 38 | } |
| 39 | } |
| 40 | } |
| 41 | |
| 42 | public function createProperty( $propery ) { |
| 43 | if ( isset( $propery['type'] ) ) { |
| 44 | $class = $propery['type']; |
| 45 | |
| 46 | return new $class(); |
| 47 | } |
| 48 | } |
| 49 | |
| 50 | public function resolveMap( $resolvedProperties ) { |
| 51 | $mapped = array(); |
| 52 | foreach ( $this->map as $key => $value ) { |
| 53 | $mapped[ $key ] = $resolvedProperties[ $value ]; |
| 54 | } |
| 55 | } |
| 56 | |
| 57 | public function get( $path, $default = null ) { |
| 58 | return LodashBasic::get( $this->merged(), $path, $default ); |
| 59 | } |
| 60 | |
| 61 | public function merged() { |
| 62 | return LodashBasic::merge( $this->default, $this->value ); |
| 63 | } |
| 64 | |
| 65 | public function __toString() { |
| 66 | if ( is_string( $this->value ) ) { |
| 67 | return $this->value; |
| 68 | } |
| 69 | } |
| 70 | } |
| 71 |