Skip to content

Latest commit

 

History

History
41 lines (26 loc) · 751 Bytes

constant_adapter.md

File metadata and controls

41 lines (26 loc) · 751 Bytes

ConstantAdapter

The ConstantAdapter transforms the input value from the string representation of a constant into it's value.

Ex. The value <constant("ARRAY_FILTER_USE_BOTH")> will be transformed into 1.

Usage

Given there is a class like:

<?php

namespace App\Model;

final class Role
{
    public const ROLE_USER = 'user';
}

Then the following should happen:

<?php

use Presta\BehatEvaluator\Adapter\ConstantAdapter;

$evaluate = new ConstantAdapter(...);
$value = $evaluate('<constant("App\Model\Role::ROLE_USER")>');

// $value is equal to 'user'

You may return to the README or read other adapters guides.