tamper-8.x-1.x-dev/src/Plugin/Tamper/CastToInt.php
src/Plugin/Tamper/CastToInt.php
<?php
namespace Drupal\tamper\Plugin\Tamper;
use Drupal\tamper\TamperBase;
use Drupal\tamper\TamperableItemInterface;
/**
* Plugin implementation for casting to integer.
*
* @Tamper(
* id = "cast_to_int",
* label = @Translation("Cast to integer"),
* description = @Translation("This plugin will convert any value to its integer form."),
* category = @Translation("Text"),
* itemUsage = "ignored"
* )
*/
class CastToInt extends TamperBase {
/**
* {@inheritdoc}
*/
public function tamper($data, ?TamperableItemInterface $item = NULL) {
return (int) $data;
}
}
