diff --git a/.editorconfig b/.editorconfig index e465d36..6250ff5 100644 --- a/.editorconfig +++ b/.editorconfig @@ -12,6 +12,6 @@ insert_final_newline = true indent_style = space indent_size = 4 -[*{.js,.json,.scss}] +[*.{ym,yaml,js,json,scss}] indent_style = space indent_size = 2 diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 5a9750f..51cfd52 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -1,13 +1,14 @@ # Contributing -Contributions are **welcome** and will be **credited**. We accept contributions via Pull Requests on [GitHub](https://github.com/8fold/php-markup). +Contributions are **welcome** and will be **credited**. We accept contributions via Pull Requests on [GitHub](https://github.com/8fold/php-shoop). -## Goals +## Priorities -- Readability over speed over cleverness. -- Fail gracefully not by blowing things up. +We leverage GitHub's labeling system to inform prioritization of issues. The higher the number, the higher priority. -### Overall +Security is always the highest priority within the applicable scope of the product. Therefore, some packages are low-level and intended for developers and give the flexibility to them to surround the package with a security layer. + +## Overall goals (philosophy and values) There are a lot of philosphical things tied in to the way we strive to do software development. Some you are most likely familiar with, others maybe not so much. @@ -27,6 +28,8 @@ There are a lot of philosphical things tied in to the way we strive to do softwa **Solutions over scapegoats:** There are times when these principles will not be followed or someone will make a mistake. Berating the offender doesn't get any of us any closer to improving the execution of these principles. +**The Community Principle:** If you create or acquire it you help maintain it; time, food, money, and so on. + ## Code promotion Capabilities should be implemented at a low, concrete level before being promoted to higher-levels and made more abstract. @@ -38,3 +41,7 @@ If the language being used allows access levels on variable, constants, methods, This reduces the size of the public API, which makes the class easier to consume by developers. Further, it is preferred that class properties remain private, always. This means pre- and post-processing for setting and getting properties can be added without being a breaking change to developers. + +## Releasing + +Major - fix bugs -> Patch - optimize -> Minor - fix bugs -> Patch - new feature -> Minor - interface changes -> Major diff --git a/.github/ISSUE_TEMPLATE/Deprecation_notice_or_request.md b/.github/ISSUE_TEMPLATE/Deprecation_notice_or_request.md new file mode 100644 index 0000000..77585aa --- /dev/null +++ b/.github/ISSUE_TEMPLATE/Deprecation_notice_or_request.md @@ -0,0 +1,10 @@ +--- +name: Deprecation Notice or Request +about: Notify or request a feature be deprecated +--- + +**What feature should be deprecated?** + +**Why should the feature be deprecated?** + +**What alternative means delivers similar or same results?** diff --git a/.github/LICENSE b/.github/LICENSE index 68ede65..7a8390b 100644 --- a/.github/LICENSE +++ b/.github/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2019 Josh Bruce +Copyright (c) 2021 8fold Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -19,7 +19,3 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -## Notice - -This software makes use of software developed by others. Those software applications are not subject to this license, nor is this software subject to those licenses. See the individual modules for further details. diff --git a/.github/PULL_REQUEST_TEMPLATE/feature.md b/.github/PULL_REQUEST_TEMPLATE.md similarity index 100% rename from .github/PULL_REQUEST_TEMPLATE/feature.md rename to .github/PULL_REQUEST_TEMPLATE.md diff --git a/.github/PULL_REQUEST_TEMPLATE/deprecation.md b/.github/PULL_REQUEST_TEMPLATE/deprecation.md new file mode 100644 index 0000000..4cee712 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE/deprecation.md @@ -0,0 +1,14 @@ +--- +name: Deprecation Notice or Request +about: Notify or request a feature be deprecated +--- + +**What feature should be deprecated?** + +**Why should the feature be deprecated?** + +**What alternative means delivers similar or same results?** + +## List of issues fixed + +[Please use GitHub notation to automatically close the issues: Fixes #{issue number}] diff --git a/.github/PULL_REQUEST_TEMPLATE/issue.md b/.github/PULL_REQUEST_TEMPLATE/issue.md deleted file mode 100644 index 5b9ee2a..0000000 --- a/.github/PULL_REQUEST_TEMPLATE/issue.md +++ /dev/null @@ -1,5 +0,0 @@ -[Describe what this PR is about] - -## List of issues fixed - -[Please use GitHub notation to automatically close the issues: Fixes #{issue number}] diff --git a/.github/SECURITY.md b/.github/SECURITY.md index 7c74db6..39c5777 100644 --- a/.github/SECURITY.md +++ b/.github/SECURITY.md @@ -1,6 +1,6 @@ # Security Policy -The only completely secure system is the one that doesn't exist in the first place. Having said that, we take the security of Marked very seriously. +The only completely secure system is the one that doesn't exist in the first place. Having said that, we take security seriously. ## Reporting a Vulnerability diff --git a/.github/coding-standards-and-styles.md b/.github/coding-standards-and-styles.md new file mode 100644 index 0000000..dc41b2d --- /dev/null +++ b/.github/coding-standards-and-styles.md @@ -0,0 +1,30 @@ +# Coding Standards and Styles + +Coding standards help multiple developers work in the same codebase and not have to answer certain questions because they are already answered by the standards. Further, whenever possible, if the language being discussed has community accepted standards or a governing body, those standards should be used. Finally, minimal exceptions can be made with just cause so long as those changes minimize cognitive load across the majority of developers working in the various codebases. + +For example, the [w3c](https://www.w3.org/) is the generally accepted governing body for HTML and CSS; therefore, when it comes to answering questions or disputes related to HTML or CSS, that's where one should go. ECMAScript is the generally accepted standard for JavaScript. And, the PHP Framework Interop Group \([PHP-Fig](https://www.php-fig.org)\) is the same for PHP. + +Therefore, if I, as a developer, go from the 8fold Component, to Laravel, to AMOS, there are certain conventions I should be able to reasonably expect. + +## PHP + +Standards come in the form of PHP Standards Recommendations \([PSRs](https://www.php-fig.org/psr/)\) proposals are made, debated, modified, and potentially accepted. As the PHP-FIG discusses proposals that could impact all PHP developers, the PSRs are generally not accepted lightly. + +If no commentary is added for a specific PSR or section of a PSR, it is safe to assume following the full specification is desired. Modifications and extensions will be indicated by _italics_. + +* [**PSR-1**](https://www.php-fig.org/psr/psr-1/)**:** + * PSR-1 is the base recommendation and is required by both of the following recommendations. +* [**PSR-2**](https://www.php-fig.org/psr/psr-2/)**:** + * As visibility is required and the following are not, `abstract`, `final`, _and_ `static` must precede visibility. If `static` is present, it must come directly before the visibility. _These modifications front-load the answering of the following questions in turn: Do I need to implement it? Can I override it? Is it a class function or instance method? From where can I see it, if at all? + * Opening braces for control structures MUST go on the same line, and closing braces MUST go on the next line after the body. _The body of a control structure SHOULD be followed by a blank line to distinguish between discreet thoughts. The body MAY be preceded by a blank line to reduce visual complexity and minimize blurring the lines._ +* [**PSR-12**](https://github.com/php-fig/fig-standards/blob/master/proposed/extended-coding-style-guide.md)**:** This PSR is under review. With that said, it is the primary recommendation followed. Specifically-multi line control structures. + * 2.5: _Unless a library we use needs something else. At which point we should notify the library authors._ + * 4.4: _See modifications from PSR-2._ + * 4.5: _Any method returning a value MUST declare a return type. Methods SHOULD NOT return null (void is exception), favoring an empty value of the correct type. Wildcard arguments that can be of_ any _type SHOULD be avoided, and arguments SHOULD have a type specified._ + * 5.1: _See modifications from PSR-2 regarding ordering._ + * 5.2: _See modifications from PSR-2 regarding control structures._ + * 5.6: _See modifications from PSR-2 regarding control structures._ + * 6: _Ternary operators SHOULD NOT be used unless simple in form and MUST NOT be more than one unless as an artifact of a library being used. Unary operators SHOULD be avoided to clearly express the intent and reduce possible ordering problems \(ex. x-- may not be the same as --x; whereas x-y and y-x is clearly understood\)._ +* **Other** + * Variables SHOULD NOT be nullable. Instead of null, use an empty variation of the same type. This reduces boilerplate null-checking code. + diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml deleted file mode 100644 index 359ce88..0000000 --- a/.github/workflows/php.yml +++ /dev/null @@ -1,31 +0,0 @@ -name: PHP Composer -on: - push: - branches: - - master - pull_request: - branches: - - master - -jobs: - build: - - runs-on: ubuntu-latest - - steps: - - name: Checkout - uses: actions/checkout@v2 - - - name: Setup PHP Action - uses: shivammathur/setup-php@2.9.0 - with: - php-version: '7.4' - - - name: Validate composer.json and composer.lock - run: composer validate - - - name: Install dependencies - run: composer install --prefer-dist --no-progress --no-suggest - - - name: Run test suite - run: vendor/bin/phpunit diff --git a/.github/workflows/php8.yml b/.github/workflows/php8.yml deleted file mode 100644 index fa2bf43..0000000 --- a/.github/workflows/php8.yml +++ /dev/null @@ -1,31 +0,0 @@ -name: PHP Composer -on: - push: - branches: - - master - pull_request: - branches: - - master - -jobs: - build: - - runs-on: ubuntu-latest - - steps: - - name: Checkout - uses: actions/checkout@v2 - - - name: Setup PHP Action - uses: shivammathur/setup-php@2.9.0 - with: - php-version: '8.0' - - - name: Validate composer.json and composer.lock - run: composer validate - - - name: Install dependencies - run: composer install --prefer-dist --no-progress --no-suggest - - - name: Run test suite - run: vendor/bin/phpunit diff --git a/.github/workflows/php81.yml b/.github/workflows/php81.yml new file mode 100644 index 0000000..30842e9 --- /dev/null +++ b/.github/workflows/php81.yml @@ -0,0 +1,34 @@ +name: PHP 8.0 + +on: + push: + branches: [main] + pull_request: + branches: [main] + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Setup PHP Action + uses: shivammathur/setup-php@2.15.0 + with: + php-version: '8.1' + + - name: Validate composer.json and composer.lock + run: composer validate + + - name: Install dependencies + run: composer install --prefer-dist --no-progress + + - name: Run style check + run: composer run style + + - name: Run static analyzer + run: composer run stan + + - name: Run tests + run: composer run test diff --git a/composer.json b/composer.json index ae37a7a..a642db4 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { "name": "8fold/php-markup", - "description": "8fold Markup seeks to make writing semi-structured data easier while allowing for more dynamism.", + "description": "8fold Markup makes writing semi-structured data easier while allowing for more dynamism.", "type": "library", "license": "MIT", "authors": [ @@ -25,8 +25,7 @@ }, "autoload-dev": { "psr-4": { - "Eightfold\\Markup\\Tests\\": "./tests/", - "Eightfold\\Foldable\\Tests\\": "./vendor/8fold/php-foldable/tests/" + "Eightfold\\Markup\\Tests\\": "./tests/" } }, "config": { @@ -41,13 +40,8 @@ "@stan", "@test" ], - "deploy": [ - "@production", - "@optimize-autoload" - ], "style": "./vendor/bin/phpcs --standard=phpcs.xml", "stan": "./vendor/bin/phpstan analyze", - "test": "./vendor/bin/phpunit", - "optimize-autoload": "composer dumpautoload --no-dev --classmap-authoritative" + "test": "./vendor/bin/phpunit" } } diff --git a/composer.lock b/composer.lock index ab0794d..3251974 100644 --- a/composer.lock +++ b/composer.lock @@ -206,9 +206,6 @@ "require": { "php": "^7.1 || ^8.0" }, - "replace": { - "myclabs/deep-copy": "self.version" - }, "require-dev": { "doctrine/collections": "^1.0", "doctrine/common": "^2.6", @@ -2346,5 +2343,5 @@ "php": "^8.1" }, "platform-dev": [], - "plugin-api-version": "2.0.0" + "plugin-api-version": "2.2.0" } diff --git a/phpcs.xml b/phpcs.xml index a8aaf1d..18ffb74 100644 --- a/phpcs.xml +++ b/phpcs.xml @@ -1,7 +1,6 @@ PHP-FIG PSR-12 standards with modifications to: control structure (empty space before closing brace). - src diff --git a/phpstan.neon b/phpstan.neon index bd28db0..5ba97e5 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -4,5 +4,3 @@ parameters: - src ignoreErrors: - '#Call to an undefined static method Eightfold\\HTMLBuilder\\Element::(.*)#' - - '#Call to an undefined static method Eightfold\\XMLBuilder\\Element::(.*)#' - - '#Call to an undefined static method Eightfold\\XMLBuilder\\Document::(.*)#' diff --git a/phpunit.xml b/phpunit.xml index 8edbcc5..735ef89 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -11,22 +11,21 @@ processIsolation="false" stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"> - - - ./src/ - - - vendor/ - - - - - ./tests/ - - - - - - - + + + ./src/ + + + vendor/ + + + + + ./tests/ + + + + + + diff --git a/src/Anchor.php b/src/Anchor.php new file mode 100755 index 0000000..ab58a20 --- /dev/null +++ b/src/Anchor.php @@ -0,0 +1,50 @@ + + */ + private array $properties = []; + + public static function create(string $content, string $href): Anchor + { + return new Anchor($content, $href); + } + + public function __construct(string $content, string $href) + { + $this->content = $content; + + $this->href = $href; + } + + public function props(string ...$properties): Anchor + { + $this->properties = $properties; + + return $this; + } + + public function build(): string + { + return HtmlElement::a($this->content) + ->props('href ' . $this->href, ...$this->properties) + ->build(); + } + + public function __toString(): string + { + return $this->build(); + } +} diff --git a/src/Element.php b/src/Element.php deleted file mode 100644 index 0d7524a..0000000 --- a/src/Element.php +++ /dev/null @@ -1,149 +0,0 @@ -at(0)->unfold(); - if ($args->length()->is(1)->unfold()) { - return new static($element); - } - - $args = $args->dropAt(0)->retain(function($v) { - $v = Shoop::this($v); - return $v->isArray()->reversed()->unfold() and - $v->isBoolean()->reversed()->unfold(); - }); - - return new static($element, [], false, ...$args); - } - - public function __construct(string $element, array $attributes = [], bool $omitEndTag = false, ...$content) - { - $this->main = $element; - $this->attributes = $attributes; - $this->omitEndTag = $omitEndTag; - $this->content = $content; - } - - public function args($includeMain = false) - { - $args = []; - - if ($includeMain) { - $args[] = $this->main; - } - - $args[] = $this->attributes; - $args[] = $this->omitEndTag; - - if (Shoop::this($this->content)->isEmpty()->reversed()->unfold()) { - $args[] = $this->content; - } - - return $args; - } - - // TODO: PHP 8.0 bool|ESBool - public function omitEndTag(bool $omit = null)// TODO: PHP 8.0 : static|bool - { - if ($omit === null) { - return $this->omitEndTag; - - } elseif (Shoop::this($omit)->efIsBoolean()) { - $this->omitEndTag = $omit; - - } - - return $this; - } - - /** - * attr = setter/override - * - * attrList = x="y" or ESDictionary - * - */ - public function attr(string ...$attributes): Element - { - $this->attributes = Shoop::this( - $this->attrList(false) - )->append( - AttrDictionary::apply()->unfoldUsing($attributes) - )->each( - function($v, $m, &$build) { - $build[] = Shoop::this($m)->append(" ")->append($v)->unfold(); - } - )->unfold(); - - return $this; - } - - // TODO: PHP 8.0 bool|ESBool -> ESArray|ESDictionary - public function attrList(bool $useArray = true): array - { - return ($useArray) - ? $this->attributes - : AttrDictionary::apply()->unfoldUsing($this->attributes); - } - - public function attrString() - { - return AttrString::apply()->unfoldUsing($this->attributes); - } - - public function unfold() - { - // TODO: some type of str_replace for Shooped - $main = str_replace("_", "-", $this->main); - - $base = Shoop::this($main)->prepend("<")->append( - $this->attrString() - )->append(">"); - - if (Shoop::this($this->omitEndTag)->unfold()) { - return $base->unfold(); - } - - $base = $base->append( - Shoop::this($this->content)->each(function($v, $m, &$build) { - if (Apply::isString()->unfoldUsing($v)) { - $build[] = $v; - - } elseif (is_a($v, Foldable::class)) { - $build[] = $v->unfold(); - - } - })->efToString() - ); - return $base->append("append($main)->append(">")->unfold(); - } - - public function __toString(): string - { - return $this->unfold(); - } -} diff --git a/src/Feed.php b/src/Feed.php deleted file mode 100755 index 39570cb..0000000 --- a/src/Feed.php +++ /dev/null @@ -1,28 +0,0 @@ -title = $title; - $this->link = $link; - $this->description = $description; - $this->content = $content; - } - - // TODO: Use __call() and verify against list of available members - public function language(string $language = "en-us"): Channel - { - if (strlen($language) > 0) { - $this->otherChannelMeta["language"] = $language; - } - return $this; - } - - public function copyright(string $content = ""): Channel - { - if (strlen($content) > 0) { - $this->otherChannelMeta["copyright"] = $content; - } - return $this; - } - - public function unfold(): string - { - $content = Shoop::this([ - Element::fold("title", $this->title), - Element::fold("link", $this->link), - Element::fold("description", $this->description) - ]); - - foreach ($this->otherChannelMeta as $element => $value) { - $content = $content->append([Element::fold($element, $value)]); - } - - // Shoop::this($this->otherChannelMeta)->each( - // function($value, $element) use (&$content) { - // $content = $content->plus(Element::fold($element, $value)); - // }); - - $content = $content->append($this->content); - - return Shoop::this( - Element::fold("rss", - Element::fold("channel", - ...$content->each(function($item) { - return $item->unfold(); - }) - ) - )->attr("version ". $this->rssVersion)->unfold() - )->prepend('xmlVersion .'"?>'."\n")->unfold(); - } - - /** - * language The language the channel is written in. This allows aggregators to group all Italian language sites, for example, on a single page. A list of allowable values for this element, as provided by Netscape, is here. You may also use values defined by the W3C. en-us - * copyright Copyright notice for content in the channel. Copyright 2002, Spartanburg Herald-Journal - * managingEditor Email address for person responsible for editorial content. geo@herald.com (George Matesky) - * webMaster Email address for person responsible for technical issues relating to channel. betty@herald.com (Betty Guernsey) - * pubDate The publication date for the content in the channel. For example, the New York Times publishes on a daily basis, the publication date flips once every 24 hours. That's when the pubDate of the channel changes. All date-times in RSS conform to the Date and Time Specification of RFC 822, with the exception that the year may be expressed with two characters or four characters (four preferred). Sat, 07 Sep 2002 0:00:01 GMT - * lastBuildDate The last time the content of the channel changed. Sat, 07 Sep 2002 9:42:31 GMT - * category Specify one or more categories that the channel belongs to. Follows the same rules as the -level category element. More info. Newspapers - * generator A string indicating the program used to generate the channel. MightyInHouse Content System v2.3 - * docs A URL that points to the documentation for the format used in the RSS file. It's probably a pointer to this page. It's for people who might stumble across an RSS file on a Web server 25 years from now and wonder what it is. http://backend.userland.com/rss - * cloud Allows processes to register with a cloud to be notified of updates to the channel, implementing a lightweight publish-subscribe protocol for RSS feeds. More info here. - * ttl ttl stands for time to live. It's a number of minutes that indicates how long a channel can be cached before refreshing from the source. More info here. 60 - * image Specifies a GIF, JPEG or PNG image that can be displayed with the channel. More info here. - * textInput Specifies a text input box that can be displayed with the channel. More info here. - * skipHours A hint for aggregators telling them which hours they can skip. More info here. - * skipDays A hint for aggregators telling them which days they can skip. More info here. - */ -} diff --git a/src/Feed/Rss/Item.php b/src/Feed/Rss/Item.php deleted file mode 100644 index f68ba83..0000000 --- a/src/Feed/Rss/Item.php +++ /dev/null @@ -1,118 +0,0 @@ -title = $title; - $this->link = $link; - $this->description = $description; - } - - public function guid(string $content = ""): Channel - { - if (strlen($content) > 0) { - $this->otherItemContent["guid"] = $content; - - } else { - $this->otherItemContent["guid"] = $this->link; - - } - return $this; - } - - public function date( - string $date, - string $format = "Ymd", - string $timezone = "America/Detroit" - ) - { - $this->otherItemContent["pubDate"] = Carbon::createFromFormat( - "Ymd", - $date, - $timezone)->hour(12)->minute(0)->second(0)->toRssString(); - return $this; - } - - public function descriptionLimit(int $limit = 50): Item - { - $this->descriptionLimit = $limit; - return $this; - } - - private function description() - { - // TODO: Once Shoop Shelf is ready - add dropTags to ESString - $tagless = strip_tags($this->description); - $return = Shoop::this($tagless)->divide(" "); - - if ($this->descriptionLimit !== null) { - $return = $return->first($this->descriptionLimit); - } - - if ($return->efIsArray()) { - $return = $return->asString(" "); - - } - return $return->append($this->descriptionTail)->unfold(); - } - - public function unfold(): string - { - $content = Shoop::this([ - Element::fold("title",htmlspecialchars($this->title)), - Element::fold("link", $this->link), - Element::fold("description", $this->description()) - ]); - - return Shoop::this( - Element::fold("item", ...$content)->unfold() - )->unfold(); - - // ...static::rssItemsStoreItems()->each(function($path) { - // $markdown = static::uriContentStore($path)->markdown(); - - // $item = Element::fold( - // "item", - // Element::fold("title", htmlspecialchars($title)), - // Element::fold("link", $link), - // Element::fold("guid", $link), - // Element::fold("description", htmlspecialchars($description)), - // $t - // ); - } - - /** - * title The title of the item. Venice Film Festival Tries to Quit Sinking - * link The URL of the item. http://www.nytimes.com/2002/09/07/movies/07FEST.html - * description The item synopsis. Some of the most heated chatter at the Venice Film Festival this week was about the way that the arrival of the stars at the Palazzo del Cinema was being staged. - * guid A string that uniquely identifies the item. More. http://inessential.com/2002/09/01.php#a2 - * author Email address of the author of the item. More. oprah@oxygen.net - * category Includes the item in one or more categories. More. Simpsons Characters - * comments URL of a page for comments relating to the item. More. http://www.myblog.org/cgi-local/mt/mt-comments.cgi?entry_id=290 - * enclosure Describes a media object that is attached to the item. More. - * pubDate Indicates when the item was published. More. Sun, 19 May 2002 15:21:36 GMT - * source The RSS channel that the item came from. More. Quotes of the Day - */ -} diff --git a/src/Filters/AttrDictionary.php b/src/Filters/AttrDictionary.php deleted file mode 100644 index 8d957f7..0000000 --- a/src/Filters/AttrDictionary.php +++ /dev/null @@ -1,23 +0,0 @@ -each(function($v, $k, &$build) { - list($attr, $content) = Shoop::this($v)->divide(" ", false, 2); - $build[$attr] = $content; - })->unfold(); - } -} diff --git a/src/Filters/AttrString.php b/src/Filters/AttrString.php deleted file mode 100644 index 6885cc2..0000000 --- a/src/Filters/AttrString.php +++ /dev/null @@ -1,25 +0,0 @@ -each(function($v, $m, &$build) { - list($attr, $content) = Shoop::this($v)->divide(" ", false, 2); - $build[] = (Shoop::this($attr)->is($content)->unfold()) - ? "{$attr}" - : "{$attr}=\"{$content}\""; - })->asString(" ")->prepend(" ")->unfold(); - } -} diff --git a/src/Filters/AttrStringHtml.php b/src/Filters/AttrStringHtml.php deleted file mode 100644 index 831e8d2..0000000 --- a/src/Filters/AttrStringHtml.php +++ /dev/null @@ -1,131 +0,0 @@ - $content) { - if (array_key_exists($attr, $orderedAttributes)) { - $orderedAttributes[$attr] = $content; - - } elseif ($index->hasComponentNamed($attr) and - $a = $index->componentNamed($attr) - ) { - if ($a->isEvent()) { - $eventAttributes[$attr] = $content; - - } elseif ($a->isData()) { - $dataAttributes[$attr] = $content; - - } elseif ($a->isGlobal()) { - $globalAttributes[$attr] = $content; - - } elseif ($a->isOther()) { - $otherAttributes[$attr] = $content; - - } elseif ($a->isBoolean()) { - $booleanAttributes[$attr] = $content; - - } - - } else { - $otherAttributes[$attr] = $content; - - } - } - - $orderedAttributes = array_filter($orderedAttributes); - - $eventAttributes = array_filter($eventAttributes); - ksort($eventAttributes); - - $dataAttributes = array_filter($dataAttributes); - ksort($eventAttributes); - - $globalAttributes = array_filter($globalAttributes); - ksort($globalAttributes); - - $otherAttributes = array_filter($otherAttributes); - ksort($otherAttributes); - - $booleanAttributes = array_filter($booleanAttributes); - ksort($booleanAttributes); - - $merged = array_merge( - $orderedAttributes, - $eventAttributes, - $dataAttributes, - $globalAttributes, - $otherAttributes, - $booleanAttributes - ); - - $build = []; - foreach ($merged as $attr => $content) { - $build[] = "{$attr} {$content}"; - } - - return AttrString::apply()->unfoldUsing($build); - } -} diff --git a/src/Html.php b/src/Html.php deleted file mode 100644 index 04af19e..0000000 --- a/src/Html.php +++ /dev/null @@ -1,19 +0,0 @@ -hasComponentNamed($element)) { - return HtmlElement::fold($element, ...$elements); - } - return Element::fold($element, ...$elements); - } -} diff --git a/src/Html/HtmlElement.php b/src/Html/HtmlElement.php deleted file mode 100644 index 26fe896..0000000 --- a/src/Html/HtmlElement.php +++ /dev/null @@ -1,32 +0,0 @@ -attrList(false); - return AttrStringHtml::apply()->unfoldUsing($attributes); - } - - public function unfold() - { - if (HtmlIndex::init()->hasComponentNamed($this->main) and - $element = HtmlIndex::init()->componentNamed($this->main) and - ! $element->acceptsChildren() - ) { - $this->omitEndTag = true; - - } - return parent::unfold(); - } -} diff --git a/src/Image.php b/src/Image.php new file mode 100755 index 0000000..66ea97b --- /dev/null +++ b/src/Image.php @@ -0,0 +1,52 @@ + + */ + private array $properties = []; + + public static function create(string $alt, string $src): Image + { + return new Image($alt, $src); + } + + public function __construct(string $alt, string $src) + { + $this->alt = $alt; + $this->src = $src; + } + + public function props(string ...$properties): Image + { + $this->properties = $properties; + + return $this; + } + + public function build(): string + { + return HtmlElement::img()->omitEndTag() + ->props( + 'alt ' . $this->alt, + 'src ' . $this->src, + ...$this->properties + )->build(); + } + + public function __toString(): string + { + return $this->build(); + } +} diff --git a/src/PageTitle.php b/src/PageTitle.php new file mode 100755 index 0000000..459c6d8 --- /dev/null +++ b/src/PageTitle.php @@ -0,0 +1,77 @@ + + */ + private array $parts = []; + + private string $separator = ' | '; + + private bool $reversed = false; + + private bool $stringOnly = false; + + /** + * @param array $parts [description] + */ + public static function create( + array $parts, + string $separator = ' | ' + ): PageTitle { + return new PageTitle($parts, $separator); + } + + /** + * @param array $parts [description] + */ + public function __construct(array $parts, string $separator = ' | ') + { + $this->parts = $parts; + + $this->separator = $separator; + } + + public function build(): string + { + if ($this->reversed) { + $this->parts = array_reverse($this->parts); + + } + + $string = implode($this->separator, $this->parts); + + if ($this->stringOnly) { + return $string; + + } + + return HtmlElement::title($string)->build(); + } + + public function __toString(): string + { + return $this->build(); + } + + public function reversed(): PageTitle + { + $this->reversed = true; + + return $this; + } + + public function stringOnly(): PageTitle + { + $this->stringOnly = true; + + return $this; + } +} diff --git a/src/SimpleList.php b/src/SimpleList.php new file mode 100755 index 0000000..656ffd0 --- /dev/null +++ b/src/SimpleList.php @@ -0,0 +1,72 @@ + + */ + private array $items = []; + + private string $type = 'unordered'; + + /** + * @var array + */ + private array $properties = []; + + public static function create(string|Buildable ...$items): SimpleList + { + return new SimpleList(...$items); + } + + /** + * @param HtmlElement|string $items [description] + */ + public function __construct(string|Buildable ...$items) + { + $this->items = $items; + } + + public function props(string ...$properties): SimpleList + { + $this->properties = $properties; + + return $this; + } + + public function build(): string + { + $items = []; + foreach ($this->items as $item) { + $items[] = HtmlElement::li($item); + } + + $elem = HtmlElement::ul(...$items); + if ($this->type === 'ordered') { + $elem = HtmlElement::ol(...$items); + } + + if (count($this->properties) > 0) { + $elem = $elem->props(...$this->properties); + } + + return $elem->build(); + } + + public function __toString(): string + { + return $this->build(); + } + + public function ordered(): SimpleList + { + $this->type = 'ordered'; + return $this; + } +} diff --git a/src/UIKit.php b/src/UIKit.php deleted file mode 100755 index 696bcee..0000000 --- a/src/UIKit.php +++ /dev/null @@ -1,238 +0,0 @@ -unfold(); - return new $class( - $currentPage, - $totalItems, - $linkPrefix, - $totalItemsPerPage, - $middleLimit - ); - } - - static public function tableWith(...$rows) - { - $class = self::class("tableWith", self::CLASSES)->unfold(); - return new $class(...$rows); - } - - static public function listWith(...$content) - { - return new UIKit\Elements\Simple\SimpleList(...$content); - } - - static public function fileInput($label, $name) - { - $class = self::class("fileInput", self::CLASSES)->unfold(); - return new $class($label, $name); - } - - static public function hiddenInput($name, $value) - { - $class = self::class("hiddenInput", self::CLASSES)->unfold(); - return new $class($name, $value); - } - - // TODO: Should be able to accept unfoldable - static public function anchor(string $text, string $href) - { - return new UIKit\Elements\Simple\Anchor($text, $href); - } - - static public function image(string $altText, string $path) - { - return new UIKit\Elements\Simple\Image($altText, $path); - } - - static public function markdown(string $markdown, array $config = []) - { - return new UIKit\Elements\Compound\Markdown($markdown, $config); - } - - static public function stripeElements($formId, $apiKey, $inputLabel, $buttonLabel) - { - $class = self::class("stripeElements", self::CLASSES)->unfold(); - return new $class($formId, $apiKey, $inputLabel, $buttonLabel); - } - - static public function socialMeta( - string $title, - string $url, - string $description, - string $image = "", - string $type = "website", - string $appId = "" - ) - { - return new UIKit\Elements\Compound\SocialMeta( - $title, - $url, - $description, - $image, - $type, - $appId - ); - } - - static public function accordion( - string $summaryId, - string $summary, - ...$content - ) - { - return new UIKit\Elements\Compound\Accordion( - $summaryId, - $summary, - ...$content - ); - } - - static public function __callStatic(string $element, array $elements) - { - if (array_key_exists($element, static::CLASSES)) { - switch ($element) { - case ('primary_nav' - || 'secondary_nav' - || 'side_nav' - || 'user_card'): - return new $class(...$elements); - break; - - case ('glyph' || 'head' || 'avatar'): - return new $class($args[0]); - break; - - case ('footer' || 'image'): - if (isset($args[1])) { - return new $class($args[0], $args[1]); - - } - return new $class($args[0]); - break; - - case ('alert'): - return new $class($args[0], $args[1]); - break; - - case 'header': - $main = $args[0]; - unset($args[0]); - return new $class($main, ...$args); - break; - - case ('select' - || 'textarea' - || 'markdown_textarea' - || 'textInput' - || 'date_input'): - if (isset($args[3])) { - return new $class($args[0], $args[1], $args[2], $args[3]); - - } elseif ($isset(args[2])) { - return new $class($args[0], $args[1], $args[3]); - - } - return new $class($args[0], $args[1]); - break; - - case 'progress': - if (isset($args[2])) { - return new $class($args[0], $args[1], $args[2]); - - } elseif (isset($args[1])) { - return new $class($args[0], $args[1]); - - } - return new $class($args[0]); - break; - - default: - return parent::$element(...$args); - break; - } - } - return Html::$element(...$elements); - } - - const CLASSES = [ - 'webView' => \Eightfold\Markup\UIKit\Elements\Pages\WebView::class, - // 'form' => UIKit\Elements\Forms\Form::class, - 'listWith' => \Eightfold\Markup\UIKit\Elements\Simple\SimpleList::class, - 'tableWith' => \Eightfold\Markup\UIKit\Elements\Simple\SimpleTable::class, - 'anchor' => \Eightfold\Markup\UIKit\Elements\Simple\Anchor::class, - 'glyph' => \Eightfold\Markup\UIKit\Elements\Simple\Glyph::class, - 'image' => \Eightfold\Markup\UIKit\Elements\Simple\Image::class, - // 'button' => UIKit\Elements\FormControls\Button::class, - - 'stripeElements' => \Eightfold\Markup\UIKit\Elements\FormControls\StripeElements::class, - 'hiddenInput' => \Eightfold\Markup\UIKit\Elements\FormControls\InputHidden::class, - 'fileInput' => \Eightfold\Markup\UIKit\Elements\FormControls\InputFile::class, - 'textInput' => \Eightfold\Markup\UIKit\Elements\FormControls\InputText::class, - // , 'user_card' => UIKit\Elements\Simple\UserCard::class - - // , 'alert' => UIKit\Elements\Compound\Alert::class - 'doubleWrap' => \Eightfold\Markup\UIKit\Elements\Compound\DoubleWrap::class, - 'markdown' => \Eightfold\Markup\UIKit\Elements\Compound\Markdown::class, - 'pagination' => \Eightfold\Markup\UIKit\Elements\Compound\Pagination::class, - 'socialMeta' => \Eightfold\Markup\UIKit\Elements\Compound\SocialMeta::class, - 'webHead' => \Eightfold\Markup\UIKit\Elements\Compound\WebHead::class, - 'accordion' => \Eightfold\Markup\UIKit\Elements\Compound\Accordion::class - // , 'primary_nav' => UIKit\Elements\Compound\NavigationPrimary::class - // , 'secondary_nav' => UIKit\Elements\Compound\NavigationSecondary::class - // , 'side_nav' => UIKit\Elements\Compound\NavigationSide::class - // , 'footer' => UIKit\Elements\Compound\Footer::class - // // , 'head' => UIKit\Elements\Compound\Head::class - // , 'header' => UIKit\Elements\Compound\Header::class - // , 'action_container' => UIKit\Elements\Compound\ActionContainer::class - - // , 'select' => UIKit\Elements\FormControls\Select::class - - // , 'progress' => UIKit\Elements\FormControls\Progress::class - // , 'textarea' => UIKit\Elements\FormControls\Textarea::class - // , 'markdown_textarea' => UIKit\Elements\FormControls\TextareaMarkdown::class - // , 'date_input' => UIKit\Elements\FormControls\InputDate::class - - - - - - ]; -} diff --git a/src/UIKit/Elements/Compound/Accordion.php b/src/UIKit/Elements/Compound/Accordion.php deleted file mode 100644 index 120c233..0000000 --- a/src/UIKit/Elements/Compound/Accordion.php +++ /dev/null @@ -1,60 +0,0 @@ -content = $content; - - $this->summary = $summary; - $this->summaryId = $summaryId; - $this->panelId = $this->summaryId ."-panel"; - } - - public function unfold(): string - { - $header = UIKit::h2( - UIKit::button( - $this->summary - )->attr( - "aria-expanded true", - "id {$this->summaryId}", - "aria-controls {$this->panelId}" - ) - )->attr("is accordion")->unfold(); - - $panel = UIKit::div( - ...$this->content - )->attr( - "is accordion-panel", - "tabindex -1", - "role region", - "aria-hidden false", - "id {$this->panelId}", - "aria-labelledby {$this->summaryId}" - )->unfold(); - - return $header . $panel; - } -} diff --git a/src/UIKit/Elements/Compound/DoubleWrap.php b/src/UIKit/Elements/Compound/DoubleWrap.php deleted file mode 100755 index 91c690d..0000000 --- a/src/UIKit/Elements/Compound/DoubleWrap.php +++ /dev/null @@ -1,47 +0,0 @@ -content = $content; - } - - public function outer(string $outer, string ...$outerAttr): DoubleWrap - { - $this->outerElement = $outer; - $this->outerAttr = $outerAttr; - return $this; - } - - public function inner(string $inner, string ...$innerAttr): DoubleWrap - { - $this->innerElement = $inner; - $this->innerAttr = $innerAttr; - return $this; - } - - public function unfold(string ...$attributes): string - { - return UIKit::{$this->outerElement}( - UIKit::{$this->innerElement}( - ...$this->content - )->attr(...$this->innerAttr) - )->attr(...$this->outerAttr)->unfold(...$attributes); - } -} diff --git a/src/UIKit/Elements/Compound/Markdown.php b/src/UIKit/Elements/Compound/Markdown.php deleted file mode 100755 index 365b1cd..0000000 --- a/src/UIKit/Elements/Compound/Markdown.php +++ /dev/null @@ -1,92 +0,0 @@ -config = $config; - $this->markdown = $markdown; - } - - public function caseSensitive($caseSensitive = true) - { - $this->caseSensitive = $caseSensitive; - - return $this; - } - - public function markdownReplacements($replacements = []) - { - $this->markdownReplacements = $replacements; - - return $this; - } - - public function htmlReplacements($replacements = []) - { - $this->htmlReplacements = $replacements; - - return $this; - } - - public function trim($trim = true) - { - $this->trim = $trim; - - return $this; - } - - public function minified($minified = true) - { - $this->minified = $minified; - - return $this; - } - - public function extensions(...$extensions) - { - $this->extensions = Shoop::this($extensions) - ->drop(fn($v) => empty($v))->unfold(); - - return $this; - } - - public function prepend(string $markdown) - { - $this->markdown = $markdown . $this->markdown; - - return $this; - } - - public function meta() - { - return Shoop::markdown($this->markdown)->meta(); - } - - public function unfold(): string - { - return Shoop::markdown($this->markdown, ...$this->extensions) - ->html( - $this->markdownReplacements, - $this->htmlReplacements, - $this->caseSensitive, - $this->minified, - $this->config - )->unfold(); - } -} diff --git a/src/UIKit/Elements/Compound/Pagination.php b/src/UIKit/Elements/Compound/Pagination.php deleted file mode 100644 index 03279e7..0000000 --- a/src/UIKit/Elements/Compound/Pagination.php +++ /dev/null @@ -1,230 +0,0 @@ -totalItems = Type::sanitizeType($totalItems, ESInt::class); - $this->totalItemsPerPage = Type::sanitizeType($totalItemsPerPage, ESInt::class); - $this->middleLimit = Type::sanitizeType($middleLimit, ESInt::class) - ->isOdd(function($result, $int) { - return ($result->unfold()) ? $int : $int->plus(1); - }); - - $this->currentPage = Type::sanitizeType($currentPage, ESInt::class); - - $this->linkPrefix = Type::sanitizeType($linkPrefix, ESString::class); - } - - public function totalItems(): ESInt - { - return $this->totalItems; - } - - public function totalItemsPerPage(): ESInt - { - return $this->totalItemsPerPage; - } - - public function middleLimit() - { - return $this->middleLimit; - } - - public function currentPage(): ESInt - { - return $this->currentPage; - } - - public function linkPrefix(): ESString - { - return $this->linkPrefix; - } - - public function totalPages(): ESInt - { - return Shoop::int($this->totalItems())->roundUp($this->totalItemsPerPage); - } - - public function totalLinksToDisplay() - { - $total = $this->totalItems()->roundDown($this->totalItemsPerPage()); - if ($total->isGreaterThanUnfolded($this->middleLimit())) { - return $this->middleLimit()->plus(2); - } - return $this->totalItems()->roundDown($this->totalItemsPerPage()); - } - - public function totalMiddleSurrounding() - { - return $this->middleLimit()->roundDown(2); - } - public function firstPageNumber() - { - return Shoop::int(1); - } - - public function lastPageNumber() - { - return $this->totalPages(); - } - - public function secondPageNumber() - { - if ($this->totalLinksToDisplay()->isLessThanOrEqualUnfolded(2)) { - // if the number of pages is less than or equal to 2 always return 0 - return Shoop::int(0); - - } elseif ($this->currentPage()->minus($this->totalMiddleSurrounding())->isLessThanOrEqualUnfolded(2)) { - // if the number of pages is less than middleLimit + 2 always return 2 - // 1 2 3 4 5* 6 ... 10 - return Shoop::int(2); - - } elseif ($this->currentPage()->isGreaterThanUnfolded($this->totalPages()->minus($this->middleLimit())->plus(1))) { - // if the current page is greater than or equal to totalPages - middleLimit + 1 always return - // totalPages - middleLimit + 1 - // 1 ... 5 6 7 8* 9 10 - return $this->totalPages()->minus($this->middleLimit()); - - } else { - // 1 ... 4 5 6* 7 8 ... 10 - return $this->currentPage()->minus($this->totalMiddleSurrounding()); - - } - } - - public function penultimatePageNumber() - { - if ($this->totalLinksToDisplay()->isLessThanOrEqualUnfolded(2)) { - // if the number of pages is less than or equal to 2 always return 0 - return Shoop::int(0); - - } elseif ($this->totalPages()->isLessThanOrEqualUnfolded($this->firstPageNumber()->plus($this->totalMiddleSurrounding()))) { - return $this->totalPages()->minus(1); - - } else { - return $this->secondPageNumber()->plus($this->middleLimit()->minus(1)) - ->isGreaterThanOrEqual($this->totalPages(), function($result, $int) { - if ($result->unfold()) { - return $this->totalPages()->minus(1); - } - return $this->secondPageNumber()->plus($this->middleLimit() - ->minus(1)); - }); - } - } - - public function middleRange() - { - return $this->secondPageNumber()->asArray($this->penultimatePageNumber()) - ->noEmpties()->reindex(); - } - - public function unfold(): string - { - if ($this->totalPages()->isUnfolded(1)) { - return ""; - - } elseif ($this->totalPages()->isUnfolded(2)) { - return UIKit::nav( - UIKit::listWith( - UIKit::listWith(... - Shoop::array([$this->anchorFor(1), $this->anchorFor(2)]) - )->attr("class page-links") - ) - )->attr("class pagination"); - - } - - $previous = $this->anchorFor(1); - if ($this->currentPage()->minus(1)->isGreaterThanUnfolded(1)) { - $previous = $this->anchorFor($this->currentPage()->minus(1)); - - } elseif ($this->currentPage()->isUnfolded(1)) { - $previous = ""; - - } - - $next = $this->anchorFor($this->currentPage()->plus(1)); - if ($this->currentPage()->plus(1)->isGreaterThanUnfolded($this->totalPages())) { - $next = $this->anchorFor($this->totalPages()); - - } elseif ($this->currentPage()->isUnfolded($this->totalPages())) { - $next = ""; - - } - - $links = $this->secondPageNumber()->asArray($this->penultimatePageNumber()) - ->each(function($pageNumber) { - return $this->anchorFor($pageNumber); - })->start($this->anchorFor(1))->end($this->anchorFor($this->totalPages())); - - $hasPrevious = $this->currentPage()->isGreaterThanUnfolded(1); - $hasNext = $this->currentPage()->isLessThanUnfolded($this->totalPages()); - - $navClass = "class pagination next previous"; // both - if (! $hasNext and $hasPrevious) { - $navClass = "class pagination previous"; - - } elseif ($hasNext and ! $hasPrevious) { - $navClass = "class pagination next"; - - } - - return UIKit::nav( - UIKit::listWith(... - Shoop::array([$previous, $next])->plus(...$links)->noEmpties() - ) - )->attr($navClass); - } - - private function anchorFor($pageNumber, $isNext = false, $isPrevious = false) - { - $pageNumber = Type::sanitizeType($pageNumber, ESInt::class)->unfold(); - $isNext = Type::sanitizeType($isNext, ESBool::class)->unfold(); - $isPrevious = Type::sanitizeType($isPrevious, ESBool::class)->unfold(); - $link = UIKit::anchor( - $pageNumber, - $this->linkPrefix->plus("/{$pageNumber}") - )->attr("aria-label Goto page {$pageNumber}"); - if ($this->currentPage->isUnfolded($pageNumber)) { - $link = $link->attr( - "aria-label Current page, page {$pageNumber}", - "aria-current true", - "class current" - ); - - } elseif ($isNext and ! $isPrevious) { - $link = $link->attr("class next"); - - } elseif (! $isNext and $isPrevious) { - $link = $link->attr("class previous"); - - } - return $link; - } -} diff --git a/src/UIKit/Elements/Compound/SocialMeta.php b/src/UIKit/Elements/Compound/SocialMeta.php deleted file mode 100644 index 89cbbad..0000000 --- a/src/UIKit/Elements/Compound/SocialMeta.php +++ /dev/null @@ -1,75 +0,0 @@ -args = [$title, $url, $description, $image, $type, $appId]; - $this->meta = Shoop::this([ - "og:type" => $type, - "og:title" => $title, - "og:url" => $url, - "og:description" => (Shoop::this($description)->efIsEmpty()) ? "Description unavailable" : $description - ]); - - if (Shoop::this($image)->isEmpty()->reversed()->unfold()) { - $this->meta = $this->meta->append(["og:image" => $image]); - } - - if (Shoop::this($appId)->isEmpty()->reversed()->unfold()) { - $this->meta = $this->meta->append(["og:app_id" => $appId]); - } - } - - public function twitter($site = "", $card = "summary_large_image") - { - $this->meta = $this->meta->append(["twitter:card" => $card]); - if (Shoop::this($site)->isEmpty()->reversed()->unfold()) { - $this->meta = $this->meta->append(["twitter:site" => $site]); - } - return $this; - } - - public function unfold(): string - { - return $this->meta->each(function($v, $m, &$build) { - $build[] = (Shoop::this($m)->efStartsWith("og:")) - ? Html::meta()->attr("property {$m}", "content {$v}")->unfold() - : Html::meta()->attr("name {$m}", "content {$v}")->unfold(); - }); - } -} diff --git a/src/UIKit/Elements/Compound/WebHead.php b/src/UIKit/Elements/Compound/WebHead.php deleted file mode 100644 index 5e7f03e..0000000 --- a/src/UIKit/Elements/Compound/WebHead.php +++ /dev/null @@ -1,150 +0,0 @@ -favicons = Shoop::this([]); - $this->styles = Shoop::this([]); - $this->scripts = Shoop::this([]); - $this->favicons = Shoop::this([]); - $this->social = Shoop::this([]); - } - - /** - * - * @param string $baseIcon ico - base icon - * @param string $appleTouch No specific image type required - for apple touch devices - * @param string $icon32 PNG only - 32px varient (Android) - * @param string $icon16 PNG only - 16px varient (Android) - * - * @return this - */ - public function favicons( - string $baseIcon, - string $appleTouch = "", - string $icon32 = "", - string $icon16 = "" - ) - { - $this->favicons = Shoop::this([ - Html::link()->attr("type image/x-icon", "rel icon", "href {$baseIcon}") - ]); - - if (Shoop::this($appleTouch)->efToBoolean()) { - $this->favicons = $this->favicons->append( - [ - Html::link() - ->attr("rel apple-touch-icon", "href {$appleTouch}", "sizes 180x180") - ] - ); - } - - if (Shoop::this($icon32)->efToBoolean()) { - $this->favicons = $this->favicons->append( - [ - Html::link() - ->attr("rel image/png", "href {$icon32}", "sizes 32x32") - ] - ); - } - - if (Shoop::this($icon16)->efToBoolean()) { - $this->favicons = $this->favicons->append( - [ - Html::link()->attr("rel image/png", "href {$icon16}", "sizes 16x16") - ] - ); - } - return $this; - } - - public function styles(...$paths) - { - $this->styles = Shoop::this($paths)->each(function($v) { - return Html::link()->attr("rel stylesheet", "href {$v}"); - }); - return $this; - } - - public function scripts(...$paths) - { - $this->scripts = Shoop::this($paths)->each(function($v) { - return Html::script()->attr("src {$v}"); - }); - return $this; - } - - public function social( - string $title, - string $url, - string $description, - string $image = "", - string $type = "website", - string $appId = "" - ) - { - $this->social = UIKit::socialMeta( - $title, - $url, - $description, - $image, - $type, - $appId - ); - return $this; - } - - public function socialTwitter( - string $twitterHandle = "", - string $twitterCard = "summary_large_image" - ) - { - $this->social = $this->social->twitter($twitterHandle, $twitterCard); - return $this; - } - - public function unfold(): string - { - $base = Html::meta()->attr( - "name viewport", - "content width=device-width,initial-scale=1" - )->unfold(); - $favicons = $this->favicons->unfold(); - $social = $this->social->unfold(); - $styles = $this->styles->unfold(); - $scripts = $this->scripts->unfold(); - - return Shoop::this([$base]) - ->append($favicons) - ->append([$social]) - ->append($styles) - ->append($scripts) - ->each(function($v) { - if (Shoop::this($v)->efIsString()) { - return $v; - - } elseif (is_a($v, Foldable::class)) { - return $v->unfold(); - - } - })->efToString(); - } -} diff --git a/src/UIKit/Elements/Pages/WebView.php b/src/UIKit/Elements/Pages/WebView.php deleted file mode 100755 index 6b3f817..0000000 --- a/src/UIKit/Elements/Pages/WebView.php +++ /dev/null @@ -1,51 +0,0 @@ -title = $title; - $this->content = $content; - } - - public function unfold(): string - { - $string = UIKit::html( - UIKit::head(...Shoop::this([ - UIKit::title($this->title) - ])->append($this->meta) - ), - UIKit::body(...$this->content)->attr(...$this->bodyAttributes) - )->unfold(); - - return "". $string; - } - - public function meta(...$meta) - { - $this->meta = $meta; - return $this; - } - - public function bodyAttr(string ...$attributes) - { - $this->bodyAttributes = $attributes; - return $this; - } -} diff --git a/src/UIKit/Elements/Simple/Anchor.php b/src/UIKit/Elements/Simple/Anchor.php deleted file mode 100755 index a73127a..0000000 --- a/src/UIKit/Elements/Simple/Anchor.php +++ /dev/null @@ -1,22 +0,0 @@ -main)->attr(...$this->attributes)->unfold(); - } -} - diff --git a/src/UIKit/Elements/Simple/Image.php b/src/UIKit/Elements/Simple/Image.php deleted file mode 100755 index 3852c12..0000000 --- a/src/UIKit/Elements/Simple/Image.php +++ /dev/null @@ -1,20 +0,0 @@ -attr("alt {$alt}", "src {$src}"); - } - - public function unfold(): string - { - return Html::img()->attr(...$this->attributes)->unfold(); - } -} diff --git a/src/UIKit/Elements/Simple/PageTitle.php b/src/UIKit/Elements/Simple/PageTitle.php deleted file mode 100755 index cc287a9..0000000 --- a/src/UIKit/Elements/Simple/PageTitle.php +++ /dev/null @@ -1,56 +0,0 @@ -main = $titleParts; - - $this->separater = $separater; - } - - public function unfold(): string - { - if (count($this->main) === 0) { - return ""; - } - - if ($this->reversed) { - $this->main = array_reverse($this->main); - } - - $string = implode($this->separater, $this->main); - - if ($this->stringOnly) { - return $string; - } - - return Html::title($string)->attr(...$this->attributes)->unfold(); - } - - public function reversed(): PageTitle - { - $this->reversed = true; - return $this; - } - - public function stringOnly(): PageTitle - { - $this->stringOnly = true; - return $this; - } -} diff --git a/src/UIKit/Elements/Simple/SimpleList.php b/src/UIKit/Elements/Simple/SimpleList.php deleted file mode 100755 index 4dc82cd..0000000 --- a/src/UIKit/Elements/Simple/SimpleList.php +++ /dev/null @@ -1,87 +0,0 @@ -main = $items; - } - - public function unfold(): string - { - if (count($this->main) === 0) { - return ""; - } - - $container = 'ul'; - if ($this->type == 'ordered') { - $container = 'ol'; - - } elseif ($this->type == 'description') { - $container = 'dl'; - - } - - $listItems = $this->listItems($this->main); - return Html::$container(...$listItems)->attr(...$this->attributes)->unfold(); - } - - public function ordered(): SimpleList - { - $this->type = 'ordered'; - return $this; - } - - public function description(int ...$terms): SimpleList - { - $this->type = 'description'; - $this->descriptionTerms = $terms; - return $this; - } - - private function listItems(array $content) - { - $count = 0; - $listItems = []; - foreach ($content as $index => $item) { - if ($this->type == 'unordered' || $this->type == 'ordered') { - $listItems[] = Html::li($item); - - } else { - $count++; - - if (count($this->descriptionTerms) == 0) { - if ($count % 2 == 0) { - $items = Html::dd($item); - - } else { - $items = Html::dt($item); - - } - - } elseif (in_array($index + 1, $this->descriptionTerms)) { - $items = Html::dt($item); - - - } else { - $items = Html::dd($item); - - } - $listItems[] = $items; - } - } - return $listItems; - } -} diff --git a/tests/AnchorTest.php b/tests/AnchorTest.php new file mode 100755 index 0000000..9a1b6f2 --- /dev/null +++ b/tests/AnchorTest.php @@ -0,0 +1,48 @@ +assertEquals( + (string) Anchor::create('link content', 'https://8fold.pro') + ->props('class some-class', 'id some-id'), + 'link content' + ); + } + + /** + * @test + */ + public function anchor_can_have_custom_properties(): void + { + $this->assertEquals( + Anchor::create('link content', 'https://8fold.pro') + ->props('class some-class', 'id some-id') + ->build(), + 'link content' + ); + } + + /** + * @test + */ + public function anchor_returns_correct_element_with_required_parts(): void + { + $this->assertEquals( + Anchor::create('link content', 'https://8fold.pro')->build(), + 'link content' + ); + } +} diff --git a/tests/Element/ElementTest.php b/tests/Element/ElementTest.php deleted file mode 100644 index 2f315c7..0000000 --- a/tests/Element/ElementTest.php +++ /dev/null @@ -1,186 +0,0 @@ -', - "string", - 14.76, // 14.59, // shoopified 7.17, // 5.29, // 4.56, // 4.02, - 475 // 437 // 436 // 433 // 427 // 426 // 401 // 397 // 394 // 393 - )->unfoldUsing( - Element::fold("container")->attr("id hello")->omitEndTag(true) - ); - - AssertEquals::applyWith( - '', - "string", - 3.36, // 1.9, // 0.85, // 0.5, // 0.42, // 0.27, // 0.26, // 0.25, - 1 - )->unfoldUsing( - Element::fold("container")->attr("id hello")->omitEndTag(true) - ->attr("id goodbye") - ); - - AssertEquals::applyWith( - '', - "string", - 4.33, // 3.68, // 3.61, - 374 - )->unfoldUsing( - Element::fold("html") - ); - - AssertEquals::applyWith( - '

Hello, World!

', - "string", - 11.26, // 7.08, // 3.95, - 470 // 311 - )->unfoldUsing( - Element::fold("p", - Element::fold("span", "Hello, World!") - )->unfold() - ); - } - - /** - * @test - */ - public function self_contained_element() - { - AssertEquals::applyWith( - '', - "string", - 4.08, // 3.35, // 3.33, - 304 // 300 - )->unfoldUsing( - new Element("img", [], true) - ); - - AssertEquals::applyWith( - 'description', - "string", - 4.47, // 4.46, - 393 - )->unfoldUsing( - new Element("img", ["src /path", "alt description"], true) - ); - - AssertEquals::applyWith( - '', - "string", - 1.38, // 1.33, // 1.25, // 1.23, // 1.21, // 1.03, // 0.32, // 0.3, // 0.27, // 0.21, // 0.2, - 1 - )->unfoldUsing( - new Element("a", ["href /path"], false) - ); - } - - /** - * @test - */ - public function element_only_arguments() - { - AssertEquals::applyWith( - [[], false], - "array", - 3.56, // 3.42, - 305 - )->unfoldUsing( - Element::fold("hello")->args() - ); - } - - /** - * @test - */ - public function attribute_list() - { - AssertEquals::applyWith( - ["id" => "hello"], - "array", - 4.54, // 3.84, // 3.45, // 3.43, // 0.001 - 307 - )->unfoldUsing( - AttrDictionary::apply()->unfoldUsing(["id hello"]) - ); - - AssertEquals::applyWith( - ["id hello"], - "array", - 0.23, // 0.18, - 15 - )->unfoldUsing( - (new Element("hello", ["id hello"]))->attrList() - ); - - AssertEquals::applyWith( - ["id" => "hello"], - "array", - 0.35, // 0.28, // 0.21, // 0.07, - 1 - )->unfoldUsing( - (new Element("hello", ["id hello"]))->attrList(false) - ); - - AssertEquals::applyWith( - ["id" => "hello"], - "array", - 1.09, // 1.01, // 1, // 0.94, // 0.86, // 0.81, // 0.42, // 0.25, // 0.21, // 0.18, // 0.17, // increase shoop 0.13, // 0.11, // 0.09, - 1 - )->unfoldUsing( - Element::fold("hello")->attr("id hello")->attrList(false) - ); - } - - /** - * @test - */ - public function testPage() - { - AssertEquals::applyWith( - 'Hello, World!A picture of the world

Hello, World!

World Domination

Done!

', - "string", - 16.26, // 13.11, // 5.71, - 397 - )->unfoldUsing( - Element::fold('html', - Element::fold('head', - Element::fold('title', 'Hello, World!'), - Element::fold('style') - ), - Element::fold('body', - Element::fold('img') - ->omitEndTag(true) - ->attr( - 'src http://example.com', - 'alt A picture of the world' - ), - Element::fold('p', 'Hello, World!')->attr("is my-component", "required required"), - Element::fold("my-link", 'World Domination') - ->attr('href http://example.com/domination'), - '

Done!

' - ) - )->unfold() - ); - } -} diff --git a/tests/Feed/Rss/RssTest.php b/tests/Feed/Rss/RssTest.php deleted file mode 100644 index 5105b04..0000000 --- a/tests/Feed/Rss/RssTest.php +++ /dev/null @@ -1,56 +0,0 @@ -'."\n".'Titlehttps://8fold.devDescription of content.'; - $actual = Feed::rss( - "Title", - "https://8fold.dev", - "Description of content." - ); - $this->assertSame($expected, $actual->unfold()); - - $expected = ''."\n".'Titlehttps://8fold.devDescription of content.en-us'; - $actual = $actual->language(); - $this->assertSame($expected, $actual->unfold()); - } - - /** - * @test - */ - public function item() - { - $expected = 'Titlehttps://8fold.devHello. How are you, won\'t you tell me your name?...'; - $actual = Feed::rssItem("Title", "https://8fold.dev", "

Hello. How are you, won't you tell me your name?

"); - $this->assertSame($expected, $actual->unfold()); - - $expected = 'Titlehttps://8fold.devHello....'; - $actual = $actual->descriptionLimit(1); - $this->assertSame($expected, $actual->unfold()); - - $expected = 'Titlehttps://8fold.devHello. How are you,...'; - $actual = $actual->descriptionLimit(4); - $this->assertSame($expected, $actual->unfold()); - - $expected = 'Titlehttps://8fold.devHello. How are you,...'; - $actual = $actual->date(20200402); - $this->assertSame($expected, $actual->unfold()); - } -} diff --git a/tests/Html/HtmlElementTest.php b/tests/Html/HtmlElementTest.php deleted file mode 100644 index bbcefe2..0000000 --- a/tests/Html/HtmlElementTest.php +++ /dev/null @@ -1,191 +0,0 @@ -Hello

', - "string", - 10.52, // 10.03, // 9.89, // 9.69, // 8.42, // 8.34, // 7.8, // 7.38, // updated shoop 8.11 // 7.82 // 7.6 // 6.85 - 559 - )->unfoldUsing( - Html::p('Hello') - ->attr( - 'role alert', - 'accesskey S', - 'tabindex 1', - 'type some_type', - 'style background: red;', - 'class somethingElse somethingElse2', - 'id something') - ->unfold() - ); - } - - /** - * @test - */ - public function full_page() - { - AssertEquals::applyWith( - '
', - "string", - 4.12, // 3.19, // 2.48, // 1.99, // 1.48, // 1.29, // updated shoop 5.24 // 4.98 - 1 - )->unfoldUsing( - Html::div(Html::div())->unfold() - ); - - AssertEquals::applyWith( - 'Hello, World!A picture of the world

Hello, World!

World Domination

Done!

', - "string", - 20.44, // 18.93, // 18.84, // 18.13, // 17.62, // 15.45, // 8.56, // 7.07, // 6.69, // 6.64, // 6.59, // 6.11, // 5.53, // 5.34, // 9.56 // 7.14 // 6.94 - 1 - )->unfoldUsing( - Html::html( - Html::head( - Html::title('Hello, World!') - , Html::style() - ) - , Html::body( - Html::img() - ->attr('src http://example.com', 'alt A picture of the world') - , Html::p('Hello, World!') - ->attr("is my-component") - , Html::my_link('World Domination') - ->attr('href http://example.com/domination') - , '

Done!

' - ) - )->unfold() - ); - } - - /** - * @test - */ - public function child_elements_omitting_end_tag() - { - AssertEquals::applyWith( - '', - "string", - 15.21, // 12.75, // 12.57, // 9.17, // 5.34, // 4.11, // 3.51, // 3.01, // updated shoop 6.87 // 6.67 // 6.24 - 1 - )->unfoldUsing( - Html::object( - Html::param() - ->attr('name hello', 'value world'), - Html::param() - ->attr('name you', 'value are'), - Html::param() - ->attr('name awesome', 'value today!') - )->unfold() - ); - - AssertEquals::applyWith( - '
', - "string", - 1.3, // 0.5, // 0.46, // 0.44, // 1.44 - 1 - )->unfoldUsing( - Html::hr()->unfold() - ); - - AssertEquals::applyWith( - 'Hello, World!', - "string", - 12.1, // 11.66, // 10.72, // 8.63, // 8.37, // 4.93, // 4.86, // 4.73, // 4.01, // 3.14, // 2.84, // 5.24 - 1 - )->unfoldUsing( - Html::head( - Html::title('Hello, World!'), - Html::link()->attr('rel stylesheet', 'href #'), - Html::link()->attr('href #', 'rel stylesheet') - )->unfold() - ); - } - - /** - * @test - */ - public function nested_elements_with_string() - { - AssertEquals::applyWith( - '
  • Hello
    1. My name is:
', - "string", - 16.17, // 10.23, // 8.76, // 8.22, // 6.19, // 4.95, // 4.16, // 3.04, // 3, // 2.88, // 2.78, // 2.53, // updated shoop 7.24 - 1 - )->unfoldUsing( - Html::ul( - Html::li( - 'Hello' - , Html::ol( - Html::li('My name is:') - ) - ) - )->unfold() - ); - - AssertEquals::applyWith( - 'Hello', - "string", - 4.87, // 4.5, // 4.04, // 3.99, // 3.93, // 3.9, // 3.75, // 3.32, // 1.76, // 1.6, // 1.56, // 1.21, // 1.13, // 0.97, // 0.87, // 2.37 - 1 - )->unfoldUsing( - Html::a('Hello')->attr('class some-class', 'href http://example.com') - ->unfold() - ); - } - - /** - * @test - */ - public function all_passed_attributes_end_up_in_the_element() - { - AssertEquals::applyWith( - '', - "string", - 10.55, // 3, // 2.83, // 2.24, // 2.09, // 1.12, // 0.95, // 0.85, // 0.78, // updated shoop 4.13 // 6.15 // 6.12 // 5.76 - 1 - )->unfoldUsing( - Html::body()->attr("role document")->unfold() - ); - - AssertEquals::applyWith( - '', - "string", - 6.98, // 3.25, // 2.81, // 2.59, // 2.56, // 2.29, // 1.95, // 1.52, // 0.9, // 0.85, // 0.83, // 0.75, // 0.72, // 0.67, // 0.8 // 0.74 // 0.72 // 0.58 // 0.56 // 0.32 // 0.64 // 0.53 // 0.41 - 1 - )->unfoldUsing( - Html::body()->attr("role application")->unfold() - ); - - AssertEquals::applyWith( - '', - "string", - 3.02, // 2.61, // 2.28, // 1.17, // 0.9, // 0.72, // 0.76 // 0.7 // 0.68 // 0.57 // 0.25 // 0.19 // 5.85 - 1 - )->unfoldUsing( - Html::body()->attr("id acceptable")->unfold() - ); - } -} diff --git a/tests/ImageTest.php b/tests/ImageTest.php new file mode 100755 index 0000000..ab64be8 --- /dev/null +++ b/tests/ImageTest.php @@ -0,0 +1,48 @@ +assertEquals( + (string) Image::create('alt content', 'https://8fold.pro') + ->props('class some-class', 'id some-id'), + 'alt content' + ); + } + + /** + * @test + */ + public function image_can_have_custom_properties(): void + { + $this->assertEquals( + Image::create('alt content', 'https://8fold.pro') + ->props('class some-class', 'id some-id') + ->build(), + 'alt content' + ); + } + + /** + * @test + */ + public function image_returns_correct_element_with_required_parts(): void + { + $this->assertEquals( + Image::create('alt content', 'https://8fold.pro')->build(), + 'alt content' + ); + } +} diff --git a/tests/PageTitleTest.php b/tests/PageTitleTest.php new file mode 100755 index 0000000..3ea7ecb --- /dev/null +++ b/tests/PageTitleTest.php @@ -0,0 +1,69 @@ +assertEquals( + (string) PageTitle::create(['Hello!', 'How are you?'], ' : ') + ->reversed(), + 'How are you? : Hello!' + ); + } + + /** + * @test + */ + public function page_title_can_return_with_tag(): void + { + $this->assertEquals( + PageTitle::create(['Hello!', 'How are you?'], ' : ')->reversed() + ->stringOnly()->build(), + 'How are you? : Hello!' + ); + } + + /** + * @test + */ + public function page_title_respects_custom_separator(): void + { + $this->assertEquals( + PageTitle::create(['Hello!', 'How are you?'], ' : ')->build(), + 'Hello! : How are you?' + ); + } + + /** + * @test + */ + public function page_title_can_have_multiple_parts(): void + { + $this->assertEquals( + PageTitle::create(['Hello!', 'How are you?'])->build(), + 'Hello! | How are you?' + ); + } + + /** + * @test + */ + public function page_title_returns_correct_element(): void + { + $this->assertEquals( + PageTitle::create(['Hello!'])->build(), + 'Hello!' + ); + } +} diff --git a/tests/SimpleListTest.php b/tests/SimpleListTest.php new file mode 100755 index 0000000..68c7e5b --- /dev/null +++ b/tests/SimpleListTest.php @@ -0,0 +1,65 @@ +assertEquals( + (string) SimpleList::create('list item'), + '
  • list item
' + ); + } + + /** + * @test + */ + public function list_can_have_custom_properties(): void + { + $this->assertEquals( + SimpleList::create( + 'list item', + Anchor::create('hello', 'file://example.pdf') + )->props('class some-class', 'id some-id')->build(), + '' + ); + } + + /** + * @test + */ + public function list_can_be_ordered(): void + { + $this->assertEquals( + SimpleList::create( + 'list item' + )->ordered()->build(), + '
  1. list item
' + ); + } + + /** + * @test + */ + public function list_returns_correct_default_element_with_required_parts(): void + { + $this->assertEquals( + SimpleList::create( + 'list item' + )->build(), + '
  • list item
' + ); + } +} diff --git a/tests/UIKit/CompoundTest.php b/tests/UIKit/CompoundTest.php deleted file mode 100755 index 6eec9a1..0000000 --- a/tests/UIKit/CompoundTest.php +++ /dev/null @@ -1,109 +0,0 @@ -
', - "string", - 20.36, // 9.97, // 7.79 - 578 // 573 - )->unfoldUsing( - UIKit::doubleWrap() - ); - } - - /** - * @test - */ - public function web_head() - { - // For 0.2.0 was 10.25 - AssertEquals::applyWith( - '', - "string", - 7.78, - 549 // 547 - )->unfoldUsing( - UIKit::webHead() - ); - - // For 0.2.0 was 23.25 - AssertEquals::applyWith( - '', - "string", - 41.86, // 22.09, // 13.62, - 596 // 594 // 588 - )->unfoldUsing( - UIKit::webHead()->favicons( - "favicon.ico", - "apple-touch-icon.png", - "favicon-32x32.png", - "favicon-16x16.png" - ) - ); - - // For 0.2.0 was 24ms - AssertEquals::applyWith( - '', - "string", - 14.36, // 14.24, // 14.08, // 13.84, // 13.31, // 10.88, // 6.17, // 5.86, // 5.14, // 4.95, // 4.47, // 3.73, - 4 // 3 - )->unfoldUsing( - UIKit::webHead() - ->favicons("favicon.ico") - ->styles("main.css") - ->scripts("main.js") - ); - - // For 0.2.0 was 25ms - AssertEquals::applyWith( - '', - "string", - 27.96, // 24.18, // 22.08, // 21.04, // 19.46, // 14.88, // 12.25, // 7.47, - 570 - )->unfoldUsing( - UIKit::webHead()->social( - "8fold PHP Markup", - "https://8fold.dev/open-source/markup/php", - "Get the HTML out of your PHP with this HTML generator." - )->socialTwitter("8foldPros") - ); - } - - /** - * @test - */ - public function accordion() - { - $summaryId = "accordion"; - $summary = "Summary"; - $content = UIKit::p("The content."); - - // For 0.2.0 was 24ms - AssertEquals::applyWith( - '

'. $content->unfold() .'
', - "string", - 18.54, // 17.82, // 17.66, // 17.01, // 13.7, // 7.36, // 5.78 - 13 - )->unfoldUsing( - UIKit::accordion($summaryId, $summary, $content) - ); - } -} diff --git a/tests/UIKit/MarkdownTest.php b/tests/UIKit/MarkdownTest.php deleted file mode 100755 index 04dd1d3..0000000 --- a/tests/UIKit/MarkdownTest.php +++ /dev/null @@ -1,139 +0,0 @@ -Heading

Content

', - "string", - 30.48, // 13.06, // 12.69, // 11.83, // 11.8, - 1868 // 1758 // 1658 // 1100 - )->unfoldUsing( - UIKit::markdown($this->doc()) - ); - - AssertEquals::applyWith( - '

Hello, World!

', - "string", - 0.99, // 0.84, // 0.22, // 0.18, // 0.16, - 42 // 39 - )->unfoldUsing( - UIKit::markdown("Hello, World!") - ); - } - - /** - * @test - */ - public function replacements() - { - AssertEquals::applyWith( - '

Heading

Content

', - "string", - 12.97, // 11.24, - 1092 - )->unfoldUsing( - UIKit::markdown($this->doc()) - ->markdownReplacements(["# " => ""]) - ); - - AssertEquals::applyWith( - 'Content', - "string", - 12.55, // 11.83, - 1091 - )->unfoldUsing( - UIKit::markdown($this->doc()) - ->markdownReplacements(["# Heading" => ""]) - ->htmlReplacements(["

" => "", "

" => ""]) - ); - } - - /** - * @test - */ - public function remove() - { - AssertEquals::applyWith( - '

Content

', - "string", - 13.33, - 1091 - )->unfoldUsing( - UIKit::markdown($this->doc()) - ->markdownReplacements(["# Heading" => ""]) - ); - } - - /** - * @test - */ - public function default_extensions() - { - $expected = '
Header 1Header 2
Cell 1Cell 2
'; - - AssertEquals::applyWith( - $expected, - "string", - 21.68, - 1459 - )->unfoldUsing( - UIKit::markdown($this->docTable())->extensions( - new TableExtension() - ) - ); - } - - /** - * @test - */ - public function testCanPrepend() - { - $doc = <<< EOD - Base - EOD; - - AssertEquals::applyWith( - '

Heading

Base

', - "string", - 1.21, // 0.98, // 0.88, // 0.86, // 0.59, // 0.47, - 48 - )->unfoldUsing( - UIKit::markdown($doc)->prepend("# Heading\n\n") - ); - } -} diff --git a/tests/UIKit/PageTest.php b/tests/UIKit/PageTest.php deleted file mode 100755 index 5af9945..0000000 --- a/tests/UIKit/PageTest.php +++ /dev/null @@ -1,39 +0,0 @@ -UIKit

Hello, World!

', - "string", - 26.99, // 18.66, // 17.82, // 17.28, // 13.74, // 10.21 // 9.69 // 9.46 - 596 - )->unfoldUsing( - UIKit::webView( - "UIKit", - UIKit::p("Hello, World!") - )->meta( - UIKit::meta()->attr("charset utf-8"), - UIKit::meta()->attr( - "name viewport", - "content width=device-width, initial-scale=1" - ) - )->bodyAttr("class theme") - ); - } -} diff --git a/tests/UIKit/SimpleTest.php b/tests/UIKit/SimpleTest.php deleted file mode 100755 index d551355..0000000 --- a/tests/UIKit/SimpleTest.php +++ /dev/null @@ -1,175 +0,0 @@ -Hello!

', - "string", - 8.48, // 7.75, // 7.29, - 573 - )->unfoldUsing( - UIKit::p("Hello!") - ); - } - - /** - * @test - */ - public function page_title() - { - AssertEquals::applyWith( - 'Hello, World!', - "string", - 3.31, // 2.31, // 0.91, // 0.71, // 0.6, - 5 // 4 - )->unfoldUsing( - UIKit::pageTitle(["Hello, World!"]) - ); - - AssertEquals::applyWith( - 'How are you? | Hello, World!', - "string", - 2.13, // 1.94, // 1.66, // 0.91, // 0.71, // 0.6, - 3 - )->unfoldUsing( - UIKit::pageTitle(["How are you?", "Hello, World!"]) - ); - - AssertEquals::applyWith( - 'How are you? : Hello, World!', - "string", - 1.95, // 1.82, // 0.91, // 0.71, // 0.6, - 3 - )->unfoldUsing( - UIKit::pageTitle(["Hello, World!", "How are you?"], " : ")->reversed() - ); - - AssertEquals::applyWith( - 'How are you? : Hello, World!', - "string", - 1.95, // 1.82, // 0.91, // 0.71, // 0.6, - 3 - )->unfoldUsing( - UIKit::pageTitle(["Hello, World!", "How are you?"], " : ")->reversed()->stringOnly() - ); - } - - /** - * @test - */ - public function anchor() - { - // For 0.2.0 was 13.5ms - AssertEquals::applyWith( - 'Hello, World!', - "string", - 9.69, // 4.49, - 18 - )->unfoldUsing( - UIKit::anchor( - 'Hello, World!', - 'http://example.com' - )->unfold() - ); - - AssertEquals::applyWith( - 'Hello, World!', - "string", - 5.93, // 5.06, // 4.04, // 1.97, // 1.76, // 1.55, // 1.33, - 1.09 - )->unfoldUsing( - UIKit::anchor( - "Hello, World!", - "http://example.com" - )->attr("id hello")->unfold() - ); - } - - /** - * @test - */ - public function simple_lists() - { - AssertEquals::applyWith( - '
  • hello
  • good-bye
', - "string", - 11.32, // 6.34, // 4.93, // 4.69, // 3.8, - 73 // 72 // 8 - )->unfoldUsing( - UIKit::listWith( - "hello", - "good-bye" - )->unfold() - ); - - AssertEquals::applyWith( - '
  1. hello
  2. good-bye
', - "string", - 10.88, // 6.43, // 5.99, // 5.6, // 5.11, // 3.65, // 3.59, // 3.56, // 2.23, // 2.19, // 2.1, - 2.66 - )->unfoldUsing( - UIKit::listWith( - "hello", - "good-bye" - )->ordered()->unfold() - ); - - AssertEquals::applyWith( - '
hello
good-bye
', - "string", - 8.69, // 6.44, // 3.52, // 3.2, - 1 - )->unfoldUsing( - UIKit::listWith( - "hello", - "good-bye" - )->description()->unfold() - ); - - AssertEquals::applyWith( - '
hello
good-bye
hello
good-bye
good-bye
', - "string", - 12.48, // 12.37, // 12.16, // 11.53, // 10.71, // 5.25, // 4.59, // 4.49, - 1 - )->unfoldUsing( - UIKit::listWith( - "hello", - "good-bye", - "hello", - "good-bye", - "good-bye" - )->description(1, 3)->unfold() - ); - } - - /** - * @test - */ - public function images() - { - AssertEquals::applyWith( - 'Alt text', - "string", - 5.2, // 4.4, // 3.94, // 3.31, // 2.37, // 2.3, // 2.03, - 3 - )->unfoldUsing( - UIKit::image("Alt text", "https://path.to/image.jpg") - ); - } -} diff --git a/tests/UIKit/SocialMetaTest.php b/tests/UIKit/SocialMetaTest.php deleted file mode 100755 index 57b799e..0000000 --- a/tests/UIKit/SocialMetaTest.php +++ /dev/null @@ -1,72 +0,0 @@ -', - "string", - 19.43, // 13.62, // 11.17, // 9.8, // 9.51, - 552 - )->unfoldUsing( - UIKit::socialMeta( - "Hello, World!", - "https://8fold.pro", - "A short description. LinkedIn would like to have 100+ characters." - ) - ); - - AssertEquals::applyWith( - '', - "string", - 41.13, // 22.92, // 21.38, // 20.31, // 18.94, // 18.23, // 16.28, // 9.33, // 8.67, // 8.61, // 6.3, // 5.93, // 5.54, - 1 - )->unfoldUsing( - UIKit::socialMeta( - "Hello, World!", - "https://8fold.pro", - "A short description. LinkedIn would like to have 100+ characters.", - "https://8fold.pro/assets/ui/logo.svg", - "website", - "ABCDEFGHIJKLMNOP" - ) - ); - } - - /** - * @test - */ - public function twitter() - { - AssertEquals::applyWith( - '', - "string", - 55.02, // 25.4, // 23.79, // 18.99, // 10.74, // 8.14, // 7.77, // 6.73, // 6.54, - 1 - )->unfoldUsing( - UIKit::socialMeta( - "Hello, World!", - "https://8fold.pro", - "A short description. LinkedIn would like to have 100+ characters.", - "https://8fold.pro/assets/ui/logo.svg", - "website", - "ABCDEFGHIJKLMNOP" - )->twitter() - ); - } -}