4 * This file is part of the Symfony package.
6 * (c) Fabien Potencier <fabien@symfony.com>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Symfony\Component\VarDumper\Caster;
14 use Symfony\Component\VarDumper\Cloner\Stub;
17 * Represents the main properties of a PHP variable, pre-casted by a caster.
19 * @author Nicolas Grekas <p@tchwork.com>
21 class CutStub extends Stub
23 public function __construct($value)
25 $this->value = $value;
27 switch (gettype($value)) {
29 $this->type = self::TYPE_OBJECT;
30 $this->class = get_class($value);
35 $this->type = self::TYPE_ARRAY;
36 $this->class = self::ARRAY_ASSOC;
37 $this->cut = $this->value = count($value);
42 case 'resource (closed)':
43 $this->type = self::TYPE_RESOURCE;
44 $this->handle = (int) $value;
45 if ('Unknown' === $this->class = @get_resource_type($value)) {
46 $this->class = 'Closed';
52 $this->type = self::TYPE_STRING;
53 $this->class = preg_match('//u', $value) ? self::STRING_UTF8 : self::STRING_BINARY;
54 $this->cut = self::STRING_BINARY === $this->class ? strlen($value) : mb_strlen($value, 'UTF-8');