calculates the size of given value

@param   string|array|\Countable|\Iterator|\IteratorAggregate  $value
@return  int
3728
private function sizeOf($value): int
    {
        if (is_string($value)) {
            return strlen($value);
        } elseif (is_array($value) || $value instanceof \Countable) {
            return count($value);
        }

        $traversable = $this->traversable($value);
        $key         = $traversable->key();
        $count       = iterator_count($traversable);
        // rewinds traversable to previous key to not change state of traversable
        // because iterator_count() changes the pointer
        $traversable->rewind();
        while ($traversable->valid() && $key !== $traversable->key()) {
            $traversable->next();
        }

        return $count;
    }
1364887
public function numToBinary($value)
    {
        $saved_object_count = $this->writtenObjectCount++;

        $val = "";
        if (intval($value) == $value && !is_float($value) && strpos($value, '.') === false) {
            $val = $this->intToBinary($value);
        } else {
            $val = $this->realToBinary($value);
        }

        $this->objectTable[$saved_object_count] = $val;
        return $saved_object_count;
    }
902916
public static function castInt($value): int
    {
        if ($value !== null && !is_scalar($value)) {
            throw new InvalidArgumentException('Value could not be parsed to integer');
        }

        return (int)$value;
    }
551031
public function computeZigzag32Size($value)
    {
        $varint = ($value << 1) ^ ($value >> 32 - 1);
        $size   = $this->computeVarintSize($varint);

        return $size;
    }
360419
final protected function valueInBounds($value)
    {
        return is_null($value) || (
            (is_null($this->getMinLength()) || strlen($value) >= $this->getMinLength())
            &&
            (is_null($this->getMaxLength()) || strlen($value) <= $this->getMaxLength())
        );
    }
894189
def size(self, value):
		
		
		if self._combining:  # We are a field-compound query fragment, e.g. (Foo.bar & Foo.baz).
			return reduce(self._combining, (q.size(value) for q in self._field))
		
		# Optimize this away in production; diagnosic aide.
		if __debug__ and _complex_safety_check(self._field, {'$size', '#array'}):  # pragma: no cover
			raise NotImplementedError("{self!r} does not allow $size comparison.".format(self=self))
		
		return Filter({self._name: {'$size': int(value)}})
1160722
public static function isSizeValue($value, $separator = ' x ')
    {
        /*
         * Not a string?
         * Nothing to do
         */
        if (!is_string($value)) {
            return false;
        }

        $pattern = self::getSizePattern($separator);

        return (bool)preg_match($pattern, $value);
    }
324295
protected function getSize($attribute, $value)
    {
        $hasNumeric = $this->hasRule($attribute, $this->numericRules);

        // This method will determine if the attribute is a number, string, or file and
        // return the proper size accordingly. If it is a number, then number itself
        // is the size. If it is a file, we take kilobytes, and for a string the
        // entire length of the string will be considered the attribute size.
        if (is_numeric($value) && $hasNumeric) {
            return array_get($this->data, $attribute);
        } elseif (is_array($value)) {
            return count($value);
        } elseif (in_array($value, $_FILES, true)) {
            return $value->getSize() / 1024;
        } else {
            return $this->getStringSize($value);
        }
    }
804251
public static function int($value=0, bool $flatten=false) {
		ref\cast::int($value, $flatten);
		return $value;
	}
1278135
private function parseAmount($value)
    {
        if ('%' === substr($value, -1)) {
            return substr($value, 0, -1);
        }
        $number = 0;
        $suffix = '';
        $value = preg_replace('/\s+/', '', $value);
        sscanf($value, '%u%s', $number, $suffix);
        if ('' === $suffix) {
            return $value;
        }

        if (false !== ($pow = array_search($suffix, $this->units))) {
            $bytes = $number * (1 << (10 * $pow));

            return (string) $bytes;
        } else {
            throw new \InvalidArgumentException(
                'Invalid size value. One of ['.join(
                    ', ',
                    $this->units
                ).'] allowed (or just a numeric byte value)'
            );
        }
    }
772147
public function validate($value)
    {
        return ($value instanceof \stdClass && count((array) $value) <= $this->size)
            || parent::validate($value);
    }
1123505
public static function format($value)
    {
        $value = Utils::toString($value);
        $bn = Utils::toBn($value);
        $int = (int) $bn->toString();

        return $int;
    }
340694
public function countValue($value)
    {
        return count(array_filter($this->data, function ($item) use ($value) {
            return $value === $item;
        }));
    }
252409
private function getResult(string $value, int $flags)
    {
        if (($flags & self::F_PACKED) !== self::F_PACKED) {
            $value = $this->removeTerminationNull($value);
        }

        $out = null;
        if (($flags & self::F_SERIALIZED) === self::F_SERIALIZED) {
            $out = Serializer::unserialize($value);
        }

        if (($flags & self::F_IS_BOOL) === self::F_IS_BOOL) {
            $out = (bool)$value;
        } else if (($flags & self::F_IS_INT) === self::F_IS_INT) {
            if (($flags & self::F_PACKED) === self::F_PACKED) {
                $res = unpack(self::P_INT . 'num', $value);
                $out = $res['num'];
                unset($res);
            } else {
                $out = (int)$value;
            }

        } else if (($flags & self::F_IS_FLOAT) === self::F_IS_FLOAT) {
            if (($flags & self::F_PACKED) === self::F_PACKED) {
                $res = unpack(self::P_FLOAT . 'num', $value);
                $out = $res['num'];
                unset($res);
            } else {
                $out = (double)$value;
            }
        } else if (($flags & self::F_IS_STRING) === self::F_IS_STRING) {
            $out = (string)$value;
        } else if (($flags & self::F_IS_NULL) === self::F_IS_NULL) {
            $out = null;
        } else if (($flags & self::F_IS_ARRAY) === self::F_IS_ARRAY) {
            if (($flags & self::F_SERIALIZED) === self::F_SERIALIZED) {
                $value = Serializer::unserialize($value);
            }

            if (($flags & self::F_IS_ARRAY_OBJECT) === self::F_IS_ARRAY_OBJECT) {
                $out = (object)$value;
            } else {
                $out = (array)$value;
            }
        }


        return $out;
    }
190796
public final function expand( int $value = 1 ) : Size
   {

      $this->triggerFixedErrorByNeed( 'expand' );

      $this->_width  = $this->_width + $value;
      $this->_height = $this->_height + $value;

      return $this;

   }
930793
protected function toNumber($value)
    {
        if (is_numeric($value)) {
            return $value + 0; // cast to number
        }
        if (is_bool($value) || is_null($value)) {
            return (int) $value;
        }
        if ($this->getTypeCheck()->isArray($value) && count($value) === 1) {
            return $this->toNumber(reset($value));
        }

        return $value;
    }
317942
public function getAndSet(int $value): int
    {
        return intval($this->handle->getSet($this->name, strval($value)));
    }