Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
<?php

namespace TBela\CSS\Property;
namespace TBela\CSS\Element\Declaration;

use TBela\CSS\Interfaces\RenderableInterface;
use TBela\CSS\Value;

/**
* Comment property class
Expand Down
25 changes: 15 additions & 10 deletions src/Property/Config.php → src/Element/Declaration/Config.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php

namespace TBela\CSS\Property;
namespace TBela\CSS\Element\Declaration;

$file = dirname(__DIR__).'/config.json';
$file = dirname(__DIR__.'/../../..').'/config.json';

if (is_file($file)) {

Expand All @@ -29,7 +29,8 @@ final class Config {
* load properties configuration from a JSON file
* @param string $file
*/
public static function load($file) {
public static function load(string $file): void
{

Config::$config = json_decode(file_get_contents($file), true) ?? [];
}
Expand All @@ -39,7 +40,8 @@ public static function load($file) {
* @param string $path
* @return bool
*/
public static function exists($path) {
public static function exists(string $path): bool
{

$found = true;
$item = Config::$config['alias'];
Expand Down Expand Up @@ -83,7 +85,8 @@ public static function exists($path) {
* @return mixed|null
* @ignore
*/
public static function getPath($path, $default = null) {
public static function getPath(string $path, mixed $default = null): mixed
{

$data = Config::$config;

Expand All @@ -106,7 +109,8 @@ public static function getPath($path, $default = null) {
* @param mixed|null $default
* @return array|mixed|null
*/
public static function getProperty ($name = null, $default = null) {
public static function getProperty (string $name = null, mixed $default = null): mixed
{

if (is_null($name)) {

Expand Down Expand Up @@ -136,7 +140,8 @@ public static function getProperty ($name = null, $default = null) {
* @return array
* @ignore
*/
public static function addSet ($shorthand, $pattern, array $properties, $separator = null, $shorthandOverride = null) {
public static function addSet ($shorthand, $pattern, array $properties, string $separator = null, string $shorthandOverride = null): array
{

$config = [];

Expand All @@ -157,7 +162,7 @@ public static function addSet ($shorthand, $pattern, array $properties, $separat
// build value map
foreach ($properties as $property => $data) {

if (strpos($property, '.') !== false) {
if (str_contains($property, '.')) {

continue;
}
Expand All @@ -167,7 +172,7 @@ public static function addSet ($shorthand, $pattern, array $properties, $separat

foreach ($properties as $property => $data) {

if (strpos($property, '.') !== false) {
if (str_contains($property, '.')) {

$config[$shorthand][preg_replace('#^[^.]+\.#', '', $property)] = $data;
continue;
Expand All @@ -177,7 +182,7 @@ public static function addSet ($shorthand, $pattern, array $properties, $separat

if (isset($data['value_map'])) {

$map_keys = $value_map_keys[$properties[$property]['type']];
$map_keys = $value_map_keys[$data['type']];

$config[$shorthand]['value_map'][$property] = array_map(function ($value) use ($map_keys) {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace TBela\CSS\Property;
namespace TBela\CSS\Element\Declaration;

use ArrayAccess;
use TBela\CSS\ArrayTrait;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
<?php

namespace TBela\CSS\Property;
namespace TBela\CSS\Element\Declaration;

use ArrayIterator;
use IteratorAggregate;
use TBela\CSS\Value;
use TBela\CSS\Element\Rule;
use TBela\CSS\Element\RuleList;

Expand Down
Loading