Skip to content

Commit

Permalink
Merge pull request #19 from ARCANEDEV/update-1
Browse files Browse the repository at this point in the history
Update the package
  • Loading branch information
arcanedev-maroc authored Apr 5, 2019
2 parents 71b92ce + 2d1ff17 commit 603b5c9
Show file tree
Hide file tree
Showing 9 changed files with 45 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .scrutinizer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ checks:
tools:
external_code_coverage:
timeout: 600
runs: 3
runs: 4
php_code_sniffer:
enabled: true
config:
Expand Down
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ php:
- 7.1.3
- 7.1
- 7.2
- 7.3
- nightly

matrix:
Expand Down
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2015-2018 | ARCANEDEV <[email protected]> - LaravelSitemap
Copyright (c) 2015-2019 | ARCANEDEV <[email protected]> - LaravelSitemap

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ This package allows you to manage and generate a sitemap without you having to a
* Easy setup &amp; configuration.
* Well documented &amp; IDE Friendly.
* Well tested with maximum code quality.
* Laravel `5.4 | 5.5 | 5.6` are supported.
* Laravel `5.4` to `5.6` are supported.
* Made with :heart: &amp; :coffee:.

## Table of contents
Expand Down
4 changes: 3 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
"type": "library",
"license": "MIT",
"require": {
"php": ">=7.0",
"php": ">=7.1.3",
"ext-dom": "*",
"ext-json": "*",
"arcanedev/support": "~4.3.0"
},
"require-dev": {
Expand Down
5 changes: 2 additions & 3 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false">
stopOnFailure="false">
<testsuites>
<testsuite name="Package Test Suite">
<directory suffix=".php">./tests/</directory>
Expand All @@ -22,6 +21,6 @@
<logging>
<log type="coverage-clover" target="build/logs/clover.xml"/>
<log type="coverage-text" target="build/logs/coverage.txt"/>
<log type="coverage-html" target="build/logs/coverage" charset="UTF-8" yui="true" highlight="true"/>
<log type="coverage-html" target="build/logs/coverage"/>
</logging>
</phpunit>
4 changes: 3 additions & 1 deletion src/Exceptions/SitemapException.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
<?php namespace Arcanedev\LaravelSitemap\Exceptions;

use Exception;

/**
* Class SitemapException
*
* @package Arcanedev\LaravelSitemap\Exceptions
* @author ARCANEDEV <[email protected]>
*/
class SitemapException extends \Exception {}
class SitemapException extends Exception {}
28 changes: 21 additions & 7 deletions src/SitemapBuilder.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
<?php namespace Arcanedev\LaravelSitemap;

use Arcanedev\LaravelSitemap\Contracts\Entities\Sitemap;
use DOMDocument;
use Illuminate\Support\Collection;
use Illuminate\Support\Str;

/**
* Class SitemapBuilder
*
* @package Arcanedev\LaravelSitemap\Tests
* @package Arcanedev\LaravelSitemap
* @author ARCANEDEV <[email protected]>
*/
class SitemapBuilder
Expand All @@ -19,7 +21,7 @@ class SitemapBuilder
/**
* Create the builder instance.
*
* @return self
* @return \Arcanedev\LaravelSitemap\SitemapBuilder
*/
public static function make()
{
Expand All @@ -33,9 +35,11 @@ public static function make()
* @param \Illuminate\Support\Collection $sitemaps
* @param string $format
*
* @throws \Throwable
*
* @return string|null
*/
public function build($name, $sitemaps, $format)
public function build($name, Collection $sitemaps, $format)
{
if ($sitemaps->isEmpty())
return null;
Expand All @@ -46,7 +50,9 @@ public function build($name, $sitemaps, $format)
: static::renderSitemap($format, $sitemaps->first());
}

list($name, $key) = Str::contains($name, '.') ? explode('.', $name, 2) : [$name, null];
list($name, $key) = Str::contains($name, '.')
? explode('.', $name, 2)
: [$name, null];

if ($sitemaps->has($name))
return static::renderSitemap($format, $sitemaps->get($name), $key);
Expand All @@ -66,9 +72,11 @@ public function build($name, $sitemaps, $format)
* @param \Arcanedev\LaravelSitemap\Contracts\Entities\Sitemap|null $sitemap
* @param string|null $key
*
* @throws \Throwable
*
* @return string|null
*/
protected function renderSitemap($format, $sitemap, $key = null)
protected function renderSitemap($format, Sitemap $sitemap = null, $key = null)
{
if (is_null($sitemap))
return null;
Expand All @@ -89,7 +97,9 @@ protected function renderSitemap($format, $sitemap, $key = null)
* @param string $format
* @param \Illuminate\Support\Collection $sitemaps
*
* @return null|string
* @throws \Throwable
*
* @return string|null
*/
protected function renderSitemapIndex($format, $sitemaps)
{
Expand All @@ -103,7 +113,9 @@ protected function renderSitemapIndex($format, $sitemaps)
* @param string $type
* @param array $data
*
* @return null|string
* @throws \Throwable
*
* @return string|null
*/
protected function render($format, $type, array $data)
{
Expand Down Expand Up @@ -147,6 +159,8 @@ protected function renderXml($format, $type, array $data)
* @param string $format
* @param array $data
*
* @throws \Throwable
*
* @return string
*/
protected function renderView($type, $format, array $data)
Expand Down
14 changes: 12 additions & 2 deletions src/SitemapManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,13 @@ public function has($name)

list($name, $key) = explode('.', $name, 2);

$map = $this->sitemaps->filter(function (SitemapContract $map) use ($name) {
$map = $this->sitemaps->filter(function (SitemapContract $map) {
return $map->isExceeded();
})->get($name);

return is_null($map) ? false : $map->chunk()->has(intval($key));
return is_null($map)
? false
: $map->chunk()->has(intval($key));
}

/**
Expand Down Expand Up @@ -163,6 +165,8 @@ public function count()
*
* @param string $name
*
* @throws \Throwable
*
* @return string|null
*/
public function render($name = null)
Expand All @@ -176,6 +180,8 @@ public function render($name = null)
* @param string $path
* @param string|null $name
*
* @throws \Throwable
*
* @return self
*/
public function save($path, $name = null)
Expand All @@ -201,6 +207,8 @@ public function save($path, $name = null)
* @param int $status
* @param array $headers
*
* @throws \Throwable
*
* @return \Illuminate\Contracts\Routing\ResponseFactory|\Symfony\Component\HttpFoundation\Response
*/
public function respond($name = null, $status = 200, array $headers = [])
Expand Down Expand Up @@ -245,6 +253,8 @@ public function jsonSerialize()
*
* @param string $path
* @param \Arcanedev\LaravelSitemap\Contracts\Entities\Sitemap $sitemap
*
* @throws \Throwable
*/
private function saveMultiple($path, $sitemap)
{
Expand Down

0 comments on commit 603b5c9

Please sign in to comment.