1
0
Fork 0
forked from deblan/gist
gist/src/Gist/Model/Gist.php

53 lines
1.1 KiB
PHP
Raw Normal View History

2015-05-06 14:11:00 +02:00
<?php
namespace Gist\Model;
use Gist\Model\Base\Gist as BaseGist;
class Gist extends BaseGist
{
public function hydrateWith(array $data)
{
if (isset($data['title'])) {
$this->setTitle(trim($data['title']));
}
if (isset($data['type'])) {
$this->setType($data['type']);
}
2015-05-06 20:35:30 +02:00
$this->setCipher(isset($data['cipher']) && $data['cipher'] === 'yes');
2015-05-06 14:11:00 +02:00
return $this;
}
public function generateFilename()
{
$this->setFile(uniqid());
}
2015-05-07 13:38:24 +02:00
2015-05-09 12:30:33 +02:00
public function getGeshiType()
{
$data = array(
'html' => 'xml',
);
return str_replace(array_keys($data), array_values($data), $this->getType());
}
2015-05-07 13:38:24 +02:00
public function getTypeAsExtension()
{
$data = array(
'javascript' => 'js',
2016-09-24 16:07:35 +02:00
'yaml' => 'yml',
2015-05-07 13:38:24 +02:00
'perl' => 'pl',
'python' => 'py',
'bash' => 'sh',
'actionscript3' => 'as',
'text' => 'txt',
);
return str_replace(array_keys($data), array_values($data), $this->getType());
}
2015-05-06 14:11:00 +02:00
}