Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove static classes #206; Reactivate PHPCPD and PHPMD #220

Merged
merged 7 commits into from
May 4, 2014
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Deprecate static classes Footnotes, Endnotes, and TOC (#206); Reactiv…
…ate `phpcpd` and `phpmd` on Travis
  • Loading branch information
ivanlanin committed May 3, 2014
commit 725162bc6b433f4eaa2beb0a28fe9ef791150a20
18 changes: 9 additions & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ before_script:
- pyrus install pear/PHP_CodeSniffer
- phpenv rehash
## PHP Copy/Paste Detector
#- curl -o phpcpd.phar https://phar.phpunit.de/phpcpd.phar
- curl -o phpcpd.phar https://phar.phpunit.de/phpcpd.phar
## PHP Mess Detector
#- pear config-set preferred_state beta
#- printf "\n" | pecl install imagick
#- pear channel-discover pear.phpmd.org
#- pear channel-discover pear.pdepend.org
#- pear install --alldeps phpmd/PHP_PMD
#- phpenv rehash
- pear config-set preferred_state beta
- printf "\n" | pecl install imagick
- pear channel-discover pear.phpmd.org
- pear channel-discover pear.pdepend.org
- pear install --alldeps phpmd/PHP_PMD
- phpenv rehash
## PHPLOC
#- curl -o phploc.phar https://phar.phpunit.de/phploc.phar

Expand All @@ -41,9 +41,9 @@ script:
- phpcs --standard=PSR2 -n src/ --ignore=src/PhpWord/Shared/PCLZip
- phpcs --standard=PSR2 -n tests/
## PHP Copy/Paste Detector
#- php phpcpd.phar --verbose src/
- php phpcpd.phar --verbose src/
## PHP Mess Detector
#- phpmd src/ text unusedcode,naming,design
- phpmd src/ text phpmd.xml --exclude pclzip.lib.php
## PHPLOC
#- php phploc.phar src/
## PHPUnit
Expand Down
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ This release marked heavy refactorings on internal code structure with the creat
- Link: Ability to add link in header/footer - @ivanlanin GH-187
- Object: Ability to add object in header, footer, textrun, and footnote - @ivanlanin GH-187
- Media: Add `Media::resetElements()` to reset all media data - @juzi GH-19
- General: Add `Style::resetStyles()`, `Footnote::resetElements()`, and `TOC::resetTitles()` - @ivanlanin GH-187
- General: Add `Style::resetStyles()` - @ivanlanin GH-187
- DOCX Reader: Ability to read header, footer, footnotes, link, preservetext, textbreak, pagebreak, table, list, image, and title - @ivanlanin
- Endnote: Ability to add endnotes - @ivanlanin
- ListItem: Ability to create custom list and reset list number - @ivanlanin GH-10 GH-198
Expand Down Expand Up @@ -66,6 +66,7 @@ This release marked heavy refactorings on internal code structure with the creat
- `Element\Link::getLinkSrc` replaced by `Element\Link::getTarget`
- `Element\Link::getLinkName` replaced by `Element\Link::getText`
- `Style\Cell::getDefaultBorderColor`
- Static classes `Footnotes`, `Endnotes`, and `TOC`

### Miscellaneous

Expand All @@ -87,6 +88,8 @@ This release marked heavy refactorings on internal code structure with the creat
- Refactor: Apply composite pattern for writers - @ivanlanin
- Refactor: Split `AbstractContainer` from `AbstractElement` - @ivanlanin
- Refactor: Apply composite pattern for Word2007 reader - @ivanlanin
- Refactor: Replace static classes `Footnotes`, `Endnotes`, and `TOC` with `Collections` - @ivanlanin GH-206
- QA: Reactivate `phpcpd` and `phpmd` on Travis - @ivanlanin

## 0.9.1 - 27 Mar 2014

Expand Down
Binary file modified samples/resources/Sample_11_ReadWord2007.docx
Binary file not shown.
87 changes: 87 additions & 0 deletions src/PhpWord/Collection/AbstractCollection.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
<?php
/**
* PHPWord
*
* @link https://github.com/PHPOffice/PHPWord
* @copyright 2014 PHPWord
* @license http:https://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
*/

namespace PhpOffice\PhpWord\Collection;

/**
* Collection abstract class
*
* @since 0.10.0
*/
abstract class AbstractCollection
{
/**
* Items
*
* @var array
*/
private $items = array();

/**
* Get items
*
* @return array
*/
public function getItems()
{
return $this->items;
}

/**
* Get item by index
*
* @param int $index
* @return mixed
*/
public function getItem($index)
{
if (array_key_exists($index, $this->items)) {
return $this->items[$index];
} else {
return null;
}
}

/**
* Set item
*
* @param int $index
* @param mixed $item
*/
public function setItem($index, $item)
{
if (array_key_exists($index, $this->items)) {
$this->items[$index] = $item;
}
}

/**
* Add new item
*
* @param mixed $item
* @return int
*/
public function addItem($item)
{
$index = $this->countItems() + 1;
$this->items[$index] = $item;

return $index;
}

/**
* Get item count
*
* @return int
*/
public function countItems()
{
return count($this->items);
}
}
19 changes: 19 additions & 0 deletions src/PhpWord/Collection/Endnotes.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php
/**
* PHPWord
*
* @link https://github.com/PHPOffice/PHPWord
* @copyright 2014 PHPWord
* @license http:https://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
*/

namespace PhpOffice\PhpWord\Collection;

/**
* Endnotes collection
*
* @since 0.10.0
*/
class Endnotes extends AbstractCollection
{
}
19 changes: 19 additions & 0 deletions src/PhpWord/Collection/Footnotes.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php
/**
* PHPWord
*
* @link https://github.com/PHPOffice/PHPWord
* @copyright 2014 PHPWord
* @license http:https://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
*/

namespace PhpOffice\PhpWord\Collection;

/**
* Footnotes collection
*
* @since 0.10.0
*/
class Footnotes extends AbstractCollection
{
}
19 changes: 19 additions & 0 deletions src/PhpWord/Collection/Titles.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php
/**
* PHPWord
*
* @link https://github.com/PHPOffice/PHPWord
* @copyright 2014 PHPWord
* @license http:https://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
*/

namespace PhpOffice\PhpWord\Collection;

/**
* Titles collection
*
* @since 0.10.0
*/
class Titles extends AbstractCollection
{
}
Loading