@param string $fieldName
@param int $maxValue
@param int $valueToTest
@param int $exceptionCode

@throws InvalidValueException
3024
protected function ensureIsLowerThan($fieldName, $maxValue, $valueToTest, $exceptionCode = 0)
    {
        if ($valueToTest >= $maxValue) {
            $message = sprintf(
                '%s is greater than or equal expected value "%d", got "%d"',
                $fieldName,
                $maxValue,
                $valueToTest
            );
            throw new InvalidValueException($message, $exceptionCode);
        }
    }
1317501
protected function ensureIsGreaterThan($fieldName, $minValue, $valueToTest, $exceptionCode = 0)
    {
        if ($valueToTest <= $minValue) {
            $message = sprintf(
                '%s is lower than or equal expected value "%d", got "%d"',
                $fieldName,
                $minValue,
                $valueToTest
            );
            throw new InvalidValueException($message, $exceptionCode);
        }
    }
1276189
public function validateValueType($value)
    {
        if ($this->hasOption(Entity\Reflection\Property\Option\Primary::KEY)
            && (Entity\Reflection\Property\Option\Primary::isEmpty($value))
        ) {
            throw new Exception\InvalidArgumentException(
                "Primary value can not be empty string or null!",
                $value
            );
        }

        if ($value === null) {
            return;
        }

        // Enumeration
        if ($this->hasOption(Entity\Reflection\Property\Option\Enum::KEY)
            && !$this->getOption(Entity\Reflection\Property\Option\Enum::KEY)->isValid($value)
        ) {
            throw new Exception\InvalidArgumentException(
                "Value " . $value . " is not from defined entity enumeration "
                . "range on property " . $this->name . "!",
                $value
            );
        }

        // Scalar or array type
        if (self::isScalarType($this->type) || $this->type === self::TYPE_ARRAY) {

            if (gettype($value) === $this->type) {
                return;
            }
            throw new Exception\InvalidArgumentException(
                "Expected " . $this->type . " but " . gettype($value)
                . " given on property " . $this->name . "!",
                $value
            );
        }

        // Object validation
        $givenType = gettype($value);
        if ($givenType === "object") {
            $givenType = get_class($value);
        }

        if ($this->type === self::TYPE_ENTITY) {
            // Entity

            $expectedEntityClass = Convention::nameToClass($this->typeOption, Convention::ENTITY_MASK);
            if ($value instanceof $expectedEntityClass) {
                return;
            } else {
                throw new Exception\InvalidArgumentException(
                    "Expected entity " . $this->typeOption . " but " . $givenType
                    . " given on property " . $this->name . "!",
                    $value
                );
            }
        } elseif ($this->type === self::TYPE_COLLECTION) {
            // Collection

            $entityClass = Convention::nameToClass($this->typeOption, Convention::ENTITY_MASK);
            if (!$value instanceof Entity\Collection) {

                throw new Exception\InvalidArgumentException(
                    "Expected entity collection but " . $givenType . " given on"
                    . " property " . $this->name . "!",
                    $value
                );
            } elseif ($value->getEntityClass() !== $entityClass) {
                throw new Exception\InvalidArgumentException(
                    "Expected collection of entity " . $entityClass
                    . " but collection of entity " . $value->getEntityClass()
                    . " given on property " . $this->name . "!",
                    $value
                );
            } else {
                return;
            }
        } elseif ($this->type === self::TYPE_DATETIME) {
            // DateTime

            if ($value instanceof \DateTime) {
                return;
            } else {
                throw new Exception\InvalidArgumentException(
                    "Expected DateTime but " . $givenType . " given on"
                    . " property " . $this->name . "!",
                    $value
                );
            }
        } elseif ($this->type === self::TYPE_DATE) {
            // Date

            if ($value instanceof \DateTime) {
                return;
            } else {
                throw new Exception\InvalidArgumentException(
                    "Expected date as DateTime object but " . $givenType
                    . " given on property " . $this->name . "!",
                    $value
                );
            }
        } else {
            // Unexpected

            throw new \Exception("Unsupported type " . $this->type . "!");
        }
    }
1305163
protected function ensureIsNotEmpty($fieldName, $valueToTest, $exceptionCode = 0)
    {
        if ($valueToTest === 0 || $valueToTest === '0' || $valueToTest === false) {
            return;
        }

        if (empty($valueToTest)) {
            $message = sprintf('%s should not be empty', $fieldName);
            throw new InvalidValueException($message, $exceptionCode);
        }
    }
865493
private function validatePayloadSize(array $rawData, $fieldName, $maxSize)
    {
        if (!isset($rawData[$fieldName])) {
            return;
        }
        if (strlen(json_encode($rawData[$fieldName])) > $maxSize) {
            throw new Exception(
                ucfirst($fieldName)." payload is to big (max {$maxSize} bytes)",
                Exception::MALFORMED_REQUEST
            );
        }
    }
29100
protected function _setValue($property, $value, $validate = true)
    {
        if ($this->_propertyExists($property)) {
            if ($validate) {
                self::$_manager->validateAttribute($this, $property, ['maxLength','readOnly'], $value);
            }
            if ($this->_propertyTypeAllowed($property, $value)) {
                $this->{$property} = $value;
            } else {
                $this->{$property} = $this->tryFormat($value, $this->_getPropertyType($property), $property);
            }
        } else {
            if ($this->_getDynamicAttributeDenied()) {
                throw new \Exception('Dynamic attribute: ' . $property . ' not allowed for entity ' . get_class($this));
            }
            $this->{$property} = $value;
        }
    }
318471
final public static function parseValue($searchValue, bool $looseComparison = false): string
    {
        if (false !== $name = \array_search($searchValue, self::getClassConstants(static::class), !$looseComparison)) {
            return $name;
        }

        throw new \InvalidArgumentException('Unknown enumeration value: ' . $searchValue);
    }
387714
public static function collect(
        string $className,
        $objectAnnotation = null,
        string $propertyName = '',
        string $methodName = '',
        $propertyValue = null
    ) {
        if ($objectAnnotation instanceof Strings) {
            self::collectString($objectAnnotation, $className, $methodName);
        } elseif ($objectAnnotation instanceof Floats) {
            self::collectFloats($objectAnnotation, $className, $methodName);
        } elseif ($objectAnnotation instanceof Number) {
            self::collectNumber($objectAnnotation, $className, $methodName);
        } elseif ($objectAnnotation instanceof Integer) {
            self::collectInteger($objectAnnotation, $className, $methodName);
        } elseif ($objectAnnotation instanceof Enum) {
            self::collectEnum($objectAnnotation, $className, $methodName);
        }
    }
1161250
public function push($fieldName, $value)
    {
        $oldValue = $this->get($fieldName);

        // check if old value is list or sub document
        // on sub document throw exception
        if (is_array($oldValue)) {
            $isSubDocument = (array_keys($oldValue) !== range(0, count($oldValue) - 1));
            if ($isSubDocument) {
                throw new InvalidOperationException(sprintf(
                    'The field "%s" must be an array but is of type Object',
                    $fieldName
                ));
            }
        }

        // prepare new value
        $value = Structure::prepareToStore($value);

        // field not exists
        if (!$oldValue) {
            if ($this->getId()) {
                $this->operator->push($fieldName, $value);
            }
            $value = array($value);
        } // field already exist and has single value
        elseif (!is_array($oldValue)) {
            $value = array_merge((array) $oldValue, array($value));
            if ($this->getId()) {
                $this->operator->set($fieldName, $value);
            }
        } // field exists and is array
        else {
            if ($this->getId()) {
                $setValue = $this->operator->get('$set', $fieldName);
                if ($setValue) {
                    $setValue[] = $value;
                    $this->operator->set($fieldName, $setValue);
                } else {
                    $this->operator->push($fieldName, $value);
                }
            }
            $value = array_merge($oldValue, array($value));
        }

        // update local data
        parent::set($fieldName, $value);

        return $this;
    }
617628
protected function validate($value)
    {
        foreach ($this->validators as $validator) {
            if (!$validator->validate($value)) {
                throw new InvalidValueException(
                    "Field {$this->name}, was set with invalid value: " . var_export($value, true)
                );
            }
        }
    }
515822
public function getValuesData(AttributeInterface $attribute, array $context = null)
    {
        $this->checkAttribute($attribute);
        $valuesData = new ArrayCollection();
        try {
            foreach ($this->getValues($attribute, $context) as $value) {
                $valuesData->add($value->getValueData());
            }
        } catch (ExceptionInterface $e) {
            throw new InvalidValueDataException("Unable to access data for attribute {$attribute->getCode()}", 0, $e);
        }


        return $valuesData;
    }
459828
public function isException($test, $value) {
		$exceptions = $this->getTestExceptions($test);
		return (!empty($exceptions) && in_array($value, $exceptions));
	}
909368
public function evaluateRule($fieldValue)
    {
        // what type of variable are we dealing with?
        // todo maybe pick and choose when to treat variable as string
        $testFunction = "return ('" . $fieldValue . "' $this->operator  '$this->value' ) ? true : false ;";
        $result = eval($testFunction);
        if (!is_bool($result)) {
            throw new HTTPException('DenyIf rule returned invalid result.  Must be a boolean', 500, ['code' => '136497941613689198']);
        }
        return $result;
    }
801981
protected function validate_calculated_value($calculatedvalue) {
        if ($calculatedvalue > self::MAX_VALUE || $calculatedvalue < self::MIN_VALUE) {
            throw new \coding_exception('Calculated values should be higher than ' . self::MIN_VALUE .
                ' and lower than ' . self::MAX_VALUE . ' ' . $calculatedvalue . ' received');
        }
        return true;
    }
1016984
public function setField($fieldName = '', $fieldValue = '')
    {
        if (in_array($fieldName, array_keys($this->validFields))) {
            $this->fieldData[$fieldName] = $this->cleanString($fieldValue);
            if ($fieldName == 'LU_ENABLE_TOKEN') {
                if ($fieldValue) {
                    $this->fieldData['LU_TOKEN_TYPE'] = 'PAY_BY_CLICK';
                }
            }
            return true;
        }
        $this->debugMessage[] = 'SET FIELD: Invalid field in setField: ' . $fieldName;
        return false;
    }
1223734
public static function restoreValueCode($valueName, $abstractSyntaxTree, $indentation)
    {
        $result = '';
        if (is_array($abstractSyntaxTree)) {
            $multiline = false;
            if (array_key_exists('__objectType', $abstractSyntaxTree) && $abstractSyntaxTree['__objectType'] !== null) {
                $multiline = true;
                $result .= $indentation . $valueName . ' = ' . $abstractSyntaxTree['__objectType'] . ' {' . chr(10);
                foreach (array_keys($abstractSyntaxTree) as $key) {
                    if (in_array($key, self::$RESERVED_KEYS, true)) {
                        continue;
                    }
                    $result .= self::restoreValueCode($key, $abstractSyntaxTree[$key], $indentation . self::INDENTATION);
                }
            } elseif (array_key_exists('__eelExpression', $abstractSyntaxTree) && $abstractSyntaxTree['__eelExpression'] !== null) {
                $result .= $indentation . $valueName . ' = ${' . $abstractSyntaxTree['__eelExpression'] . '}' . chr(10);
            } elseif (array_key_exists('__value', $abstractSyntaxTree)) {
                if (is_string($abstractSyntaxTree['__value'])) {
                    $result .= $indentation . $valueName . ' = "' . $abstractSyntaxTree['__value'] . '"' . chr(10);
                } else {
                    $result .= $indentation . $valueName . ' = ' . (string)$abstractSyntaxTree['__value'] . chr(10);
                }
            } else {
                $multiline = true;
                $result .= $indentation . $valueName . ' {' . chr(10);
                foreach (array_keys($abstractSyntaxTree) as $key) {
                    $result .= self::restoreValueCode($key, $abstractSyntaxTree[$key], $indentation . self::INDENTATION);
                }
            }

            if ($multiline) {
                if (array_key_exists('__meta', $abstractSyntaxTree)) {
                    foreach (array_keys($abstractSyntaxTree['__meta']) as $key) {
                        $result .= self::restoreValueCode('@' . $key, $abstractSyntaxTree['__meta'][$key], $indentation . self::INDENTATION);
                    }
                }

                // handle __prototypes
                if (array_key_exists('__prototypes', $abstractSyntaxTree)) {
                    foreach (array_keys($abstractSyntaxTree['__prototypes']) as $key) {
                        $result .= self::restorePrototypeCode($key, $abstractSyntaxTree['__prototypes'][$key], $indentation . self::INDENTATION);
                    }
                }
                $result .= $indentation . '}' . chr(10);
            } else {
                // handle __meta
                if (array_key_exists('__meta', $abstractSyntaxTree)) {
                    foreach (array_keys($abstractSyntaxTree['__meta']) as $key) {
                        $result .= self::restoreValueCode($valueName . '.@' . $key, $abstractSyntaxTree['__meta'][$key], $indentation);
                    }
                }
            }
        } else {
            if (is_string($abstractSyntaxTree)) {
                $result .= $indentation . $valueName . ' = "' . $abstractSyntaxTree . '"' . chr(10);
            } elseif (is_bool($abstractSyntaxTree)) {
                $result .= $indentation . $valueName . ' = ' . ($abstractSyntaxTree ? 'true' : 'false') . chr(10);
            } elseif (is_null($abstractSyntaxTree)) {
                $result .= $indentation . $valueName . ' = null' . chr(10);
            } elseif (is_scalar($abstractSyntaxTree)) {
                $result .= $indentation . $valueName . ' = ' . (string)$abstractSyntaxTree . chr(10);
            } else {
                $result .= $indentation . $valueName . ' = ' . json_encode($abstractSyntaxTree) . chr(10);
            }
        }
        return $result;
    }
91757
public function setProperty($propertyName, $propertyValue)
    {
        if ($propertyName == '')
            throw new Exception('Property Name not specified');

        if ($propertyValue == '')
            throw new Exception('Property Value not specified');

        //build URI 
        $strURI = Product::$baseProductUri . '/email/' . $this->getFileName() . '/properties/' . $propertyName;

        $put_data_arr['Value'] = $propertyValue;

        $put_data = json_encode($put_data_arr);

        //sign URI
        $signedURI = Utils::sign($strURI);

        $responseStream = Utils::processCommand($signedURI, 'PUT', 'json', $put_data);

        $json = json_decode($responseStream);

        if ($json->Code == 200)
            return $json->EmailProperty->Value;
        else
            return false;
    }