Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / vendor / symfony / console / Helper / Helper.php
index 4fb176527a1d23fe02b0a70baa75d9615075d7a7..0954bad6b2df713f9af9c61e02a9d8dc19fe9b7a 100644 (file)
@@ -23,9 +23,7 @@ abstract class Helper implements HelperInterface
     protected $helperSet = null;
 
     /**
-     * Sets the helper set associated with this helper.
-     *
-     * @param HelperSet $helperSet A HelperSet instance
+     * {@inheritdoc}
      */
     public function setHelperSet(HelperSet $helperSet = null)
     {
@@ -33,9 +31,7 @@ abstract class Helper implements HelperInterface
     }
 
     /**
-     * Gets the helper set associated with this helper.
-     *
-     * @return HelperSet|null
+     * {@inheritdoc}
      */
     public function getHelperSet()
     {
@@ -58,6 +54,24 @@ abstract class Helper implements HelperInterface
         return mb_strwidth($string, $encoding);
     }
 
+    /**
+     * Returns the subset of a string, using mb_substr if it is available.
+     *
+     * @param string   $string String to subset
+     * @param int      $from   Start offset
+     * @param int|null $length Length to read
+     *
+     * @return string The string subset
+     */
+    public static function substr($string, $from, $length = null)
+    {
+        if (false === $encoding = mb_detect_encoding($string, null, true)) {
+            return substr($string, $from, $length);
+        }
+
+        return mb_substr($string, $from, $length, $encoding);
+    }
+
     public static function formatTime($secs)
     {
         static $timeFormats = array(