repo stringlengths 6 63 | path stringlengths 5 140 | func_name stringlengths 3 151 | original_string stringlengths 84 13k | language stringclasses 1
value | code stringlengths 84 13k | code_tokens list | docstring stringlengths 3 47.2k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 91 247 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
mako-framework/framework | src/mako/database/midgard/ORM.php | ORM.create | public static function create(array $columns = [], bool $raw = false, bool $whitelist = true)
{
$model = new static($columns, $raw, $whitelist);
$model->save();
return $model;
} | php | public static function create(array $columns = [], bool $raw = false, bool $whitelist = true)
{
$model = new static($columns, $raw, $whitelist);
$model->save();
return $model;
} | [
"public",
"static",
"function",
"create",
"(",
"array",
"$",
"columns",
"=",
"[",
"]",
",",
"bool",
"$",
"raw",
"=",
"false",
",",
"bool",
"$",
"whitelist",
"=",
"true",
")",
"{",
"$",
"model",
"=",
"new",
"static",
"(",
"$",
"columns",
",",
"$",
... | Creates a new record and returns the model.
@param array $columns Column values
@param bool $raw Set raw values?
@param bool $whitelist Remove columns that are not in the whitelist?
@return static | [
"Creates",
"a",
"new",
"record",
"and",
"returns",
"the",
"model",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/database/midgard/ORM.php#L794-L801 | train |
mako-framework/framework | src/mako/database/midgard/ORM.php | ORM.hasOne | protected function hasOne(string $model, ?string $foreignKey = null): HasOne
{
$related = new $model;
return new HasOne($related->getConnection(), $this, $related, $foreignKey);
} | php | protected function hasOne(string $model, ?string $foreignKey = null): HasOne
{
$related = new $model;
return new HasOne($related->getConnection(), $this, $related, $foreignKey);
} | [
"protected",
"function",
"hasOne",
"(",
"string",
"$",
"model",
",",
"?",
"string",
"$",
"foreignKey",
"=",
"null",
")",
":",
"HasOne",
"{",
"$",
"related",
"=",
"new",
"$",
"model",
";",
"return",
"new",
"HasOne",
"(",
"$",
"related",
"->",
"getConnec... | Returns a HasOne relation.
@param string $model Related model
@param string|null $foreignKey Foreign key name
@return \mako\database\midgard\relations\HasOne | [
"Returns",
"a",
"HasOne",
"relation",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/database/midgard/ORM.php#L810-L815 | train |
mako-framework/framework | src/mako/database/midgard/ORM.php | ORM.hasOnePolymorphic | protected function hasOnePolymorphic(string $model, string $polymorphicType): HasOnePolymorphic
{
$related = new $model;
return new HasOnePolymorphic($related->getConnection(), $this, $related, $polymorphicType);
} | php | protected function hasOnePolymorphic(string $model, string $polymorphicType): HasOnePolymorphic
{
$related = new $model;
return new HasOnePolymorphic($related->getConnection(), $this, $related, $polymorphicType);
} | [
"protected",
"function",
"hasOnePolymorphic",
"(",
"string",
"$",
"model",
",",
"string",
"$",
"polymorphicType",
")",
":",
"HasOnePolymorphic",
"{",
"$",
"related",
"=",
"new",
"$",
"model",
";",
"return",
"new",
"HasOnePolymorphic",
"(",
"$",
"related",
"->"... | Returns a HasOnePolymorphic relation.
@param string $model Related model
@param string $polymorphicType Polymorphic type
@return \mako\database\midgard\relations\HasOnePolymorphic | [
"Returns",
"a",
"HasOnePolymorphic",
"relation",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/database/midgard/ORM.php#L824-L829 | train |
mako-framework/framework | src/mako/database/midgard/ORM.php | ORM.hasMany | protected function hasMany(string $model, ?string $foreignKey = null): HasMany
{
$related = new $model;
return new HasMany($related->getConnection(), $this, $related, $foreignKey);
} | php | protected function hasMany(string $model, ?string $foreignKey = null): HasMany
{
$related = new $model;
return new HasMany($related->getConnection(), $this, $related, $foreignKey);
} | [
"protected",
"function",
"hasMany",
"(",
"string",
"$",
"model",
",",
"?",
"string",
"$",
"foreignKey",
"=",
"null",
")",
":",
"HasMany",
"{",
"$",
"related",
"=",
"new",
"$",
"model",
";",
"return",
"new",
"HasMany",
"(",
"$",
"related",
"->",
"getCon... | Returns a HasMany relation.
@param string $model Related model
@param string|null $foreignKey Foreign key name
@return \mako\database\midgard\relations\HasMany | [
"Returns",
"a",
"HasMany",
"relation",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/database/midgard/ORM.php#L838-L843 | train |
mako-framework/framework | src/mako/database/midgard/ORM.php | ORM.hasManyPolymorphic | protected function hasManyPolymorphic(string $model, string $polymorphicType): HasManyPolymorphic
{
$related = new $model;
return new HasManyPolymorphic($related->getConnection(), $this, $related, $polymorphicType);
} | php | protected function hasManyPolymorphic(string $model, string $polymorphicType): HasManyPolymorphic
{
$related = new $model;
return new HasManyPolymorphic($related->getConnection(), $this, $related, $polymorphicType);
} | [
"protected",
"function",
"hasManyPolymorphic",
"(",
"string",
"$",
"model",
",",
"string",
"$",
"polymorphicType",
")",
":",
"HasManyPolymorphic",
"{",
"$",
"related",
"=",
"new",
"$",
"model",
";",
"return",
"new",
"HasManyPolymorphic",
"(",
"$",
"related",
"... | Returns a HasManyPolymorphic relation.
@param string $model Related model
@param string $polymorphicType Polymorphic type
@return \mako\database\midgard\relations\HasManyPolymorphic | [
"Returns",
"a",
"HasManyPolymorphic",
"relation",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/database/midgard/ORM.php#L852-L857 | train |
mako-framework/framework | src/mako/database/midgard/ORM.php | ORM.manyToMany | protected function manyToMany(string $model, ?string $foreignKey = null, ?string $junctionTable = null, ?string $junctionKey = null): ManyToMany
{
$related = new $model;
return new ManyToMany($related->getConnection(), $this, $related, $foreignKey, $junctionTable, $junctionKey);
} | php | protected function manyToMany(string $model, ?string $foreignKey = null, ?string $junctionTable = null, ?string $junctionKey = null): ManyToMany
{
$related = new $model;
return new ManyToMany($related->getConnection(), $this, $related, $foreignKey, $junctionTable, $junctionKey);
} | [
"protected",
"function",
"manyToMany",
"(",
"string",
"$",
"model",
",",
"?",
"string",
"$",
"foreignKey",
"=",
"null",
",",
"?",
"string",
"$",
"junctionTable",
"=",
"null",
",",
"?",
"string",
"$",
"junctionKey",
"=",
"null",
")",
":",
"ManyToMany",
"{... | Returns a ManyToMany relation.
@param string $model Related model
@param string|null $foreignKey Foreign key name
@param string|null $junctionTable Junction table name
@param string|null $junctionKey Junction key name
@return \mako\database\midgard\relations\ManyToMany | [
"Returns",
"a",
"ManyToMany",
"relation",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/database/midgard/ORM.php#L868-L873 | train |
mako-framework/framework | src/mako/database/midgard/ORM.php | ORM.belongsTo | protected function belongsTo(string $model, ?string $foreignKey = null): BelongsTo
{
$related = new $model;
return new BelongsTo($related->getConnection(), $this, $related, $foreignKey);
} | php | protected function belongsTo(string $model, ?string $foreignKey = null): BelongsTo
{
$related = new $model;
return new BelongsTo($related->getConnection(), $this, $related, $foreignKey);
} | [
"protected",
"function",
"belongsTo",
"(",
"string",
"$",
"model",
",",
"?",
"string",
"$",
"foreignKey",
"=",
"null",
")",
":",
"BelongsTo",
"{",
"$",
"related",
"=",
"new",
"$",
"model",
";",
"return",
"new",
"BelongsTo",
"(",
"$",
"related",
"->",
"... | Returns a BelongsTo relation.
@param string $model Related model
@param string|null $foreignKey Foreign key name
@return \mako\database\midgard\relations\BelongsTo | [
"Returns",
"a",
"BelongsTo",
"relation",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/database/midgard/ORM.php#L882-L887 | train |
mako-framework/framework | src/mako/database/midgard/ORM.php | ORM.belongsToPolymorphic | protected function belongsToPolymorphic(string $model, string $polymorphicType): BelongsToPolymorphic
{
$related = new $model;
return new BelongsToPolymorphic($related->getConnection(), $this, $related, $polymorphicType);
} | php | protected function belongsToPolymorphic(string $model, string $polymorphicType): BelongsToPolymorphic
{
$related = new $model;
return new BelongsToPolymorphic($related->getConnection(), $this, $related, $polymorphicType);
} | [
"protected",
"function",
"belongsToPolymorphic",
"(",
"string",
"$",
"model",
",",
"string",
"$",
"polymorphicType",
")",
":",
"BelongsToPolymorphic",
"{",
"$",
"related",
"=",
"new",
"$",
"model",
";",
"return",
"new",
"BelongsToPolymorphic",
"(",
"$",
"related... | Returns a BelongsToPolymorphic relation.
@param string $model Related model
@param string $polymorphicType Polymorphic type
@return \mako\database\midgard\relations\BelongsToPolymorphic | [
"Returns",
"a",
"BelongsToPolymorphic",
"relation",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/database/midgard/ORM.php#L896-L901 | train |
mako-framework/framework | src/mako/database/midgard/ORM.php | ORM.getModified | public function getModified(): array
{
$modified = [];
foreach($this->columns as $key => $value)
{
if(!array_key_exists($key, $this->original) || $this->original[$key] !== $value)
{
$modified[$key] = $value;
}
}
return $modified;
} | php | public function getModified(): array
{
$modified = [];
foreach($this->columns as $key => $value)
{
if(!array_key_exists($key, $this->original) || $this->original[$key] !== $value)
{
$modified[$key] = $value;
}
}
return $modified;
} | [
"public",
"function",
"getModified",
"(",
")",
":",
"array",
"{",
"$",
"modified",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"columns",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"key"... | Returns the modified column values of the record.
@return array | [
"Returns",
"the",
"modified",
"column",
"values",
"of",
"the",
"record",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/database/midgard/ORM.php#L918-L931 | train |
mako-framework/framework | src/mako/database/midgard/ORM.php | ORM.insertRecord | protected function insertRecord(Query $query): void
{
if($this->primaryKeyType === static::PRIMARY_KEY_TYPE_INCREMENTING)
{
$this->columns[$this->primaryKey] = $query->insertAndGetId($this->columns, $this->primaryKey);
}
else
{
switch($this->primaryKeyType)
{
case static::PRIMARY_KEY_TYPE_UUID:
$this->columns[$this->primaryKey] = UUID::v4();
break;
case static::PRIMARY_KEY_TYPE_CUSTOM:
$this->columns[$this->primaryKey] = $this->generatePrimaryKey();
break;
}
$query->insert($this->columns);
}
} | php | protected function insertRecord(Query $query): void
{
if($this->primaryKeyType === static::PRIMARY_KEY_TYPE_INCREMENTING)
{
$this->columns[$this->primaryKey] = $query->insertAndGetId($this->columns, $this->primaryKey);
}
else
{
switch($this->primaryKeyType)
{
case static::PRIMARY_KEY_TYPE_UUID:
$this->columns[$this->primaryKey] = UUID::v4();
break;
case static::PRIMARY_KEY_TYPE_CUSTOM:
$this->columns[$this->primaryKey] = $this->generatePrimaryKey();
break;
}
$query->insert($this->columns);
}
} | [
"protected",
"function",
"insertRecord",
"(",
"Query",
"$",
"query",
")",
":",
"void",
"{",
"if",
"(",
"$",
"this",
"->",
"primaryKeyType",
"===",
"static",
"::",
"PRIMARY_KEY_TYPE_INCREMENTING",
")",
"{",
"$",
"this",
"->",
"columns",
"[",
"$",
"this",
"-... | Inserts a new record into the database.
@param \mako\database\midgard\Query $query Query builder | [
"Inserts",
"a",
"new",
"record",
"into",
"the",
"database",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/database/midgard/ORM.php#L949-L969 | train |
mako-framework/framework | src/mako/database/midgard/ORM.php | ORM.save | public function save(): bool
{
$success = true;
if(!$this->isPersisted)
{
// This is a new record so we need to insert it into the database.
$this->insertRecord($this->builder());
$this->isPersisted = true;
}
elseif($this->isModified())
{
// This record exists and is modified so all we have to do is update it.
$success = $this->updateRecord($this->builder());
}
if($success)
{
// Sync up if save was successful
$this->synchronize();
}
return $success;
} | php | public function save(): bool
{
$success = true;
if(!$this->isPersisted)
{
// This is a new record so we need to insert it into the database.
$this->insertRecord($this->builder());
$this->isPersisted = true;
}
elseif($this->isModified())
{
// This record exists and is modified so all we have to do is update it.
$success = $this->updateRecord($this->builder());
}
if($success)
{
// Sync up if save was successful
$this->synchronize();
}
return $success;
} | [
"public",
"function",
"save",
"(",
")",
":",
"bool",
"{",
"$",
"success",
"=",
"true",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"isPersisted",
")",
"{",
"// This is a new record so we need to insert it into the database.",
"$",
"this",
"->",
"insertRecord",
"(",
... | Saves the record to the database.
@return bool | [
"Saves",
"the",
"record",
"to",
"the",
"database",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/database/midgard/ORM.php#L989-L1016 | train |
mako-framework/framework | src/mako/database/midgard/ORM.php | ORM.protect | public function protect($column)
{
if($column === false)
{
$this->protected = [];
}
else
{
$this->protected = array_unique(array_merge($this->protected, (array) $column));
}
return $this;
} | php | public function protect($column)
{
if($column === false)
{
$this->protected = [];
}
else
{
$this->protected = array_unique(array_merge($this->protected, (array) $column));
}
return $this;
} | [
"public",
"function",
"protect",
"(",
"$",
"column",
")",
"{",
"if",
"(",
"$",
"column",
"===",
"false",
")",
"{",
"$",
"this",
"->",
"protected",
"=",
"[",
"]",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"protected",
"=",
"array_unique",
"(",
"arra... | Excludes the chosen columns and relations from array and json representations of the record.
You expose all fields by passing FALSE.
@param string|array|bool $column Column or relation to hide from the
@return $this | [
"Excludes",
"the",
"chosen",
"columns",
"and",
"relations",
"from",
"array",
"and",
"json",
"representations",
"of",
"the",
"record",
".",
"You",
"expose",
"all",
"fields",
"by",
"passing",
"FALSE",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/database/midgard/ORM.php#L1060-L1072 | train |
mako-framework/framework | src/mako/database/midgard/ORM.php | ORM.expose | public function expose($column)
{
if($column === true)
{
$this->protected = [];
}
else
{
$this->protected = array_diff($this->protected, (array) $column);
}
return $this;
} | php | public function expose($column)
{
if($column === true)
{
$this->protected = [];
}
else
{
$this->protected = array_diff($this->protected, (array) $column);
}
return $this;
} | [
"public",
"function",
"expose",
"(",
"$",
"column",
")",
"{",
"if",
"(",
"$",
"column",
"===",
"true",
")",
"{",
"$",
"this",
"->",
"protected",
"=",
"[",
"]",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"protected",
"=",
"array_diff",
"(",
"$",
"t... | Exposes the chosen columns and relations in the array and json representations of the record.
You can expose all fields by passing TRUE.
@param string|array|bool $column Column or relation to hide from the
@return $this | [
"Exposes",
"the",
"chosen",
"columns",
"and",
"relations",
"in",
"the",
"array",
"and",
"json",
"representations",
"of",
"the",
"record",
".",
"You",
"can",
"expose",
"all",
"fields",
"by",
"passing",
"TRUE",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/database/midgard/ORM.php#L1081-L1093 | train |
mako-framework/framework | src/mako/database/midgard/ORM.php | ORM.toArray | public function toArray(): array
{
$columns = $this->columns;
// Removes protected columns from the array
if(!empty($this->protected))
{
$columns = array_diff_key($columns, array_flip($this->protected));
}
// Mutate column values if needed
foreach($columns as $name => $value)
{
$value = $this->getColumnValue($name);
if($value instanceof DateTimeInterface)
{
$value = $value->format($this->dateOutputFormat);
}
$columns[$name] = $value;
}
// Merge in related records
foreach($this->related as $relation => $related)
{
if(in_array($relation, $this->protected))
{
continue;
}
$columns += [$relation => ($related === false ? $related : $related->toArray())];
}
// Returns array representation of the record
return $columns;
} | php | public function toArray(): array
{
$columns = $this->columns;
// Removes protected columns from the array
if(!empty($this->protected))
{
$columns = array_diff_key($columns, array_flip($this->protected));
}
// Mutate column values if needed
foreach($columns as $name => $value)
{
$value = $this->getColumnValue($name);
if($value instanceof DateTimeInterface)
{
$value = $value->format($this->dateOutputFormat);
}
$columns[$name] = $value;
}
// Merge in related records
foreach($this->related as $relation => $related)
{
if(in_array($relation, $this->protected))
{
continue;
}
$columns += [$relation => ($related === false ? $related : $related->toArray())];
}
// Returns array representation of the record
return $columns;
} | [
"public",
"function",
"toArray",
"(",
")",
":",
"array",
"{",
"$",
"columns",
"=",
"$",
"this",
"->",
"columns",
";",
"// Removes protected columns from the array",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"protected",
")",
")",
"{",
"$",
"columns"... | Returns an array representation of the record.
@return array | [
"Returns",
"an",
"array",
"representation",
"of",
"the",
"record",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/database/midgard/ORM.php#L1100-L1140 | train |
mako-framework/framework | src/mako/security/Signer.php | Signer.validate | public function validate(string $string)
{
$validated = mb_substr($string, static::MAC_LENGTH, null, '8bit');
if(hash_equals($this->getSignature($validated), mb_substr($string, 0, static::MAC_LENGTH, '8bit')))
{
return $validated;
}
return false;
} | php | public function validate(string $string)
{
$validated = mb_substr($string, static::MAC_LENGTH, null, '8bit');
if(hash_equals($this->getSignature($validated), mb_substr($string, 0, static::MAC_LENGTH, '8bit')))
{
return $validated;
}
return false;
} | [
"public",
"function",
"validate",
"(",
"string",
"$",
"string",
")",
"{",
"$",
"validated",
"=",
"mb_substr",
"(",
"$",
"string",
",",
"static",
"::",
"MAC_LENGTH",
",",
"null",
",",
"'8bit'",
")",
";",
"if",
"(",
"hash_equals",
"(",
"$",
"this",
"->",... | Returns the original string if the signature is valid or FALSE if not.
@param string $string The string you want to validate
@return string|bool | [
"Returns",
"the",
"original",
"string",
"if",
"the",
"signature",
"is",
"valid",
"or",
"FALSE",
"if",
"not",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/security/Signer.php#L73-L83 | train |
mako-framework/framework | src/mako/view/renderers/traits/EscaperTrait.php | EscaperTrait.escapeHTML | public function escapeHTML(?string $string, string $charset, bool $doubleEncode = true): string
{
return htmlspecialchars($string, ENT_QUOTES, $charset, $doubleEncode);
} | php | public function escapeHTML(?string $string, string $charset, bool $doubleEncode = true): string
{
return htmlspecialchars($string, ENT_QUOTES, $charset, $doubleEncode);
} | [
"public",
"function",
"escapeHTML",
"(",
"?",
"string",
"$",
"string",
",",
"string",
"$",
"charset",
",",
"bool",
"$",
"doubleEncode",
"=",
"true",
")",
":",
"string",
"{",
"return",
"htmlspecialchars",
"(",
"$",
"string",
",",
"ENT_QUOTES",
",",
"$",
"... | Returns a string that has been escaped for a HTML body context.
@param string|null $string String to escape
@param string $charset Character set
@param bool $doubleEncode Should existing entities be encoded?
@return string | [
"Returns",
"a",
"string",
"that",
"has",
"been",
"escaped",
"for",
"a",
"HTML",
"body",
"context",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/view/renderers/traits/EscaperTrait.php#L53-L56 | train |
mako-framework/framework | src/mako/view/renderers/traits/EscaperTrait.php | EscaperTrait.attributeEscaper | protected function attributeEscaper(array $matches): string
{
$chr = $matches[0];
$ord = ord($chr);
// The following replaces characters undefined in HTML with the
// hex entity for the Unicode replacement character.
if(($ord <= 0x1f && $chr !== "\t" && $chr !== "\n" && $chr !== "\r") || ($ord >= 0x7f && $ord <= 0x9f))
{
return '�';
}
// Check if the current character to escape has a name entity we should
// replace it with while grabbing the integer value of the character.
if(strlen($chr) > 1)
{
$chr = mb_convert_encoding($chr, 'UTF-16BE', 'UTF-8');
}
$hex = bin2hex($chr);
$ord = hexdec($hex);
if(isset($this->htmlNamedEntityMap[$ord]))
{
return '&' . $this->htmlNamedEntityMap[$ord] . ';';
}
// Per OWASP recommendations, we'll use upper hex entities
// for any other characters where a named entity does not exist.
if($ord > 255)
{
return sprintf('&#x%04X;', $ord);
}
return sprintf('&#x%02X;', $ord);
} | php | protected function attributeEscaper(array $matches): string
{
$chr = $matches[0];
$ord = ord($chr);
// The following replaces characters undefined in HTML with the
// hex entity for the Unicode replacement character.
if(($ord <= 0x1f && $chr !== "\t" && $chr !== "\n" && $chr !== "\r") || ($ord >= 0x7f && $ord <= 0x9f))
{
return '�';
}
// Check if the current character to escape has a name entity we should
// replace it with while grabbing the integer value of the character.
if(strlen($chr) > 1)
{
$chr = mb_convert_encoding($chr, 'UTF-16BE', 'UTF-8');
}
$hex = bin2hex($chr);
$ord = hexdec($hex);
if(isset($this->htmlNamedEntityMap[$ord]))
{
return '&' . $this->htmlNamedEntityMap[$ord] . ';';
}
// Per OWASP recommendations, we'll use upper hex entities
// for any other characters where a named entity does not exist.
if($ord > 255)
{
return sprintf('&#x%04X;', $ord);
}
return sprintf('&#x%02X;', $ord);
} | [
"protected",
"function",
"attributeEscaper",
"(",
"array",
"$",
"matches",
")",
":",
"string",
"{",
"$",
"chr",
"=",
"$",
"matches",
"[",
"0",
"]",
";",
"$",
"ord",
"=",
"ord",
"(",
"$",
"chr",
")",
";",
"// The following replaces characters undefined in HTM... | Escapes characters for use in a HTML attribute context.
(This method contains code from the SecurityMultiTool library).
@param array $matches Regex matches
@return string | [
"Escapes",
"characters",
"for",
"use",
"in",
"a",
"HTML",
"attribute",
"context",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/view/renderers/traits/EscaperTrait.php#L77-L117 | train |
mako-framework/framework | src/mako/view/renderers/traits/EscaperTrait.php | EscaperTrait.escapeAttribute | public function escapeAttribute(?string $string, string $charset): string
{
if($charset !== 'UTF-8')
{
$string = mb_convert_encoding($string, 'UTF-8', $charset);
}
$string = preg_replace_callback('/[^a-z0-9,\.\-_]/iSu', [$this, 'attributeEscaper'], $string);
if($charset !== 'UTF-8')
{
$string = mb_convert_encoding($string, $charset, 'UTF-8');
}
return $string;
} | php | public function escapeAttribute(?string $string, string $charset): string
{
if($charset !== 'UTF-8')
{
$string = mb_convert_encoding($string, 'UTF-8', $charset);
}
$string = preg_replace_callback('/[^a-z0-9,\.\-_]/iSu', [$this, 'attributeEscaper'], $string);
if($charset !== 'UTF-8')
{
$string = mb_convert_encoding($string, $charset, 'UTF-8');
}
return $string;
} | [
"public",
"function",
"escapeAttribute",
"(",
"?",
"string",
"$",
"string",
",",
"string",
"$",
"charset",
")",
":",
"string",
"{",
"if",
"(",
"$",
"charset",
"!==",
"'UTF-8'",
")",
"{",
"$",
"string",
"=",
"mb_convert_encoding",
"(",
"$",
"string",
",",... | Returns a string that has been escaped for a HTML attribute context.
@param string|null $string String to escape
@param string $charset Character set
@return string | [
"Returns",
"a",
"string",
"that",
"has",
"been",
"escaped",
"for",
"a",
"HTML",
"attribute",
"context",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/view/renderers/traits/EscaperTrait.php#L126-L141 | train |
mako-framework/framework | src/mako/view/renderers/traits/EscaperTrait.php | EscaperTrait.cssEscaper | protected function cssEscaper(array $matches): string
{
$chr = $matches[0];
if(strlen($chr) === 1)
{
$ord = ord($chr);
}
else
{
$chr = mb_convert_encoding($chr, 'UTF-16BE', 'UTF-8');
$ord = hexdec(bin2hex($chr));
}
return sprintf('\\%X ', $ord);
} | php | protected function cssEscaper(array $matches): string
{
$chr = $matches[0];
if(strlen($chr) === 1)
{
$ord = ord($chr);
}
else
{
$chr = mb_convert_encoding($chr, 'UTF-16BE', 'UTF-8');
$ord = hexdec(bin2hex($chr));
}
return sprintf('\\%X ', $ord);
} | [
"protected",
"function",
"cssEscaper",
"(",
"array",
"$",
"matches",
")",
":",
"string",
"{",
"$",
"chr",
"=",
"$",
"matches",
"[",
"0",
"]",
";",
"if",
"(",
"strlen",
"(",
"$",
"chr",
")",
"===",
"1",
")",
"{",
"$",
"ord",
"=",
"ord",
"(",
"$"... | Escapes characters for use in a CSS context.
(This method contains code from the SecurityMultiTool library).
@param array $matches Regex matches
@return string | [
"Escapes",
"characters",
"for",
"use",
"in",
"a",
"CSS",
"context",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/view/renderers/traits/EscaperTrait.php#L151-L167 | train |
mako-framework/framework | src/mako/view/renderers/traits/EscaperTrait.php | EscaperTrait.escapeCSS | public function escapeCSS(?string $string, string $charset): string
{
if($string === '' || ctype_digit($string))
{
return $string;
}
if($charset !== 'UTF-8')
{
$string = mb_convert_encoding($string, 'UTF-8', $charset);
}
$string = preg_replace_callback('/[^a-z0-9]/iSu', [$this, 'cssEscaper'], $string);
if($charset !== 'UTF-8')
{
$string = mb_convert_encoding($string, $charset, 'UTF-8');
}
return $string;
} | php | public function escapeCSS(?string $string, string $charset): string
{
if($string === '' || ctype_digit($string))
{
return $string;
}
if($charset !== 'UTF-8')
{
$string = mb_convert_encoding($string, 'UTF-8', $charset);
}
$string = preg_replace_callback('/[^a-z0-9]/iSu', [$this, 'cssEscaper'], $string);
if($charset !== 'UTF-8')
{
$string = mb_convert_encoding($string, $charset, 'UTF-8');
}
return $string;
} | [
"public",
"function",
"escapeCSS",
"(",
"?",
"string",
"$",
"string",
",",
"string",
"$",
"charset",
")",
":",
"string",
"{",
"if",
"(",
"$",
"string",
"===",
"''",
"||",
"ctype_digit",
"(",
"$",
"string",
")",
")",
"{",
"return",
"$",
"string",
";",... | Returns a string that has been escaped for a CSS context.
@param string|null $string String to escape
@param string $charset Character set
@return string | [
"Returns",
"a",
"string",
"that",
"has",
"been",
"escaped",
"for",
"a",
"CSS",
"context",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/view/renderers/traits/EscaperTrait.php#L176-L196 | train |
mako-framework/framework | src/mako/view/renderers/traits/EscaperTrait.php | EscaperTrait.javascriptEscaper | protected function javascriptEscaper(array $matches): string
{
$chr = $matches[0];
if(strlen($chr) === 1)
{
return sprintf('\\x%02X', ord($chr));
}
$chr = mb_convert_encoding($chr, 'UTF-16BE', 'UTF-8');
return sprintf('\\u%04s', strtoupper(bin2hex($chr)));
} | php | protected function javascriptEscaper(array $matches): string
{
$chr = $matches[0];
if(strlen($chr) === 1)
{
return sprintf('\\x%02X', ord($chr));
}
$chr = mb_convert_encoding($chr, 'UTF-16BE', 'UTF-8');
return sprintf('\\u%04s', strtoupper(bin2hex($chr)));
} | [
"protected",
"function",
"javascriptEscaper",
"(",
"array",
"$",
"matches",
")",
":",
"string",
"{",
"$",
"chr",
"=",
"$",
"matches",
"[",
"0",
"]",
";",
"if",
"(",
"strlen",
"(",
"$",
"chr",
")",
"===",
"1",
")",
"{",
"return",
"sprintf",
"(",
"'\... | Escapes characters for use in a Javascript context.
(This method contains code from the SecurityMultiTool library).
@param array $matches Regex matches
@return string | [
"Escapes",
"characters",
"for",
"use",
"in",
"a",
"Javascript",
"context",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/view/renderers/traits/EscaperTrait.php#L206-L218 | train |
mako-framework/framework | src/mako/view/renderers/traits/EscaperTrait.php | EscaperTrait.escapeJavascript | public function escapeJavascript(?string $string, string $charset): string
{
if($charset !== 'UTF-8')
{
$string = mb_convert_encoding($string, 'UTF-8', $charset);
}
$string = preg_replace_callback('/[^a-z0-9,\._]/iSu', [$this, 'javascriptEscaper'], $string);
if($charset !== 'UTF-8')
{
$string = mb_convert_encoding($string, $charset, 'UTF-8');
}
return $string;
} | php | public function escapeJavascript(?string $string, string $charset): string
{
if($charset !== 'UTF-8')
{
$string = mb_convert_encoding($string, 'UTF-8', $charset);
}
$string = preg_replace_callback('/[^a-z0-9,\._]/iSu', [$this, 'javascriptEscaper'], $string);
if($charset !== 'UTF-8')
{
$string = mb_convert_encoding($string, $charset, 'UTF-8');
}
return $string;
} | [
"public",
"function",
"escapeJavascript",
"(",
"?",
"string",
"$",
"string",
",",
"string",
"$",
"charset",
")",
":",
"string",
"{",
"if",
"(",
"$",
"charset",
"!==",
"'UTF-8'",
")",
"{",
"$",
"string",
"=",
"mb_convert_encoding",
"(",
"$",
"string",
","... | Returns a string that has been escaped for a Javascript context.
@param string|null $string String to escape
@param string $charset Character set
@return string | [
"Returns",
"a",
"string",
"that",
"has",
"been",
"escaped",
"for",
"a",
"Javascript",
"context",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/view/renderers/traits/EscaperTrait.php#L227-L242 | train |
mako-framework/framework | src/mako/http/request/Body.php | Body.parseBody | protected function parseBody($rawBody, $contentType): array
{
if($contentType === 'application/x-www-form-urlencoded')
{
$parsed = [];
parse_str($rawBody, $parsed);
return $parsed;
}
elseif($contentType === 'application/json' || $contentType === 'text/json' || strpos($contentType, '+json') !== false)
{
return json_decode($rawBody, true) ?? [];
}
return [];
} | php | protected function parseBody($rawBody, $contentType): array
{
if($contentType === 'application/x-www-form-urlencoded')
{
$parsed = [];
parse_str($rawBody, $parsed);
return $parsed;
}
elseif($contentType === 'application/json' || $contentType === 'text/json' || strpos($contentType, '+json') !== false)
{
return json_decode($rawBody, true) ?? [];
}
return [];
} | [
"protected",
"function",
"parseBody",
"(",
"$",
"rawBody",
",",
"$",
"contentType",
")",
":",
"array",
"{",
"if",
"(",
"$",
"contentType",
"===",
"'application/x-www-form-urlencoded'",
")",
"{",
"$",
"parsed",
"=",
"[",
"]",
";",
"parse_str",
"(",
"$",
"ra... | Converts the request body into an associative array.
@param string $rawBody Raw request body
@param string $contentType Content type
@return array | [
"Converts",
"the",
"request",
"body",
"into",
"an",
"associative",
"array",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/http/request/Body.php#L39-L55 | train |
mako-framework/framework | src/mako/gatekeeper/Gatekeeper.php | Gatekeeper.registerAdapterInstance | protected function registerAdapterInstance(AdapterInterface $adapter): string
{
$this->adapters[$name = $adapter->getName()] = $adapter;
return $name;
} | php | protected function registerAdapterInstance(AdapterInterface $adapter): string
{
$this->adapters[$name = $adapter->getName()] = $adapter;
return $name;
} | [
"protected",
"function",
"registerAdapterInstance",
"(",
"AdapterInterface",
"$",
"adapter",
")",
":",
"string",
"{",
"$",
"this",
"->",
"adapters",
"[",
"$",
"name",
"=",
"$",
"adapter",
"->",
"getName",
"(",
")",
"]",
"=",
"$",
"adapter",
";",
"return",
... | Registers an adapter instance.
@param \mako\gatekeeper\adapters\AdapterInterface $adapter Adapter instance
@return string | [
"Registers",
"an",
"adapter",
"instance",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/gatekeeper/Gatekeeper.php#L93-L98 | train |
mako-framework/framework | src/mako/gatekeeper/Gatekeeper.php | Gatekeeper.registerAdapterFactory | protected function registerAdapterFactory(string $name, Closure $factory): string
{
$this->adapterFactories[$name] = $factory;
return $name;
} | php | protected function registerAdapterFactory(string $name, Closure $factory): string
{
$this->adapterFactories[$name] = $factory;
return $name;
} | [
"protected",
"function",
"registerAdapterFactory",
"(",
"string",
"$",
"name",
",",
"Closure",
"$",
"factory",
")",
":",
"string",
"{",
"$",
"this",
"->",
"adapterFactories",
"[",
"$",
"name",
"]",
"=",
"$",
"factory",
";",
"return",
"$",
"name",
";",
"}... | Registers an adapter factory.
@param string $name Adapter name
@param \Closure $factory Adapter factory
@return string | [
"Registers",
"an",
"adapter",
"factory",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/gatekeeper/Gatekeeper.php#L107-L112 | train |
mako-framework/framework | src/mako/gatekeeper/Gatekeeper.php | Gatekeeper.registerAdapter | protected function registerAdapter($adapter): string
{
if($adapter instanceof AdapterInterface)
{
return $this->registerAdapterInstance($adapter);
}
[$name, $factory] = $adapter;
return $this->registerAdapterFactory($name, $factory);
} | php | protected function registerAdapter($adapter): string
{
if($adapter instanceof AdapterInterface)
{
return $this->registerAdapterInstance($adapter);
}
[$name, $factory] = $adapter;
return $this->registerAdapterFactory($name, $factory);
} | [
"protected",
"function",
"registerAdapter",
"(",
"$",
"adapter",
")",
":",
"string",
"{",
"if",
"(",
"$",
"adapter",
"instanceof",
"AdapterInterface",
")",
"{",
"return",
"$",
"this",
"->",
"registerAdapterInstance",
"(",
"$",
"adapter",
")",
";",
"}",
"[",
... | Registers an adapter.
@param array|\mako\gatekeeper\adapters\AdapterInterface $adapter Array containing the adapter name and closure factory or an adapter instance
@return string | [
"Registers",
"an",
"adapter",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/gatekeeper/Gatekeeper.php#L120-L130 | train |
mako-framework/framework | src/mako/gatekeeper/Gatekeeper.php | Gatekeeper.adapterFactory | protected function adapterFactory(string $name): AdapterInterface
{
$factory = $this->adapterFactories[$name];
return $this->adapters[$name] = $factory();
} | php | protected function adapterFactory(string $name): AdapterInterface
{
$factory = $this->adapterFactories[$name];
return $this->adapters[$name] = $factory();
} | [
"protected",
"function",
"adapterFactory",
"(",
"string",
"$",
"name",
")",
":",
"AdapterInterface",
"{",
"$",
"factory",
"=",
"$",
"this",
"->",
"adapterFactories",
"[",
"$",
"name",
"]",
";",
"return",
"$",
"this",
"->",
"adapters",
"[",
"$",
"name",
"... | Creates an adapter instance using a factory.
@param string $name Adapter name
@return \mako\gatekeeper\adapters\AdapterInterface | [
"Creates",
"an",
"adapter",
"instance",
"using",
"a",
"factory",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/gatekeeper/Gatekeeper.php#L164-L169 | train |
mako-framework/framework | src/mako/gatekeeper/Gatekeeper.php | Gatekeeper.adapter | public function adapter(?string $name = null): AdapterInterface
{
$name = $name ?? $this->defaultAdapter;
return $this->adapters[$name] ?? $this->adapterFactory($name);
} | php | public function adapter(?string $name = null): AdapterInterface
{
$name = $name ?? $this->defaultAdapter;
return $this->adapters[$name] ?? $this->adapterFactory($name);
} | [
"public",
"function",
"adapter",
"(",
"?",
"string",
"$",
"name",
"=",
"null",
")",
":",
"AdapterInterface",
"{",
"$",
"name",
"=",
"$",
"name",
"??",
"$",
"this",
"->",
"defaultAdapter",
";",
"return",
"$",
"this",
"->",
"adapters",
"[",
"$",
"name",
... | Returns an adapter instance.
@param string|null $name Adapter name
@return \mako\gatekeeper\adapters\AdapterInterface | [
"Returns",
"an",
"adapter",
"instance",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/gatekeeper/Gatekeeper.php#L177-L182 | train |
mako-framework/framework | src/mako/application/Application.php | Application.start | public static function start(string $applicationPath)
{
if(!empty(static::$instance))
{
throw new LogicException('The application has already been started.');
}
static::$instance = new static($applicationPath);
return static::$instance->boot();
} | php | public static function start(string $applicationPath)
{
if(!empty(static::$instance))
{
throw new LogicException('The application has already been started.');
}
static::$instance = new static($applicationPath);
return static::$instance->boot();
} | [
"public",
"static",
"function",
"start",
"(",
"string",
"$",
"applicationPath",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"static",
"::",
"$",
"instance",
")",
")",
"{",
"throw",
"new",
"LogicException",
"(",
"'The application has already been started.'",
")",
"... | Starts the application and returns a singleton instance of the application.
@param string $applicationPath Application path
@throws \LogicException
@return static | [
"Starts",
"the",
"application",
"and",
"returns",
"a",
"singleton",
"instance",
"of",
"the",
"application",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/application/Application.php#L113-L123 | train |
mako-framework/framework | src/mako/application/Application.php | Application.setLanguage | public function setLanguage(array $language): void
{
$this->language = $language['strings'];
foreach($language['locale'] as $category => $locale)
{
setlocale($category, $locale);
}
} | php | public function setLanguage(array $language): void
{
$this->language = $language['strings'];
foreach($language['locale'] as $category => $locale)
{
setlocale($category, $locale);
}
} | [
"public",
"function",
"setLanguage",
"(",
"array",
"$",
"language",
")",
":",
"void",
"{",
"$",
"this",
"->",
"language",
"=",
"$",
"language",
"[",
"'strings'",
"]",
";",
"foreach",
"(",
"$",
"language",
"[",
"'locale'",
"]",
"as",
"$",
"category",
"=... | Sets the application language settings.
@param array $language Application language settings | [
"Sets",
"the",
"application",
"language",
"settings",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/application/Application.php#L196-L204 | train |
mako-framework/framework | src/mako/application/Application.php | Application.getPackage | public function getPackage(string $package): Package
{
if(!isset($this->packages[$package]))
{
throw new RuntimeException(vsprintf('Unknown package [ %s ].', [$package]));
}
return $this->packages[$package];
} | php | public function getPackage(string $package): Package
{
if(!isset($this->packages[$package]))
{
throw new RuntimeException(vsprintf('Unknown package [ %s ].', [$package]));
}
return $this->packages[$package];
} | [
"public",
"function",
"getPackage",
"(",
"string",
"$",
"package",
")",
":",
"Package",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"packages",
"[",
"$",
"package",
"]",
")",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"vsprintf",
"(",... | Returns a package by its name.
@param string $package Package name
@throws \RuntimeException
@return \mako\application\Package | [
"Returns",
"a",
"package",
"by",
"its",
"name",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/application/Application.php#L233-L241 | train |
mako-framework/framework | src/mako/application/Application.php | Application.serviceRegistrar | protected function serviceRegistrar(string $type): void
{
foreach($this->config->get('application.services.' . $type) as $service)
{
(new $service($this, $this->container, $this->config))->register();
}
} | php | protected function serviceRegistrar(string $type): void
{
foreach($this->config->get('application.services.' . $type) as $service)
{
(new $service($this, $this->container, $this->config))->register();
}
} | [
"protected",
"function",
"serviceRegistrar",
"(",
"string",
"$",
"type",
")",
":",
"void",
"{",
"foreach",
"(",
"$",
"this",
"->",
"config",
"->",
"get",
"(",
"'application.services.'",
".",
"$",
"type",
")",
"as",
"$",
"service",
")",
"{",
"(",
"new",
... | Registers services in the container.
@param string $type Service type | [
"Registers",
"services",
"in",
"the",
"container",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/application/Application.php#L312-L318 | train |
mako-framework/framework | src/mako/application/Application.php | Application.registerServices | protected function registerServices(): void
{
// Register core services
$this->serviceRegistrar('core');
// Register environment specific services
if($this->isCommandLine())
{
$this->registerCLIServices();
}
else
{
$this->registerWebServices();
}
} | php | protected function registerServices(): void
{
// Register core services
$this->serviceRegistrar('core');
// Register environment specific services
if($this->isCommandLine())
{
$this->registerCLIServices();
}
else
{
$this->registerWebServices();
}
} | [
"protected",
"function",
"registerServices",
"(",
")",
":",
"void",
"{",
"// Register core services",
"$",
"this",
"->",
"serviceRegistrar",
"(",
"'core'",
")",
";",
"// Register environment specific services",
"if",
"(",
"$",
"this",
"->",
"isCommandLine",
"(",
")"... | Register services in the container. | [
"Register",
"services",
"in",
"the",
"container",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/application/Application.php#L339-L355 | train |
mako-framework/framework | src/mako/application/Application.php | Application.registerClassAliases | protected function registerClassAliases(): void
{
$aliases = $this->config->get('application.class_aliases');
if(!empty($aliases))
{
$aliasLoader = new AliasLoader($aliases);
spl_autoload_register([$aliasLoader, 'load']);
}
} | php | protected function registerClassAliases(): void
{
$aliases = $this->config->get('application.class_aliases');
if(!empty($aliases))
{
$aliasLoader = new AliasLoader($aliases);
spl_autoload_register([$aliasLoader, 'load']);
}
} | [
"protected",
"function",
"registerClassAliases",
"(",
")",
":",
"void",
"{",
"$",
"aliases",
"=",
"$",
"this",
"->",
"config",
"->",
"get",
"(",
"'application.class_aliases'",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"aliases",
")",
")",
"{",
"$",
... | Registers class aliases. | [
"Registers",
"class",
"aliases",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/application/Application.php#L360-L370 | train |
mako-framework/framework | src/mako/application/Application.php | Application.bootstrap | protected function bootstrap(): void
{
(function($app, $container): void
{
include $this->applicationPath . '/bootstrap.php';
})($this, $this->container);
} | php | protected function bootstrap(): void
{
(function($app, $container): void
{
include $this->applicationPath . '/bootstrap.php';
})($this, $this->container);
} | [
"protected",
"function",
"bootstrap",
"(",
")",
":",
"void",
"{",
"(",
"function",
"(",
"$",
"app",
",",
"$",
"container",
")",
":",
"void",
"{",
"include",
"$",
"this",
"->",
"applicationPath",
".",
"'/bootstrap.php'",
";",
"}",
")",
"(",
"$",
"this",... | Loads the application bootstrap file. | [
"Loads",
"the",
"application",
"bootstrap",
"file",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/application/Application.php#L375-L381 | train |
mako-framework/framework | src/mako/application/Application.php | Application.packageBooter | protected function packageBooter(string $type): void
{
foreach($this->config->get('application.packages.' . $type) as $package)
{
$package = new $package($this->container);
$package->boot();
$this->packages[$package->getName()] = $package;
}
} | php | protected function packageBooter(string $type): void
{
foreach($this->config->get('application.packages.' . $type) as $package)
{
$package = new $package($this->container);
$package->boot();
$this->packages[$package->getName()] = $package;
}
} | [
"protected",
"function",
"packageBooter",
"(",
"string",
"$",
"type",
")",
":",
"void",
"{",
"foreach",
"(",
"$",
"this",
"->",
"config",
"->",
"get",
"(",
"'application.packages.'",
".",
"$",
"type",
")",
"as",
"$",
"package",
")",
"{",
"$",
"package",
... | Boots packages.
@param string $type Package type | [
"Boots",
"packages",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/application/Application.php#L388-L398 | train |
mako-framework/framework | src/mako/application/Application.php | Application.bootPackages | protected function bootPackages(): void
{
$this->packageBooter('core');
// Register environment specific services
if($this->isCommandLine())
{
$this->bootCliPackages();
}
else
{
$this->bootWebPackages();
}
} | php | protected function bootPackages(): void
{
$this->packageBooter('core');
// Register environment specific services
if($this->isCommandLine())
{
$this->bootCliPackages();
}
else
{
$this->bootWebPackages();
}
} | [
"protected",
"function",
"bootPackages",
"(",
")",
":",
"void",
"{",
"$",
"this",
"->",
"packageBooter",
"(",
"'core'",
")",
";",
"// Register environment specific services",
"if",
"(",
"$",
"this",
"->",
"isCommandLine",
"(",
")",
")",
"{",
"$",
"this",
"->... | Boot packages. | [
"Boot",
"packages",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/application/Application.php#L419-L433 | train |
mako-framework/framework | src/mako/application/Application.php | Application.configFactory | protected function configFactory(): Config
{
return new Config(new Loader($this->container->get(FileSystem::class), $this->applicationPath . '/config'), $this->getEnvironment());
} | php | protected function configFactory(): Config
{
return new Config(new Loader($this->container->get(FileSystem::class), $this->applicationPath . '/config'), $this->getEnvironment());
} | [
"protected",
"function",
"configFactory",
"(",
")",
":",
"Config",
"{",
"return",
"new",
"Config",
"(",
"new",
"Loader",
"(",
"$",
"this",
"->",
"container",
"->",
"get",
"(",
"FileSystem",
"::",
"class",
")",
",",
"$",
"this",
"->",
"applicationPath",
"... | Creates a configuration instance.
@return \mako\config\Config | [
"Creates",
"a",
"configuration",
"instance",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/application/Application.php#L450-L453 | train |
mako-framework/framework | src/mako/application/Application.php | Application.initialize | protected function initialize(): void
{
// Create container instance and register it in itself so that it can be injected
$this->container = $this->containerFactory();
$this->container->registerInstance([Container::class, 'container'], $this->container);
// Register self so that the application instance can be injected
$this->container->registerInstance([Application::class, 'app'], $this);
// Register file system instance
$this->container->registerInstance([FileSystem::class, 'fileSystem'], new FileSystem);
// Register config instance
$this->config = $this->configFactory();
$this->container->registerInstance([Config::class, 'config'], $this->config);
} | php | protected function initialize(): void
{
// Create container instance and register it in itself so that it can be injected
$this->container = $this->containerFactory();
$this->container->registerInstance([Container::class, 'container'], $this->container);
// Register self so that the application instance can be injected
$this->container->registerInstance([Application::class, 'app'], $this);
// Register file system instance
$this->container->registerInstance([FileSystem::class, 'fileSystem'], new FileSystem);
// Register config instance
$this->config = $this->configFactory();
$this->container->registerInstance([Config::class, 'config'], $this->config);
} | [
"protected",
"function",
"initialize",
"(",
")",
":",
"void",
"{",
"// Create container instance and register it in itself so that it can be injected",
"$",
"this",
"->",
"container",
"=",
"$",
"this",
"->",
"containerFactory",
"(",
")",
";",
"$",
"this",
"->",
"conta... | Sets up the framework core. | [
"Sets",
"up",
"the",
"framework",
"core",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/application/Application.php#L458-L479 | train |
mako-framework/framework | src/mako/application/Application.php | Application.boot | public function boot()
{
// Set up the framework core
$this->initialize();
// Configure
$this->configure();
// Register services in the IoC injection container
$this->registerServices();
// Register class aliases
$this->registerClassAliases();
// Load the application bootstrap file
$this->bootstrap();
// Boot packages
$this->bootPackages();
// Return application instnace
return $this;
} | php | public function boot()
{
// Set up the framework core
$this->initialize();
// Configure
$this->configure();
// Register services in the IoC injection container
$this->registerServices();
// Register class aliases
$this->registerClassAliases();
// Load the application bootstrap file
$this->bootstrap();
// Boot packages
$this->bootPackages();
// Return application instnace
return $this;
} | [
"public",
"function",
"boot",
"(",
")",
"{",
"// Set up the framework core",
"$",
"this",
"->",
"initialize",
"(",
")",
";",
"// Configure",
"$",
"this",
"->",
"configure",
"(",
")",
";",
"// Register services in the IoC injection container",
"$",
"this",
"->",
"r... | Boots the application.
@return $this | [
"Boots",
"the",
"application",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/application/Application.php#L486-L515 | train |
mako-framework/framework | src/mako/utility/HTML.php | HTML.attributes | protected function attributes(array $attributes): string
{
$attr = '';
foreach($attributes as $attribute => $value)
{
if(is_int($attribute))
{
$attribute = $value;
}
$attr .= ' ' . $attribute . '="' . $value . '"';
}
return $attr;
} | php | protected function attributes(array $attributes): string
{
$attr = '';
foreach($attributes as $attribute => $value)
{
if(is_int($attribute))
{
$attribute = $value;
}
$attr .= ' ' . $attribute . '="' . $value . '"';
}
return $attr;
} | [
"protected",
"function",
"attributes",
"(",
"array",
"$",
"attributes",
")",
":",
"string",
"{",
"$",
"attr",
"=",
"''",
";",
"foreach",
"(",
"$",
"attributes",
"as",
"$",
"attribute",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"is_int",
"(",
"$",
"att... | Takes an array of attributes and turns it into a string.
@param array $attributes Array of tags
@return string | [
"Takes",
"an",
"array",
"of",
"attributes",
"and",
"turns",
"it",
"into",
"a",
"string",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/utility/HTML.php#L47-L62 | train |
mako-framework/framework | src/mako/utility/HTML.php | HTML.buildMedia | protected function buildMedia(string $type, $files, array $attributes): string
{
$sources = '';
foreach((array) $files as $file)
{
$sources .= $this->tag('source', ['src' => $file]);
}
return $this->tag($type, $attributes, $sources);
} | php | protected function buildMedia(string $type, $files, array $attributes): string
{
$sources = '';
foreach((array) $files as $file)
{
$sources .= $this->tag('source', ['src' => $file]);
}
return $this->tag($type, $attributes, $sources);
} | [
"protected",
"function",
"buildMedia",
"(",
"string",
"$",
"type",
",",
"$",
"files",
",",
"array",
"$",
"attributes",
")",
":",
"string",
"{",
"$",
"sources",
"=",
"''",
";",
"foreach",
"(",
"(",
"array",
")",
"$",
"files",
"as",
"$",
"file",
")",
... | Helper method for building media tags.
@param string $type Tag type
@param string|array $files File or array of files
@param array $attributes Tag attributes
@return string | [
"Helper",
"method",
"for",
"building",
"media",
"tags",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/utility/HTML.php#L85-L95 | train |
mako-framework/framework | src/mako/database/query/compilers/Compiler.php | Compiler.raw | protected function raw(Raw $raw): string
{
$parameters = $raw->getParameters();
if(!empty($parameters))
{
$this->params = array_merge($this->params, $parameters);
}
return $raw->getSql();
} | php | protected function raw(Raw $raw): string
{
$parameters = $raw->getParameters();
if(!empty($parameters))
{
$this->params = array_merge($this->params, $parameters);
}
return $raw->getSql();
} | [
"protected",
"function",
"raw",
"(",
"Raw",
"$",
"raw",
")",
":",
"string",
"{",
"$",
"parameters",
"=",
"$",
"raw",
"->",
"getParameters",
"(",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"parameters",
")",
")",
"{",
"$",
"this",
"->",
"params",
... | Compiles a raw SQL statement.
@param \mako\database\query\Raw $raw Raw SQL
@return string | [
"Compiles",
"a",
"raw",
"SQL",
"statement",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/database/query/compilers/Compiler.php#L102-L112 | train |
mako-framework/framework | src/mako/database/query/compilers/Compiler.php | Compiler.subquery | protected function subquery(Subquery $subquery, bool $enclose = true): string
{
$query = $subquery->getQuery();
if($query instanceof Closure)
{
$builder = $query;
$query = $this->query->newInstance()->inSubqueryContext();
$builder($query);
}
$query = $query->getCompiler()->select();
$this->params = array_merge($this->params, $query['params']);
if($enclose)
{
$query['sql'] = '(' . $query['sql'] . ')';
}
if(($alias = $subquery->getAlias()) !== null)
{
$query['sql'] .= ' AS ' . $this->escapeIdentifier($alias);
}
return $query['sql'];
} | php | protected function subquery(Subquery $subquery, bool $enclose = true): string
{
$query = $subquery->getQuery();
if($query instanceof Closure)
{
$builder = $query;
$query = $this->query->newInstance()->inSubqueryContext();
$builder($query);
}
$query = $query->getCompiler()->select();
$this->params = array_merge($this->params, $query['params']);
if($enclose)
{
$query['sql'] = '(' . $query['sql'] . ')';
}
if(($alias = $subquery->getAlias()) !== null)
{
$query['sql'] .= ' AS ' . $this->escapeIdentifier($alias);
}
return $query['sql'];
} | [
"protected",
"function",
"subquery",
"(",
"Subquery",
"$",
"subquery",
",",
"bool",
"$",
"enclose",
"=",
"true",
")",
":",
"string",
"{",
"$",
"query",
"=",
"$",
"subquery",
"->",
"getQuery",
"(",
")",
";",
"if",
"(",
"$",
"query",
"instanceof",
"Closu... | Compiles subquery, merges parameters and returns subquery SQL.
@param \mako\database\query\Subquery $subquery Subquery container
@param bool $enclose Should the subquery be enclosed in parentheses?
@return string | [
"Compiles",
"subquery",
"merges",
"parameters",
"and",
"returns",
"subquery",
"SQL",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/database/query/compilers/Compiler.php#L121-L149 | train |
mako-framework/framework | src/mako/database/query/compilers/Compiler.php | Compiler.escapeIdentifiers | public function escapeIdentifiers(array $identifiers): array
{
foreach($identifiers as $key => $identifier)
{
$identifiers[$key] = $this->escapeIdentifier($identifier);
}
return $identifiers;
} | php | public function escapeIdentifiers(array $identifiers): array
{
foreach($identifiers as $key => $identifier)
{
$identifiers[$key] = $this->escapeIdentifier($identifier);
}
return $identifiers;
} | [
"public",
"function",
"escapeIdentifiers",
"(",
"array",
"$",
"identifiers",
")",
":",
"array",
"{",
"foreach",
"(",
"$",
"identifiers",
"as",
"$",
"key",
"=>",
"$",
"identifier",
")",
"{",
"$",
"identifiers",
"[",
"$",
"key",
"]",
"=",
"$",
"this",
"-... | Returns an array of escaped identifiers.
@param array $identifiers Identifiers to escape
@return array | [
"Returns",
"an",
"array",
"of",
"escaped",
"identifiers",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/database/query/compilers/Compiler.php#L168-L176 | train |
mako-framework/framework | src/mako/database/query/compilers/Compiler.php | Compiler.escapeTable | public function escapeTable(string $table): string
{
$segments = [];
foreach(explode('.', $table) as $segment)
{
$segments[] = $this->escapeIdentifier($segment);
}
return implode('.', $segments);
} | php | public function escapeTable(string $table): string
{
$segments = [];
foreach(explode('.', $table) as $segment)
{
$segments[] = $this->escapeIdentifier($segment);
}
return implode('.', $segments);
} | [
"public",
"function",
"escapeTable",
"(",
"string",
"$",
"table",
")",
":",
"string",
"{",
"$",
"segments",
"=",
"[",
"]",
";",
"foreach",
"(",
"explode",
"(",
"'.'",
",",
"$",
"table",
")",
"as",
"$",
"segment",
")",
"{",
"$",
"segments",
"[",
"]"... | Escapes a table name.
@param string $table Table name
@return string | [
"Escapes",
"a",
"table",
"name",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/database/query/compilers/Compiler.php#L222-L232 | train |
mako-framework/framework | src/mako/database/query/compilers/Compiler.php | Compiler.setOperations | protected function setOperations(array $setOperations): string
{
if(empty($setOperations))
{
return '';
}
$sql = '';
foreach($setOperations as $setOperation)
{
$sql .= $this->subquery($setOperation['query'], false) . ' ' . $setOperation['operation'] . ' ';
}
return $sql;
} | php | protected function setOperations(array $setOperations): string
{
if(empty($setOperations))
{
return '';
}
$sql = '';
foreach($setOperations as $setOperation)
{
$sql .= $this->subquery($setOperation['query'], false) . ' ' . $setOperation['operation'] . ' ';
}
return $sql;
} | [
"protected",
"function",
"setOperations",
"(",
"array",
"$",
"setOperations",
")",
":",
"string",
"{",
"if",
"(",
"empty",
"(",
"$",
"setOperations",
")",
")",
"{",
"return",
"''",
";",
"}",
"$",
"sql",
"=",
"''",
";",
"foreach",
"(",
"$",
"setOperatio... | Compiles set operations.
@param array $setOperations Set operations
@return string | [
"Compiles",
"set",
"operations",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/database/query/compilers/Compiler.php#L240-L255 | train |
mako-framework/framework | src/mako/database/query/compilers/Compiler.php | Compiler.escapeColumn | public function escapeColumn(string $column): string
{
$segments = [];
foreach(explode('.', $column) as $segment)
{
if($segment === '*')
{
$segments[] = $segment;
}
else
{
$segments[] = $this->escapeIdentifier($segment);
}
}
return implode('.', $segments);
} | php | public function escapeColumn(string $column): string
{
$segments = [];
foreach(explode('.', $column) as $segment)
{
if($segment === '*')
{
$segments[] = $segment;
}
else
{
$segments[] = $this->escapeIdentifier($segment);
}
}
return implode('.', $segments);
} | [
"public",
"function",
"escapeColumn",
"(",
"string",
"$",
"column",
")",
":",
"string",
"{",
"$",
"segments",
"=",
"[",
"]",
";",
"foreach",
"(",
"explode",
"(",
"'.'",
",",
"$",
"column",
")",
"as",
"$",
"segment",
")",
"{",
"if",
"(",
"$",
"segme... | Escapes a column name.
@param string $column Column name
@return string | [
"Escapes",
"a",
"column",
"name",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/database/query/compilers/Compiler.php#L289-L306 | train |
mako-framework/framework | src/mako/database/query/compilers/Compiler.php | Compiler.compileColumnName | protected function compileColumnName(string $column): string
{
if($this->hasJsonPath($column))
{
$segments = explode(static::JSON_PATH_SEPARATOR, $column);
$column = $this->escapeColumn(array_shift($segments));
return $this->buildJsonGet($column, $segments);
}
return $this->escapeColumn($column);
} | php | protected function compileColumnName(string $column): string
{
if($this->hasJsonPath($column))
{
$segments = explode(static::JSON_PATH_SEPARATOR, $column);
$column = $this->escapeColumn(array_shift($segments));
return $this->buildJsonGet($column, $segments);
}
return $this->escapeColumn($column);
} | [
"protected",
"function",
"compileColumnName",
"(",
"string",
"$",
"column",
")",
":",
"string",
"{",
"if",
"(",
"$",
"this",
"->",
"hasJsonPath",
"(",
"$",
"column",
")",
")",
"{",
"$",
"segments",
"=",
"explode",
"(",
"static",
"::",
"JSON_PATH_SEPARATOR"... | Compiles a column name.
@param string $column Column name
@return string | [
"Compiles",
"a",
"column",
"name",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/database/query/compilers/Compiler.php#L314-L326 | train |
mako-framework/framework | src/mako/database/query/compilers/Compiler.php | Compiler.columns | public function columns(array $columns, bool $allowAlias = false): string
{
$pieces = [];
foreach($columns as $column)
{
$pieces[] = $this->column($column, $allowAlias);
}
return implode(', ', $pieces);
} | php | public function columns(array $columns, bool $allowAlias = false): string
{
$pieces = [];
foreach($columns as $column)
{
$pieces[] = $this->column($column, $allowAlias);
}
return implode(', ', $pieces);
} | [
"public",
"function",
"columns",
"(",
"array",
"$",
"columns",
",",
"bool",
"$",
"allowAlias",
"=",
"false",
")",
":",
"string",
"{",
"$",
"pieces",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"columns",
"as",
"$",
"column",
")",
"{",
"$",
"pieces",
"... | Returns a comma-separated list of compiled columns.
@param array $columns Array of columns
@param bool $allowAlias Allow aliases?
@return string | [
"Returns",
"a",
"comma",
"-",
"separated",
"list",
"of",
"compiled",
"columns",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/database/query/compilers/Compiler.php#L362-L372 | train |
mako-framework/framework | src/mako/database/query/compilers/Compiler.php | Compiler.param | protected function param($param, bool $enclose = true): string
{
if($param instanceof Raw)
{
return $this->raw($param);
}
elseif($param instanceof Subquery)
{
return $this->subquery($param, $enclose);
}
elseif($param instanceof DateTimeInterface)
{
$this->params[] = $param->format(static::$dateFormat);
return '?';
}
$this->params[] = $param;
return '?';
} | php | protected function param($param, bool $enclose = true): string
{
if($param instanceof Raw)
{
return $this->raw($param);
}
elseif($param instanceof Subquery)
{
return $this->subquery($param, $enclose);
}
elseif($param instanceof DateTimeInterface)
{
$this->params[] = $param->format(static::$dateFormat);
return '?';
}
$this->params[] = $param;
return '?';
} | [
"protected",
"function",
"param",
"(",
"$",
"param",
",",
"bool",
"$",
"enclose",
"=",
"true",
")",
":",
"string",
"{",
"if",
"(",
"$",
"param",
"instanceof",
"Raw",
")",
"{",
"return",
"$",
"this",
"->",
"raw",
"(",
"$",
"param",
")",
";",
"}",
... | Returns raw SQL or a paramter placeholder.
@param mixed $param Parameter
@param bool $enclose Should subqueries be enclosed in parentheses?
@return string | [
"Returns",
"raw",
"SQL",
"or",
"a",
"paramter",
"placeholder",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/database/query/compilers/Compiler.php#L392-L412 | train |
mako-framework/framework | src/mako/database/query/compilers/Compiler.php | Compiler.params | protected function params(array $params, bool $enclose = true): string
{
$pieces = [];
foreach($params as $param)
{
$pieces[] = $this->param($param, $enclose);
}
return implode(', ', $pieces);
} | php | protected function params(array $params, bool $enclose = true): string
{
$pieces = [];
foreach($params as $param)
{
$pieces[] = $this->param($param, $enclose);
}
return implode(', ', $pieces);
} | [
"protected",
"function",
"params",
"(",
"array",
"$",
"params",
",",
"bool",
"$",
"enclose",
"=",
"true",
")",
":",
"string",
"{",
"$",
"pieces",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"params",
"as",
"$",
"param",
")",
"{",
"$",
"pieces",
"[",
... | Returns a comma-separated list of parameters.
@param array $params Array of parameters
@param bool $enclose Should subqueries be enclosed in parentheses?
@return string | [
"Returns",
"a",
"comma",
"-",
"separated",
"list",
"of",
"parameters",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/database/query/compilers/Compiler.php#L421-L431 | train |
mako-framework/framework | src/mako/database/query/compilers/Compiler.php | Compiler.between | protected function between(array $where): string
{
return $this->column($where['column']) . ($where['not'] ? ' NOT BETWEEN ' : ' BETWEEN ') . $this->param($where['value1']) . ' AND ' . $this->param($where['value2']);
} | php | protected function between(array $where): string
{
return $this->column($where['column']) . ($where['not'] ? ' NOT BETWEEN ' : ' BETWEEN ') . $this->param($where['value1']) . ' AND ' . $this->param($where['value2']);
} | [
"protected",
"function",
"between",
"(",
"array",
"$",
"where",
")",
":",
"string",
"{",
"return",
"$",
"this",
"->",
"column",
"(",
"$",
"where",
"[",
"'column'",
"]",
")",
".",
"(",
"$",
"where",
"[",
"'not'",
"]",
"?",
"' NOT BETWEEN '",
":",
"' B... | Compiles BETWEEN clauses.
@param array $where Where clause
@return string | [
"Compiles",
"BETWEEN",
"clauses",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/database/query/compilers/Compiler.php#L439-L442 | train |
mako-framework/framework | src/mako/database/query/compilers/Compiler.php | Compiler.in | protected function in(array $where): string
{
$values = $this->params($where['values'], false);
return $this->column($where['column']) . ($where['not'] ? ' NOT IN ' : ' IN ') . '(' . $values . ')';
} | php | protected function in(array $where): string
{
$values = $this->params($where['values'], false);
return $this->column($where['column']) . ($where['not'] ? ' NOT IN ' : ' IN ') . '(' . $values . ')';
} | [
"protected",
"function",
"in",
"(",
"array",
"$",
"where",
")",
":",
"string",
"{",
"$",
"values",
"=",
"$",
"this",
"->",
"params",
"(",
"$",
"where",
"[",
"'values'",
"]",
",",
"false",
")",
";",
"return",
"$",
"this",
"->",
"column",
"(",
"$",
... | Compiles IN clauses.
@param array $where Where clause
@return string | [
"Compiles",
"IN",
"clauses",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/database/query/compilers/Compiler.php#L450-L455 | train |
mako-framework/framework | src/mako/database/query/compilers/Compiler.php | Compiler.joinCondition | protected function joinCondition(array $condition): string
{
return $this->column($condition['column1']) . ' ' . $condition['operator'] . ' ' . $this->column($condition['column2']);
} | php | protected function joinCondition(array $condition): string
{
return $this->column($condition['column1']) . ' ' . $condition['operator'] . ' ' . $this->column($condition['column2']);
} | [
"protected",
"function",
"joinCondition",
"(",
"array",
"$",
"condition",
")",
":",
"string",
"{",
"return",
"$",
"this",
"->",
"column",
"(",
"$",
"condition",
"[",
"'column1'",
"]",
")",
".",
"' '",
".",
"$",
"condition",
"[",
"'operator'",
"]",
".",
... | Compiles a JOIN condition.
@param array $condition Join condition
@return string | [
"Compiles",
"a",
"JOIN",
"condition",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/database/query/compilers/Compiler.php#L565-L568 | train |
mako-framework/framework | src/mako/database/query/compilers/Compiler.php | Compiler.joinConditions | protected function joinConditions(Join $join): string
{
$conditions = [];
$conditionCounter = 0;
foreach($join->getConditions() as $condition)
{
$conditions[] = ($conditionCounter > 0 ? $condition['separator'] . ' ' : null) . $this->{$condition['type']}($condition);
$conditionCounter++;
}
return implode(' ', $conditions);
} | php | protected function joinConditions(Join $join): string
{
$conditions = [];
$conditionCounter = 0;
foreach($join->getConditions() as $condition)
{
$conditions[] = ($conditionCounter > 0 ? $condition['separator'] . ' ' : null) . $this->{$condition['type']}($condition);
$conditionCounter++;
}
return implode(' ', $conditions);
} | [
"protected",
"function",
"joinConditions",
"(",
"Join",
"$",
"join",
")",
":",
"string",
"{",
"$",
"conditions",
"=",
"[",
"]",
";",
"$",
"conditionCounter",
"=",
"0",
";",
"foreach",
"(",
"$",
"join",
"->",
"getConditions",
"(",
")",
"as",
"$",
"condi... | Compiles JOIN conditions.
@param \mako\database\query\Join $join Join
@return string | [
"Compiles",
"JOIN",
"conditions",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/database/query/compilers/Compiler.php#L589-L603 | train |
mako-framework/framework | src/mako/database/query/compilers/Compiler.php | Compiler.joins | protected function joins(array $joins): string
{
if(empty($joins))
{
return '';
}
$sql = [];
foreach($joins as $join)
{
$sql[] = $join->getType() . ' JOIN ' . $this->table($join->getTable()) . ' ON ' . $this->joinConditions($join);
}
return ' ' . implode(' ', $sql);
} | php | protected function joins(array $joins): string
{
if(empty($joins))
{
return '';
}
$sql = [];
foreach($joins as $join)
{
$sql[] = $join->getType() . ' JOIN ' . $this->table($join->getTable()) . ' ON ' . $this->joinConditions($join);
}
return ' ' . implode(' ', $sql);
} | [
"protected",
"function",
"joins",
"(",
"array",
"$",
"joins",
")",
":",
"string",
"{",
"if",
"(",
"empty",
"(",
"$",
"joins",
")",
")",
"{",
"return",
"''",
";",
"}",
"$",
"sql",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"joins",
"as",
"$",
"joi... | Compiles JOIN clauses.
@param array $joins Array of joins
@return string | [
"Compiles",
"JOIN",
"clauses",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/database/query/compilers/Compiler.php#L611-L626 | train |
mako-framework/framework | src/mako/database/query/compilers/Compiler.php | Compiler.orderings | protected function orderings(array $orderings): string
{
if(empty($orderings))
{
return '';
}
$sql = [];
foreach($orderings as $order)
{
$sql[] = $this->columns($order['column']) . ' ' . $order['order'];
}
return ' ORDER BY ' . implode(', ', $sql);
} | php | protected function orderings(array $orderings): string
{
if(empty($orderings))
{
return '';
}
$sql = [];
foreach($orderings as $order)
{
$sql[] = $this->columns($order['column']) . ' ' . $order['order'];
}
return ' ORDER BY ' . implode(', ', $sql);
} | [
"protected",
"function",
"orderings",
"(",
"array",
"$",
"orderings",
")",
":",
"string",
"{",
"if",
"(",
"empty",
"(",
"$",
"orderings",
")",
")",
"{",
"return",
"''",
";",
"}",
"$",
"sql",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"orderings",
"as... | Compiles ORDER BY clauses.
@param array $orderings Array of order by clauses
@return string | [
"Compiles",
"ORDER",
"BY",
"clauses",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/database/query/compilers/Compiler.php#L645-L660 | train |
mako-framework/framework | src/mako/database/query/compilers/Compiler.php | Compiler.havingCondictions | protected function havingCondictions(array $havings): string
{
$conditions = [];
$conditionCounter = 0;
foreach($havings as $having)
{
$conditions[] = ($conditionCounter > 0 ? $having['separator'] . ' ' : null) . $this->column($having['column']) . ' ' . $having['operator'] . ' ' . $this->param($having['value']);
$conditionCounter++;
}
return implode(' ', $conditions);
} | php | protected function havingCondictions(array $havings): string
{
$conditions = [];
$conditionCounter = 0;
foreach($havings as $having)
{
$conditions[] = ($conditionCounter > 0 ? $having['separator'] . ' ' : null) . $this->column($having['column']) . ' ' . $having['operator'] . ' ' . $this->param($having['value']);
$conditionCounter++;
}
return implode(' ', $conditions);
} | [
"protected",
"function",
"havingCondictions",
"(",
"array",
"$",
"havings",
")",
":",
"string",
"{",
"$",
"conditions",
"=",
"[",
"]",
";",
"$",
"conditionCounter",
"=",
"0",
";",
"foreach",
"(",
"$",
"havings",
"as",
"$",
"having",
")",
"{",
"$",
"con... | Compiles HAVING conditions.
@param array $havings Having conditions
@return string | [
"Compiles",
"HAVING",
"conditions",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/database/query/compilers/Compiler.php#L668-L682 | train |
mako-framework/framework | src/mako/database/query/compilers/Compiler.php | Compiler.insertWithValues | protected function insertWithValues(array $values): string
{
$sql = 'INSERT INTO ';
$sql .= $this->escapeTable($this->query->getTable());
$sql .= ' (' . implode(', ', $this->escapeIdentifiers(array_keys($values))) . ')';
$sql .= ' VALUES';
$sql .= ' (' . $this->params($values) . ')';
return $sql;
} | php | protected function insertWithValues(array $values): string
{
$sql = 'INSERT INTO ';
$sql .= $this->escapeTable($this->query->getTable());
$sql .= ' (' . implode(', ', $this->escapeIdentifiers(array_keys($values))) . ')';
$sql .= ' VALUES';
$sql .= ' (' . $this->params($values) . ')';
return $sql;
} | [
"protected",
"function",
"insertWithValues",
"(",
"array",
"$",
"values",
")",
":",
"string",
"{",
"$",
"sql",
"=",
"'INSERT INTO '",
";",
"$",
"sql",
".=",
"$",
"this",
"->",
"escapeTable",
"(",
"$",
"this",
"->",
"query",
"->",
"getTable",
"(",
")",
... | Returns a INSERT query with values.
@param array $values Array of values
@return string | [
"Returns",
"a",
"INSERT",
"query",
"with",
"values",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/database/query/compilers/Compiler.php#L763-L772 | train |
mako-framework/framework | src/mako/database/query/compilers/Compiler.php | Compiler.insert | public function insert(array $values = []): array
{
$sql = $this->query->getPrefix();
if(empty($values))
{
$sql .= $this->insertWithoutValues();
}
else
{
$sql .= $this->insertWithValues($values);
}
return ['sql' => $sql, 'params' => $this->params];
} | php | public function insert(array $values = []): array
{
$sql = $this->query->getPrefix();
if(empty($values))
{
$sql .= $this->insertWithoutValues();
}
else
{
$sql .= $this->insertWithValues($values);
}
return ['sql' => $sql, 'params' => $this->params];
} | [
"public",
"function",
"insert",
"(",
"array",
"$",
"values",
"=",
"[",
"]",
")",
":",
"array",
"{",
"$",
"sql",
"=",
"$",
"this",
"->",
"query",
"->",
"getPrefix",
"(",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"values",
")",
")",
"{",
"$",
"sql"... | Compiles a INSERT query.
@param array $values Array of values
@return array | [
"Compiles",
"a",
"INSERT",
"query",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/database/query/compilers/Compiler.php#L790-L804 | train |
mako-framework/framework | src/mako/database/query/compilers/Compiler.php | Compiler.updateColumns | protected function updateColumns(array $columns): string
{
$pieces = [];
foreach($columns as $column => $value)
{
$param = $this->param($value);
if($this->hasJsonPath($column))
{
$segments = explode(static::JSON_PATH_SEPARATOR, $column);
$column = $this->escapeColumn(array_shift($segments));
$pieces[] = $this->buildJsonSet($column, $segments, $param);
}
else
{
$pieces[] = $this->escapeColumn($column) . ' = ' . $param;
}
}
return implode(', ', $pieces);
} | php | protected function updateColumns(array $columns): string
{
$pieces = [];
foreach($columns as $column => $value)
{
$param = $this->param($value);
if($this->hasJsonPath($column))
{
$segments = explode(static::JSON_PATH_SEPARATOR, $column);
$column = $this->escapeColumn(array_shift($segments));
$pieces[] = $this->buildJsonSet($column, $segments, $param);
}
else
{
$pieces[] = $this->escapeColumn($column) . ' = ' . $param;
}
}
return implode(', ', $pieces);
} | [
"protected",
"function",
"updateColumns",
"(",
"array",
"$",
"columns",
")",
":",
"string",
"{",
"$",
"pieces",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"columns",
"as",
"$",
"column",
"=>",
"$",
"value",
")",
"{",
"$",
"param",
"=",
"$",
"this",
"... | Compiles update columns.
@param array $columns Associative array of columns and values
@return string | [
"Compiles",
"update",
"columns",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/database/query/compilers/Compiler.php#L812-L835 | train |
mako-framework/framework | src/mako/database/query/compilers/Compiler.php | Compiler.update | public function update(array $values): array
{
$sql = $this->query->getPrefix();
$sql .= 'UPDATE ';
$sql .= $this->escapeTable($this->query->getTable());
$sql .= ' SET ';
$sql .= $this->updateColumns($values);
$sql .= $this->wheres($this->query->getWheres());
return ['sql' => $sql, 'params' => $this->params];
} | php | public function update(array $values): array
{
$sql = $this->query->getPrefix();
$sql .= 'UPDATE ';
$sql .= $this->escapeTable($this->query->getTable());
$sql .= ' SET ';
$sql .= $this->updateColumns($values);
$sql .= $this->wheres($this->query->getWheres());
return ['sql' => $sql, 'params' => $this->params];
} | [
"public",
"function",
"update",
"(",
"array",
"$",
"values",
")",
":",
"array",
"{",
"$",
"sql",
"=",
"$",
"this",
"->",
"query",
"->",
"getPrefix",
"(",
")",
";",
"$",
"sql",
".=",
"'UPDATE '",
";",
"$",
"sql",
".=",
"$",
"this",
"->",
"escapeTabl... | Compiles a UPDATE query.
@param array $values Array of values
@return array | [
"Compiles",
"a",
"UPDATE",
"query",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/database/query/compilers/Compiler.php#L843-L853 | train |
mako-framework/framework | src/mako/database/query/compilers/Compiler.php | Compiler.delete | public function delete(): array
{
$sql = $this->query->getPrefix();
$sql .= 'DELETE FROM ';
$sql .= $this->escapeTable($this->query->getTable());
$sql .= $this->wheres($this->query->getWheres());
return ['sql' => $sql, 'params' => $this->params];
} | php | public function delete(): array
{
$sql = $this->query->getPrefix();
$sql .= 'DELETE FROM ';
$sql .= $this->escapeTable($this->query->getTable());
$sql .= $this->wheres($this->query->getWheres());
return ['sql' => $sql, 'params' => $this->params];
} | [
"public",
"function",
"delete",
"(",
")",
":",
"array",
"{",
"$",
"sql",
"=",
"$",
"this",
"->",
"query",
"->",
"getPrefix",
"(",
")",
";",
"$",
"sql",
".=",
"'DELETE FROM '",
";",
"$",
"sql",
".=",
"$",
"this",
"->",
"escapeTable",
"(",
"$",
"this... | Compiles a DELETE query.
@return array | [
"Compiles",
"a",
"DELETE",
"query",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/database/query/compilers/Compiler.php#L860-L868 | train |
mako-framework/framework | src/mako/security/crypto/Crypto.php | Crypto.encrypt | public function encrypt(string $string): string
{
return $this->signer->sign($this->adapter->encrypt($string));
} | php | public function encrypt(string $string): string
{
return $this->signer->sign($this->adapter->encrypt($string));
} | [
"public",
"function",
"encrypt",
"(",
"string",
"$",
"string",
")",
":",
"string",
"{",
"return",
"$",
"this",
"->",
"signer",
"->",
"sign",
"(",
"$",
"this",
"->",
"adapter",
"->",
"encrypt",
"(",
"$",
"string",
")",
")",
";",
"}"
] | Encrypts string.
@param string $string String to encrypt
@return string | [
"Encrypts",
"string",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/security/crypto/Crypto.php#L53-L56 | train |
mako-framework/framework | src/mako/security/crypto/Crypto.php | Crypto.decrypt | public function decrypt(string $string)
{
$string = $this->signer->validate($string);
if($string === false)
{
throw new CryptoException('Ciphertex has been modified or an invalid authentication key has been provided.');
}
return $this->adapter->decrypt($string);
} | php | public function decrypt(string $string)
{
$string = $this->signer->validate($string);
if($string === false)
{
throw new CryptoException('Ciphertex has been modified or an invalid authentication key has been provided.');
}
return $this->adapter->decrypt($string);
} | [
"public",
"function",
"decrypt",
"(",
"string",
"$",
"string",
")",
"{",
"$",
"string",
"=",
"$",
"this",
"->",
"signer",
"->",
"validate",
"(",
"$",
"string",
")",
";",
"if",
"(",
"$",
"string",
"===",
"false",
")",
"{",
"throw",
"new",
"CryptoExcep... | Decrypts string.
@param string $string String to decrypt
@throws \mako\security\crypto\CryptoException
@return string|bool | [
"Decrypts",
"string",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/security/crypto/Crypto.php#L65-L75 | train |
mako-framework/framework | src/mako/validator/rules/file/MaxFilesize.php | MaxFilesize.convertToBytes | protected function convertToBytes($size)
{
if(is_numeric($unit = substr($size, -3)) === false)
{
$size = substr($size, 0, -3);
switch($unit)
{
case 'KiB':
return $size * 1024;
case 'MiB':
return $size * (1024 ** 2);
case 'GiB':
return $size * (1024 ** 3);
case 'TiB':
return $size * (1024 ** 4);
case 'PiB':
return $size * (1024 ** 5);
case 'EiB':
return $size * (1024 ** 6);
case 'ZiB':
return $size * (1024 ** 7);
case 'YiB':
return $size * (1024 ** 8);
default:
throw new RuntimeException(vsprintf('Invalid unit type [ %s ].', [$unit]));
}
}
return (int) $size;
} | php | protected function convertToBytes($size)
{
if(is_numeric($unit = substr($size, -3)) === false)
{
$size = substr($size, 0, -3);
switch($unit)
{
case 'KiB':
return $size * 1024;
case 'MiB':
return $size * (1024 ** 2);
case 'GiB':
return $size * (1024 ** 3);
case 'TiB':
return $size * (1024 ** 4);
case 'PiB':
return $size * (1024 ** 5);
case 'EiB':
return $size * (1024 ** 6);
case 'ZiB':
return $size * (1024 ** 7);
case 'YiB':
return $size * (1024 ** 8);
default:
throw new RuntimeException(vsprintf('Invalid unit type [ %s ].', [$unit]));
}
}
return (int) $size;
} | [
"protected",
"function",
"convertToBytes",
"(",
"$",
"size",
")",
"{",
"if",
"(",
"is_numeric",
"(",
"$",
"unit",
"=",
"substr",
"(",
"$",
"size",
",",
"-",
"3",
")",
")",
"===",
"false",
")",
"{",
"$",
"size",
"=",
"substr",
"(",
"$",
"size",
",... | Convert human friendly size to bytes.
@param int|string $size Size
@throws \RuntimeException
@return int|float | [
"Convert",
"human",
"friendly",
"size",
"to",
"bytes",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/validator/rules/file/MaxFilesize.php#L57-L87 | train |
mako-framework/framework | src/mako/file/FileSystem.php | FileSystem.isEmpty | public function isEmpty(string $path): bool
{
if(is_dir($path))
{
return (new FilesystemIterator($path))->valid() === false;
}
return filesize($path) === 0;
} | php | public function isEmpty(string $path): bool
{
if(is_dir($path))
{
return (new FilesystemIterator($path))->valid() === false;
}
return filesize($path) === 0;
} | [
"public",
"function",
"isEmpty",
"(",
"string",
"$",
"path",
")",
":",
"bool",
"{",
"if",
"(",
"is_dir",
"(",
"$",
"path",
")",
")",
"{",
"return",
"(",
"new",
"FilesystemIterator",
"(",
"$",
"path",
")",
")",
"->",
"valid",
"(",
")",
"===",
"false... | Returns TRUE if a file or directory is empty and FALSE if not.
@param string $path Path to directory
@return bool | [
"Returns",
"TRUE",
"if",
"a",
"file",
"or",
"directory",
"is",
"empty",
"and",
"FALSE",
"if",
"not",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/file/FileSystem.php#L75-L83 | train |
mako-framework/framework | src/mako/file/FileSystem.php | FileSystem.removeDirectory | public function removeDirectory(string $path): bool
{
foreach(new FilesystemIterator($path) as $item)
{
if($item->isDir())
{
$this->removeDirectory($item->getPathname());
}
else
{
unlink($item->getPathname());
}
}
return rmdir($path);
} | php | public function removeDirectory(string $path): bool
{
foreach(new FilesystemIterator($path) as $item)
{
if($item->isDir())
{
$this->removeDirectory($item->getPathname());
}
else
{
unlink($item->getPathname());
}
}
return rmdir($path);
} | [
"public",
"function",
"removeDirectory",
"(",
"string",
"$",
"path",
")",
":",
"bool",
"{",
"foreach",
"(",
"new",
"FilesystemIterator",
"(",
"$",
"path",
")",
"as",
"$",
"item",
")",
"{",
"if",
"(",
"$",
"item",
"->",
"isDir",
"(",
")",
")",
"{",
... | Deletes a directory and its contents from disk.
@param string $path Path to directory
@return bool | [
"Deletes",
"a",
"directory",
"and",
"its",
"contents",
"from",
"disk",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/file/FileSystem.php#L169-L184 | train |
mako-framework/framework | src/mako/file/FileSystem.php | FileSystem.put | public static function put(string $file, $data, bool $lock = false)
{
return file_put_contents($file, $data, $lock ? LOCK_EX : 0);
} | php | public static function put(string $file, $data, bool $lock = false)
{
return file_put_contents($file, $data, $lock ? LOCK_EX : 0);
} | [
"public",
"static",
"function",
"put",
"(",
"string",
"$",
"file",
",",
"$",
"data",
",",
"bool",
"$",
"lock",
"=",
"false",
")",
"{",
"return",
"file_put_contents",
"(",
"$",
"file",
",",
"$",
"data",
",",
"$",
"lock",
"?",
"LOCK_EX",
":",
"0",
")... | Writes the supplied data to a file.
@param string $file File path
@param mixed $data File data
@param bool $lock Acquire an exclusive write lock?
@return int|bool | [
"Writes",
"the",
"supplied",
"data",
"to",
"a",
"file",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/file/FileSystem.php#L217-L220 | train |
mako-framework/framework | src/mako/file/FileSystem.php | FileSystem.prepend | public static function prepend(string $file, $data, bool $lock = false)
{
return file_put_contents($file, $data . file_get_contents($file), $lock ? LOCK_EX : 0);
} | php | public static function prepend(string $file, $data, bool $lock = false)
{
return file_put_contents($file, $data . file_get_contents($file), $lock ? LOCK_EX : 0);
} | [
"public",
"static",
"function",
"prepend",
"(",
"string",
"$",
"file",
",",
"$",
"data",
",",
"bool",
"$",
"lock",
"=",
"false",
")",
"{",
"return",
"file_put_contents",
"(",
"$",
"file",
",",
"$",
"data",
".",
"file_get_contents",
"(",
"$",
"file",
")... | Prepends the supplied data to a file.
@param string $file File path
@param mixed $data File data
@param bool $lock Acquire an exclusive write lock?
@return int|bool | [
"Prepends",
"the",
"supplied",
"data",
"to",
"a",
"file",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/file/FileSystem.php#L230-L233 | train |
mako-framework/framework | src/mako/file/FileSystem.php | FileSystem.append | public static function append(string $file, $data, bool $lock = false)
{
return file_put_contents($file, $data, $lock ? FILE_APPEND | LOCK_EX : FILE_APPEND);
} | php | public static function append(string $file, $data, bool $lock = false)
{
return file_put_contents($file, $data, $lock ? FILE_APPEND | LOCK_EX : FILE_APPEND);
} | [
"public",
"static",
"function",
"append",
"(",
"string",
"$",
"file",
",",
"$",
"data",
",",
"bool",
"$",
"lock",
"=",
"false",
")",
"{",
"return",
"file_put_contents",
"(",
"$",
"file",
",",
"$",
"data",
",",
"$",
"lock",
"?",
"FILE_APPEND",
"|",
"L... | Appends the supplied data to a file.
@param string $file File path
@param mixed $data File data
@param bool $lock Acquire an exclusive write lock?
@return int|bool | [
"Appends",
"the",
"supplied",
"data",
"to",
"a",
"file",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/file/FileSystem.php#L243-L246 | train |
mako-framework/framework | src/mako/file/FileSystem.php | FileSystem.truncate | public static function truncate(string $file, bool $lock = false): bool
{
return (0 === file_put_contents($file, null, $lock ? LOCK_EX : 0));
} | php | public static function truncate(string $file, bool $lock = false): bool
{
return (0 === file_put_contents($file, null, $lock ? LOCK_EX : 0));
} | [
"public",
"static",
"function",
"truncate",
"(",
"string",
"$",
"file",
",",
"bool",
"$",
"lock",
"=",
"false",
")",
":",
"bool",
"{",
"return",
"(",
"0",
"===",
"file_put_contents",
"(",
"$",
"file",
",",
"null",
",",
"$",
"lock",
"?",
"LOCK_EX",
":... | Truncates a file.
@param string $file File path
@param bool $lock Acquire an exclusive write lock?
@return bool | [
"Truncates",
"a",
"file",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/file/FileSystem.php#L255-L258 | train |
mako-framework/framework | src/mako/file/FileSystem.php | FileSystem.file | public function file(string $file, string $openMode = 'r', bool $useIncludePath = false)
{
return new SplFileObject($file, $openMode, $useIncludePath);
} | php | public function file(string $file, string $openMode = 'r', bool $useIncludePath = false)
{
return new SplFileObject($file, $openMode, $useIncludePath);
} | [
"public",
"function",
"file",
"(",
"string",
"$",
"file",
",",
"string",
"$",
"openMode",
"=",
"'r'",
",",
"bool",
"$",
"useIncludePath",
"=",
"false",
")",
"{",
"return",
"new",
"SplFileObject",
"(",
"$",
"file",
",",
"$",
"openMode",
",",
"$",
"useIn... | Returns a SplFileObject.
@param string $file Path to file
@param string $openMode Open mode
@param bool $useIncludePath Use include path?
@return \SplFileObject | [
"Returns",
"a",
"SplFileObject",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/file/FileSystem.php#L336-L339 | train |
mako-framework/framework | src/mako/cli/input/helpers/Confirmation.php | Confirmation.normalizeKeys | protected function normalizeKeys(array $array): array
{
$normalized = [];
foreach($array as $key => $value)
{
$normalized[mb_strtolower($key)] = $value;
}
return $normalized;
} | php | protected function normalizeKeys(array $array): array
{
$normalized = [];
foreach($array as $key => $value)
{
$normalized[mb_strtolower($key)] = $value;
}
return $normalized;
} | [
"protected",
"function",
"normalizeKeys",
"(",
"array",
"$",
"array",
")",
":",
"array",
"{",
"$",
"normalized",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"array",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"normalized",
"[",
"mb_strtolower",
... | Returns an array where all array keys lower case.
@param array $array Array
@return array | [
"Returns",
"an",
"array",
"where",
"all",
"array",
"keys",
"lower",
"case",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/cli/input/helpers/Confirmation.php#L29-L39 | train |
mako-framework/framework | src/mako/cli/input/helpers/Confirmation.php | Confirmation.getOptions | protected function getOptions(array $options, string $default): string
{
$highlighted = [];
foreach(array_keys($options) as $option)
{
$highlighted[] = $option === $default ? mb_strtoupper($option) : $option;
}
return implode('/', $highlighted);
} | php | protected function getOptions(array $options, string $default): string
{
$highlighted = [];
foreach(array_keys($options) as $option)
{
$highlighted[] = $option === $default ? mb_strtoupper($option) : $option;
}
return implode('/', $highlighted);
} | [
"protected",
"function",
"getOptions",
"(",
"array",
"$",
"options",
",",
"string",
"$",
"default",
")",
":",
"string",
"{",
"$",
"highlighted",
"=",
"[",
"]",
";",
"foreach",
"(",
"array_keys",
"(",
"$",
"options",
")",
"as",
"$",
"option",
")",
"{",
... | Returns a slash-separated list of valid options where the default one is highlighted as upper-case.
@param array $options Answer options
@param string $default Default answer
@return string | [
"Returns",
"a",
"slash",
"-",
"separated",
"list",
"of",
"valid",
"options",
"where",
"the",
"default",
"one",
"is",
"highlighted",
"as",
"upper",
"-",
"case",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/cli/input/helpers/Confirmation.php#L48-L58 | train |
mako-framework/framework | src/mako/cli/input/helpers/Confirmation.php | Confirmation.ask | public function ask(string $question, $default = 'n', ?array $options = null)
{
$options = $options === null ? ['y' => true, 'n' => false] : $this->normalizeKeys($options);
$input = parent::ask(trim($question) . ' [' . $this->getOptions($options, $default) . '] ');
$input = mb_strtolower(empty($input) ? $default : $input);
if(!isset($options[$input]))
{
return $this->ask($question, $default, $options);
}
return $options[$input];
} | php | public function ask(string $question, $default = 'n', ?array $options = null)
{
$options = $options === null ? ['y' => true, 'n' => false] : $this->normalizeKeys($options);
$input = parent::ask(trim($question) . ' [' . $this->getOptions($options, $default) . '] ');
$input = mb_strtolower(empty($input) ? $default : $input);
if(!isset($options[$input]))
{
return $this->ask($question, $default, $options);
}
return $options[$input];
} | [
"public",
"function",
"ask",
"(",
"string",
"$",
"question",
",",
"$",
"default",
"=",
"'n'",
",",
"?",
"array",
"$",
"options",
"=",
"null",
")",
"{",
"$",
"options",
"=",
"$",
"options",
"===",
"null",
"?",
"[",
"'y'",
"=>",
"true",
",",
"'n'",
... | Asks user for confirmation and returns value corresponding to the chosen value.
@param string $question Question to ask
@param string $default Default answer
@param array|null $options Answer options
@return bool | [
"Asks",
"user",
"for",
"confirmation",
"and",
"returns",
"value",
"corresponding",
"to",
"the",
"chosen",
"value",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/cli/input/helpers/Confirmation.php#L68-L82 | train |
mako-framework/framework | src/mako/cli/output/helpers/Alert.php | Alert.wordWrap | protected function wordWrap(string $string, int $width): string
{
return trim(preg_replace(sprintf('/(.{1,%1$u})(?:\s|$)|(.{%1$u})/uS', $width), '$1$2' . PHP_EOL, $string));
} | php | protected function wordWrap(string $string, int $width): string
{
return trim(preg_replace(sprintf('/(.{1,%1$u})(?:\s|$)|(.{%1$u})/uS', $width), '$1$2' . PHP_EOL, $string));
} | [
"protected",
"function",
"wordWrap",
"(",
"string",
"$",
"string",
",",
"int",
"$",
"width",
")",
":",
"string",
"{",
"return",
"trim",
"(",
"preg_replace",
"(",
"sprintf",
"(",
"'/(.{1,%1$u})(?:\\s|$)|(.{%1$u})/uS'",
",",
"$",
"width",
")",
",",
"'$1$2'",
"... | Wraps a string to a given number of characters.
@param string $string String
@param int $width Max line width
@return string | [
"Wraps",
"a",
"string",
"to",
"a",
"given",
"number",
"of",
"characters",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/cli/output/helpers/Alert.php#L112-L115 | train |
mako-framework/framework | src/mako/cli/output/helpers/Alert.php | Alert.escape | protected function escape(string $string): string
{
if($this->formatter !== null)
{
return $this->formatter->escape($string);
}
return $string;
} | php | protected function escape(string $string): string
{
if($this->formatter !== null)
{
return $this->formatter->escape($string);
}
return $string;
} | [
"protected",
"function",
"escape",
"(",
"string",
"$",
"string",
")",
":",
"string",
"{",
"if",
"(",
"$",
"this",
"->",
"formatter",
"!==",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"formatter",
"->",
"escape",
"(",
"$",
"string",
")",
";",
"}",... | Escapes style tags if we have a formatter.
@param string $string string
@return string | [
"Escapes",
"style",
"tags",
"if",
"we",
"have",
"a",
"formatter",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/cli/output/helpers/Alert.php#L123-L131 | train |
mako-framework/framework | src/mako/cli/output/helpers/Alert.php | Alert.format | protected function format(string $string): string
{
$lineWidth = $this->width - (static::PADDING * 2);
$lines = explode(PHP_EOL, PHP_EOL . $this->wordWrap($string, $lineWidth) . PHP_EOL);
foreach($lines as $key => $value)
{
$value = $this->escape($value) . str_repeat(' ', $lineWidth - mb_strlen($value));
$lines[$key] = sprintf('%1$s%2$s%1$s', str_repeat(' ', static::PADDING), $value);
}
return implode(PHP_EOL, $lines);
} | php | protected function format(string $string): string
{
$lineWidth = $this->width - (static::PADDING * 2);
$lines = explode(PHP_EOL, PHP_EOL . $this->wordWrap($string, $lineWidth) . PHP_EOL);
foreach($lines as $key => $value)
{
$value = $this->escape($value) . str_repeat(' ', $lineWidth - mb_strlen($value));
$lines[$key] = sprintf('%1$s%2$s%1$s', str_repeat(' ', static::PADDING), $value);
}
return implode(PHP_EOL, $lines);
} | [
"protected",
"function",
"format",
"(",
"string",
"$",
"string",
")",
":",
"string",
"{",
"$",
"lineWidth",
"=",
"$",
"this",
"->",
"width",
"-",
"(",
"static",
"::",
"PADDING",
"*",
"2",
")",
";",
"$",
"lines",
"=",
"explode",
"(",
"PHP_EOL",
",",
... | Formats the string.
@param string $string String
@return string | [
"Formats",
"the",
"string",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/cli/output/helpers/Alert.php#L139-L153 | train |
mako-framework/framework | src/mako/cli/output/helpers/Alert.php | Alert.render | public function render(string $message, string $template = Alert::DEFAULT): string
{
return sprintf($template, $this->format($message)) . PHP_EOL;
} | php | public function render(string $message, string $template = Alert::DEFAULT): string
{
return sprintf($template, $this->format($message)) . PHP_EOL;
} | [
"public",
"function",
"render",
"(",
"string",
"$",
"message",
",",
"string",
"$",
"template",
"=",
"Alert",
"::",
"DEFAULT",
")",
":",
"string",
"{",
"return",
"sprintf",
"(",
"$",
"template",
",",
"$",
"this",
"->",
"format",
"(",
"$",
"message",
")"... | Renders an alert.
@param string $message Message
@param string $template Alert template
@return string | [
"Renders",
"an",
"alert",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/cli/output/helpers/Alert.php#L162-L165 | train |
mako-framework/framework | src/mako/http/routing/Route.php | Route.getAction | public function getAction()
{
if($this->action instanceof Closure || empty($this->namespace))
{
return $this->action;
}
return $this->namespace . $this->action;
} | php | public function getAction()
{
if($this->action instanceof Closure || empty($this->namespace))
{
return $this->action;
}
return $this->namespace . $this->action;
} | [
"public",
"function",
"getAction",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"action",
"instanceof",
"Closure",
"||",
"empty",
"(",
"$",
"this",
"->",
"namespace",
")",
")",
"{",
"return",
"$",
"this",
"->",
"action",
";",
"}",
"return",
"$",
"thi... | Returns the route action.
@return string|\Closure | [
"Returns",
"the",
"route",
"action",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/http/routing/Route.php#L150-L158 | train |
mako-framework/framework | src/mako/http/routing/Route.php | Route.prefix | public function prefix(string $prefix): Route
{
if(!empty($prefix))
{
$this->prefix .= '/' . trim($prefix, '/');
}
return $this;
} | php | public function prefix(string $prefix): Route
{
if(!empty($prefix))
{
$this->prefix .= '/' . trim($prefix, '/');
}
return $this;
} | [
"public",
"function",
"prefix",
"(",
"string",
"$",
"prefix",
")",
":",
"Route",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"prefix",
")",
")",
"{",
"$",
"this",
"->",
"prefix",
".=",
"'/'",
".",
"trim",
"(",
"$",
"prefix",
",",
"'/'",
")",
";",
"... | Adds a prefix to the route.
@param string $prefix Route prefix
@return \mako\http\routing\Route | [
"Adds",
"a",
"prefix",
"to",
"the",
"route",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/http/routing/Route.php#L241-L249 | train |
mako-framework/framework | src/mako/http/routing/Route.php | Route.middleware | public function middleware($middleware): Route
{
$this->middleware = array_merge($this->middleware, (array) $middleware);
return $this;
} | php | public function middleware($middleware): Route
{
$this->middleware = array_merge($this->middleware, (array) $middleware);
return $this;
} | [
"public",
"function",
"middleware",
"(",
"$",
"middleware",
")",
":",
"Route",
"{",
"$",
"this",
"->",
"middleware",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"middleware",
",",
"(",
"array",
")",
"$",
"middleware",
")",
";",
"return",
"$",
"this",
"... | Adds a set of middleware.
@param array|string $middleware Middleware
@return \mako\http\routing\Route | [
"Adds",
"a",
"set",
"of",
"middleware",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/http/routing/Route.php#L270-L275 | train |
mako-framework/framework | src/mako/http/routing/Route.php | Route.constraint | public function constraint($constraint): Route
{
$this->constraints = array_merge($this->constraints, (array) $constraint);
return $this;
} | php | public function constraint($constraint): Route
{
$this->constraints = array_merge($this->constraints, (array) $constraint);
return $this;
} | [
"public",
"function",
"constraint",
"(",
"$",
"constraint",
")",
":",
"Route",
"{",
"$",
"this",
"->",
"constraints",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"constraints",
",",
"(",
"array",
")",
"$",
"constraint",
")",
";",
"return",
"$",
"this",
... | Adds a set of constraints.
@param array|string $constraint Constraint
@return \mako\http\routing\Route | [
"Adds",
"a",
"set",
"of",
"constraints",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/http/routing/Route.php#L283-L288 | train |
mako-framework/framework | src/mako/cli/input/helpers/Secret.php | Secret.hasStty | protected function hasStty(): bool
{
if(static::$hasStty === null)
{
exec('stty 2>&1', $output, $status);
static::$hasStty = $status === 0;
}
return static::$hasStty;
} | php | protected function hasStty(): bool
{
if(static::$hasStty === null)
{
exec('stty 2>&1', $output, $status);
static::$hasStty = $status === 0;
}
return static::$hasStty;
} | [
"protected",
"function",
"hasStty",
"(",
")",
":",
"bool",
"{",
"if",
"(",
"static",
"::",
"$",
"hasStty",
"===",
"null",
")",
"{",
"exec",
"(",
"'stty 2>&1'",
",",
"$",
"output",
",",
"$",
"status",
")",
";",
"static",
"::",
"$",
"hasStty",
"=",
"... | Do we have stty support?
@return bool | [
"Do",
"we",
"have",
"stty",
"support?"
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/cli/input/helpers/Secret.php#L35-L45 | train |
mako-framework/framework | src/mako/error/ErrorHandler.php | ErrorHandler.fallbackHandler | protected function fallbackHandler(): void
{
$this->handle(Throwable::class, function($e): void
{
echo '[ ' . get_class($e) . '] ' . $e->getMessage() . ' on line [ ' . $e->getLine() . ' ] in [ ' . $e->getFile() . ' ]';
echo PHP_EOL;
echo $e->getTraceAsString();
});
} | php | protected function fallbackHandler(): void
{
$this->handle(Throwable::class, function($e): void
{
echo '[ ' . get_class($e) . '] ' . $e->getMessage() . ' on line [ ' . $e->getLine() . ' ] in [ ' . $e->getFile() . ' ]';
echo PHP_EOL;
echo $e->getTraceAsString();
});
} | [
"protected",
"function",
"fallbackHandler",
"(",
")",
":",
"void",
"{",
"$",
"this",
"->",
"handle",
"(",
"Throwable",
"::",
"class",
",",
"function",
"(",
"$",
"e",
")",
":",
"void",
"{",
"echo",
"'[ '",
".",
"get_class",
"(",
"$",
"e",
")",
".",
... | Adds basic fallback handler to the stack. | [
"Adds",
"basic",
"fallback",
"handler",
"to",
"the",
"stack",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/error/ErrorHandler.php#L91-L101 | train |
mako-framework/framework | src/mako/error/ErrorHandler.php | ErrorHandler.disableLoggingFor | public function disableLoggingFor($exceptionType): void
{
$this->disableLoggingFor = array_unique(array_merge($this->disableLoggingFor, (array) $exceptionType));
} | php | public function disableLoggingFor($exceptionType): void
{
$this->disableLoggingFor = array_unique(array_merge($this->disableLoggingFor, (array) $exceptionType));
} | [
"public",
"function",
"disableLoggingFor",
"(",
"$",
"exceptionType",
")",
":",
"void",
"{",
"$",
"this",
"->",
"disableLoggingFor",
"=",
"array_unique",
"(",
"array_merge",
"(",
"$",
"this",
"->",
"disableLoggingFor",
",",
"(",
"array",
")",
"$",
"exceptionTy... | Disables logging for an exception type.
@param string|array $exceptionType Exception type or array of exception types | [
"Disables",
"logging",
"for",
"an",
"exception",
"type",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/error/ErrorHandler.php#L157-L160 | train |
mako-framework/framework | src/mako/error/ErrorHandler.php | ErrorHandler.handle | public function handle(string $exceptionType, $handler): void
{
array_unshift($this->handlers, ['exceptionType' => $exceptionType, 'handler' => $handler]);
} | php | public function handle(string $exceptionType, $handler): void
{
array_unshift($this->handlers, ['exceptionType' => $exceptionType, 'handler' => $handler]);
} | [
"public",
"function",
"handle",
"(",
"string",
"$",
"exceptionType",
",",
"$",
"handler",
")",
":",
"void",
"{",
"array_unshift",
"(",
"$",
"this",
"->",
"handlers",
",",
"[",
"'exceptionType'",
"=>",
"$",
"exceptionType",
",",
"'handler'",
"=>",
"$",
"han... | Prepends an exception handler to the stack.
@param string $exceptionType Exception type
@param string|\Closure $handler Exception handler | [
"Prepends",
"an",
"exception",
"handler",
"to",
"the",
"stack",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/error/ErrorHandler.php#L176-L179 | train |
mako-framework/framework | src/mako/error/ErrorHandler.php | ErrorHandler.clearHandlers | public function clearHandlers(string $exceptionType): void
{
foreach($this->handlers as $key => $handler)
{
if($handler['exceptionType'] === $exceptionType)
{
unset($this->handlers[$key]);
}
}
} | php | public function clearHandlers(string $exceptionType): void
{
foreach($this->handlers as $key => $handler)
{
if($handler['exceptionType'] === $exceptionType)
{
unset($this->handlers[$key]);
}
}
} | [
"public",
"function",
"clearHandlers",
"(",
"string",
"$",
"exceptionType",
")",
":",
"void",
"{",
"foreach",
"(",
"$",
"this",
"->",
"handlers",
"as",
"$",
"key",
"=>",
"$",
"handler",
")",
"{",
"if",
"(",
"$",
"handler",
"[",
"'exceptionType'",
"]",
... | Clears all error handlers for an exception type.
@param string $exceptionType Exception type | [
"Clears",
"all",
"error",
"handlers",
"for",
"an",
"exception",
"type",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/error/ErrorHandler.php#L186-L195 | train |
mako-framework/framework | src/mako/error/ErrorHandler.php | ErrorHandler.replaceHandlers | public function replaceHandlers(string $exceptionType, Closure $handler): void
{
$this->clearHandlers($exceptionType);
$this->handle($exceptionType, $handler);
} | php | public function replaceHandlers(string $exceptionType, Closure $handler): void
{
$this->clearHandlers($exceptionType);
$this->handle($exceptionType, $handler);
} | [
"public",
"function",
"replaceHandlers",
"(",
"string",
"$",
"exceptionType",
",",
"Closure",
"$",
"handler",
")",
":",
"void",
"{",
"$",
"this",
"->",
"clearHandlers",
"(",
"$",
"exceptionType",
")",
";",
"$",
"this",
"->",
"handle",
"(",
"$",
"exceptionT... | Replaces all error handlers for an exception type with a new one.
@param string $exceptionType Exception type
@param \Closure $handler Exception handler | [
"Replaces",
"all",
"error",
"handlers",
"for",
"an",
"exception",
"type",
"with",
"a",
"new",
"one",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/error/ErrorHandler.php#L203-L208 | train |
mako-framework/framework | src/mako/error/ErrorHandler.php | ErrorHandler.shouldExceptionBeLogged | protected function shouldExceptionBeLogged(Throwable $exception): bool
{
if($this->logger === null)
{
return false;
}
foreach($this->disableLoggingFor as $exceptionType)
{
if($exception instanceof $exceptionType)
{
return false;
}
}
return true;
} | php | protected function shouldExceptionBeLogged(Throwable $exception): bool
{
if($this->logger === null)
{
return false;
}
foreach($this->disableLoggingFor as $exceptionType)
{
if($exception instanceof $exceptionType)
{
return false;
}
}
return true;
} | [
"protected",
"function",
"shouldExceptionBeLogged",
"(",
"Throwable",
"$",
"exception",
")",
":",
"bool",
"{",
"if",
"(",
"$",
"this",
"->",
"logger",
"===",
"null",
")",
"{",
"return",
"false",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"disableLoggingF... | Should the exception be logged?
@param \Throwable $exception An exception object
@return bool | [
"Should",
"the",
"exception",
"be",
"logged?"
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/error/ErrorHandler.php#L224-L240 | train |
mako-framework/framework | src/mako/error/ErrorHandler.php | ErrorHandler.handleException | protected function handleException($handler, Throwable $exception)
{
if($handler instanceof Closure)
{
return $handler($exception);
}
return $this->handlerFactory($handler)->handle($exception);
} | php | protected function handleException($handler, Throwable $exception)
{
if($handler instanceof Closure)
{
return $handler($exception);
}
return $this->handlerFactory($handler)->handle($exception);
} | [
"protected",
"function",
"handleException",
"(",
"$",
"handler",
",",
"Throwable",
"$",
"exception",
")",
"{",
"if",
"(",
"$",
"handler",
"instanceof",
"Closure",
")",
"{",
"return",
"$",
"handler",
"(",
"$",
"exception",
")",
";",
"}",
"return",
"$",
"t... | Handle the exception.
@param string|\Closure $handler Exception handler
@param \Throwable $exception Exceotion
@return mixed | [
"Handle",
"the",
"exception",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/error/ErrorHandler.php#L260-L268 | train |
mako-framework/framework | src/mako/error/ErrorHandler.php | ErrorHandler.handler | public function handler(Throwable $exception): void
{
try
{
// Empty output buffers
$this->clearOutputBuffers();
// Loop through the exception handlers
foreach($this->handlers as $handler)
{
if($exception instanceof $handler['exceptionType'])
{
if($this->handleException($handler['handler'], $exception) !== null)
{
break;
}
}
}
// Log exception
if($this->shouldExceptionBeLogged($exception))
{
$this->getLogger()->error($exception->getMessage(), ['exception' => $exception]);
}
}
catch(Throwable $e)
{
// Empty output buffers
$this->clearOutputBuffers();
// One of the exception handlers failed so we'll just show the user a generic error screen
echo $e->getMessage() . ' on line [ ' . $e->getLine() . ' ] in [ ' . $e->getFile() . ' ]' . PHP_EOL;
}
exit(1);
} | php | public function handler(Throwable $exception): void
{
try
{
// Empty output buffers
$this->clearOutputBuffers();
// Loop through the exception handlers
foreach($this->handlers as $handler)
{
if($exception instanceof $handler['exceptionType'])
{
if($this->handleException($handler['handler'], $exception) !== null)
{
break;
}
}
}
// Log exception
if($this->shouldExceptionBeLogged($exception))
{
$this->getLogger()->error($exception->getMessage(), ['exception' => $exception]);
}
}
catch(Throwable $e)
{
// Empty output buffers
$this->clearOutputBuffers();
// One of the exception handlers failed so we'll just show the user a generic error screen
echo $e->getMessage() . ' on line [ ' . $e->getLine() . ' ] in [ ' . $e->getFile() . ' ]' . PHP_EOL;
}
exit(1);
} | [
"public",
"function",
"handler",
"(",
"Throwable",
"$",
"exception",
")",
":",
"void",
"{",
"try",
"{",
"// Empty output buffers",
"$",
"this",
"->",
"clearOutputBuffers",
"(",
")",
";",
"// Loop through the exception handlers",
"foreach",
"(",
"$",
"this",
"->",
... | Handles uncaught exceptions.
@param \Throwable $exception An exception object | [
"Handles",
"uncaught",
"exceptions",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/error/ErrorHandler.php#L275-L315 | train |
mako-framework/framework | src/mako/file/FileInfo.php | FileInfo.getMimeType | public function getMimeType(): ?string
{
$info = finfo_open(FILEINFO_MIME_TYPE);
$mime = finfo_file($info, $this->getPathname());
finfo_close($info);
return $mime ?: null;
} | php | public function getMimeType(): ?string
{
$info = finfo_open(FILEINFO_MIME_TYPE);
$mime = finfo_file($info, $this->getPathname());
finfo_close($info);
return $mime ?: null;
} | [
"public",
"function",
"getMimeType",
"(",
")",
":",
"?",
"string",
"{",
"$",
"info",
"=",
"finfo_open",
"(",
"FILEINFO_MIME_TYPE",
")",
";",
"$",
"mime",
"=",
"finfo_file",
"(",
"$",
"info",
",",
"$",
"this",
"->",
"getPathname",
"(",
")",
")",
";",
... | Returns the MIME type of the file.
@return string|null | [
"Returns",
"the",
"MIME",
"type",
"of",
"the",
"file",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/file/FileInfo.php#L31-L40 | train |
mako-framework/framework | src/mako/file/FileInfo.php | FileInfo.getMimeEncoding | public function getMimeEncoding(): ?string
{
$info = finfo_open(FILEINFO_MIME_ENCODING);
$encoding = finfo_file($info, $this->getPathname());
finfo_close($info);
return $encoding ?: null;
} | php | public function getMimeEncoding(): ?string
{
$info = finfo_open(FILEINFO_MIME_ENCODING);
$encoding = finfo_file($info, $this->getPathname());
finfo_close($info);
return $encoding ?: null;
} | [
"public",
"function",
"getMimeEncoding",
"(",
")",
":",
"?",
"string",
"{",
"$",
"info",
"=",
"finfo_open",
"(",
"FILEINFO_MIME_ENCODING",
")",
";",
"$",
"encoding",
"=",
"finfo_file",
"(",
"$",
"info",
",",
"$",
"this",
"->",
"getPathname",
"(",
")",
")... | Returns the MIME encoding of the file.
@return string|null | [
"Returns",
"the",
"MIME",
"encoding",
"of",
"the",
"file",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/file/FileInfo.php#L47-L56 | train |
mako-framework/framework | src/mako/file/FileInfo.php | FileInfo.getHash | public function getHash(string $algorithm = 'sha256', bool $raw = false): string
{
return hash_file($algorithm, $this->getPathname(), $raw);
} | php | public function getHash(string $algorithm = 'sha256', bool $raw = false): string
{
return hash_file($algorithm, $this->getPathname(), $raw);
} | [
"public",
"function",
"getHash",
"(",
"string",
"$",
"algorithm",
"=",
"'sha256'",
",",
"bool",
"$",
"raw",
"=",
"false",
")",
":",
"string",
"{",
"return",
"hash_file",
"(",
"$",
"algorithm",
",",
"$",
"this",
"->",
"getPathname",
"(",
")",
",",
"$",
... | Generates a hash using the contents of the file.
@param string $algorithm Hashing algorithm
@param bool $raw Output raw binary data?
@return string | [
"Generates",
"a",
"hash",
"using",
"the",
"contents",
"of",
"the",
"file",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/file/FileInfo.php#L65-L68 | train |
mako-framework/framework | src/mako/file/FileInfo.php | FileInfo.validateHash | public function validateHash(string $hash, string $algorithm = 'sha256', bool $raw = false): bool
{
return hash_equals($hash, $this->getHash($algorithm, $raw));
} | php | public function validateHash(string $hash, string $algorithm = 'sha256', bool $raw = false): bool
{
return hash_equals($hash, $this->getHash($algorithm, $raw));
} | [
"public",
"function",
"validateHash",
"(",
"string",
"$",
"hash",
",",
"string",
"$",
"algorithm",
"=",
"'sha256'",
",",
"bool",
"$",
"raw",
"=",
"false",
")",
":",
"bool",
"{",
"return",
"hash_equals",
"(",
"$",
"hash",
",",
"$",
"this",
"->",
"getHas... | Returns true if the file matches the provided hash and false if not.
@param string $hash Hash
@param string $algorithm Hashing algorithm
@param bool $raw Is the provided hash raw?
@return bool | [
"Returns",
"true",
"if",
"the",
"file",
"matches",
"the",
"provided",
"hash",
"and",
"false",
"if",
"not",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/file/FileInfo.php#L78-L81 | train |
mako-framework/framework | src/mako/file/FileInfo.php | FileInfo.getHmac | public function getHmac(string $key, string $algorithm = 'sha256', bool $raw = false): string
{
return hash_hmac_file($algorithm, $this->getPathname(), $key, $raw);
} | php | public function getHmac(string $key, string $algorithm = 'sha256', bool $raw = false): string
{
return hash_hmac_file($algorithm, $this->getPathname(), $key, $raw);
} | [
"public",
"function",
"getHmac",
"(",
"string",
"$",
"key",
",",
"string",
"$",
"algorithm",
"=",
"'sha256'",
",",
"bool",
"$",
"raw",
"=",
"false",
")",
":",
"string",
"{",
"return",
"hash_hmac_file",
"(",
"$",
"algorithm",
",",
"$",
"this",
"->",
"ge... | Generates a HMAC using the contents of the file.
@param string $key Shared secret key
@param string $algorithm Hashing algorithm
@param bool $raw Output raw binary data?
@return string | [
"Generates",
"a",
"HMAC",
"using",
"the",
"contents",
"of",
"the",
"file",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/file/FileInfo.php#L91-L94 | train |
mako-framework/framework | src/mako/file/FileInfo.php | FileInfo.validateHmac | public function validateHmac(string $hmac, string $key, string $algorithm = 'sha256', bool $raw = false): bool
{
return hash_equals($hmac, $this->getHmac($key, $algorithm, $raw));
} | php | public function validateHmac(string $hmac, string $key, string $algorithm = 'sha256', bool $raw = false): bool
{
return hash_equals($hmac, $this->getHmac($key, $algorithm, $raw));
} | [
"public",
"function",
"validateHmac",
"(",
"string",
"$",
"hmac",
",",
"string",
"$",
"key",
",",
"string",
"$",
"algorithm",
"=",
"'sha256'",
",",
"bool",
"$",
"raw",
"=",
"false",
")",
":",
"bool",
"{",
"return",
"hash_equals",
"(",
"$",
"hmac",
",",... | Returns true if the file matches the provided HMAC and false if not.
@param string $hmac HMAC
@param string $key Key
@param string $algorithm Hashing algorithm
@param bool $raw Is the provided HMAC raw?
@return bool | [
"Returns",
"true",
"if",
"the",
"file",
"matches",
"the",
"provided",
"HMAC",
"and",
"false",
"if",
"not",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/file/FileInfo.php#L105-L108 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.