Verzeichnisstruktur phpBB-3.2.0
- Veröffentlicht
- 06.01.2017
So funktioniert es
|
Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück |
Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis. |
|
(Beispiel Datei-Icons)
|
Auf das Icon klicken um den Quellcode anzuzeigen |
Native.php
001 <?php
002 /**
003 * Zend Framework (http://framework.zend.com/)
004 *
005 * @link http://github.com/zendframework/zf2 for the canonical source repository
006 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
007 * @license http://framework.zend.com/license/new-bsd New BSD License
008 */
009
010 namespace Zend\Stdlib\StringWrapper;
011
012 use Zend\Stdlib\Exception;
013 use Zend\Stdlib\StringUtils;
014
015 class Native extends AbstractStringWrapper
016 {
017 /**
018 * The character encoding working on
019 * (overwritten to change defaut encoding)
020 *
021 * @var string
022 */
023 protected $encoding = 'ASCII';
024
025 /**
026 * Check if the given character encoding is supported by this wrapper
027 * and the character encoding to convert to is also supported.
028 *
029 * @param string $encoding
030 * @param string|null $convertEncoding
031 * @return bool
032 */
033 public static function isSupported($encoding, $convertEncoding = null)
034 {
035 $encodingUpper = strtoupper($encoding);
036 $supportedEncodings = static::getSupportedEncodings();
037
038 if (!in_array($encodingUpper, $supportedEncodings)) {
039 return false;
040 }
041
042 // This adapter doesn't support to convert between encodings
043 if ($convertEncoding !== null && $encodingUpper !== strtoupper($convertEncoding)) {
044 return false;
045 }
046
047 return true;
048 }
049
050 /**
051 * Get a list of supported character encodings
052 *
053 * @return string[]
054 */
055 public static function getSupportedEncodings()
056 {
057 return StringUtils::getSingleByteEncodings();
058 }
059
060 /**
061 * Set character encoding working with and convert to
062 *
063 * @param string $encoding The character encoding to work with
064 * @param string|null $convertEncoding The character encoding to convert to
065 * @return StringWrapperInterface
066 */
067 public function setEncoding($encoding, $convertEncoding = null)
068 {
069 $supportedEncodings = static::getSupportedEncodings();
070
071 $encodingUpper = strtoupper($encoding);
072 if (!in_array($encodingUpper, $supportedEncodings)) {
073 throw new Exception\InvalidArgumentException(
074 'Wrapper doesn\'t support character encoding "' . $encoding . '"'
075 );
076 }
077
078 if ($encodingUpper !== strtoupper($convertEncoding)) {
079 $this->convertEncoding = $encodingUpper;
080 }
081
082 if ($convertEncoding !== null) {
083 if ($encodingUpper !== strtoupper($convertEncoding)) {
084 throw new Exception\InvalidArgumentException(
085 'Wrapper doesn\'t support to convert between character encodings'
086 );
087 }
088
089 $this->convertEncoding = $encodingUpper;
090 } else {
091 $this->convertEncoding = null;
092 }
093 $this->encoding = $encodingUpper;
094
095 return $this;
096 }
097
098 /**
099 * Returns the length of the given string
100 *
101 * @param string $str
102 * @return int|false
103 */
104 public function strlen($str)
105 {
106 return strlen($str);
107 }
108
109 /**
110 * Returns the portion of string specified by the start and length parameters
111 *
112 * @param string $str
113 * @param int $offset
114 * @param int|null $length
115 * @return string|false
116 */
117 public function substr($str, $offset = 0, $length = null)
118 {
119 return substr($str, $offset, $length);
120 }
121
122 /**
123 * Find the position of the first occurrence of a substring in a string
124 *
125 * @param string $haystack
126 * @param string $needle
127 * @param int $offset
128 * @return int|false
129 */
130 public function strpos($haystack, $needle, $offset = 0)
131 {
132 return strpos($haystack, $needle, $offset);
133 }
134 }
135