@param      $data
@param null $class

@return array|\yii2lab\domain\BaseEntity
771686
public function forgeEntity($data, $class = null) {
		if(empty($data)) {
			return [];
		}
		if(empty($class)) {
			$class = $this->id;
		}
		$array = ArrayHelper::toArray($data);
		$array = $this->getAlias()->decode($array);
		return $this->domain->factory->entity->create($class, $array);
	}
911555
public function load(string $class)
    {
        $alias = $this->loader;
        if (isset($alias[$class])) {
            class_alias($alias[$class], $class);
        }

        $class = $this->alias($class);
        if (!$this->container->has($class)) {
            return null;
        }

        $instance = $this->container[$class];
        if (is_object($instance)) {
            return $instance;
        }

        return null;
    }
921677
public function unserialise($input, $class = null)
    {
        $contents = Yaml::parse($input);

        if (!is_null($class)) {
            return (new Mapper())->map($contents, $class);
        }

        return $contents;
    }
1252187
private function getEntityFromIdentityMap($className, array $data)
    {
        // TODO: Abstract this code and UnitOfWork::createEntity() equivalent?
        $class = $this->_metadataCache[$className];

        /* @var $class ClassMetadata */
        if ($class->isIdentifierComposite) {
            $idHash = '';

            foreach ($class->identifier as $fieldName) {
                $idHash .= ' ' . (isset($class->associationMappings[$fieldName])
                    ? $data[$class->associationMappings[$fieldName]['joinColumns'][0]['name']]
                    : $data[$fieldName]);
            }

            return $this->_uow->tryGetByIdHash(ltrim($idHash), $class->rootEntityName);
        } else if (isset($class->associationMappings[$class->identifier[0]])) {
            return $this->_uow->tryGetByIdHash($data[$class->associationMappings[$class->identifier[0]]['joinColumns'][0]['name']], $class->rootEntityName);
        }

        return $this->_uow->tryGetByIdHash($data[$class->identifier[0]], $class->rootEntityName);
    }
36137
public static function createEntities($entityClass, $dataArray)
    {
        return array_map(function ($data) use ($entityClass) {
            return static::createEntity($entityClass, $data);
        }, $dataArray);
    }
1324520
protected function buildValidation($class = null)
    {
        $validations = [];
        $metadata = $this->validator->getMetadataFor($class);
        $entityConstraints = [];
        foreach ($metadata->getConstraints() as $constraint) {
            $class = new \ReflectionClass($constraint);
            $fields = $constraint->fields;
            $entityConstraint = [implode(', ', (array) $fields) => $constraint->message];
            $entityConstraints = array_merge($entityConstraints, $entityConstraint);
            $validations[$class->getShortName()] = $entityConstraint;
        }

        foreach ($metadata->getConstrainedProperties() as $property) {
            $constraints = $metadata->getPropertyMetadata($property)[0]->constraints;
            $result = [];
            foreach ($constraints as $constraint) {
                $class = new \ReflectionObject($constraint);
                switch ($name = $class->getShortName()) {
                    case 'True':
                        $result[$name] = $constraint->message;
                        break;
                    case 'NotBlank':
                        $result[$name] = $constraint->message;
                        break;
                    case 'Type':
                        $result[$name] = $constraint->type;
                        break;
                    case 'Length':
                        $result[$name] = $this->constraintMessages($constraint);
                        break;
                    case 'Count':
                        $result[$name] = $this->constraintMessages($constraint);
                        break;
                }
            }
            $validations[$property] = $result;
        }

        return $validations;
    }
384067
final public static function getInstance($data=null)
    {
        $class = get_called_class();
        if (empty($class)) return null;

        if (empty($data)){
            $classID = $class;

        } elseif(is_array($data)){
            $classID = $class.md5(implode('', array_keys($data)));

        } else {
            $classID = $class.md5($data);
        }

        if (!isset(self::$_instances[$classID])){
            self::$_instances[$classID] = new $class($data);
        }

        return self::$_instances[$classID];
    }
974571
public function getValueByKey($key, $default = '', $class = null)
    {
        if (null === $class) {
            $class = $this->getEntityClass();
        }

        $result = $this->getDoctrine()->getRepository($class)->findOneBy(
            [
                'key' => $key,
            ]
        );

        if (null === $result) {
            return $default;
        }

        return $result->getValue();
    }
1125262
public function findById($class, $id) {
        $mapper = MapperBuilder::buildFromMapping($this->mapping, $class);

        $newEntity = NULL;

        $query = "SELECT * FROM `" . $mapper->getTable() . "` WHERE id='$id'";
        $result = $this->conn->executeQuery($query);

        if ($result) {
            $class = $mapper->getClass();
            $newEntity = new $class();
            $this->populateEntity($newEntity, $result[0], $mapper);

            // populate relations
            foreach ($mapper->getRelations() as $relation) {

                $relMapper = MapperBuilder::buildFromName($this->mapping, $relation->getEntity());
                $queryRel = $this->buildSelectRelation($newEntity, $mapper, $relation, $relMapper);
                $resRel = $this->conn->executeQuery($queryRel);

                $classRel = $relMapper->getClass();
                $method = "set" . $relation->getName();
                if ($resRel) {
                    foreach ($resRel as $row) {
                        $newEntityRel = new $classRel();
                        $this->populateEntity($newEntityRel, $row, $relMapper, $relation->getForeignColumn());
                        $array[] = $newEntityRel;
                    }
                    $newEntity->$method($array);
                }
            }
        }
        return $newEntity;
    }
983559
public function parseClass($class)
    {
        $reflectionClass = new ReflectionClass($class);

        // check if class is entity
        if ($this->reader->getClassAnnotation($reflectionClass, '\ProAI\Datamapper\Annotations\Entity')) {
            return $this->parseEntity($class);
        } else {
            return null;
        }
    }
28056
public function make(string $class = null, string $type = null, array $args = [])
    {
        $class = $class ?? $this->class ?? $this->resolveClassName($type);
        \assert('class_exists($class)');
        $reflection = new \ReflectionClass($class);
        if ($args !== [] && !\is_int(key($args))) {
            $args = $this->resolveConstructorArguments($args, $reflection);
        }
        return $reflection->newInstanceArgs($args);
    }
84458
public function getChildOfClass($class)
    {
        // Check for namespace alias
        if (strpos($class, ':') !== false) {
            list($namespaceAlias, $simpleClassName) = explode(':', $class);
            $class = $this->em->getConfiguration()->getEntityNamespace($namespaceAlias) . '\\' . $simpleClassName;
        }
        foreach ($this->getChildren() as $child) {
            if ($child->getPage() instanceof $class) {
                return $child;
            }
        }

        return null;
    }
631062
public static function parameters($class, $method, $data = null)
    {
        $params = [];
        $reflexion = Inspector::inspect($class);
        $parameters = $reflexion->getMethod($method)->getParameters();
        if ($data === null) {
            return $parameters;
        }
        foreach ($data as $key => $value) {
            $name = $key;
            if ($parameters) {
                $parameter = array_shift($parameters);
                $name = $parameter->getName();
            }
            $params[$name] = $value;
        }
        foreach ($parameters as $parameter) {
            if ($parameter->isDefaultValueAvailable()) {
                $params[$parameter->getName()] = $parameter->getDefaultValue();
            }
        }
        return $params;
    }
607356
public function links($class = null)
    {
        if (is_null($class)) {
            $class = '';
        }

        $dateArray = explode('-', $this->date);
        $previousMonth = Carbon::create($dateArray[0], $dateArray[1], $dateArray[2])->subMonth()->toDateString();
        $nextMonth = Carbon::create($dateArray[0], $dateArray[1], $dateArray[2])->addMonth()->toDateString();

        $links = '<div class="row calendar-links"><div class="col-12">';
        $links .= '<a class="previous '.$class.'" href="'.url('events/'.$previousMonth).'">Previous Month</a>';
        $links .= '<a class="next '.$class.'" href="'.url('events/'.$nextMonth).'">Next Month</a>';
        $links .= '</div></div>';

        return $links;
    }
966331
public function getValidations($class = null)
    {
        $reflectionClass = $class ? new \ReflectionClass($class) : false;
        if ($reflectionClass === false) {
            return [];
        }
        $result = $this->buildValidation($class);
        $validations = [];
        foreach ($result as $keyElement => $element) {
            if (is_array($element)) {
                foreach ($element as $keyChild => $child) {
                    if (is_array($child)) {
                        foreach ($child as $grandChild) {
                            $validations[] = sprintf('%s => %s', $keyChild, $grandChild);
                        }
                    } else {
                        $validations[] = sprintf('%s => %s', $keyElement, $child);
                    }
                }
            } else {
                $validations[] = $element;
            }
        }

        return $validations;
    }
784238
protected function create($data = null)
    {
        $method = '__'.str_replace(__CLASS__.'::', '', __METHOD__);

        if ($this->hasMethod($method) && is_callable([$this, $method])) {
            $arguments = func_get_args();
            if (empty($arguments)) {
                $result = $this->{$method}();
            } else {
                $result = call_user_func_array([$this, $method], $arguments);
            }

            return $result;
        }
    }
1051614
protected function getFamily($data, $class, array $context)
    {
        if (\is_array($data) || $data instanceof \ArrayAccess) {
            foreach (['familyCode', 'family_code', 'family'] as $property) {
                if (array_key_exists($property, $data) && $data[$property]) {
                    /** @noinspection PhpIncompatibleReturnTypeInspection */

                    return $this->denormalizer->denormalize($data[$property], FamilyInterface::class, $context);
                }
            }
        }

        // Check if family information is present in the context
        if (array_key_exists('family', $context)) {
            /** @noinspection PhpIncompatibleReturnTypeInspection */

            return $this->denormalizer->denormalize($context['family'], FamilyInterface::class, $context);
        }

        // Last attempt: try to determine the family from the class
        $matchingFamilies = [];
        foreach ($this->familyRegistry->getFamilies() as $family) {
            if ($family->isInstantiable() && $family->getDataClass() === $class) {
                $matchingFamilies[] = $family;
            }
        }

        // If there is only ONE family exactly matching the data class, let's use this one
        if (1 === \count($matchingFamilies)) {
            return array_pop($matchingFamilies);
        }

        throw new UnexpectedValueException("Unable to determine the Family for the class {$class}");
    }