X-Git-Url: http://www.aleph1.co.uk/gitweb/?a=blobdiff_plain;f=web%2Fcore%2Fmodules%2Fmigrate%2Fsrc%2FPlugin%2Fmigrate%2Fprocess%2FSubstr.php;fp=web%2Fcore%2Fmodules%2Fmigrate%2Fsrc%2FPlugin%2Fmigrate%2Fprocess%2FSubstr.php;h=1f852a9238b69460dab82157d9f4c7598904b6d2;hb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;hp=0000000000000000000000000000000000000000;hpb=57c063afa3f66b07c4bbddc2d6129a96d90f0aad;p=yaffs-website diff --git a/web/core/modules/migrate/src/Plugin/migrate/process/Substr.php b/web/core/modules/migrate/src/Plugin/migrate/process/Substr.php new file mode 100644 index 000000000..1f852a923 --- /dev/null +++ b/web/core/modules/migrate/src/Plugin/migrate/process/Substr.php @@ -0,0 +1,78 @@ +configuration['start']) ? $this->configuration['start'] : 0; + if (!is_int($start)) { + throw new MigrateException('The start position configuration value should be an integer. Omit this key to capture from the beginning of the string.'); + } + $length = isset($this->configuration['length']) ? $this->configuration['length'] : NULL; + if (!is_null($length) && !is_int($length)) { + throw new MigrateException('The character length configuration value should be an integer. Omit this key to capture from the start position to the end of the string.'); + } + if (!is_string($value)) { + throw new MigrateException('The input value must be a string.'); + } + + // Use optional start or length to return a portion of $value. + $new_value = Unicode::substr($value, $start, $length); + return $new_value; + } + +}