private function buildArguments(string $class, array $dependency): array
    {
        //initialize arguments array
        $args = [];

        //argument required from class
        foreach ($dependency as $argValue) {
            if (\class_exists((string) $argValue->getType())) {
                //add to array of arguments
                $paramClass = $argValue->getClass()->name;
                $args[] = $this->cache[$paramClass];
                continue;
            }

            $args[] = null;
        }

        //check if there is rules for this class
        if (isset($this->rules[$class])) {
            //merge arguments
            $args = \array_replace($args, $this->rules[$class]);
        }

        return $args;
    }