@inheritdoc

@SuppressWarnings(PHPMD.StaticAccess)
194271
public function apply()
    {
        Schema::create(Model::TABLE_NAME, function (Blueprint $table) {
            $table->increments(Model::FIELD_ID);
            $table->unsignedInteger(Model::FIELD_ID_USER);
            $table->unsignedInteger(Model::FIELD_ID_POST);
            $table->text(Model::FIELD_TEXT);
            $table->softDeletes();
            $table->timestamps();

            /** @noinspection PhpUndefinedMethodInspection */
            $table->foreign(Model::FIELD_ID_POST)
                ->references(Post::FIELD_ID)->on(Post::TABLE_NAME)->onDelete('cascade');

            /** @noinspection PhpUndefinedMethodInspection */
            $table->foreign(Model::FIELD_ID_USER)
                ->references(User::FIELD_ID)->on(User::TABLE_NAME)->onDelete('cascade');
        });
    }
124097
static function __static()
	{
		XmlTypeCode::$typeToCodeMap = array(
			'xs:anyType'				=> XmlTypeCode::AnyType,
			'xs:anySimpleType'			=> XmlTypeCode::AnyAtomicType,
			'xs:untypedAtomic'			=> XmlTypeCode::UntypedAtomic,
			'xs:string'					=> XmlTypeCode::String,
			'xs:boolean'				=> XmlTypeCode::Boolean,
			'xs:decimal'				=> XmlTypeCode::Decimal,
			'xs:double'					=> XmlTypeCode::Double,
			'xs:float'					=> XmlTypeCode::Float,
			'xs:duration'				=> XmlTypeCode::Duration,
			'xs:dateTime'				=> XmlTypeCode::DateTime,
			'xs:time'					=> XmlTypeCode::Time,
			'xs:date'					=> XmlTypeCode::Date,
			'xs:gYearMonth'				=> XmlTypeCode::GYearMonth,
			'xs:gYear'					=> XmlTypeCode::GYear,
			'xs:gMonthDay'				=> XmlTypeCode::GMonthDay,
			'xs:gDay'					=> XmlTypeCode::GDay,
			'xs:gMonth'					=> XmlTypeCode::GMonth,
			'xs:hexBinary'				=> XmlTypeCode::HexBinary,
			'xs:base64Binary'			=> XmlTypeCode::Base64Binary,
			'xs:anyURI'					=> XmlTypeCode::AnyUri,
			'xs:QName'					=> XmlTypeCode::QName,
			'xs:NOTATION'				=> XmlTypeCode::Notation,
			'xs:normalizedString'		=> XmlTypeCode::NormalizedString,
			'xs:token'					=> XmlTypeCode::Token,
			'xs:language'				=> XmlTypeCode::Language,
			'xs:Name'					=> XmlTypeCode::Name,
			'xs:NCName'					=> XmlTypeCode::NCName,
			'xs:NMTOKEN'				=> XmlTypeCode::NmToken,
			'xs:ID'						=> XmlTypeCode::Id,
			'xs:IDREF'					=> XmlTypeCode::Idref,
			'xs:ENTITY'					=> XmlTypeCode::Entity,
			'xs:integer'				=> XmlTypeCode::Integer,
			'xs:nonPositiveInteger'		=> XmlTypeCode::NonPositiveInteger,
			'xs:long'					=> XmlTypeCode::Long,
			'xs:nonNegativeInteger'		=> XmlTypeCode::NonNegativeInteger,
			'xs:negativeInteger' 		=> XmlTypeCode::NegativeInteger,
			'xs:int'					=> XmlTypeCode::Int,
			'xs:short'					=> XmlTypeCode::Short,
			'xs:byte'					=> XmlTypeCode::Byte,
			'xs:positiveInteger' 		=> XmlTypeCode::PositiveInteger,
			'xs:unsignedLong' 			=> XmlTypeCode::UnsignedLong,
			'xs:unsignedInt' 			=> XmlTypeCode::UnsignedInt,
			'xs:unsignedShort'			=> XmlTypeCode::UnsignedShort,
			'xs:unsignedByte'			=> XmlTypeCode::UnsignedByte,
			'xs:IDREFS'					=> XmlTypeCode::IDREFS,
			'xs:ENTITIES'				=> XmlTypeCode::ENTITIES,
			'xs:NMTOKENS'				=> XmlTypeCode::NMTOKENS,
			'xs:yearMonthDuration'		=> XmlTypeCode::YearMonthDuration,
			'xs:dayTimeDuration'		=> XmlTypeCode::DayTimeDuration,
			'xs:UNION'					=> XmlTypeCode::UNION,
		);

		XmlTypeCode::$codeToTypeMap = array_flip( XmlTypeCode::$typeToCodeMap );
	}
1236624
static function exists($obj)
    {
        $tabela = strtolower(FuncoesReflections::pegaNomeClasseObjeto($obj));
        $schema = JsonReader::read(BASE_DIR . '/phiber_config.json')->phiber->link->database_name;
        $sql    = "SELECT * FROM information_schema.tables WHERE table_schema = ? AND table_name = ?";
        
        if (JsonReader::read(BASE_DIR . "/phiber_config.json")->phiber->execute_querys == 1 ? true : false) {
            $pdo = self::getConnection()->prepare($sql);
            $pdo->bindValue(1, $schema);
            $pdo->bindValue(2, $tabela);
            $pdo->execute();
            
            if ($pdo->rowCount() > 0) {
                return true;
            }
                
            return false;

        } else {
            return $sql;
        }
    }
821186
public static function filter(&$object, array $fields, $mode = 'allow')
    {
        if('allow' === $mode)
        {
            $unsetKeys = [];
            foreach($object as $field => $value)
            {
                if(!in_array($field, $fields))
                {
                    $unsetKeys[] = $field;
                }
            }
            foreach($unsetKeys as $key)
            {
                static::remove($object, $key);
            }
        }
        else if('deny' === $mode)
        {
            foreach($fields as $field)
            {
                static::remove($object, $field);
            }
        }
        else
        {
            throw new \InvalidArgumentException(sprintf('Unknow mode %s', $mode));
        }
    }
753101
public function php($baseIndent = 0) {
    $php = $this->phpDocBlock($baseIndent);
    
    $php .= str_repeat(' ',$baseIndent);
    $ms = array(
                self::MODIFIER_PUBLIC => 'public',
                self::MODIFIER_PRIVATE => 'private',
                self::MODIFIER_PROTECTED => 'protected',
                self::MODIFIER_STATIC => 'static',
                // self::MODIFIER_FINAL => 'final' // kein final für properties?
               );
    
    foreach ($ms as $const => $modifier) {
      if (($const & $this->modifiers) == $const)
        $php .= $modifier.' ';
    }
    
    $php .= '$'.$this->name;
    
    if ($this->hasDefaultValue() && $this->getDefaultValue() !== NULL) {
      $php .= ' = '.$this->exportPropertyValue($this->getDefaultValue());
    }
    
    return $php;
  }
718494
public function indexAction()
    {
        $request = $this->getRequest();
        $type    = $request->getParam( 'type' );

        if ( ! $request instanceof ConsoleRequest )
        {
            throw new \RuntimeException( sprintf(
                '%s can only be used from a console.',
                __METHOD__
            ) );
        }

        $phpSelf = realpath( static::PHP_SELF );

        if ( empty( $phpSelf ) || ! is_file( $phpSelf ) )
        {
            throw new \RuntimeException( sprintf(
                '%s: php not found at "%s" (in "%s").',
                __METHOD__,
                static::PHP_SELF,
                getcwd()
            ) );
        }

        $result = 'Running ' . $type . ' cron(s) ...' . PHP_EOL . PHP_EOL;

        foreach ( $this->mimicSiteInfos() as $siteInfo )
        {
            $domain  = $siteInfo->getDomain();
            $process = new Process( array(
                'command'   => 'php',
                'arguments' => array(
                    $phpSelf,
                    'cron',
                    $domain,
                    $type,
                ),
                'environmentVariables'  => array(
                    'GRIDGUYZ_HOST'     => $domain,
                    'HTTP_HOST'         => $domain,
                ),
            ) );

            $result .= 'Calling process ...' . PHP_EOL .
                       $process->getRunCommand() . PHP_EOL;

            $output = tempnam( './data/', $domain );
            $descr  = array( Process::TYPE_FILE, $output, Process::MODE_APPEND );
            file_put_contents( $output, '' );

            $process->open( array(
                Process::STREAM_STDOUT => $descr,
                Process::STREAM_STDERR => $descr,
            ) );

            $return     = $process->close();
            $messages   = rtrim( file_get_contents( $output ), PHP_EOL );
            unlink( $output );

            if ( $messages )
            {
                $result .= static::PADDING . preg_replace(
                    '/[' . PHP_EOL . ']+/',
                    '$0' . static::PADDING,
                    $messages
                ) . PHP_EOL;
            }

            $result .= sprintf(
                'Process returned with #%d: %s' . PHP_EOL . PHP_EOL,
                $return,
                $return ? 'error!' : 'success.'
            );
        }

        $result .= 'Done.' . PHP_EOL;
        return $result;
    }
1124069
public function build($definition, $context = null, $name = null)
    {
        if ($definition instanceof ProviderInterface) {
            return $this->getProviderValue($definition, $context);
        } elseif ($definition instanceof FieldInterface) {
            return $definition->getResult($context);
        } elseif (is_array($definition)) {
            $result = [];
            foreach ($definition as $key => $value) {
                $result[$key] = $this->build($value, $context);
            }

            return new Record(
                $name === null ? 'record' : $name, 
                $result
            );
        } elseif (is_string($definition)) {
            if ($context !== null) {
                if (is_array($context)) {
                    if (array_key_exists($definition, $context)) {
                        return $context[$definition];
                    } else {
                        throw new RuntimeException('Referenced unknown key "' . $definition . '" in context');
                    }
                } elseif ($context instanceof \ArrayAccess) {
                    if ($context->offsetExists($definition)) {
                        return $context->offsetGet($definition);
                    } else {
                        throw new RuntimeException('Referenced unknown key "' . $definition . '" in context');
                    }
                } else {
                    throw new RuntimeException('Context must be either an array or instance of ArrayAccess');
                }
            } else {
                return $definition;
            }
        } else {
            return $definition;
        }
    }
585188
public function execute($response) {
        global $DB;

        $params = $this->parse_template();
        $contextid = $params['context_id'];
        $isget = $response->get_request_method() === self::HTTP_GET;
        if ($isget) {
            $contenttype = $response->get_accept();
        } else {
            $contenttype = $response->get_content_type();
        }
        $container = empty($contenttype) || ($contenttype === $this->formats[0]);
        // We will receive typeid when working with LTI 1.x, if not the we are in LTI 2.
        $typeid = optional_param('type_id', null, PARAM_ALPHANUM);
        if (is_null($typeid)) {
            if (!$this->check_tool_proxy(null, $response->get_request_data())) {
                $response->set_code(403);
                $response->set_reason("Invalid tool proxy specified.");
                return;
            }
        } else {
            switch ($response->get_request_method()) {
                case self::HTTP_GET:
                    if (!$this->check_type($typeid, $contextid, 'LineItem.collection:get', $response->get_request_data())) {
                        $response->set_code(403);
                        $response->set_reason("This resource does not support GET requests.");
                        return;
                    }
                    break;
                case self::HTTP_POST:
                    if (!$this->check_type($typeid, $contextid, 'LineItem.collection:post', $response->get_request_data())) {
                        $response->set_code(403);
                        $response->set_reason("This resource does not support POST requests.");
                        return;
                    }
                    break;
                default:  // Should not be possible.
                    $response->set_code(405);
                    $response->set_reason("Invalid request method specified.");
                    return;
            }
        }
        if (empty($contextid) || !($container ^ ($response->get_request_method() === self::HTTP_POST)) ||
                (!empty($contenttype) && !in_array($contenttype, $this->formats))) {
            $response->set_code(400);
            $response->set_reason("Invalid request made.");
            return;
        }
        if (!$DB->record_exists('course', array('id' => $contextid))) {
            $response->set_code(404);
            $response->set_reason("Not Found: Course $contextid doesn't exist.");
            return;
        }
        switch ($response->get_request_method()) {
            case self::HTTP_GET:
                $resourceid = optional_param('resource_id', null, PARAM_TEXT);
                $ltilinkid = optional_param('lti_link_id', null, PARAM_TEXT);
                $tag = optional_param('tag', null, PARAM_TEXT);
                $limitnum = optional_param('limit', 0, PARAM_INT);
                $limitfrom = optional_param('from', 0, PARAM_INT);
                $itemsandcount = $this->get_service()->get_lineitems($contextid, $resourceid, $ltilinkid, $tag, $limitfrom,
                        $limitnum, $typeid);
                $items = $itemsandcount[1];
                $totalcount = $itemsandcount[0];
                $json = $this->get_json_for_get_request($items, $resourceid, $ltilinkid, $tag, $limitfrom,
                        $limitnum, $totalcount, $typeid, $response);
                $response->set_content_type($this->formats[0]);
                break;
            case self::HTTP_POST:
                try {
                    $json = $this->get_json_for_post_request($response->get_request_data(), $contextid, $typeid);
                    $response->set_code(201);
                    $response->set_content_type($this->formats[1]);
                } catch (\Exception $e) {
                    $response->set_code($e->getCode());
                    $response->set_reason($e->getMessage());
                }
                break;
            default:  // Should not be possible.
                $response->set_code(405);
                $response->set_reason("Invalid request method specified.");
                return;
        }
        $response->set_body($json);
    }
653820
public function getFieldTypes()
    {
        static $cached = [];

        $class = static::class;

        if (!isset($cached[$class])) {
            if (!$doc = static::sample()) {

                if (!$docs = $this->getConnection()->fetchAll($this->getSource(), [], ['limit' => 1])) {
                    throw new RuntimeException(['`:collection` collection has none record', 'collection' => $this->getSource()]);
                }
                $doc = $docs[0];
            }

            $types = [];
            foreach ($doc as $field => $value) {
                $type = gettype($value);
                if ($type === 'integer') {
                    $types[$field] = 'int';
                } elseif ($type === 'string') {
                    $types[$field] = 'string';
                } elseif ($type === 'double') {
                    $types[$field] = 'float';
                } elseif ($type === 'boolean') {
                    $types[$field] = 'bool';
                } elseif ($type === 'array') {
                    $types[$field] = 'array';
                } elseif ($value instanceof ObjectID) {
                    if ($field === '_id') {
                        continue;
                    }
                    $types[$field] = 'objectid';
                } else {
                    throw new RuntimeException(['`:field` field value type can not be infered.', 'field' => $field]);
                }
            }

            $cached[$class] = $types;
        }

        return $cached[$class];
    }
283556
public function execute($request)
    {
        RequestNotSupportedException::assertSupports($this, $request);

        /** @var PaymentInterface $payment */
        $payment = $request->getSource();

        $details = ArrayObject::ensureArrayObject($payment->getDetails());

        $details['MerchantTradeNo'] = $payment->getNumber();
        $details['TotalAmount'] = $payment->getTotalAmount();
        $details['TradeDesc'] = $payment->getDescription();

        $request->setResult((array) $details);
    }
638908
protected function execute()
    {
        $result = false;

        $service = $this->getSubmittedValue('service');
        $source = $this->submittedSource;
        switch ($service) {
            case 'invoice_add':
                $forceSend = (bool) $this->getSubmittedValue('value');
                $result = $this->invoiceManager->send1($source, $forceSend);
                break;

            case 'invoice_paymentstatus_set':
                $localEntryInfo = $this->acumulusEntryManager->getByInvoiceSource($source);
                if ($localEntryInfo) {
                    if ((int) $this->getSubmittedValue('value') === Api::PaymentStatus_Paid) {
                        $paymentStatus = Api::PaymentStatus_Paid;
                        $dateFieldName = $this->getIdPrefix($this->submittedSource) . 'payment_date';
                        $paymentDate = $this->submittedValues[$dateFieldName];
                    } else {
                        $paymentStatus = Api::PaymentStatus_Due;
                        $paymentDate = '';
                    }
                    $result = $this->service->setPaymentStatus($localEntryInfo->getToken(), $paymentStatus, $paymentDate);
                } else {
                    $this->addErrorMessages(sprintf($this->t('unknown_entry'),
                        strtolower($this->t($this->submittedSource->getType())),
                        $this->submittedSource->getId()
                    ));
                }
                break;

            case 'entry_deletestatus_set':
                $localEntryInfo = $this->acumulusEntryManager->getByInvoiceSource($source);
                if ($localEntryInfo) {
                    $deleteStatus = $this->getSubmittedValue('value') === Api::Entry_Delete ? Api::Entry_Delete : Api::Entry_UnDelete;
                    $result = $this->service->setDeleteStatus($localEntryInfo->getEntryId(), $deleteStatus);
                } else {
                    $this->addErrorMessages(sprintf($this->t('unknown_entry'),
                    strtolower($this->t($this->submittedSource->getType())),
                        $this->submittedSource->getId()
                    ));
                }
                break;

            default:
                $this->addErrorMessages(sprintf($this->t('unknown_action'), $service));
                break;
        }

        return $result;
    }
214862
public function get($id = null)
    {
        if ($id == null)
            return false;
        $this->currentId        = $id;
        $this->currentKey       = $this->getRowKey($id);
        $this->setDocuments($this->getData()[$this->currentKey]);
        foreach ($this->documentEntries as $field => $value)
            $this->tableFields->{$field} = $value;
        return $this;
    }
1271236
public function setData($property, $value = null)
    {
        if (is_array($property)) {
            $description = $this->getEntityDescription();
            $properties = $property;
            $access = pick($value, AnDomain::ACCESS_PUBLIC);

            foreach ($properties as $key => $value) {
                $property = $description->getProperty($key);
                if ($property && $property->getWriteAccess() >= $access) {
                    //ignore any type related exceptions
                      try {
                          $this->setData($property->getName(), $value);
                      } catch (AnDomainExceptionType $e) {
                          print $e->getMessage();
                          die;
                      }
                } elseif (!$property) {
                    $this->$key = $value;
                }
            }

            return $this;
        } else {
            $name = $property;
            $description = $this->getEntityDescription();
            $property = $description->getProperty($property);

            if (!$property instanceof AnDomainPropertyAbstract) {
                $this->set($name, $value);

                return $this;
            }

            $name = $property->getName();
            $method = 'set'.ucfirst($name);

            if ($this->methodExists($method)) {
                $this->$method($value);
            } else {
                //only set the property if it's not write proteced (write != private )
                if ($property->getWriteAccess() < AnDomain::ACCESS_PROTECTED) {
                    throw new AnException(get_class($this).'::$'.$name.' is write protected');
                }

                $this->set($name, $value);
            }

            return $this;
        }
    }
332161
function bindAndExecute() {
		$conn = $this->connection;

		if ($conn === null) {
			throw new RuntimeException('bindAndExecute cannot be called on a QueryStatement without a connection.');
		}
		if ($conn instanceof DBMSSQL && $conn->getDriver() === 'dblib' && function_exists('mb_detect_encoding')) {
			return $conn->query($this->__toString());
		}
		if ($conn instanceof DBSQLite) {
			return $conn->query($this->__toString());
		}

		$string = self::embedIdentifiers($this->getString(), array_values($this->identifiers), $conn);

		$result = $conn->prepare($string);
		foreach ($this->getParams() as $key => $value) {
			$pdo_type = PDO::PARAM_STR;
			if (is_int($value)) {
				$pdo_type = PDO::PARAM_INT;
			} elseif (is_null($value)) {
				$pdo_type = PDO::PARAM_NULL;
			} elseif (is_bool($value)) {
				$value = $value ? 1 : 0;
				$pdo_type = PDO::PARAM_INT;
			}
			$result->bindValue($key + 1, $value, $pdo_type);
		}
		$result->execute();
		return $result;
	}
74149
public function resolve($resource, $attribute = null)
    {
        $attribute = $attribute ?? $this->attribute;

        $value = $resource->{$attribute} ?? null;

        $value = is_object($value) || is_array($value) ? $value : json_decode($value);

        $fields = $this->fields->whereInstanceOf(Resolvable::class)->reduce(function ($values, $field) {
            return $values->map(function ($row) use ($field) {
                $key = $field->attribute;
                $cb = $field->resolveCallback;

                if (isset($row->{$key})) {
                    $row->{$key} = $cb ? call_user_func($cb, $row->{$key}) : $row->{$key};
                }

                if (property_exists($field, 'computeCallback') && $field->computeCallback) {
                    $row->{$key} = call_user_func($field->computeCallback, $row);
                }

                return $row;
            });
        }, collect($value));

        if (!$this->resolveCallback) {
            $this->resolveCallback = function () use ($fields) {
                return $fields->toArray();
            };
        }

        $this->withMeta(['fields' => $this->fields]);

        parent::resolve($resource, $attribute);
    }
96213
static function calls($array) {
        $return = '';
        if(is_countable($array) && count($array) > 1) {
            array_shift($array);
            foreach($array as $key => $value) {
                $func = $key;
                $return .= self::$func($value);
            }
        }
        return $return;
    }
466270
private function setObjectValue(&$object, FieldDefinition $fieldDefinition, $value): void
    {
        //using setter
        $accessor = new PropertyAccessor();
        $propertyName = $fieldDefinition->getOriginName();
        if (\is_array($object)) {
            $object[$propertyName ?? $fieldDefinition->getName()] = $value;
        } else {
            if ($accessor->isWritable($object, $propertyName)) {
                $accessor->setValue($object, $propertyName, $value);
            } else {
                //using reflection
                $refClass = new \ReflectionClass(\get_class($object));
                if ($refClass->hasProperty($object) && $property = $refClass->getProperty($object)) {
                    $property->setAccessible(true);
                    $property->setValue($object, $value);
                }
            }
        }
    }