Skip to content

Commit

Permalink
1.3.1
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitrii-fediuk committed Feb 27, 2023
1 parent 5a2eb74 commit 31a0231
Show file tree
Hide file tree
Showing 15 changed files with 138 additions and 138 deletions.
12 changes: 6 additions & 6 deletions Controller/Index/Index.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?php
namespace Df\GoogleFont\Controller\Index;
namespace Dfe\GoogleFont\Controller\Index;
use Df\Framework\W\Result\Json;
use Df\GoogleFont\Font;
use Df\GoogleFont\Font\Variant;
use Df\GoogleFont\Font\Variant\Preview\Params;
use Df\GoogleFont\Fonts as _Fonts;
use Df\GoogleFont\Fonts\Sprite;
use Dfe\GoogleFont\Font;
use Dfe\GoogleFont\Font\Variant;
use Dfe\GoogleFont\Font\Variant\Preview\Params;
use Dfe\GoogleFont\Fonts as _Fonts;
use Dfe\GoogleFont\Fonts\Sprite;
# 2015-12-08
/** @final Unable to use the PHP «final» keyword here because of the M2 code generation. */
class Index extends \Magento\Framework\App\Action\Action {
Expand Down
8 changes: 4 additions & 4 deletions Controller/Index/Preview.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?php
namespace Df\GoogleFont\Controller\Index;
use Df\GoogleFont\Font\Variant\Preview as VariantPreview;
namespace Dfe\GoogleFont\Controller\Index;
use Dfe\GoogleFont\Font\Variant\Preview as VariantPreview;
# 2016-02-17
# Иначе bin/magento setup:di:compile почему-то выдаёт сбой:
# Cannot use Df\GoogleFont\Fonts as Fonts because the name is already in use
# Cannot use Dfe\GoogleFont\Fonts as Fonts because the name is already in use
# app/code/Df/Api/Controller/Google/FontPreview.php on line 6
use Df\GoogleFont\Fonts as _Fonts;
use Dfe\GoogleFont\Fonts as _Fonts;
# 2015-11-29
/** @final Unable to use the PHP «final» keyword here because of the M2 code generation. */
class Preview extends \Df\Framework\App\Action\Image {
Expand Down
2 changes: 1 addition & 1 deletion Exception.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
namespace Df\GoogleFont;
namespace Dfe\GoogleFont;
# 2015-11-17
# В документации об этом ни слова не сказано, однако в случае сбоя Google API возвращает JSON следующией структуры:
# {
Expand Down
14 changes: 7 additions & 7 deletions Font.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
namespace Df\GoogleFont;
namespace Dfe\GoogleFont;
use Df\Core\Exception as DFE;
use Df\GoogleFont\Font\Variant as V;
use Dfe\GoogleFont\Font\Variant as V;
/**
* 2015-11-27
* https://developers.google.com/fonts/docs/developer_api#Example
Expand Down Expand Up @@ -33,14 +33,14 @@ final class Font extends \Df\Core\O {
/**
* 2015-11-28 "family": "ABeeZee"
* @used-by self::variant()
* @used-by \Df\GoogleFont\Fonts::items()
* @used-by \Df\GoogleFont\Font\Variant\Preview::family()
* @used-by \Dfe\GoogleFont\Fonts::items()
* @used-by \Dfe\GoogleFont\Font\Variant\Preview::family()
*/
function family():string {return $this['family'];}

/**
* 2015-11-29
* @used-by \Df\GoogleFont\Controller\Index\Preview::contents()
* @used-by \Dfe\GoogleFont\Controller\Index\Preview::contents()
* @throws DFE
*/
function variant(string $n):V {return df_assert(dfa($this->variants(), $n),
Expand All @@ -51,7 +51,7 @@ function variant(string $n):V {return df_assert(dfa($this->variants(), $n),
* 2015-11-27
* @used-by self::variant()
* @used-by self::variantsAvailable()
* @used-by \Df\GoogleFont\Controller\Index\Index::execute()
* @used-by \Dfe\GoogleFont\Controller\Index\Index::execute()
* @return array(string => V)
*/
function variants():array {return dfc($this, function():array {
Expand All @@ -62,7 +62,7 @@ function variants():array {return dfc($this, function():array {

/**
* 2015-12-08
* @used-by \Df\GoogleFont\Fonts\Sprite::previews()
* @used-by \Dfe\GoogleFont\Fonts\Sprite::previews()
* @return array(string => V)
*/
function variantsAvailable():array {return dfc($this, function():array {return array_filter(
Expand Down
26 changes: 13 additions & 13 deletions Font/Variant.php
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
<?php
namespace Df\GoogleFont\Font;
use Df\GoogleFont\Font;
use Df\GoogleFont\Font\Variant\Preview;
use Df\GoogleFont\Font\Variant\Preview\Params;
use Df\GoogleFont\Fonts\Fs;
namespace Dfe\GoogleFont\Font;
use Dfe\GoogleFont\Font;
use Dfe\GoogleFont\Font\Variant\Preview;
use Dfe\GoogleFont\Font\Variant\Preview\Params;
use Dfe\GoogleFont\Fonts\Fs;
final class Variant {
/**
* 2022-12-31
* @used-by \Df\GoogleFont\Font::variants()
* @used-by \Dfe\GoogleFont\Font::variants()
*/
function __construct(Font $font, string $name, string $url) {
$this->_font = $font; $this->_name = $name; $this->_url = $url;
}

/** @used-by \Df\GoogleFont\Font\Variant\Preview::folderFamily() */
/** @used-by \Dfe\GoogleFont\Font\Variant\Preview::folderFamily() */
function font():Font {return $this->_font;}

/** @used-by \Df\GoogleFont\Font\Variant\Preview::baseName() */
/** @used-by \Dfe\GoogleFont\Font\Variant\Preview::baseName() */
function name():string {return $this->_name;}

/**
* 2015-11-29
* @used-by \Df\GoogleFont\Controller\Index\Index::execute()
* @used-by \Df\GoogleFont\Controller\Index\Preview::contents()
* @used-by \Df\GoogleFont\Font::variantsAvailable()
* @used-by \Df\GoogleFont\Fonts\Sprite::previews()
* @used-by \Dfe\GoogleFont\Controller\Index\Index::execute()
* @used-by \Dfe\GoogleFont\Controller\Index\Preview::contents()
* @used-by \Dfe\GoogleFont\Font::variantsAvailable()
* @used-by \Dfe\GoogleFont\Fonts\Sprite::previews()
*/
function preview(Params $p = null):Preview {
$p = $p ?: Params::fromRequest();
Expand All @@ -33,7 +33,7 @@ function preview(Params $p = null):Preview {

/**
* 2015-11-30
* @used-by \Df\GoogleFont\Font\Variant\Preview::ttfPath()
* @used-by \Dfe\GoogleFont\Font\Variant\Preview::ttfPath()
*/
function ttfPath():string {return dfc($this, function():string {/** @var string $r */
if (!file_exists($r = Fs::s()->absolute(['ttf', basename($this->_url)]))) {
Expand Down
40 changes: 20 additions & 20 deletions Font/Variant/Preview.php
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
<?php
namespace Df\GoogleFont\Font\Variant;
use Df\GoogleFont\Font\Variant;
use Df\GoogleFont\Font\Variant\Preview\Params;
final class Preview extends \Df\GoogleFont\Fonts\Png {
namespace Dfe\GoogleFont\Font\Variant;
use Dfe\GoogleFont\Font\Variant;
use Dfe\GoogleFont\Font\Variant\Preview\Params;
final class Preview extends \Dfe\GoogleFont\Fonts\Png {
/**
* 2015-12-08
* Стандартный способ генерации идентификатора нас не устраивает, потому что он создаёт идентификатор случайным образом,
* а нам нужно, чтобы идентификатор был одним и тем же для двух любых запросов к серверу
* (чтобы сопоставлять preview и datumPoints).
* @used-by \Df\GoogleFont\Fonts\Sprite::datumPoint()
* @used-by \Df\GoogleFont\Fonts\Sprite::draw()
* @used-by \Dfe\GoogleFont\Fonts\Sprite::datumPoint()
* @used-by \Dfe\GoogleFont\Fonts\Sprite::draw()
*/
function getId():string {return implode(':', [$this->family(), $this->variant()->name()]);}

/**
* 2015-12-08
* @used-by \Df\GoogleFont\Font::variantsAvailable()
* @used-by \Dfe\GoogleFont\Font::variantsAvailable()
*/
function isAvailable():bool {return !!$this->url();}

Expand All @@ -24,8 +24,8 @@ function isAvailable():bool {return !!$this->url();}
* Точка отсчёта системы координат [0, 0] — это самая левая верхняя точка холста.
* Далее кординаты увеличиваются вниз и вправо.
* @override
* @see \Df\GoogleFont\Fonts\Png::draw()
* @used-by \Df\GoogleFont\Fonts\Png::image()
* @see \Dfe\GoogleFont\Fonts\Png::draw()
* @used-by \Dfe\GoogleFont\Fonts\Png::image()
* @param resource $i
*/
protected function draw($i):void {
Expand Down Expand Up @@ -54,18 +54,18 @@ protected function draw($i):void {
/**
* 2015-12-08
* @override
* @see \Df\GoogleFont\Fonts\Png::height()
* @used-by \Df\GoogleFont\Fonts\Png::image()
* @used-by \Df\GoogleFont\Fonts\Sprite::height()
* @used-by \Df\GoogleFont\Fonts\Sprite::draw()
* @see \Dfe\GoogleFont\Fonts\Png::height()
* @used-by \Dfe\GoogleFont\Fonts\Png::image()
* @used-by \Dfe\GoogleFont\Fonts\Sprite::height()
* @used-by \Dfe\GoogleFont\Fonts\Sprite::draw()
*/
protected function height():int {return $this->params()->height();}

/**
* 2015-12-08
* @override
* @see \Df\GoogleFont\Fonts\Png::pathRelativeA()
* @used-by \Df\GoogleFont\Fonts\Png::path()
* @see \Dfe\GoogleFont\Fonts\Png::pathRelativeA()
* @used-by \Dfe\GoogleFont\Fonts\Png::path()
* @return string[]
*/
protected function pathRelativeA():array {return [
Expand All @@ -78,10 +78,10 @@ protected function pathRelativeA():array {return [
/**
* 2015-12-08
* @override
* @see \Df\GoogleFont\Fonts\Png::width()
* @used-by \Df\GoogleFont\Fonts\Png::image()
* @used-by \Df\GoogleFont\Fonts\Sprite::width()
* @used-by \Df\GoogleFont\Fonts\Sprite::draw()
* @see \Dfe\GoogleFont\Fonts\Png::width()
* @used-by \Dfe\GoogleFont\Fonts\Png::image()
* @used-by \Dfe\GoogleFont\Fonts\Sprite::width()
* @used-by \Dfe\GoogleFont\Fonts\Sprite::draw()
*/
protected function width():int {return $this->params()->width();}

Expand Down Expand Up @@ -155,7 +155,7 @@ private function variant():Variant {return $this[self::$P__VARIANT];}

/**
* 2015-11-29
* @used-by \Df\GoogleFont\Font\Variant::preview()
* @used-by \Dfe\GoogleFont\Font\Variant::preview()
*/
static function i(Variant $v, Params $p):Preview {return new self([self::$P__VARIANT => $v, self::$P__PARAMS => $p]);}

Expand Down
32 changes: 16 additions & 16 deletions Font/Variant/Preview/Params.php
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
<?php
namespace Df\GoogleFont\Font\Variant\Preview;
namespace Dfe\GoogleFont\Font\Variant\Preview;
final class Params extends \Df\Core\O {
/**
* @used-by self::getId()
* @used-by \Df\GoogleFont\Fonts\Fs::nameColorsSizeMargin()
* @used-by \Dfe\GoogleFont\Fonts\Fs::nameColorsSizeMargin()
* @return int[]
*/
function bgColor():array {return $this->rgb($this[self::$P__BG_COLOR]);}

/**
* @used-by \Df\GoogleFont\Font\Variant\Preview::draw()
* @used-by \Df\GoogleFont\Fonts\Fs::nameColorsSizeMargin()
* @used-by \Dfe\GoogleFont\Font\Variant\Preview::draw()
* @used-by \Dfe\GoogleFont\Fonts\Fs::nameColorsSizeMargin()
* @used-by self::getId()
* @return int[]
*/
function fontColor():array {return $this->rgb($this[self::$P__FONT_COLOR]);}

/**
* @used-by self::getId()
* @used-by \Df\GoogleFont\Font\Variant\Preview::fontSize()
* @used-by \Df\GoogleFont\Fonts\Fs::nameColorsSizeMargin()
* @used-by \Dfe\GoogleFont\Font\Variant\Preview::fontSize()
* @used-by \Dfe\GoogleFont\Fonts\Fs::nameColorsSizeMargin()
*/
function fontSize():int {return $this[self::$P__FONT_SIZE];}

/**
* 2015-12-01
* @used-by \Df\GoogleFont\Font\Variant::preview()
* @used-by \Dfe\GoogleFont\Font\Variant::preview()
*/
function getId():string {return dfc($this, function():string {return implode('-', [
$this->width()
Expand All @@ -36,21 +36,21 @@ function getId():string {return dfc($this, function():string {return implode('-'
]);});}

/**
* @used-by \Df\GoogleFont\Font\Variant\Preview::height()
* @used-by \Df\GoogleFont\Fonts\Fs::nameResolution()
* @used-by \Df\GoogleFont\Fonts\Sprite::previewHeight()
* @used-by \Dfe\GoogleFont\Font\Variant\Preview::height()
* @used-by \Dfe\GoogleFont\Fonts\Fs::nameResolution()
* @used-by \Dfe\GoogleFont\Fonts\Sprite::previewHeight()
*/
function height() {return $this[self::$P__HEIGHT];}

/**
* @used-by \Df\GoogleFont\Font\Variant\Preview::draw()
* @used-by \Df\GoogleFont\Fonts\Fs::nameColorsSizeMargin()
* @used-by \Dfe\GoogleFont\Font\Variant\Preview::draw()
* @used-by \Dfe\GoogleFont\Fonts\Fs::nameColorsSizeMargin()
*/
function marginLeft():int {return $this[self::$P__MARGIN_LEFT];}

/**
* @used-by self::getId()
* @used-by \Df\GoogleFont\Font\Variant\Preview::width()
* @used-by \Dfe\GoogleFont\Font\Variant\Preview::width()
*/
function width():int {return $this[self::$P__WIDTH];}

Expand All @@ -63,9 +63,9 @@ private function rgb(string $colorS):array {return df_int(explode('|', $colorS))

/**
* Этот метод возвращает объект-одиночку, потому что параметры запроса у нас неизменны в течение всей жизни запроса.
* @used-by \Df\GoogleFont\Controller\Index\Index::sprite()
* @used-by \Df\GoogleFont\Font\Variant::p()
* @used-by \Df\GoogleFont\Font\Variant::preview()
* @used-by \Dfe\GoogleFont\Controller\Index\Index::sprite()
* @used-by \Dfe\GoogleFont\Font\Variant::p()
* @used-by \Dfe\GoogleFont\Font\Variant::preview()
*/
static function fromRequest():Params {
$p = [
Expand Down
6 changes: 3 additions & 3 deletions Fonts.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php
namespace Df\GoogleFont;
namespace Dfe\GoogleFont;
use ArrayIterator as AI;
use Df\Core\Exception as DFE;
use Df\Google\Settings as S;
use Dfe\Google\Settings as S;
/** @method static Fonts s() */
final class Fonts extends \Df\Core\O implements \Countable, \IteratorAggregate {
/**
Expand All @@ -14,7 +14,7 @@ function count():int {return count($this->items());}

/**
* 2015-11-29
* @used-by \Df\GoogleFont\Controller\Index\Preview::contents()
* @used-by \Dfe\GoogleFont\Controller\Index\Preview::contents()
* @throws DFE
*/
function get(string $f):Font {return df_assert(dfa($this->items(), $f), "Font family is not found: «{$f}».");}
Expand Down
24 changes: 12 additions & 12 deletions Fonts/Fs.php
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
<?php
namespace Df\GoogleFont\Fonts;
use Df\GoogleFont\Font\Variant\Preview\Params;
namespace Dfe\GoogleFont\Fonts;
use Dfe\GoogleFont\Font\Variant\Preview\Params;
# 2015-12-08
class Fs {
/**
* 2015-12-08
* @used-by \Df\GoogleFont\Font\Variant::ttfPath()
* @used-by \Df\GoogleFont\Fonts\Png::path()
* @used-by \Df\GoogleFont\Fonts\Sprite::pathToDatumPoints()
* @used-by \Dfe\GoogleFont\Font\Variant::ttfPath()
* @used-by \Dfe\GoogleFont\Fonts\Png::path()
* @used-by \Dfe\GoogleFont\Fonts\Sprite::pathToDatumPoints()
* @param string[] $rel
*/
function absolute(array $rel):string {return df_media_path_absolute('df/api/google/fonts/'). df_cc_path($rel);}

/**
* 2015-12-08
* @used-by \Df\GoogleFont\Font\Variant\Preview::pathRelativeA()
* @used-by \Df\GoogleFont\Fonts\Sprite::pathRelativeBase()
* @used-by \Dfe\GoogleFont\Font\Variant\Preview::pathRelativeA()
* @used-by \Dfe\GoogleFont\Fonts\Sprite::pathRelativeBase()
*/
function nameColorsSizeMargin():string {return dfc($this, function():string {$p = $this->p(); return
implode('_', [
Expand All @@ -28,16 +28,16 @@ function nameColorsSizeMargin():string {return dfc($this, function():string {$p

/**
* 2015-12-08
* @used-by \Df\GoogleFont\Font\Variant\Preview::pathRelativeA()
* @used-by \Df\GoogleFont\Fonts\Sprite::pathRelativeA()
* @used-by \Dfe\GoogleFont\Font\Variant\Preview::pathRelativeA()
* @used-by \Dfe\GoogleFont\Fonts\Sprite::pathRelativeA()
* @param string[] $p
*/
function namePng(array $p):string {return df_fs_name(implode('_', $p)) . '.png';}

/**
* 2015-12-08
* @used-by \Df\GoogleFont\Font\Variant\Preview::pathRelativeA()
* @used-by \Df\GoogleFont\Fonts\Sprite::pathRelativeBase()
* @used-by \Dfe\GoogleFont\Font\Variant\Preview::pathRelativeA()
* @used-by \Dfe\GoogleFont\Fonts\Sprite::pathRelativeBase()
*/
function nameResolution():string {$p = $this->p(); return implode('x', [$p->width(), $p->height()]);}

Expand All @@ -46,7 +46,7 @@ private function p() {return Params::fromRequest();}

/**
* 2017-03-15
* @used-by \Df\GoogleFont\Font\Variant::ttfPath()
* @used-by \Dfe\GoogleFont\Font\Variant::ttfPath()
*/
static function s():self {static $r; return $r ? $r : $r = new self;}
}
Loading

0 comments on commit 31a0231

Please sign in to comment.