Checks if the class has been enabled for encryption

@param \ReflectionClass $reflection
@param \Doctrine\ORM\Mapping\ClassMetadata $metadata

@return boolean
769551
public function hasEncryptionEnabled(\ReflectionClass $reflection, DoctrineClassMetadata $metadata = null)
    {
        $classMetadata = $this->getEncryptionMetadataFor($reflection->getName());
        return $classMetadata->encryptionEnabled;
    }
665637
protected function loadMetadataFromFile(\ReflectionClass $reflectionClass, $file)
    {
        $className = $reflectionClass->getName();
        $classMetadata = $this->generateClassMetadata($reflectionClass);

        $config = Yaml::parse(file_get_contents($file));
        if ( ! isset($config[$className])) {
            throw new EncryptionException(sprintf('Expected metadata for class %s to be defined in %s.', $className, $file));
        }

        $classConfig = $config[$className];
        $parentClassMetadata = $classMetadata->parentClassMetadata;
        $encryptionEnabled = ($parentClassMetadata && $parentClassMetadata->encryptionEnabled)
            || (isset($classConfig['encryptionEnabled']) && $classConfig['encryptionEnabled']);

        if ($encryptionEnabled) {
            $classMetadata->encryptionEnabled = true;
            $encryptedFields = isset($classConfig['encryptedFields']) && is_array($classConfig['encryptedFields'])
                ? $classConfig['encryptedFields']
                : array();

            if (isset($classConfig['encryptionMode'])) {
                $encryptionMode = $classConfig['encryptionMode'];
                if (!in_array($encryptionMode, EncryptionService::getSupportedEncryptionModes())) {
                    throw new EncryptionException(sprintf('Encryption mode %s not supported.', $encryptionMode));
                }
                $classMetadata->encryptionMode = $encryptionMode;
            }
            elseif ($parentClassMetadata) {
                $classMetadata->encryptionMode = $parentClassMetadata->encryptionMode;
            }

            if (isset($classConfig['encryptedFile'])) {
                $classMetadata->encryptedFile = $classConfig['encryptedFile'];
                if (isset($classConfig['encryptedFileMode'])) {
                    $encryptedFileMode = $classConfig['encryptedFileMode'];
                    if (!in_array($encryptedFileMode, EncryptionService::getSupportedEncryptionModes())) {
                        throw new EncryptionException(sprintf('Encryption file mode %s not supported.', $encryptedFileMode));
                    }
                    $classMetadata->encryptedFileMode = $encryptedFileMode;
                }
            }
            elseif ($parentClassMetadata) {
                $classMetadata->encryptedFile = $parentClassMetadata->encryptedFile;
                $classMetadata->encryptedFileMode = $parentClassMetadata->encryptedFileMode;
            }

            // Add the encrypted fields of the parent
            if ($parentClassMetadata) {
                $parentPropertiesMetadata = $parentClassMetadata->propertyMetadata;
                foreach ($parentPropertiesMetadata as $parentPropertyMetadata) {
                    $classMetadata->addPropertyMetadata($parentPropertyMetadata);
                }
            }

            // Add the self encrypted fields
            foreach ($encryptedFields as $fieldName => $encryptedField) {
                $reflectionProperty = $reflectionClass->hasProperty($fieldName)
                    ? $reflectionClass->getProperty($fieldName)
                    : null;

                if ($reflectionProperty) {
                    $propertyMetadata = new PropertyMetadata($reflectionClass->getName(), $reflectionProperty->getName());

                    if (null === $encryptedField) {
                        $propertyMetadata->encrypted = true;
                    }
                    else {
                        $propertyMetadata->encrypted = isset($encryptedField['encrypted']) ? $encryptedField['encrypted'] : false;
                    }
                    $classMetadata->addPropertyMetadata($propertyMetadata);
                }
            }
        }

        return $classMetadata;
    }
347167
public function shouldSkipClass(ClassMetadata $metadata, Context $context)
    {
        $obj = null;
        // Get the last item of the visiting set
        foreach ($context->getVisitingSet() as $item) {
            $obj = $item;
        }

        if ($obj && $obj instanceof Block && $obj->getParent() && $obj->getParent()->getTemplate() && $obj->getContent() && $obj->getContentId() != $this->content->getId()) {
            return true;
        }

        return false;
    }
744191
public function isFieldBlacklisted(Metadata $meta, $field, $configPath = null)
    {
        $entityName = $meta->getEntityName();

        if (!isset($this->cache[$entityName])) {
            $this->cache[$entityName] = [];
        }
        if (!isset($this->cache[$entityName][$configPath])) {
            $this->cache[$entityName][$configPath] = [];
        }
        if (!isset($this->cache[$entityName][$field][$configPath])) {
            $this->cache[$entityName][$field][$configPath] = $this->checkIfFieldBlacklisted($meta, $field, $configPath);
        }

        return $this->cache[$entityName][$field][$configPath];
    }
1119673
protected function parseNodes(\ReflectionClass $class, ClassMetadata $metadata, $config)
    {
        if (!isset($config['nodes'])) {
            return;
        }

        if (!is_array($config)) {
            throw new \RuntimeException(sprintf('Invalid YAML configuration for "%s" : "properties" property need to be an array.', $metadata->name));
        }

        foreach ($config['nodes'] as $property => $nodeProperties) {
            foreach ($nodeProperties as $nodeProperty) {
                if (!isset($nodeProperty['namespace']) || !isset($nodeProperty['tag'])) {
                    throw new \RuntimeException(sprintf('Invalid YAML configuration for "%s" : "namespace" and "tag" are required.', $metadata->name));
                }

                $node = new Node([
                    'namespace' => $nodeProperty['namespace'],
                    'tag' => $nodeProperty['tag'],
                ]);

                if ($class->hasProperty($property)) {
                    $metadata->addGraphMetadata($node, new PropertyMetadata($class->name, $property));
                }

                if ($class->hasMethod($property)) {
                    $metadata->addGraphMetadata($node, new MethodMetadata($class->name, $property));
                }
            }
        }
    }
897632
protected static function isValidGetter(\ReflectionClass &$reflection, $name)
	{
		if (!$reflection->hasMethod($name))
		{
			throw new \LogicException(
				sprintf('Invalid metadata for %s: no getter %s.', $reflection->getName(), $name)
			);
		}
		$getter = $reflection->getMethod($name);
		if (!$getter->isPublic())
		{
			throw new \LogicException(
				sprintf('Invalid metadata for %s: getter %s is not public.', $reflection->getName(), $name)
			);
		}
		if ($getter->getNumberOfRequiredParameters() > 0)
		{
			throw new \LogicException(
				sprintf('Invalid metadata for %s: getter %s should not require parameters.', $reflection->getName(), $name)
			);
		}
		return true;
	}
737399
public function getEncryptionEnabledEntitiesMetadata()
    {
        $entityManager = $this->doctrine->getManager();
        $doctrineMetadataFactory = $entityManager->getMetadataFactory();

        $encryptedEnabledTypes = array();
        $encryptionMetadata = $this->metadataFactory->getAllMetadata();
        /** @var ClassMetadata $encryptionClassMetadata */
        foreach ($encryptionMetadata as $encryptionClassMetadata) {
            if ($encryptionClassMetadata->encryptionEnabled) {
                $className = $encryptionClassMetadata->name;
                $encryptedEnabledTypes[] = $doctrineMetadataFactory->getMetadataFor($className);
            }
        }

        return $encryptedEnabledTypes;
    }
707513
public function validateReflectionClassForAccessorPublic(\ReflectionClass $reflectionClass)
    {
        if (empty($methods = $reflectionClass->getMethods(\ReflectionMethod::IS_PUBLIC))) {
            return new CoverFishMessageError(
                CoverFishMessageError::PHPUNIT_REFLECTION_NO_PUBLIC_METHODS_FOUND, null
            );
        }

        return true;
    }
825846
private function hasInternalAncestors(ReflectionClass $reflectionClass) : bool
    {
        do {
            if ($reflectionClass->isInternal()) {
                return true;
            }

            $reflectionClass = $reflectionClass->getParentClass();
        } while ($reflectionClass);

        return false;
    }
1323352
public function loadMetadataForClass($className, ClassMetadata $metadata)
    {
        $class = $metadata->getReflectionClass();
        if (! $class) {
            // this happens when running annotation driver in combination with
            // static reflection services. This is not the nicest fix
            $class = new \ReflectionClass($metadata->name);
        }

        $entityAnnot = $this->reader->getClassAnnotation($class, 'Doctrine\KeyValueStore\Mapping\Annotations\Entity');
        if (! $entityAnnot) {
            throw new \InvalidArgumentException($metadata->name . ' is not a valid key-value-store entity.');
        }
        $metadata->storageName = $entityAnnot->storageName;

        // Evaluate annotations on properties/fields
        foreach ($class->getProperties() as $property) {
            $idAnnot        = $this->reader->getPropertyAnnotation(
                $property,
                'Doctrine\KeyValueStore\Mapping\Annotations\Id'
            );
            $transientAnnot = $this->reader->getPropertyAnnotation(
                $property,
                'Doctrine\KeyValueStore\Mapping\Annotations\Transient'
            );
            if ($idAnnot) {
                $metadata->mapIdentifier($property->getName());
            } elseif ($transientAnnot) {
                $metadata->skipTransientField($property->getName());
            } else {
                $metadata->mapField(['fieldName' => $property->getName()]);
            }
        }
    }
608410
public function getEncryptionEnabledFields(\ReflectionClass $reflectionClass)
    {
        $encryptionEnabledFields = array();

        $classMetadata = $this->getEncryptionMetadataFor($reflectionClass->getName());

        if ($classMetadata->encryptionEnabled) {
            /** @var PropertyMetadata $propertyMetadata */
            foreach ($classMetadata->propertyMetadata as $propertyMetadata) {
                if ($propertyMetadata->encrypted) {
                    $reflectionProperty = $reflectionClass->getProperty($propertyMetadata->name);
                    $encryptionEnabledFields[$reflectionProperty->name] = $reflectionProperty;
                }
            }
        }

        return $encryptionEnabledFields;
    }
1061759
private function isTranslation(ClassMetadata $classMetadata)
    {
        return $this->getClassAnalyzer()->hasTrait($classMetadata->reflClass, $this->translationTrait);
    }
1359353
public function loadMetadataForClass($className, ClassMetadataInfo $metadata)
    {
        $this->metadata = $metadata;
        $this->loadMappingFile($this->findMappingFile($className));
    }
1335703
public function hasPhpdocTag($reflection, string $tagName): bool
    {
        return !empty($this->getTags($reflection, $tagName));
    }
25550
public function loadMetadataForClass($className, ClassMetadata $metadata)
    {
        /* @var $metadata \Doctrine\ORM\Mapping\ClassMetadataInfo */
        $metadata->hasEncryptedProperties = false;
        $metadata->encryptedProperties = array();
        $class = $metadata->getReflectionClass();
        
        foreach ($class->getProperties() as $name => $property) {
            /** @var \Giftcards\Encryption\Doctrine\Configuration\Annotation\Encrypted $annotation */
            $annotation = $this->reader->getPropertyAnnotation(
                $property,
                'Giftcards\Encryption\Doctrine\Configuration\Annotation\Encrypted'
            );
            
            if (!$annotation) {
                continue;
            }
            $metadata->hasEncryptedProperties = true;
            $metadata->encryptedProperties[$property->getName()] = array(
                'profile' => $annotation->profile,
                'ignored_values' => $annotation->ignoredValues
            );
        }
    }
701268
private function isGeocodable(ClassMetadata $classMetadata)
    {
        return $this->getClassAnalyzer()->hasTrait(
            $classMetadata->reflClass,
            $this->geocodableTrait,
            $this->isRecursive
        );
    }
700098
protected function getClassMeta(ReflectionClass $reflection): array
    {
        $doc = $reflection->getDocComment();
        $notations = $this->parser->parse($doc);

        return $notations;
    }