Skip to content

Commit eafe281

Browse files
committed
feat: Add Segment object representation
1 parent 3b38e43 commit eafe281

39 files changed

+1639
-3
lines changed

composer.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,10 @@
4040
"require": {
4141
"php": "^7.4 || ^8.0",
4242
"ext-json": "*",
43-
"psr/log": "^1.1"
43+
"ext-mbstring": "*",
44+
"psr/log": "^1.1",
45+
"symfony/polyfill-php80": "^1.32",
46+
"symfony/yaml": "^5.4"
4447
},
4548
"require-dev": {
4649
"phpunit/phpunit": "^9",

composer.lock

Lines changed: 304 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Datafile/Conditions.php

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Featurevisor\Datafile;
6+
7+
8+
use Featurevisor\Datafile\Conditions\ConditionFactory;
9+
use Featurevisor\Datafile\Conditions\ConditionInterface;
10+
use Featurevisor\Datafile\Conditions\EveryoneCondition;
11+
12+
final class Conditions implements ConditionInterface
13+
{
14+
private ConditionInterface $expression;
15+
16+
public static function createFromMixed($conditions): self
17+
{
18+
if ($conditions === '*') {
19+
return new self(new EveryoneCondition());
20+
}
21+
22+
if (is_array($conditions) === false) {
23+
throw new \InvalidArgumentException('Conditions must be array or string');
24+
}
25+
26+
$factory = new ConditionFactory();
27+
28+
return new self($factory->create($conditions));
29+
}
30+
31+
public function __construct(ConditionInterface $expression)
32+
{
33+
$this->expression = $expression;
34+
}
35+
36+
public function isSatisfiedBy(array $context): bool
37+
{
38+
return $this->expression->isSatisfiedBy($context);
39+
}
40+
}

0 commit comments

Comments
 (0)